fix(mcp): FastMCP-compatible redirect-URI patterns for DCR allow-list#34
Open
hunzlahmalik wants to merge 1 commit into
Open
fix(mcp): FastMCP-compatible redirect-URI patterns for DCR allow-list#34hunzlahmalik wants to merge 1 commit into
hunzlahmalik wants to merge 1 commit into
Conversation
MCP_ALLOWED_CLIENT_REDIRECT_URIS is one value shared across the stack, written in FastMCP's pattern syntax (http://localhost:*, https://claude.ai/*). The origin-equality matcher merged in #33 can't satisfy a port wildcard: http://localhost:* has no port in its prefix, so its origin resolves to http://localhost and never equals http://localhost:6274 — every MCP Inspector / loopback DCR registration fails with "redirect_uri is not allowed by this server". Port FastMCP's component-wise matcher: scheme compared exactly, host with *.example.com subdomain wildcards (apex excluded), port with a "*" wildcard plus RFC 8252 loopback any-port semantics, path as a glob. URIs carrying userinfo are rejected outright, so http://localhost@evil.com can never satisfy a localhost pattern and a host can never be extended past a too-broad entry. Verified against the sandbox allow-list (20 cases): Inspector loopback callbacks and claude.ai / claude.com callbacks match; evil-host, userinfo and scheme-swap variants do not. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What
Fixes the DCR redirect-URI allow-list matcher so the shared
MCP_ALLOWED_CLIENT_REDIRECT_URISvalue parses the same way in the Penpot MCP gate as it does forsurfsense-mcp/plane-mcp. Follow-up to #33.Problem
MCP_ALLOWED_CLIENT_REDIRECT_URISis one value shared across all three MCP servers, written in FastMCP's pattern syntax (http://localhost:*,https://claude.ai/*). The origin-equality matcher merged in #33 can't satisfy a port wildcard:http://localhost:*has no port in its prefix, sonew URL("http://localhost:").originresolves tohttp://localhostand never equalshttp://localhost:6274.Result on the sandbox: every MCP Inspector / loopback DCR registration fails with
Fix
Port FastMCP's component-wise matcher (
fastmcp/server/auth/redirect_validation.py):*.example.comsubdomain wildcards (apex excluded)*wildcard, plus RFC 8252 loopback any-port semantics (http://localhost:*/http://127.0.0.1:*match any port)/auth/*)http://localhost@evil.comcan never satisfy a localhost pattern and a host can't be extended past a too-broad entryVerified
Tested against the exact sandbox allow-list — 20 cases:
http://localhost:6274/oauth/callback,/oauth/callback/debug,http://127.0.0.1:*https://claude.ai/*,https://claude.com/*,https://sandbox.askii.ai/*and the other askii subdomainshttp://localhost@evil.com/...,https://claude.ai.evil.com/...,https://sandbox.askii.ai.evil.com/..., scheme swaps, unparseable valuestsc --noEmitclean.Note
A no-redeploy env stopgap exists for the currently-deployed image (give the loopback entries explicit ports:
http://localhost:6274/*,http://127.0.0.1:6274/*). This PR is the real fix — once merged and deployed, the allow-list can return to the FastMCP:*form for proper any-port loopback support, identical to the other MCP servers.🤖 Generated with Claude Code