Title: Keep following a relative redirect when the endpoint URL carries userinfo by maxisbey · Pull Request #3450 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: Keep following a relative redirect when the endpoint URL carries userinfo by maxisbey · Pull Request #3450 · modelcontextprotocol/python-sdk
X Title: Keep following a relative redirect when the endpoint URL carries userinfo by maxisbey · Pull Request #3450 · modelcontextprotocol/python-sdk
Description: Follow-up to #3397: an endpoint URL that carries userinfo (http://user:pass@host/mcp, which httpx2 turns into Basic auth) could no longer follow a redirect with a relative Location, because URL join keeps the base's userinfo and the transport refused any next request whose URL had userinfo. The check now refuses only userinfo the redirect itself introduces. Motivation and Context #3397 stops the transports from following a Location that carries user:pass@, since re-sending would put that pair in an Authorization header. The check was broader than its purpose: for a relative Location (/mcp/), next_request.url inherits the authority of the URL the caller configured, userinfo included, so the ordinary same-origin trailing-slash redirect was handed back unfollowed for such an endpoint and the call failed with "Redirect to … not followed". An absolute Location was unaffected. Found in review of the v1.x backport (#3448), which carries the same change. How Has This Been Tested? New helper test: a 307 with Location: /mcp/ for http://user:secret@mcp.example/mcp is followed and the second request goes to http://user:secret@mcp.example/mcp/; it fails before the change. The existing test that a Location introducing userinfo is not followed still passes. Full suite, pyright and ruff pass. Breaking Changes None. 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 am assigned to the linked issue (or it is labeled help wanted, or I'm a maintainer) I have disclosed any AI assistance and can explain the change in my own words 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 AI Disclaimer
Open Graph Description: Follow-up to #3397: an endpoint URL that carries userinfo (http://user:pass@host/mcp, which httpx2 turns into Basic auth) could no longer follow a redirect with a relative Location, because URL joi...
X Description: Follow-up to #3397: an endpoint URL that carries userinfo (http://user:pass@host/mcp, which httpx2 turns into Basic auth) could no longer follow a redirect with a relative Location, because URL joi...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/3450
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:894688d4-7e3c-fc8b-905e-7e7e151b5f94 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DE92:14EB6E:AE3B00:E519D0:6B01BC5C |
| html-safe-nonce | 3a2cb9e5f1642e9334513dfd2d81537d30fd3d5e1f34d9b66b291a45cb66e890 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTkyOjE0RUI2RTpBRTNCMDA6RTUxOUQwOjZCMDFCQzVDIiwidmlzaXRvcl9pZCI6IjUxOTU1NDMzODkxMDk1OTkzMjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 851c75902aef6a440ea06409de6a5ce09b5ce40cd61db98ef887bf7904050ebc |
| hovercard-subject-tag | pull_request:4447737907 |
| 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/3450/files |
| twitter:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| og:image:alt | Follow-up to #3397: an endpoint URL that carries userinfo (http://user:pass@host/mcp, which httpx2 turns into Basic auth) could no longer follow a redirect with a relative Location, because URL joi... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width