René's URL Explorer Experiment


Title: [v1.x] Backport transport test deflakes from main (tests-only) by maxisbey · Pull Request #2837 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: [v1.x] Backport transport test deflakes from main (tests-only) by maxisbey · Pull Request #2837 · modelcontextprotocol/python-sdk

X Title: [v1.x] Backport transport test deflakes from main (tests-only) by maxisbey · Pull Request #2837 · modelcontextprotocol/python-sdk

Description: Backports the transport test deflaking work from main (#2764, #2765, #2767, #2788) to v1.x. Tests-only: the diff touches nothing under src/. Stacked on #2717 (maxisbey/v1x-interaction-backport), which supplies the in-process streaming bridge these tests are built on. Motivation and Context The v1.x transport tests still run over real sockets with uvicorn servers in threads or subprocesses, and CI pays for it: ephemeral port races, server startup polling, and a real-clock session-timeout bet that loses under scheduler load. main fixed all of this by moving the tests in process; this PR ports those rewrites to v1.x so the v1.x matrix stops flaking on them. Two of the rewritten files have direct v1.x CI evidence (test_streamable_http_multiple_reconnections and test_json_response failures on Windows legs); the rest share the same socket-based harness and mechanism. The session-timeout deflake matters for #2717 itself: the suite that PR backports still carries the pre-#2788 real-clock test, which fails roughly 1 in 3 full-suite runs under coverage load, once per transport leg. Folding the first three commits here into #2717 instead would work equally well. Adaptations made for v1.x, each noted in the commit that makes it: The 4-line src/ delta from #2767 (a pragma removal and a stale docstring note) is dropped; v1.x has no strict pragma checking, so the retained pragma is harmless. 9 wildcard-Accept-header test params are omitted because v1.x predates the RFC 7231 wildcard parsing from #2152. The v1.x-only deprecation tests (streamablehttp_client alias, deprecated transport params) are re-added in in-process form, so no existing v1.x test is lost. In-process serving exposes two v1.x-specific teardown behaviors that the subprocess harness hid: sse-starlette < 3.0 binds a module-global exit event to the first event loop that serves a response (guarded with a reset fixture, exercised by the lowest-direct legs), and the server transport leaks anyio memory streams whose GC-time warnings would otherwise escape the per-test filters (handled with scoped filters plus a per-test gc.collect() so isolated runs stay clean). The streaming bridge now ignores response messages after the response has completed, matching what a client of a real ASGI server observes, with contract tests pinning the behavior. One ported test verifies inside its connection loop because Python 3.11 loses line tracing after an async-with teardown throws (python/cpython#106749), which otherwise misreports coverage on 3.11 legs. How Has This Been Tested? Full v1.x gate (pytest plus 100% line and branch coverage) green throughout the series. The rewritten files were run repeatedly in a scratch CI environment replicating the v1.x matrix (Windows and Ubuntu, Python 3.10 to 3.14, locked and lowest-direct resolutions): roughly 900 repetitions of the affected files with zero failures, including the lowest-direct legs that install sse-starlette 1.6.1. Contrast evidence for the timeout deflake: on the pre-deflake base, 5 of 8 full-suite runs under coverage load failed on test_session_level_timeout_applies_to_every_request; with the virtual-clock version the failure has never reproduced (28 full-suite runs plus 150 isolated repetitions). The full-suite failures that did appear during matrix stress were all in files this PR does not touch (the known Windows stdio child-cleanup and experimental-tasks flakes), which are out of scope here because fixing them requires src/ changes. Breaking Changes None. Tests-only; no public interface is touched. Types of changes Bug fix (non-breaking change which fixes an issue) New feature (non-breaking change which adds functionality) Breaking change (fix or feature that would cause existing functionality to change) Documentation update Checklist I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling I have added or updated documentation as needed Additional context Draft while #2717 is in review. If #2717 is amended, the only coupling points are tests/interaction/transports/__init__.py (the re-export added here) and the small _bridge.py and conftest.py changes; everything else is independent of its internals. Once #2717 merges this can be retargeted to v1.x. AI Disclaimer

Open Graph Description: Backports the transport test deflaking work from main (#2764, #2765, #2767, #2788) to v1.x. Tests-only: the diff touches nothing under src/. Stacked on #2717 (maxisbey/v1x-interaction-backport), wh...

X Description: Backports the transport test deflaking work from main (#2764, #2765, #2767, #2788) to v1.x. Tests-only: the diff touches nothing under src/. Stacked on #2717 (maxisbey/v1x-interaction-backport), wh...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:859e4d84-2849-2c29-8353-3161dbae07d6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE68C:A841C:150E2B2:1E32D24:6A5A2A19
html-safe-nonce2a6f00ab17210b771f5656c891039dc3e83611d90e8de548885ee3a143182b20
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjhDOkE4NDFDOjE1MEUyQjI6MUUzMkQyNDo2QTVBMkExOSIsInZpc2l0b3JfaWQiOiI4MjY5NTcxMzMzOTA4MjEyMjQ5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac4a7172ee40469be78dc40fe7d27f953aabd9bfebc57aae4a5a8e968fa21d2b89
hovercard-subject-tagpull_request:3848207212
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/2837/files
twitter:imagehttps://avatars.githubusercontent.com/u/224885523?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/224885523?s=400&v=4
og:image:altBackports the transport test deflaking work from main (#2764, #2765, #2767, #2788) to v1.x. Tests-only: the diff touches nothing under src/. Stacked on #2717 (maxisbey/v1x-interaction-backport), wh...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None19c67ad7579d2401ff06e88a32ef45460fbb40fab3191c7f7582d5e166f326fc
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
releasea3dea2706161c733403beb02e41d5765d358d44e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2837%2Ffiles
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
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%2Fpull%2F2837%2Ffiles
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%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files
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.6k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://github.com/modelcontextprotocol/python-sdk
Issues 255 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 303 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
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
maxisbeyhttps://github.com/maxisbey
maxisbey/v1x-interaction-backporthttps://github.com/modelcontextprotocol/python-sdk/tree/maxisbey/v1x-interaction-backport
maxisbey/v1x-tests-deflakehttps://github.com/modelcontextprotocol/python-sdk/tree/maxisbey/v1x-tests-deflake
Conversation 0 https://github.com/modelcontextprotocol/python-sdk/pull/2837
Commits 17 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits
Checks 19 https://github.com/modelcontextprotocol/python-sdk/pull/2837/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/2837/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files
[v1.x] Backport transport test deflakes from main (tests-only) https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#top
Show all changes 17 commits https://github.com/modelcontextprotocol/python-sdk/pull/2837/files
b880950 Deflake the session-level timeout test with trio's virtual clock (#2788) maxisbey Jun 5, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/b880950a26ca758a2a9830a27ec63d8935a58ea6
ea6a479 tests: avoid abandoned-async-generator warnings under the trio backend maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/ea6a479e41b8030728c5960e96688bc8d2552155
8d73896 tests: re-export StreamingASGITransport as the sanctioned bridge impo… maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/8d7389602750dbfcb4a3cd8bc16c7b6b54598c4a
6a6e7b7 Run transport security tests in process instead of over sockets (#2764) maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/6a6e7b7276bde130c3bf7825890e1221a0e08075
fd71a10 Filter known anyio stream teardown warnings in streamable HTTP securi… maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/fd71a106b16a90eff78ed3471ce2b1c8936dd9ac
92c4fe0 Run SSE and Unicode transport tests in process instead of over socket… maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/92c4fe063859d2cbd75e96fe79fa5bd9e66ae171
a94f3d5 Guard in-process HTTP tests against sse-starlette's global exit event maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/a94f3d5827745c85c37fded476631e4e6a18d93d
43cf9ec Run StreamableHTTP transport tests in process instead of over sockets… maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/43cf9ec76242670fae1bb23cb1999540467ed3f1
b80a9bd Force per-test GC so leaked-stream warnings stay inside the scoped fi… maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/b80a9bd7c60517d240c133b6e0190ca7ad22567e
9dc96d6 Guard streamable-HTTP test modules against sse-starlette's module-glo… maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/9dc96d66b50b2ce715873bd985ec9f173ff36cba
600c96e Extend the per-test GC fixture to the SSE and Unicode HTTP test modules maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/600c96e3f983362cb06ae45ea8e37baa6a543789
39938a2 Harden the streaming ASGI bridge against trailing responses maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/39938a2f8a784551221f807cef46caf6e29d60c0
b732867 Verify SSE request-context isolation inside each connection block maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/b732867ccfabb20fd870a173831934930498c268
3e53636 Exclude the connection loop's exit arc from branch coverage maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/3e53636d7608b3e685dd3a5798a3393031c94436
16ceeea Exclude post-teardown header checks from 3.11 coverage measurement maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/16ceeea3a98a104634e2e22c7afaf74ff312727d
e155e1b Deflake child process cleanup tests with polling instead of fixed sleeps maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/e155e1bb9e304f6b77078e5851884e1ca8be6cda
4a17006 Harden stop detection and avoid redundant tree termination in cleanup… maxisbey Jun 11, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2837/commits/4a17006005d42aa1eb5bccb345bd92d0bee49f76
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/2837/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files
test_http_unicode.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-1abfe619fb6ecef0087c7e77c14530625aee85ec1dc1db958de2f341769c21c9
test_stdio.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-49f66b09e4d89b29b440c955c429fe948dbcc3bbb08fffb504cf40be24382352
conftest.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-b61a049ecf6fc6396e71d1810e6a19663ca307f1e8cfbd1783ae95496d327863
test_timeouts.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-72f06b25a7e212f804121ef810f403578c4acd67b76b86ccda04618012a9930d
test_coverage.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-b60708448fb1fbd8bdc0fa50e9ae954833dcfdc17e67bb0ff9d544492b554c64
__init__.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-96c09033337ef37f4b1802f9ecdbc377acec2a2f130d32eca79250281aa5f492
_bridge.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-6776bddee945aaa483da4fdb6fb6e967660d3eecd4dedd0dfb99e236baab1e65
test_bridge.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-973bd36347e6d5afc67eb34b8a26000f5387e40d5200222400ed01920e68495c
test_sse_security.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-c4352f0bf263a51087a1f9dbd97e778a2fa4bf3fc0eced12e4bb84af262b7d8e
test_streamable_http_manager.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-ee0bac8ccf39135f1347002539cc4af38ee7e89b85595884e94fb4ab304a111d
test_streamable_http_security.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-99641f6cbe257be62af18938eeaacc6b089a42a859dac58486fe17506a9de558
test_sse.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
test_streamable_http.py https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-57d1f3c64af36960aa61b1d77387fb6201b90fbc2f3d606bf2761315ce618cc5
tests/client/test_http_unicode.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-1abfe619fb6ecef0087c7e77c14530625aee85ec1dc1db958de2f341769c21c9
View file https://github.com/modelcontextprotocol/python-sdk/blob/4a17006005d42aa1eb5bccb345bd92d0bee49f76/tests/client/test_http_unicode.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2837/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-1abfe619fb6ecef0087c7e77c14530625aee85ec1dc1db958de2f341769c21c9
https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-1abfe619fb6ecef0087c7e77c14530625aee85ec1dc1db958de2f341769c21c9
https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-1abfe619fb6ecef0087c7e77c14530625aee85ec1dc1db958de2f341769c21c9
https://github.com/modelcontextprotocol/python-sdk/pull/2837/files#diff-1abfe619fb6ecef0087c7e77c14530625aee85ec1dc1db958de2f341769c21c9
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2837/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2837/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.