René's URL Explorer Experiment


Title: fix(streamable-http): return spec-mandated 405 for pre-session GET (Closes #3102) by itguruhaseeb · Pull Request #3104 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: fix(streamable-http): return spec-mandated 405 for pre-session GET (Closes #3102) by itguruhaseeb · Pull Request #3104 · modelcontextprotocol/python-sdk

X Title: fix(streamable-http): return spec-mandated 405 for pre-session GET (Closes #3102) by itguruhaseeb · Pull Request #3104 · modelcontextprotocol/python-sdk

Description: Summary Fixes #3102. A GET that the Streamable HTTP server will not serve as a standalone SSE stream must be answered with 405 Method Not Allowed, per the transport spec: The server MUST either return Content-Type: text/event-stream in response to this HTTP GET, or else return HTTP 405 Method Not Allowed, indicating that the server does not offer an SSE stream at this endpoint. — Streamable HTTP § Listening for Messages from the Server In stateful mode a session-less GET previously fell through to session validation and returned 400 "Missing session ID". Spec-compliant clients (e.g. the TypeScript SDK's _startOrAuthSse) probe with a pre-initialize GET to ask "do you offer a standalone SSE stream?" and treat only 405 as the graceful "no SSE, fall through to POST" signal — so the 400 aborted the handshake before initialize was ever sent. Change In _handle_get_request, before session validation: if the server is stateful (self.mcp_session_id set) and the request carries no session id, return 405 with Allow: POST. This is the only pre-session request shape that could not previously get 405. Scoped and minimal: only the session-less GET path changes. Legitimate clients only GET after initialize (with a session id) and are unaffected. The wildcard-Accept half of the issue (*/* → 406) is already resolved on main — check_accept_headers now honors */* and text/* — so this PR is only the 405 contract. I kept the existing 406 arm for clients that genuinely do not accept text/event-stream, since that is standard HTTP content-negotiation and distinct from the spec's 405 signal. Happy to fold that in too if you'd prefer. Tests New test_get_without_session_returns_405 asserting 405 + Allow: POST for a pre-session GET that accepts SSE. Updated test_streamable_http_security_get_request: its post-Host-check assertion exercised the old 400 path; the Host-ordering intent (evil host → 421 before any session handling) is preserved. Full streamable-HTTP suite (156 tests) passes; ruff + pyright clean. AI-assistance disclosure Per CONTRIBUTING: this change was drafted with AI assistance. The human contributor (@itguruhaseeb) reviewed the diff, understands it, and owns the change and any follow-up. Open to adjusting the response shape (status text, Allow value, or extending to the 406 arm) to match your intended contract.

Open Graph Description: Summary Fixes #3102. A GET that the Streamable HTTP server will not serve as a standalone SSE stream must be answered with 405 Method Not Allowed, per the transport spec: The server MUST either re...

X Description: Summary Fixes #3102. A GET that the Streamable HTTP server will not serve as a standalone SSE stream must be answered with 405 Method Not Allowed, per the transport spec: The server MUST either re...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/3104

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:a5febe96-5ff8-1638-c6d1-49d1759edaa1
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idAB74:157C65:20405C:2C02F0:6B00C091
html-safe-nonce4494de953d60f3a90b133608f0e1c949a67916a8e59577e25b05943788635f7e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQjc0OjE1N0M2NToyMDQwNUM6MkMwMkYwOjZCMDBDMDkxIiwidmlzaXRvcl9pZCI6IjE0OTMxNDYzMzE0MzczODM4MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac30baca3bfc62b651fdde1434bc4dfe69192e0025fd9927281428fbb3bc23bb61
hovercard-subject-tagpull_request:4069780271
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/3104/files
twitter:imagehttps://avatars.githubusercontent.com/u/1244076?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1244076?s=400&v=4
og:image:altSummary Fixes #3102. A GET that the Streamable HTTP server will not serve as a standalone SSE stream must be answered with 405 Method Not Allowed, per the transport spec: The server MUST either re...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None93edd3bebc4afb7ce711ee74cb5d2a95927850b082a4d43e212222389cb1c415
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release1fee81a280ea86312b69448e261b418189bfd5b5
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3104%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F3104%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files
modelcontextprotocolhttps://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Codehttps://github.com/modelcontextprotocol/python-sdk
Issues308 (308)https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests112 (112)https://github.com/modelcontextprotocol/python-sdk/pulls
Actionshttps://github.com/modelcontextprotocol/python-sdk/actions
Projectshttps://github.com/modelcontextprotocol/python-sdk/projects
Security and quality12 (12)https://github.com/modelcontextprotocol/python-sdk/security
Insightshttps://github.com/modelcontextprotocol/python-sdk/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
itguruhaseebhttps://github.com/itguruhaseeb
modelcontextprotocol:mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
itguruhaseeb:fix/streamable-http-get-405-presessionhttps://github.com/itguruhaseeb/python-sdk/tree/fix/streamable-http-get-405-presession
Conversation 4 https://github.com/modelcontextprotocol/python-sdk/pull/3104
Commits 1 https://github.com/modelcontextprotocol/python-sdk/pull/3104/commits
Checks 31 https://github.com/modelcontextprotocol/python-sdk/pull/3104/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/3104/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files
fix(streamable-http): return spec-mandated 405 for pre-session GET (Closes #3102) https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#top
Show all changes 1 commit https://github.com/modelcontextprotocol/python-sdk/pull/3104/files
d9d65b1 fix(streamable-http): return spec-mandated 405 for pre-session GET Jul 16, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/3104/commits/d9d65b18df5e382bfd2034007bb735a27c76d035
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/3104/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files
streamable_http.py https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
test_streamable_http_security.py https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-99641f6cbe257be62af18938eeaacc6b089a42a859dac58486fe17506a9de558
test_streamable_http.py https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-57d1f3c64af36960aa61b1d77387fb6201b90fbc2f3d606bf2761315ce618cc5
src/mcp/server/streamable_http.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
View file https://github.com/itguruhaseeb/python-sdk/blob/d9d65b18df5e382bfd2034007bb735a27c76d035/src/mcp/server/streamable_http.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3104/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
cubic-dev-aihttps://github.com/apps/cubic-dev-ai
Jul 16, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#r3596680784
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files
https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-0119e4c1bbf2fde7ba89b9c9f5bc472ccc2332f84e96e47cf9e45cebef801da3
tests/server/test_streamable_http_security.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-99641f6cbe257be62af18938eeaacc6b089a42a859dac58486fe17506a9de558
View file https://github.com/itguruhaseeb/python-sdk/blob/d9d65b18df5e382bfd2034007bb735a27c76d035/tests/server/test_streamable_http_security.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3104/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-99641f6cbe257be62af18938eeaacc6b089a42a859dac58486fe17506a9de558
cubic-dev-aihttps://github.com/apps/cubic-dev-ai
Jul 16, 2026https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#r3596680791
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files
tests/shared/test_streamable_http.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-57d1f3c64af36960aa61b1d77387fb6201b90fbc2f3d606bf2761315ce618cc5
View file https://github.com/itguruhaseeb/python-sdk/blob/d9d65b18df5e382bfd2034007bb735a27c76d035/tests/shared/test_streamable_http.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/3104/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-57d1f3c64af36960aa61b1d77387fb6201b90fbc2f3d606bf2761315ce618cc5
https://github.com/modelcontextprotocol/python-sdk/pull/3104/files#diff-57d1f3c64af36960aa61b1d77387fb6201b90fbc2f3d606bf2761315ce618cc5
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/3104/files
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.