Skip to content

fix: Send required Mcp-Method/Mcp-Name headers per SEP-2243 #2176

Description

@caomengxuan666

Description

The StreamableHTTPClientTransport does not send Mcp-Method or Mcp-Name HTTP headers on POST requests. Per SEP-2243 (HTTP Standard Headers), these headers are MUST for clients:

Clients MUST include the Mcp-Method header on every POST request, set to the JSON-RPC method value from the request body.

Clients MUST include the Mcp-Name header when the request carries a params.name (tools/call, prompts/get) or params.uri (resources/read, resources/subscribe, resources/unsubscribe).

Current behavior

In streamableHttp.js, the _commonHeaders() method (line 58) only sets:

  • Authorization (if auth provider)
  • mcp-session-id (if session exists)
  • mcp-protocol-version (if protocol version known)

No Mcp-Method or Mcp-Name headers are sent.

Expected behavior

The POST path in sendMessages() should add:

  • Mcp-Method: <method> for every request
  • Mcp-Name: <name|uri> when params.name or params.uri is present

Impact

This causes the MCP conformance suite (http-header-validation scenario) to fail when testing servers that implement SEP-2243 header validation. Specifically, the ServerRejectsMissingMethodHeader test expects servers to reject requests missing Mcp-Method, but the TypeScript SDK never sends it.

Servers that enforce SEP-2243 (reject missing Mcp-Method with HTTP 400) are incompatible with the current TypeScript SDK client.

Reference

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions