feat: Make timeout for streamablehttp_client configurable via env var
Description
This PR adds a new environment variable MCP_STREAMABLE_HTTP_CLIENT_TIMEOUT that allows users to configure the HTTP client timeout for the MCP streamable HTTP client. Previously, the timeout was not configurable, This enables users to adjust the timeout based on their network conditions and MCP server response times.
Set the environment variable to configure the HTTP client timeout (in seconds):
exportMCP_STREAMABLE_HTTP_CLIENT_TIMEOUT=60
If not set, the timeout defaults to None (httpx will use its default timeout behavior).
Files Modified
backend/open_webui/env.py - Added new environment variable parsing
backend/open_webui/utils/mcp/client.py - Updated to use configurable timeout
Additional Information
No new dependencies added
No breaking changes - defaults to None which preserves existing behavior
Manual testing: Verified that the environment variable is correctly parsed and applied to the httpx client
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/open-webui/open-webui/pull/23136
**Author:** [@dkhachyan](https://github.com/dkhachyan)
**Created:** 3/27/2026
**Status:** ❌ Closed
**Base:** `main` ← **Head:** `tool-timeout`
---
### 📝 Commits (1)
- [`770c075`](https://github.com/open-webui/open-webui/commit/770c07592ac46d52750d01828412db77a9de6ab0) feat(mcp): add configurable timeout for streamable http client
### 📊 Changes
**2 files changed** (+20 additions, -3 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/env.py` (+11 -0)
📝 `backend/open_webui/utils/mcp/client.py` (+9 -3)
</details>
### 📄 Description
## Pull Request Description
### Title
**feat**: Make timeout for streamablehttp_client configurable via env var
### Description
This PR adds a new environment variable `MCP_STREAMABLE_HTTP_CLIENT_TIMEOUT` that allows users to configure the HTTP client timeout for the MCP streamable HTTP client. Previously, the timeout was not configurable, This enables users to adjust the timeout based on their network conditions and MCP server response times.
### Changed
- Added `MCP_STREAMABLE_HTTP_CLIENT_TIMEOUT` environment variable in [`backend/open_webui/env.py`](backend/open_webui/env.py:774)
- Modified [`create_insecure_httpx_client()`](backend/open_webui/utils/mcp/client.py:18) in [`backend/open_webui/utils/mcp/client.py`](backend/open_webui/utils/mcp/client.py) to use the environment variable as the default timeout when no explicit timeout is provided
### Usage
Set the environment variable to configure the HTTP client timeout (in seconds):
```bash
export MCP_STREAMABLE_HTTP_CLIENT_TIMEOUT=60
```
If not set, the timeout defaults to `None` (httpx will use its default timeout behavior).
### Files Modified
- `backend/open_webui/env.py` - Added new environment variable parsing
- `backend/open_webui/utils/mcp/client.py` - Updated to use configurable timeout
---
### Additional Information
- No new dependencies added
- No breaking changes - defaults to `None` which preserves existing behavior
- Manual testing: Verified that the environment variable is correctly parsed and applied to the httpx client
---
- [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23136
Author: @dkhachyan
Created: 3/27/2026
Status: ❌ Closed
Base:
main← Head:tool-timeout📝 Commits (1)
770c075feat(mcp): add configurable timeout for streamable http client📊 Changes
2 files changed (+20 additions, -3 deletions)
View changed files
📝
backend/open_webui/env.py(+11 -0)📝
backend/open_webui/utils/mcp/client.py(+9 -3)📄 Description
Pull Request Description
Title
feat: Make timeout for streamablehttp_client configurable via env var
Description
This PR adds a new environment variable
MCP_STREAMABLE_HTTP_CLIENT_TIMEOUTthat allows users to configure the HTTP client timeout for the MCP streamable HTTP client. Previously, the timeout was not configurable, This enables users to adjust the timeout based on their network conditions and MCP server response times.Changed
MCP_STREAMABLE_HTTP_CLIENT_TIMEOUTenvironment variable inbackend/open_webui/env.pycreate_insecure_httpx_client()inbackend/open_webui/utils/mcp/client.pyto use the environment variable as the default timeout when no explicit timeout is providedUsage
Set the environment variable to configure the HTTP client timeout (in seconds):
If not set, the timeout defaults to
None(httpx will use its default timeout behavior).Files Modified
backend/open_webui/env.py- Added new environment variable parsingbackend/open_webui/utils/mcp/client.py- Updated to use configurable timeoutAdditional Information
Nonewhich preserves existing behavior🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.