Skip to content

Send Mcp-Method and Mcp-Name only as SEP-2243 defines - #1118

Open
shwetangsinha0509 wants to merge 1 commit into
modelcontextprotocol:mainfrom
shwetangsinha0509:fix/sep-2243-client-headers
Open

shwetangsinha0509 wants to merge 1 commit into
modelcontextprotocol:mainfrom
shwetangsinha0509:fix/sep-2243-client-headers

Conversation

@shwetangsinha0509

@shwetangsinha0509 shwetangsinha0509 commented Oct 16, 2026 •

Copy link
Copy Markdown

Part of #1047

Fixes points (1) and (2) of #1047 in StreamableHttpClientTransport:

  • Mcp-Method and Mcp-Name are now sent on requests only. Notifications no longer carry them.
  • Mcp-Name is resolved per method as SEP-2243 defines: name for tools/call and prompts/get, uri for resources/read. Previously any request whose params had a name or uri (e.g. resources/subscribe) got the header.
  • All other methods carry no Mcp-Name.

The tasks/* mappings from the Tasks extension (SEP-2663) are not included, since the SDK doesn't implement that extension yet.

Point (3), gating these headers on the negotiated protocol version, is left out on purpose: it depends on #1090 and #1091.

Tests

In StreamableHttpClientTransportTest:

  • should omit MCP standard headers for notifications (replaces the notification test that expected Mcp-Method)
  • should omit MCP standard headers for notifications that carry a URI (notifications/resources/updated)
  • should send MCP name header from name for prompts get
  • should omit MCP name header for methods without a defined source (resources/subscribe)
  • should send only the MCP method header for requests without a name source (tools/list)

Rebased on main (6150050). Locally, :kotlin-sdk-client:jvmTest, ktlintCheck, detekt and checkKotlinAbi pass. No public API change.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for the PR — I left one blocking comment to resolve before merge.

Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=bc6240b7-f9c0-40e2-ac83-c1a5c0c701f3

return when (method) {
Method.Defined.ToolsCall.value, Method.Defined.PromptsGet.value -> params.stringValue("name")
Method.Defined.ResourcesRead.value -> params.stringValue("uri")
else -> null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Blocking: the new Mcp-Name source table is missing the tasks/* rows. SEP-2663 § Streamable HTTP: Routing Headers says the client MUST set Mcp-Name to params.taskId for tasks/get, tasks/update and tasks/cancel. This SDK ships tasks/get and tasks/cancel as ClientRequests whose params carry taskId (GetTaskRequestParams / CancelTaskRequestParams in kotlin-sdk-core/.../types/tasks.kt), so this else -> null now affirmatively encodes "no Mcp-Name" for them, and the KDoc above presents the table as the complete per-method mapping.

Failure scenario: a client polls tasks/get with {"taskId": "task-123"} against a load-balanced deployment. Without Mcp-Name, the intermediary cannot pin the poll to the instance holding the task state and routes it to another one — the poll fails or reports an unknown task (SEP-2663 calls this routing "typically required for correctness"). Against a server that validates the SEP-2243 standard headers — the TypeScript SDK's MCP_NAME_HEADER_SOURCE table includes the tasks/* rows — the POST is rejected with 400 / -32020 HeaderMismatch. I reproduced the omission on this branch by running the transport test with a tasks/get request: Mcp-Name is absent.

Suggested fix: add the row to mcpNameHeaderSource, and cover it with a test next to the new prompts/get case:

Method.Defined.TasksGet.value, Method.Defined.TasksCancel.value -> params.stringValue("taskId")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, confirmed against SEP-2663 § Streamable HTTP: Routing Headers. Added tasks/get and tasks/cancel → params.taskId to the Mcp-Name source mapping, updated the KDoc, and covered both with a test in 1331d1e.

tasks/update isn't defined in the SDK yet (no Method.Defined entry), so it will need the same row once the SEP-2663 methods land.

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Happy to approve — nothing blocking from my side.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=b8ff9c69-e377-4100-8aee-d0fc0954f4cb

jetbrains-air[bot]
jetbrains-air Bot previously approved these changes Oct 22, 2026

@jetbrains-air jetbrains-air Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks great — the per-method Mcp-Name mapping and the requests-only scoping both match the ratified spec, so this is good to merge.


Produced by Air Automations. Name: Code review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/409567ec-d3a7-40ac-ba95-8518ec577ac2?run=4e43b43b-6ef3-477d-af24-99f8dc0fb076

@shwetangsinha0509

Copy link
Copy Markdown
Author

Hi @devcrocod, gentle ping on this when you have a moment. It covers (1) and (2) from #1047, plus the SEP-2663 tasks/get / tasks/cancel → taskId routing that came up in review, and it merges cleanly with current main. For (3), happy to do it here or as a follow-up once #1091 lands, whichever you prefer.

@devcrocod devcrocod 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.

please drop the tasks/* commit. Those rows come from the Tasks extension (SEP-2663), which the SDK doesn't implement yet

…otocol#1047)

Restrict the headers to requests and take Mcp-Name from name for tools/call and prompts/get, from uri for resources/read, and from nothing otherwise.
@shwetangsinha0509

Copy link
Copy Markdown
Author

@devcrocod thanks, dropped the tasks/* commit. The branch is now a single commit (84faea1) rebased on main, covering points (1) and (2) only: Mcp-Method/Mcp-Name on requests only, and Mcp-Name from name for tools/call/prompts/get and uri for resources/read. I've updated the description to say the Tasks extension mappings are intentionally left out until the SDK implements SEP-2663. jvmTest, ktlintCheck, detekt and checkKotlinAbi pass locally.

This branch has not been deployed

No deployments
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.

2 participants