Skip to content

feat(mcp): allow updating headers on MCPServerHTTP#5559

Merged
longcw merged 1 commit into
mainfrom
longc/mcp-update-headers
Apr 27, 2026
Merged

feat(mcp): allow updating headers on MCPServerHTTP#5559
longcw merged 1 commit into
mainfrom
longc/mcp-update-headers

Conversation

@longcw
Copy link
Copy Markdown
Contributor

@longcw longcw commented Apr 27, 2026

Summary

  • Expose MCPServerHTTP.headers as a property with a setter that propagates updates to the active httpx.AsyncClient.

Closes #5542

Usage

mcp_server = MCPServerHTTP(url=..., headers={"Authorization": f"Bearer {token}"})
await mcp_server.initialize()

# Later, when the token rotates:
mcp_server.headers = {"Authorization": f"Bearer {new_token}"}

Expose headers as a property with a setter that propagates updates to the
active httpx.AsyncClient. This enables refreshing short-lived bearer tokens
without recreating the MCP connection.

Closes #5542
@chenghao-mou chenghao-mou requested a review from a team April 27, 2026 02:55
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Member

@theomonnom theomonnom left a comment

Choose a reason for hiding this comment

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

Lg! but let's deprecate MCPServer in favor of MCPToolset anyyway

@longcw longcw merged commit 4bb2a5b into main Apr 27, 2026
26 checks passed
@longcw longcw deleted the longc/mcp-update-headers branch April 27, 2026 06:23
@longcw
Copy link
Copy Markdown
Contributor Author

longcw commented Apr 27, 2026

let's deprecate MCPServer in favor of MCPToolset anyyway

I think we'll deprecate MCPServer for AgentSession but we still need to pass it to the MCPToolset right?

Copy link
Copy Markdown
Contributor

This is an automated Claude Code Routine created by @toubatbrian. Right now it is in experimentation stage. The automation will start porting this PR into agents-js automatically.


Triage result: skipping port

This PR adds a headers property setter on MCPServerHTTP that propagates updates to the live httpx.AsyncClient. The change is conceptually portable (an MCP runtime/plugin enhancement), but agents-js does not yet have an MCP server implementation — there is no equivalent MCPServerHTTP class, no agents/src/llm/mcp.ts, and no MCP-related exports in agents/src/llm/index.ts.

Porting this incremental enhancement in isolation isn't actionable without first porting the underlying MCP server infrastructure (transport selection between SSE / streamable HTTP, client lifecycle, tool listing/invocation, etc.), which is well beyond the scope of a single PR port.

No agents-js PR will be opened for this change. When MCP support lands in agents-js, the headers-setter behavior should be implemented at that time (the JS equivalent would expose headers as a getter/setter and update the underlying fetch/transport options on mutation).

cc @toubatbrian @livekit/agent-devs


Generated by Claude Code

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.

Ability to update the authorization header of an MCP

3 participants