fix: use localhost for MCP OAuth loopback redirect URIs - #29875
Closed
rumbin wants to merge 1 commit into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
http://localhost:<port>/callback127.0.0.1Motivation
Some OAuth providers accept loopback redirect URIs only in the
localhostform and reject the equivalent numeric loopback address127.0.0.1.That breaks first-time OAuth bootstrap during dynamic client registration even though the callback server is still strictly local.
This surfaced against the Superset MCP server at:
https://XXXX.net/mcpIn that flow:
http://localhost:<port>/callbackwas acceptedhttp://127.0.0.1:<port>/callbackwas rejectedImplementation
In
tools/mcp_oauth.py:127.0.0.1localhostIn
tests/tools/test_mcp_oauth.py:http://localhost:/callbackWhy this is safe
This does not broaden callback exposure:
localhoststill resolves to the local machine in the standard desktop/CLI OAuth loopback flowSo this is a compatibility fix, not a security relaxation.
Validation
/home/philipp/.hermes/hermes-agent/venv/bin/python -m pytest tests/tools/test_mcp_oauth.py -q→ 42 passed/home/philipp/.hermes/hermes-agent/venv/bin/python -m pytest tests/tools/test_mcp_oauth_integration.py -q→ 5 passed/home/philipp/.hermes/hermes-agent/venv/bin/hermes mcp test superset→ connected successfully, 112 tools discoveredObserved successful redirect URI:
http://localhost:50611/callbackNote on overlap
There is already an open broader redirect-host plumbing PR (#21482). This PR is intentionally narrower: it fixes the concrete interoperability issue by switching generated loopback redirect URIs to
localhostwhile preserving loopback-only binding on127.0.0.1.