René's URL Explorer Experiment


Title: fix: preserve API gateway path prefix in SSE client URL resolution by Varun6578 · Pull Request #2243 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: fix: preserve API gateway path prefix in SSE client URL resolution by Varun6578 · Pull Request #2243 · modelcontextprotocol/python-sdk

X Title: fix: preserve API gateway path prefix in SSE client URL resolution by Varun6578 · Pull Request #2243 · modelcontextprotocol/python-sdk

Description: Summary Fixes #795 When an MCP server sits behind a reverse proxy or API gateway that adds a path prefix (e.g., /gateway), the server's endpoint events contain paths without that prefix. The SSE client previously used urljoin() which drops the base URL's path prefix for absolute paths (starting with /), causing incorrect routing through the gateway. Changes src/mcp/client/sse.py: Added _resolve_endpoint_url() that detects and preserves reverse proxy/API gateway path prefixes Replaced urljoin(url, sse.data) with _resolve_endpoint_url(url, sse.data) on the endpoint event handler tests/shared/test_sse.py: Added 8 parametrized test cases for _resolve_endpoint_url() covering: Gateway prefix preservation (the reported bug) Deep gateway prefixes (/org/team/v1/sse) No prefix (preserves existing behavior) Relative paths and absolute URL endpoints How it works The function detects gateway prefixes by finding where the endpoint's first path segment appears in the base URL path. Everything before that match is the prefix to preserve. base_url: https://host/gateway/v1/sse endpoint: /v1/messages/?session_id=abc before: https://host/v1/messages/?session_id=abc (prefix lost!) after: https://host/gateway/v1/messages/?session_id=abc (prefix preserved)

Open Graph Description: Summary Fixes #795 When an MCP server sits behind a reverse proxy or API gateway that adds a path prefix (e.g., /gateway), the server's endpoint events contain paths without that prefix. The SS...

X Description: Summary Fixes #795 When an MCP server sits behind a reverse proxy or API gateway that adds a path prefix (e.g., /gateway), the server's endpoint events contain paths without that prefix. Th...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:1baa5ad7-3e58-c39c-10da-1121ad55ab13
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB6B0:1E1C8E:8837A:C43D0:6A6360AA
html-safe-nonceb07e4da1936f7e3322bb83a1194e630180b7acc43f16d086cd72c79f1096af54
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkIwOjFFMUM4RTo4ODM3QTpDNDNEMDo2QTYzNjBBQSIsInZpc2l0b3JfaWQiOiIxNDI3MDQ1MDc4NTIzODIzNzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb913a0da79a99ec000b4b4eda55ade77628040135efe7448679a6723d6340bae
hovercard-subject-tagpull_request:3366939688
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/2243/files
twitter:imagehttps://avatars.githubusercontent.com/u/34965159?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/34965159?s=400&v=4
og:image:altSummary Fixes #795 When an MCP server sits behind a reverse proxy or API gateway that adds a path prefix (e.g., /gateway), the server's endpoint events contain paths without that prefix. The SS...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None59e55daad7174ca59d63c6974d58276ccb5477442e550bebb3c035e1bef11c94
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
release71b1218de2f2ab29c4d5ce72568e68e2c56044c6
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/2243/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2243%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
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%2Fpull%2F2243%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/2243/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2243/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2243/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2243/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.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://github.com/modelcontextprotocol/python-sdk
Issues 270 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 320 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
Varun6578https://github.com/Varun6578
modelcontextprotocol:mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
Varun6578:fix/sse-gateway-prefix-resolutionhttps://github.com/Varun6578/python-sdk/tree/fix/sse-gateway-prefix-resolution
Conversation 0 https://github.com/modelcontextprotocol/python-sdk/pull/2243
Commits 2 https://github.com/modelcontextprotocol/python-sdk/pull/2243/commits
Checks 26 https://github.com/modelcontextprotocol/python-sdk/pull/2243/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/2243/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2243/files
fix: preserve API gateway path prefix in SSE client URL resolution https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#top
Show all changes 2 commits https://github.com/modelcontextprotocol/python-sdk/pull/2243/files
0172037 fix: preserve API gateway path prefix in SSE client URL resolution Mar 7, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2243/commits/01720374052d039669a5bf90ebf40e57f37748db
60d9f87 test: cover empty endpoint path branch in _resolve_endpoint_url Mar 7, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2243/commits/60d9f8736e3dbdb8dc88b91bb18fb041567d1d1c
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/2243/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2243/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2243/files
sse.py https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
test_sse.py https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
src/mcp/client/sse.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
View file https://github.com/modelcontextprotocol/python-sdk/blob/60d9f8736e3dbdb8dc88b91bb18fb041567d1d1c/src/mcp/client/sse.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2243/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-41ed2e8548ae223801c0a37a6b50ce913e24f0e660bbbc2ddd91686820c86336
tests/shared/test_sse.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
View file https://github.com/modelcontextprotocol/python-sdk/blob/60d9f8736e3dbdb8dc88b91bb18fb041567d1d1c/tests/shared/test_sse.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2243/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
https://github.com/modelcontextprotocol/python-sdk/pull/2243/files#diff-a2934f5f6ec610dff6774352c41b8c697b539614667643d69fd67f6fc6d7765e
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.