Skip to content

feat(oauth): add --callback-path for IdP-enforced redirect URIs - #19

Open
cahalane wants to merge 1 commit into
abluva:mainfrom
cahalane:feat/callback-path
Open

cahalane wants to merge 1 commit into
abluva:mainfrom
cahalane:feat/callback-path

Conversation

@cahalane

Copy link
Copy Markdown

Summary

Adds a --callback-path flag so the OAuth loopback path is configurable.

The path was hardcoded to /oauth/callback in two places that must agree: the redirect_uri sent during client registration (NodeOAuthClientProvider) and the path the local callback server listens on (coordinateAuth). Authorization servers such as Okta only accept a redirect URI that exactly matches a pre-registered one, and that URI does not always use /oauth/callback. With no way to change it, the redirect landed on a path the proxy did not serve and login never completed.

One flag now feeds both. It defaults to /oauth/callback, so existing setups are unaffected. A value without a leading slash gets one.

mcp-remote https://server/mcp 8401 --callback-path /callback
# redirect_uri and listener both become http://localhost:8401/callback

Changes

  • parseCommandLineArgs parses --callback-path and adds it to the positional-arg skip list.
  • createLazyAuthCoordinator and coordinateAuth take the path and pass it to setupOAuthCallbackServerWithLongPoll. Defaulted, so existing four-argument callers and tests are unchanged.
  • proxy.ts and client.ts thread it to the coordinator and to NodeOAuthClientProvider, which already accepted a callbackPath option that nothing set.
  • README bullet under the flag list.

Tests

Unit tests for the arg parsing (default, explicit, missing leading slash, positional-arg handling) and for the provider's redirect_uri. npm run test:unit: 213 passed.

🤖 Generated with Claude Code

The loopback path was hardcoded in two places that must agree: the
redirect_uri advertised during registration and the local callback
listener. Some IdPs (e.g. Okta) only accept an exact pre-registered
redirect URI, which may not use the default /oauth/callback path.

Both now derive from one --callback-path flag, defaulting to
/oauth/callback so existing setups are unaffected.

Generated with Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant