mirror of
https://github.com/open-webui/open-webui.git
synced 2026-06-08 10:13:22 -05:00
[PR #21092] [CLOSED] feat: add user info headers support in mcp tool calling. #64781
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/21092
Author: @notfolder
Created: 2/1/2026
Status: ❌ Closed
Base:
dev← Head:feature/dev-add-user-info-mcp-call📝 Commits (1)
c0c95cdfeat: add user info headers support in mcp tool calling.📊 Changes
2 files changed (+18 additions, -0 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+9 -0)📝
backend/open_webui/utils/tools.py(+9 -0)📄 Description
Pull Request Checklist
Note to first-time contributors
This change was discussed conceptually in advance and is intentionally designed as a small, opt-in, backward-compatible enhancement aligned with existing Open WebUI behavior.
Before submitting, I have confirmed the following:
devbranch.feat:Changelog Entry
Description
This pull request introduces an optional mechanism to forward Open WebUI user and chat context as HTTP headers when invoking external tool servers.
Currently, Open WebUI forwards user-related headers (such as user ID and chat ID) when proxying requests to OpenAI-compatible LLM endpoints. However, the same contextual information is not available to external Tool / OpenAPI servers, making it difficult to implement per-user authorization, auditing, rate limiting, or request tracing on the tool side.
This change adds a strictly opt-in, backward-compatible enhancement that allows operators to forward selected Open WebUI context headers to tool servers via an environment variable.
Added
X-OpenWebUI-User-IdX-OpenWebUI-Chat-IdENABLE_FORWARD_USER_INFO_HEADERS_TO_TOOLSChanged
backend/open_webui/utils/middleware.pybackend/open_webui/utils/tools.pyDeprecated
Removed
Fixed
Security
Breaking Changes
This change is fully backward-compatible and opt-in.
Additional Information
ENABLE_FORWARD_USER_INFO_HEADERSused in the OpenAI proxy path, ensuring conceptual and operational consistency.Testing
Manual testing was performed as follows:
ENABLE_FORWARD_USER_INFO_HEADERS_TO_TOOLSunset:X-OpenWebUI-*headers were forwarded.ENABLE_FORWARD_USER_INFO_HEADERS_TO_TOOLS=true:X-OpenWebUI-User-IdandX-OpenWebUI-Chat-Idwere correctly forwarded.This confirms both correct functionality and backward compatibility.
Screenshots or Videos
Contributor License Agreement
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.