Add stateless server conformance test#222
Open
codefromthecrypt wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
Add stateless server conformance test#222codefromthecrypt wants to merge 1 commit intomodelcontextprotocol:mainfrom
codefromthecrypt wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
Test both directions of the stateless (no session ID) transport path: - Client scenario (stateless_server): mock stateless server verifies clients handle missing Mcp-Session-Id correctly - Server scenario (stateless-server): test client verifies stateless servers omit session headers and return 405 for GET/DELETE Signed-off-by: Adrian Cole <adrian@tetrate.io>
7c6377d to
a58f460
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
The spec allows servers to omit
Mcp-Session-Identirely:The word is MAY (RFC 2119). A compliant server can omit the header. This PR adds conformance coverage for that path, testing both directions.
Client scenario:
stateless_serverstateless-init-no-sessionMcp-Session-Id. Client MUST NOT error.stateless-no-session-header-sentMcp-Session-Id(nothing to echo).stateless-get-405stateless-delete-405stateless-tools-callServer scenario:
stateless-serverstateless-server-no-session-headerMcp-Session-Id.stateless-server-post-without-sessionMcp-Session-Idin request.stateless-server-get-405stateless-server-delete-405stateless-server-tools-callHow Has This Been Tested?
Client scenario - Python SDK (latest main)
SDK clients need a
stateless_serverhandler (identical totools_call).One-line patch for Python SDK
client.py:@register("tools_call") +@register("stateless_server") async def run_tools_call(server_url: str) -> None:$ npm start -- client \ --command "cd ~/oss/python-sdk && uv run --frozen python .github/actions/conformance/client.py" \ --scenario stateless_server Checks: [stateless-no-session-header-sent] SUCCESS Client omits mcp-session-id when server did not provide one [stateless-tools-call ] SUCCESS Validates that the client can call a tool on a stateless server [stateless-init-no-session ] SUCCESS Server response contains no mcp-session-id header (stateless) [stateless-get-405 ] SKIPPED Stateless server returns 405 for GET (client did not attempt GET) [stateless-delete-405 ] SKIPPED Stateless server returns 405 for DELETE (client did not attempt DELETE) Test Results: Passed: 3/3, 0 failed, 0 warnings OVERALL: PASSEDServer scenario - TypeScript SDK stateless example
Breaking Changes
None.
Types of changes
Checklist
Additional context
Design decisions:
SDK prior art: Every major SDK already handles stateless servers correctly.