From 67befc91193d75c884588cc7ada57dd83dbdae28 Mon Sep 17 00:00:00 2001 From: Lynn Date: Tue, 24 Feb 2026 13:14:21 +0800 Subject: [PATCH] Fix: add back MCP tool custom header (#13188) ### What problem does this PR solve? Add back custom header when use MCP. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- agent/component/agent_with_tools.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/agent/component/agent_with_tools.py b/agent/component/agent_with_tools.py index 5ff55adf93..fe665ead72 100644 --- a/agent/component/agent_with_tools.py +++ b/agent/component/agent_with_tools.py @@ -76,6 +76,7 @@ class AgentParam(LLMParam, ToolParamBase): self.mcp = [] self.max_rounds = 5 self.description = "" + self.custom_header = {} class Agent(LLM, ToolBase): @@ -105,7 +106,8 @@ class Agent(LLM, ToolBase): for mcp in self._param.mcp: _, mcp_server = MCPServerService.get_by_id(mcp["mcp_id"]) - tool_call_session = MCPToolCallSession(mcp_server, mcp_server.variables) + custom_header = self._param.custom_header + tool_call_session = MCPToolCallSession(mcp_server, mcp_server.variables, custom_header) for tnm, meta in mcp["tools"].items(): self.tool_meta.append(mcp_tool_metadata_to_openai_tool(meta)) self.tools[tnm] = tool_call_session