Skip to content

feat(client): send MCP standard POST headers#894

Open
AndreKalberer wants to merge 2 commits into
modelcontextprotocol:mainfrom
AndreKalberer:andrekalberer/sep-2243-http-headers
Open

feat(client): send MCP standard POST headers#894
AndreKalberer wants to merge 2 commits into
modelcontextprotocol:mainfrom
AndreKalberer:andrekalberer/sep-2243-http-headers

Conversation

@AndreKalberer

Copy link
Copy Markdown

Problem

SEP-2243 requires Streamable HTTP clients to mirror applicable JSON-RPC request metadata into standard HTTP headers. The Kotlin client currently sends Mcp-Protocol-Version and session metadata but does not emit Mcp-Method or Mcp-Name.

Solution

  • Add Mcp-Method for JSON-RPC requests and notifications.
  • Add Mcp-Name from a string params.name, falling back to a string params.uri.
  • Omit both headers for JSON-RPC responses.
  • Add focused transport tests for name-, URI-, notification-, and response-based behavior.

Validation

  • .\gradlew.bat :kotlin-sdk-client:jvmTest --tests "io.modelcontextprotocol.kotlin.sdk.client.streamable.http.StreamableHttpClientTransportTest"
  • .\gradlew.bat :kotlin-sdk-client:ktlintCheck :kotlin-sdk-client:detekt :kotlin-sdk-client:apiCheck
  • git diff --check

Closes #787

AI assistance was used while preparing this PR. I reviewed the final change, ran the validation listed above, and take responsibility for it.

@AndreKalberer
AndreKalberer marked this pull request as ready for review July 16, 2026 22:59

val paramsObject = params as? JsonObject ?: return@headers
val mcpName = paramsObject.stringValue("name") ?: paramsObject.stringValue("uri")
mcpName?.let { append(MCP_NAME_HEADER, it) }

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.

I think this PR does not follow the value encoding specified in the spec. Please take a look: https://modelcontextprotocol.io/specification/draft/basic/transports/streamable-http#value-encoding

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.

Addressed in commit bb8ff1a. Mcp-Name now uses the specified Base64 sentinel encoding for non-ASCII or control characters, leading or trailing whitespace, and sentinel-shaped values. I added exact regression coverage for each case and reran the focused JVM tests, ktlint, detekt, API checks, and multiplatform compilation; all pass. AI assistance was used while preparing this response; I reviewed and take responsibility for the change.

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.

SEP-2243: Send required Mcp-Method/Mcp-Name HTTP headers

2 participants