[PR #24816] [CLOSED] fix: interpolate template vars in MCP connection headers #115177

Closed
opened 2026-05-18 16:07:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24816
Author: @JawafdehiBot
Created: 5/16/2026
Status: Closed

Base: mainHead: upstream/mcp-header-interpolation


📝 Commits (1)

  • 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>
GiteaMirror added the pull-request label 2026-05-18 16:07:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#115177