Title: fix for SSE URL handling when a server name is specified by aarora79 · Pull Request #597 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: fix for SSE URL handling when a server name is specified by aarora79 · Pull Request #597 · modelcontextprotocol/python-sdk
X Title: fix for SSE URL handling when a server name is specified by aarora79 · Pull Request #597 · modelcontextprotocol/python-sdk
Description: Add custom URL join function for SSE endpoints This PR adds a custom URL join function to properly handle SSE endpoint URLs by correctly managing path segments regardless of trailing slashes. Motivation and Context When connecting to SSE endpoints, we need to reliably join base URLs with endpoint paths. For example if my SSE server lives at https://mcp.example.com/weather/sse/ then I want to join the SSE event URL such as /messages/?session_id=616df71373444d76bd566df4377c9629 to create https://mcp.example.com/weather/messages/?session_id=616df71373444d76bd566df4377c9629 i.e. it includes the server name weather, the existing implementation does not include the server name. This custom function ensures paths are correctly joined including a server name if present in the path. How Has This Been Tested? Added comprehensive unit tests covering multiple base URL patterns: https://mcp.example.com/weather/sse/ https://mcp.example.com/weather/clarksburg/sse/ https://mcp.example.com/sse/ Tested with and without trailing slashes Tested with session ID query parameters Verified behavior with actual SSE connection endpoints Breaking Changes None. This is a new utility function that doesn't affect existing functionality. 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](https://modelcontextprotocol.io) 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 The function uses urlparse and urlunparse to properly handle all URL components, which ensures query parameters and fragments are preserved. We specifically handle the path joining logic to accommodate both trailing and non-trailing slash cases in base URLs. Resolves #585
Open Graph Description: Add custom URL join function for SSE endpoints This PR adds a custom URL join function to properly handle SSE endpoint URLs by correctly managing path segments regardless of trailing slashes. Moti...
X Description: Add custom URL join function for SSE endpoints This PR adds a custom URL join function to properly handle SSE endpoint URLs by correctly managing path segments regardless of trailing slashes. Moti...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/597
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:2807dcaf-2754-99b4-d042-4a9549a469b4 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | EB2C:15675C:A21DF1:E78683:6A632120 |
| html-safe-nonce | 8b7a4a28442a1e897e30d9bd10f4cc1b97c0209dad5efc67ce9c6a7a9d43a6bf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQjJDOjE1Njc1QzpBMjFERjE6RTc4NjgzOjZBNjMyMTIwIiwidmlzaXRvcl9pZCI6IjIwODMxNTMxNTI4ODQwMjM1ODUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 277f61b01ec866499d2bc7cde5d89b0ddd9443f22721634e599959bbbd72187d |
| hovercard-subject-tag | pull_request:2486497928 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/modelcontextprotocol/python-sdk/pull/597/files |
| twitter:image | https://avatars.githubusercontent.com/u/14024481?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/14024481?s=400&v=4 |
| og:image:alt | Add custom URL join function for SSE endpoints This PR adds a custom URL join function to properly handle SSE endpoint URLs by correctly managing path segments regardless of trailing slashes. Moti... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1a6c056e02f174fffc096c521ec0ff6fb83e40a2ec8cb8875466ec1524872dd6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6a93e25585f487ddff9e3996c06d5b869d6e1828 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width