René's URL Explorer Experiment


Title: test: convert test_integration.py to in-memory transport (fix flaky) by maxisbey · Pull Request #2277 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: test: convert test_integration.py to in-memory transport (fix flaky) by maxisbey · Pull Request #2277 · modelcontextprotocol/python-sdk

X Title: test: convert test_integration.py to in-memory transport (fix flaky) by maxisbey · Pull Request #2277 · modelcontextprotocol/python-sdk

Description: Summary Converts tests/server/mcpserver/test_integration.py from subprocess+TCP to the in-memory Client(mcp) pattern, eliminating port-race flakiness under pytest-xdist. Closes #1776. Root Cause The server_port fixture allocates a port by binding to 0 then releasing the socket before the subprocess can bind it: @pytest.fixture def server_port() -> int: with socket.socket() as s: s.bind(("127.0.0.1", 0)) return s.getsockname()[1] # socket closed → port released → TOCTOU window With pytest -n auto, another xdist worker's subprocess can grab the same port first. wait_for_server only checks TCP connect, so it happily accepts a connection to the wrong server. CI evidence in job 66317185239 shows a 7ms 404 on /sse — not enough time for a subprocess to start, meaning wait_for_server saw a different worker's server. Verification this is a port race, not a uvicorn lifespan gap mcp.sse_app() returns Starlette(routes=routes) with no lifespan — routes are synchronously constructed. Uvicorn+Starlette never serves 404 before 200 for a no-lifespan app; a 404 on /sse can only mean a different server bound that port. Fix None of these 20 parametrized tests (10 × 2 transports) exercise transport-specific behavior — they test MCP protocol features (tools, resources, prompts, progress, sampling, elicitation, notifications, completion, structured output). Converted all to use Client(mcp) in-memory, matching the established pattern in test_server.py (×16) and test_url_elicitation.py (×11). Transport behavior remains covered separately in tests/server/test_sse_security.py, test_streamable_http_{manager,security}.py, and tests/shared/test_{sse,streamable_http,ws}.py. Impact Before After Tests 20 (parametrized over 2 transports) 10 Runtime ~20s (subprocess spawn + uvicorn startup) ~0.5s Lines 643 359 (−284) Flakiness Port race under xdist None (in-process, deterministic) AI Disclaimer

Open Graph Description: Summary Converts tests/server/mcpserver/test_integration.py from subprocess+TCP to the in-memory Client(mcp) pattern, eliminating port-race flakiness under pytest-xdist. Closes #1776. Root Cause Th...

X Description: Summary Converts tests/server/mcpserver/test_integration.py from subprocess+TCP to the in-memory Client(mcp) pattern, eliminating port-race flakiness under pytest-xdist. Closes #1776. Root Cause Th...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:4dc5cb99-afb1-0d7d-8df4-2facf6950595
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idE2B4:2F3B67:6929BD:8A3761:6A5B34A1
html-safe-nonce4b4769d8d2be5bf00016a318566da3e3500877bd2f1476787b09e17af425991e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkI0OjJGM0I2Nzo2OTI5QkQ6OEEzNzYxOjZBNUIzNEExIiwidmlzaXRvcl9pZCI6IjY4NTk1NzgzMjQxOTA3MDQ4MDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac40e72cdfd5a9eefe6efb99075067096284b22808def389260c072922451e8cbc
hovercard-subject-tagpull_request:3385472719
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/2277/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:altSummary Converts tests/server/mcpserver/test_integration.py from subprocess+TCP to the in-memory Client(mcp) pattern, eliminating port-race flakiness under pytest-xdist. Closes #1776. Root Cause Th...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b
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
release9c975978430e9ad293956f2bbdaf153b1bd84a99
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/2277/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2277%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%2F2277%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/2277/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2277/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2277/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2277/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 258 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 301 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
mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
maxisbey/max-155-flaky-convert-test_integrationpy-to-in-process-removehttps://github.com/modelcontextprotocol/python-sdk/tree/maxisbey/max-155-flaky-convert-test_integrationpy-to-in-process-remove
Conversation 0 https://github.com/modelcontextprotocol/python-sdk/pull/2277
Commits 2 https://github.com/modelcontextprotocol/python-sdk/pull/2277/commits
Checks 33 https://github.com/modelcontextprotocol/python-sdk/pull/2277/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/2277/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2277/files
test: convert test_integration.py to in-memory transport (fix flaky) https://github.com/modelcontextprotocol/python-sdk/pull/2277/files#top
Show all changes 2 commits https://github.com/modelcontextprotocol/python-sdk/pull/2277/files
93ffa21 test: convert test_integration.py to in-memory transport maxisbey Mar 10, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2277/commits/93ffa218390255c48772fc5d8a36b83bc2c81cd9
4b3dec0 coverage: remove stale pragma on send_resource_list_changed maxisbey Mar 18, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2277/commits/4b3dec029a5234c0b892096654cabca30fee6d5a
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/2277/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2277/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2277/files
session.py https://github.com/modelcontextprotocol/python-sdk/pull/2277/files#diff-9a603a2587011a188aa76ca19a32fcd343a253516325fbcfb4f7bfb6a814634c
test_integration.py https://github.com/modelcontextprotocol/python-sdk/pull/2277/files#diff-06853ee92cf7e60bc876d235eb6b3a0ec88c2719e5af44e0a46fb6b71c9ab3e2
src/mcp/server/session.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2277/files#diff-9a603a2587011a188aa76ca19a32fcd343a253516325fbcfb4f7bfb6a814634c
View file https://github.com/modelcontextprotocol/python-sdk/blob/4b3dec029a5234c0b892096654cabca30fee6d5a/src/mcp/server/session.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2277/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2277/files#diff-9a603a2587011a188aa76ca19a32fcd343a253516325fbcfb4f7bfb6a814634c
https://github.com/modelcontextprotocol/python-sdk/pull/2277/files#diff-9a603a2587011a188aa76ca19a32fcd343a253516325fbcfb4f7bfb6a814634c
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2277/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2277/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.