Support exact MCP OAuth redirect URIs - #506
Draft
samueleguino97 wants to merge 2 commits into
Draft
samueleguino97 wants to merge 2 commits into
samueleguino97 wants to merge 2 commits into
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
oauth.redirect_uriconfiguration for remote MCP servershttp://127.0.0.1:<port>/callbackdefaultlocalhost,127.0.0.1, or[::1]URLs on their exact port and accept their configured callback pathProblem
OAuth providers do not agree on one loopback redirect form. Calendly's Dynamic Client Registration endpoint accepts
localhostbut rejects127.0.0.1, while other providers require127.0.0.1. Providers may also require a pre-registered fixed port or callback path.A global hostname change would fix one provider by breaking another.
Fix
Profile configuration can now provide the exact redirect URI required by a server:
{ "mcp": { "calendly": { "type": "http", "url": "https://mcp.calendly.com/", "oauth": { "issuer": "https://calendly.com", "redirect_uri": "http://localhost:3118/callback" } } } }When omitted, behavior remains unchanged: fx binds an ephemeral port on
127.0.0.1and advertiseshttp://127.0.0.1:<port>/callback.The configured value is restricted to an exact HTTP loopback URL with an explicit nonzero port. fx binds the corresponding loopback interface and validates the incoming request against the configured path. The exact URI is reused for client registration, authorization, and token exchange.
This covers the hostname and path cases in addition to the fixed-port use case discussed in #491.
Verification
zig fmt --check src/passedzig buildpassedzig build testpassed, exit code 0bun test mcp-auth.test.ts -t 'configured OAuth redirect URI binds the exact loopback callback'(1 pass, 0 fail)mcp-auth.test.tsrun passed the new test; one unrelated cache-ordering case failed transiently, then passed alone (1 pass, 0 fail)http://localhost:43118/oauth/callbackwith HTTP 201 and returned that exact URI