Title: Python MCP SDK: Incorrect handling of absolute paths in SSE endpoint URLs leads to incorrect URL construction. · Issue #585 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Python MCP SDK: Incorrect handling of absolute paths in SSE endpoint URLs leads to incorrect URL construction. · Issue #585 · modelcontextprotocol/python-sdk
X Title: Python MCP SDK: Incorrect handling of absolute paths in SSE endpoint URLs leads to incorrect URL construction. · Issue #585 · modelcontextprotocol/python-sdk
Description: Describe the bug When the MCP server, connected via SSE, returns an endpoint event with a data value that starts with / (e.g., /mcp/message?sessionId=...), the SDK appears to be using this absolute path directly without considering the b...
Open Graph Description: Describe the bug When the MCP server, connected via SSE, returns an endpoint event with a data value that starts with / (e.g., /mcp/message?sessionId=...), the SDK appears to be using this absolute...
X Description: Describe the bug When the MCP server, connected via SSE, returns an endpoint event with a data value that starts with / (e.g., /mcp/message?sessionId=...), the SDK appears to be using this absolute...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/issues/585
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Python MCP SDK: Incorrect handling of absolute paths in SSE endpoint URLs leads to incorrect URL construction.","articleBody":"**Describe the bug**\nWhen the MCP server, connected via SSE, returns an endpoint event with a data value that starts with / (e.g., /mcp/message?sessionId=...), the SDK appears to be using this absolute path directly without considering the base URL of the initial SSE connection. This results in the client attempting to access an incorrect URL.\n\n\n\n**To Reproduce**\nSteps to reproduce the behavior:\n\n1. Establish an SSE connection to an MCP server with a URL like: http://my.mcp-server.com/weather/sse.\n2. Observe the server sending an SSE event with event: endpoint and data: /mcp/message?sessionId=your_session_id.\n3. The client, using the Python MCP SDK, constructs the endpoint URL as http://my.mcp-server.com/mcp/message?sessionId=your_session_id.\n4. The expected behavior, based on the MCPEx specification (clients should use the same origin as the SSE connection and append the received path), is that the URL should be http://my.mcp-server.com/weather/mcp/message?sessionId=your_session_id.\n\n\n\n\n**Expected behavior**\nThe expected URL should be http://my.mcp-server.com/weather/mcp/message?sessionId=your_session_id.\n\n**Possible Root Cause:**\nRelevant Code Snippet (from langchain-mcp-adapters/client.py - for context):\n\n\n\n \nurllib.parse.urljoin treats paths starting with / as absolute paths, causing it to discard the path component of the base URL (http://my.mcp-server.com/weather/sse) and only use the hostname.\n\n**Suggested Solution**\nWhen the server returns an endpoint URL starting with /, the SDK should treat it as a path to be appended to the path of the initial SSE connection URL, rather than a completely new absolute path relative to the server root. This might involve checking if sse_data starts with / and adjusting the base URL used in the URL joining process accordingly.\n\n\n\n\n\n","author":{"url":"https://github.com/footuser","@type":"Person","name":"footuser"},"datePublished":"2025-04-25T02:05:36.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/585/python-sdk/issues/585"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:34d8051c-ba18-2f67-650d-f452b8b76b96 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFBC:153B16:1C5EC6:26925E:6A626D81 |
| html-safe-nonce | 60f54986ac7a3568f200b1d8edbbd146129dc3196c57184ac507f874cbb0207d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkJDOjE1M0IxNjoxQzVFQzY6MjY5MjVFOjZBNjI2RDgxIiwidmlzaXRvcl9pZCI6IjM0MDE2ODc1Nzg1MTczMzU0MjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 1ff38b892c1ecaf1dcb5bf083466bfabe2e10199c3d3185389d85f5eb0aa7d5b |
| hovercard-subject-tag | issue:3018808246 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/modelcontextprotocol/python-sdk/585/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1c34098e1469351ec4334aa2172ec8631e854468e5420214f74e66f2694df2c8/modelcontextprotocol/python-sdk/issues/585 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1c34098e1469351ec4334aa2172ec8631e854468e5420214f74e66f2694df2c8/modelcontextprotocol/python-sdk/issues/585 |
| og:image:alt | Describe the bug When the MCP server, connected via SSE, returns an endpoint event with a data value that starts with / (e.g., /mcp/message?sessionId=...), the SDK appears to be using this absolute... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | footuser |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19769ef9d383a84eeab48bb9b309078c20f4532b73eae2f9713b18406513e0ad |
| turbo-cache-control | no-preview |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 76dc6b11f13eaeec1329217c9f16c262ade27a1e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width