e41874a fix: interpolate template vars in MCP connection headers
📊 Changes
1 file changed (+3 additions, -3 deletions)
View changed files
📝backend/open_webui/utils/middleware.py (+3 -3)
📄 Description
Summary
MCP connection headers containing template variables ({{USER_ID}}, {{USER_NAME}}, {{CHAT_ID}}, {{MESSAGE_ID}}) were being sent literally to MCP servers in middleware.py. This PR fixes that by using get_custom_headers() — the same pattern already used by tools.py for OpenAPI tool servers — to interpolate template variables before applying connection headers.
Changes
backend/open_webui/utils/middleware.py: Import get_custom_headers from open_webui.utils.headers and use it to process MCP connection headers instead of raw assignment (3 insertions, 3 deletions)
Context
get_custom_headers is already used in:
tools.py:343 — OpenAPI tool server connections
openai.py:218 — OpenAI-compatible connections
configs.py:441,486 — Config evaluation
This fix adds MCP connections as the missing consumer.
🔄 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/24816
**Author:** [@JawafdehiBot](https://github.com/JawafdehiBot)
**Created:** 5/16/2026
**Status:** ❌ Closed
**Base:** `main` ← **Head:** `upstream/mcp-header-interpolation`
---
### 📝 Commits (1)
- [`e41874a`](https://github.com/open-webui/open-webui/commit/e41874a55cb871e380cce1f3fc43d6f28d6f88cf) fix: interpolate template vars in MCP connection headers
### 📊 Changes
**1 file changed** (+3 additions, -3 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/utils/middleware.py` (+3 -3)
</details>
### 📄 Description
## Summary
MCP connection headers containing template variables ({{USER_ID}}, {{USER_NAME}}, {{CHAT_ID}}, {{MESSAGE_ID}}) were being sent literally to MCP servers in `middleware.py`. This PR fixes that by using `get_custom_headers()` — the same pattern already used by `tools.py` for OpenAPI tool servers — to interpolate template variables before applying connection headers.
## Changes
- `backend/open_webui/utils/middleware.py`: Import `get_custom_headers` from `open_webui.utils.headers` and use it to process MCP connection headers instead of raw assignment (3 insertions, 3 deletions)
## Context
`get_custom_headers` is already used in:
- `tools.py:343` — OpenAPI tool server connections
- `openai.py:218` — OpenAI-compatible connections
- `configs.py:441,486` — Config evaluation
This fix adds MCP connections as the missing consumer.
---
<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/24816
Author: @JawafdehiBot
Created: 5/16/2026
Status: ❌ Closed
Base:
main← Head:upstream/mcp-header-interpolation📝 Commits (1)
e41874afix: interpolate template vars in MCP connection headers📊 Changes
1 file changed (+3 additions, -3 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+3 -3)📄 Description
Summary
MCP connection headers containing template variables ({{USER_ID}}, {{USER_NAME}}, {{CHAT_ID}}, {{MESSAGE_ID}}) were being sent literally to MCP servers in
middleware.py. This PR fixes that by usingget_custom_headers()— the same pattern already used bytools.pyfor OpenAPI tool servers — to interpolate template variables before applying connection headers.Changes
backend/open_webui/utils/middleware.py: Importget_custom_headersfromopen_webui.utils.headersand use it to process MCP connection headers instead of raw assignment (3 insertions, 3 deletions)Context
get_custom_headersis already used in:tools.py:343— OpenAPI tool server connectionsopenai.py:218— OpenAI-compatible connectionsconfigs.py:441,486— Config evaluationThis fix adds MCP connections as the missing consumer.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.