fix(cli): propagate --allow-http to MCPOAuthProvider.validateResourceURL#1671
Draft
bokelley wants to merge 2 commits into
Draft
fix(cli): propagate --allow-http to MCPOAuthProvider.validateResourceURL#1671bokelley wants to merge 2 commits into
bokelley wants to merge 2 commits into
Conversation
Loopback hosts (localhost, 127.0.0.1, [::1]) are now always allowed in resource URL validation, matching the ClientCredentialsFlow precedent. Non-loopback HTTP is gated on --allow-http, which is now threaded from all five CLI OAuth call sites through createCLIOAuthProvider. Also adds --allow-http to the top-level --help OPTIONS output. Closes #1664 https://claude.ai/code/session_016JQ5nbc8z8AhV9idzdYPgq
URL.hostname always returns '[::1]' (with brackets) for IPv6 loopback literals after WHATWG URL parsing, so bare '::1' is unreachable. https://claude.ai/code/session_016JQ5nbc8z8AhV9idzdYPgq
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.
Closes #1664
Summary
MCPOAuthProvider.validateResourceURLthrew unconditionally on any non-HTTPSresourceURL, blocking OAuth flows againsthttp://localhostdev servers even when--allow-httpwas passed. The flag was parsed bycomply/storyboard/gradebut never threaded into theMCPOAuthProviderconstructor.Fix (option 3 from the issue):
localhost,127.0.0.1,[::1]) are always allowed in resource URL validation — matching theClientCredentialsFlow.tsprecedent and RFC 6749 §3.1.2.1 loopback carve-outallowHttp(CLI:--allow-http)--allow-httpis now threaded from all five CLI OAuth call sites throughcreateCLIOAuthProviderto the provider--allow-httpadded toOAuthProviderConfig,createCLIOAuthProvideroptions, andcreateNonInteractiveOAuthProvideroptions--allow-httpadded to top-level--helpOPTIONS outputWhat was tested
npm run format:check✅npx tsc --project tsconfig.lib.json— no errors in changed files (2 pre-existing env errors: missing@types/nodeand deprecated tsconfignode10option — both pre-date this branch)test/mcp-oauth-provider-validate-resource-url.test.jscovering: HTTPS pass-through, loopback carve-out for all three loopback forms (localhost,127.0.0.1,[::1]), non-loopback HTTP rejection with actionable error message,--allow-httpacceptance,localhost.attacker.comnon-bypass@modelcontextprotocol/sdkinnode_modules(same failure as pre-existingtest/oauth-storyboard-plumbing.test.js); will pass in CI with full dep installPre-PR review
[::1]check is correct (bare::1unreachable after WHATWG URL normalization — clarified in follow-up commit);--save-authcall site re-parsesargsbecause it's a different block scope without a hoistedallowHttp(intentional); changeset present and correctly typedpatch[::1]branch is reachable and exercised by tests; storyboard runner intentionally doesn't threadallow_httpinto the OAuth SDK path (pre-saved token path viaNonInteractiveFlowHandler)Nits noted (not fixed in this PR)
docs/CLI.mdoptions section is broadly out of date (pre-existing);--allow-httpis one of many missing flags — full refresh is a separate taskBUILD-AN-AGENT.mdlocal-dev examples could note--allow-httpfor servers that advertise HTTP resource URLs in OAuth metadataSession: https://claude.ai/code/session_016JQ5nbc8z8AhV9idzdYPgq