René's URL Explorer Experiment


Title: Claude Code client sends tools/call without initialize handshake — SSE transport rejects with -32602 · Issue #2579 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Claude Code client sends tools/call without initialize handshake — SSE transport rejects with -32602 · Issue #2579 · modelcontextprotocol/python-sdk

X Title: Claude Code client sends tools/call without initialize handshake — SSE transport rejects with -32602 · Issue #2579 · modelcontextprotocol/python-sdk

Description: Summary Claude Code MCP clients (the official claude-code CLI / SDK) intermittently send tools/call requests directly after opening an SSE session, without first sending the initialize request and notifications/initialized notification. ...

Open Graph Description: Summary Claude Code MCP clients (the official claude-code CLI / SDK) intermittently send tools/call requests directly after opening an SSE session, without first sending the initialize request and ...

X Description: Summary Claude Code MCP clients (the official claude-code CLI / SDK) intermittently send tools/call requests directly after opening an SSE session, without first sending the initialize request and ...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/2579

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Claude Code client sends tools/call without initialize handshake — SSE transport rejects with -32602","articleBody":"## Summary\n\nClaude Code MCP clients (the official `claude-code` CLI / SDK) intermittently send `tools/call` requests directly after opening an SSE session, **without first sending the `initialize` request and `notifications/initialized` notification**. The server then rejects the request with `RuntimeError(\"Received request before initialization was complete\")` (mcp/server/session.py:193), which surfaces to the client as `-32602: Invalid request parameters`.\n\nLikely related to #1844, but we have a concrete reproduction with full server-side debug logs.\n\n## Environment\n\n- `mcp` 1.27.0 (also reproduces with 1.14.0, 1.27.1)\n- Python 3.13 on Debian 14\n- Transport: SSE via `SseServerTransport` + Starlette/Uvicorn\n- Client: `claude-code` CLI (current version, agent-SDK based)\n- Reproduces with **multiple parallel SSE sessions** from the same host (typical of a multi-agent setup)\n\n## Server-side debug log (raw)\n\n```\n[INFO]  openproject-mcp-sse - POST /messages session=f3ee2d98… method=tools/call id=14 body={\"method\": \"tools/call\", \"params\": {\"name\": \"test_connection\", \"arguments\": {}, \"_meta\": {\"claudecode/toolUseId\": \"toolu_01SqXkUVGvojypc6RaA4UriG\", \"progressToken\": 14}}, \"jsonrpc\": \"2.0\", \"id\": 14}\n[DEBUG] mcp.server.sse - Validated client message: root=JSONRPCRequest(method='tools/call', params={'name': 'test_connection', 'arguments': {}, '_meta': {'claudecode/toolUseId': 'toolu_01SqXkUVGvojypc6RaA4UriG', 'progressToken': 14}}, jsonrpc='2.0', id=14)\n[DEBUG] mcp.server.sse - Sending session message to writer: SessionMessage(...)\nINFO:     POST /messages/?session_id=f3ee2d980809439b97eb35556d220eb1 HTTP/1.1\" 202 Accepted\n[WARNING] root - Failed to validate request: Received request before initialization was complete\n[DEBUG] root - Message that failed validation: method='tools/call' params={'name': 'test_connection', 'arguments': {}, '_meta': {'claudecode/toolUseId': 'toolu_01SqXkUVGvojypc6RaA4UriG', 'progressToken': 14}} jsonrpc='2.0' id=14\n```\n\nNote: The session was just newly created by the same SSE handshake (`session_id=f3ee2d98...` was generated 11 seconds before). **The client did not send `initialize` between SSE-connect and `tools/call`** — this is observable in the raw POST body capture above.\n\n## Reproduction\n\n1. Have a Python SSE MCP server using the standard `mcp.server.sse.SseServerTransport` + `Server(...).run()` pattern (see [example in the repo](https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/servers/simple-resource/mcp_simple_resource/server.py)).\n2. Connect with the Claude Code CLI as an MCP client (configure as a SSE-type MCP server in the user's `~/.claude/config`).\n3. The server has been running and idle for \u003e1 hour.\n4. From within a Claude Code session, invoke a tool. About half the time, the request comes in **without prior `initialize`**.\n\nThe first session right after a service restart always works correctly. The problem manifests after the client has gone idle for some time and then resumes — strongly suggests the client is caching session state across what the server considers a session re-establishment.\n\n## What I'd like to know\n\n1. Is this expected client behavior — should the server tolerate `tools/call` without preceding `initialize`?\n2. Or should the SDK make the server idempotently re-initialize on first non-init request (a kind of stateless mode for SSE, like `StreamableHTTPSessionManager(stateless=True)` does for streamable_http)?\n3. Is there a workaround other than monkey-patching `_received_request`?\n\n## Workaround we are using (not great, but it works)\n\nWe replaced the `RuntimeError` with an implicit state transition + warning, as a runtime monkey-patch:\n\n```python\nasync def _patched_received_request(self, responder):\n    match responder.request.root:\n        case types.InitializeRequest() | types.PingRequest():\n            return await _original(self, responder)\n        case _:\n            if self._initialization_state != InitializationState.Initialized:\n                logger.warning(\"Implicit initialization (client skipped initialize handshake)\")\n                self._initialization_state = InitializationState.Initialized\n            return await _original(self, responder)\n\nServerSession._received_request = _patched_received_request\n```\n\nFull module: [linked in our deployment if helpful].\n\n## Possibly related\n\n- #1844 — same symptom, also Claude-Code-client-related\n- #737 — FastMCP RuntimeError on pre-init in FastAPI embeds\n- #2411 — proposed fix to return `INVALID_REQUEST` instead of crashing\n- #1845 — `stateless_sse` option PR (closed without merge?)\n\nThanks for the SDK!\n","author":{"url":"https://github.com/Aksels73","@type":"Person","name":"Aksels73"},"datePublished":"2026-05-12T10:14:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2579/python-sdk/issues/2579"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:828dbc2e-ff37-1f0c-45a9-8d2f73c2ab03
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE95E:3E383E:32BEEA:42374E:6A5FEEA4
html-safe-nonce1ae068c8d972de2ad0d57805873e3258b567b2c32d40b840de9ccdb91f368bba
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTVFOjNFMzgzRTozMkJFRUE6NDIzNzRFOjZBNUZFRUE0IiwidmlzaXRvcl9pZCI6IjExNDIwODk1NjQ1MTEyNjg1MTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacc2f8482f07586f9e6ac2d8f3e1029a1af475252af002cae721bec90745cc2c8d
hovercard-subject-tagissue:4428207921
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/2579/issue_layout
twitter:imagehttps://opengraph.githubassets.com/42c875ccab65590d58846d2013294279a55a94d9b42823fb4d438813799fcd51/modelcontextprotocol/python-sdk/issues/2579
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/42c875ccab65590d58846d2013294279a55a94d9b42823fb4d438813799fcd51/modelcontextprotocol/python-sdk/issues/2579
og:image:altSummary Claude Code MCP clients (the official claude-code CLI / SDK) intermittently send tools/call requests directly after opening an SSE session, without first sending the initialize request and ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameAksels73
hostnamegithub.com
expected-hostnamegithub.com
Noneba296ecd3a3521238fe43b3b3b08cc09207ddc21173e16ee656db03803de8e2b
turbo-cache-controlno-preview
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release6e50fb37e29e4aa0df6386cb485e58b0e3ca97ab
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/issues/2579#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F2579
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2F2579
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2579
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2579
Reloadhttps://github.com/modelcontextprotocol/python-sdk/issues/2579
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/issues/2579
modelcontextprotocol https://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Notifications https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Fork 3.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Star 23.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://github.com/modelcontextprotocol/python-sdk
Issues 265 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 312 https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality 6 https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Code https://github.com/modelcontextprotocol/python-sdk
Issues https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Claude Code client sends tools/call without initialize handshake — SSE transport rejects with -32602https://github.com/modelcontextprotocol/python-sdk/issues/2579#top
https://github.com/Aksels73
Aksels73https://github.com/Aksels73
on May 12, 2026https://github.com/modelcontextprotocol/python-sdk/issues/2579#issue-4428207921
#1844https://github.com/modelcontextprotocol/python-sdk/issues/1844
example in the repohttps://github.com/modelcontextprotocol/python-sdk/blob/main/examples/servers/simple-resource/mcp_simple_resource/server.py
SSE transport: "Received request before initialization was complete" error with Claude Code client #1844https://github.com/modelcontextprotocol/python-sdk/issues/1844
Bug Report: FastMCP RuntimeError: Received request before initialization was complete Leading to Empty SSE Responses When Embedded in FastAPI #737https://github.com/modelcontextprotocol/python-sdk/issues/737
fix(session): return INVALID_REQUEST error instead of crashing on pre-init requests #2411https://github.com/modelcontextprotocol/python-sdk/pull/2411
feat: add stateless_sse option for SSE transport #1845https://github.com/modelcontextprotocol/python-sdk/pull/1845
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.