Skip to content

feat: support custom HTTP headers from tool parameters in OneMcpServer - #10902

Merged
chkuang-g merged 1 commit into
mainfrom
chkuang/mcp-custom-header
Aug 7, 2026
Merged

feat: support custom HTTP headers from tool parameters in OneMcpServer#10902
chkuang-g merged 1 commit into
mainfrom
chkuang/mcp-custom-header

Conversation

@chkuang-g

@chkuang-g chkuang-g commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

Adds support for forwarding custom HTTP headers (Mcp-Param-*) to remote MCP tools when defined in tool input parameter schemas via the x-mcp-header property per SEP-2243.

When OneMcpServer executes a tools/call request to a remote MCP backend, it inspects tool.inputSchema.properties for "x-mcp-header": "HeaderName". If present and the corresponding argument is supplied in args, OneMcpServer attaches Mcp-Param-<HeaderName>: <value> to the outbound HTTP request headers.

Bug: 530219396

Scenarios Tested

  1. Tested listTools() and verified tool schema mapping remains unchanged.
  2. Tested callTool() with a tool having "x-mcp-header": "Region" in inputSchema.properties and verified Mcp-Param-Region: us-west1 is included in outbound POST headers to remote MCP servers.
  3. Tested callTool() without x-mcp-header properties to ensure no extra headers are injected.
  4. Ran unit tests (npx mocha src/mcp/onemcp/onemcp_server.spec.ts) and linters (npm run lint:changed-files).

Sample Commands

  • npx mocha src/mcp/onemcp/onemcp_server.spec.ts

@chkuang-g
chkuang-g requested a review from joehan August 7, 2026 02:36

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for forwarding custom HTTP headers (Mcp-Param-*) to remote MCP tools when defined in tool parameter input schemas (x-mcp-header), per SEP-2243. It updates OneMcpServer to parse the tool's inputSchema and extract parameters mapped to headers, forwarding them during tool execution, and includes corresponding unit tests. The feedback suggests reducing nesting in the parameter-extraction loop by using continue statements to align with the repository's style guide.

Comment thread src/mcp/onemcp/onemcp_server.ts
Comment thread src/mcp/onemcp/onemcp_server.ts Outdated
Comment thread src/mcp/onemcp/onemcp_server.ts
### Description
Adds support for forwarding custom HTTP headers (Mcp-Param-*) to remote MCP tools when defined in tool input parameter schemas via the x-mcp-header property per [SEP-2243](https://modelcontextprotocol.io/seps/2243-http-standardization).

When OneMcpServer executes a tools/call request to a remote MCP backend, it inspects tool.inputSchema.properties for "x-mcp-header": "HeaderName". If present and the corresponding argument is supplied in args, OneMcpServer attaches Mcp-Param-<HeaderName>: <value> to the outbound HTTP request headers.

Bug: 530219396

### Scenarios Tested
1. Tested listTools() and verified tool schema mapping remains unchanged.
2. Tested callTool() with a tool having "x-mcp-header": "Region" in inputSchema.properties and verified Mcp-Param-Region: us-west1 is included in outbound POST headers to remote MCP servers.
3. Tested callTool() without x-mcp-header properties to ensure no extra headers are injected.
4. Ran unit tests (npx mocha src/mcp/onemcp/onemcp_server.spec.ts) and linters (npm run lint:changed-files).

### Sample Commands
- npx mocha src/mcp/onemcp/onemcp_server.spec.ts
@chkuang-g
chkuang-g force-pushed the chkuang/mcp-custom-header branch from e560d80 to 992a805 Compare August 7, 2026 17:02
@chkuang-g
chkuang-g merged commit fc95493 into main Aug 7, 2026
52 of 53 checks passed
@chkuang-g
chkuang-g deleted the chkuang/mcp-custom-header branch August 7, 2026 17:31
yuichi0301 pushed a commit to yuichi0301/firebase-tools that referenced this pull request Aug 16, 2026
firebase#10902)

### Description
Adds support for forwarding custom HTTP headers (Mcp-Param-*) to remote MCP tools when defined in tool input parameter schemas via the x-mcp-header property per [SEP-2243](https://modelcontextprotocol.io/seps/2243-http-standardization).

When OneMcpServer executes a tools/call request to a remote MCP backend, it inspects tool.inputSchema.properties for "x-mcp-header": "HeaderName". If present and the corresponding argument is supplied in args, OneMcpServer attaches Mcp-Param-<HeaderName>: <value> to the outbound HTTP request headers.

Bug: 530219396

### Scenarios Tested
1. Tested listTools() and verified tool schema mapping remains unchanged.
2. Tested callTool() with a tool having "x-mcp-header": "Region" in inputSchema.properties and verified Mcp-Param-Region: us-west1 is included in outbound POST headers to remote MCP servers.
3. Tested callTool() without x-mcp-header properties to ensure no extra headers are injected.
4. Ran unit tests (npx mocha src/mcp/onemcp/onemcp_server.spec.ts) and linters (npm run lint:changed-files).

### Sample Commands
- npx mocha src/mcp/onemcp/onemcp_server.spec.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants