Skip to content

Add login --callback-host flag and required client_id in hosted CIMD#272

Merged
jancurn merged 3 commits into
mainfrom
claude/hopeful-clarke-6c4xv8
Jun 12, 2026
Merged

Add login --callback-host flag and required client_id in hosted CIMD#272
jancurn merged 3 commits into
mainfrom
claude/hopeful-clarke-6c4xv8

Conversation

@jancurn

@jancurn jancurn commented Jun 12, 2026

Copy link
Copy Markdown
Member

mcpc login gets a --callback-host flag (127.0.0.1 default, or localhost) so logins work against servers whose pre-registered OAuth client only accepts the http://localhost:<port>/callback redirect URI form. Also adds the client_id property required by the CIMD spec to the hosted client metadata document, which spec-compliant authorization servers otherwise reject.

  • --callback-host is restricted to loopback values; the callback server still binds only the 127.0.0.1 IP literal (RFC 8252 §8.3)
  • --callback-host localhost with the default hosted CIMD fails fast with guidance — the hosted document intentionally registers only 127.0.0.1 redirect URIs
  • Fixed stale --callback-port help text (claimed range 13316–13325; the actual default is three fixed ports, now derived from MCPC_OAUTH_CALLBACK_PORTS)
  • E2E coverage for the new validation paths; hosted client_id pinned in unit tests

Fixes #271
Fixes #269

https://claude.ai/code/session_01DfrRBieZsA9zumF4UV6XdT

claude added 2 commits June 12, 2026 08:49
The hosted client-metadata.json was missing the client_id property,
which draft-ietf-oauth-client-id-metadata-document section 4.1 and the
MCP authorization spec require to be present and to match the document
URL exactly. Spec-compliant authorization servers reject the document
without it. Also pin client_id to DEFAULT_CLIENT_METADATA_URL in the
existing consistency tests.

Fixes #271

https://claude.ai/code/session_01DfrRBieZsA9zumF4UV6XdT
Some authorization servers have pre-registered OAuth clients whose
redirect URI was registered with the localhost hostname form rather
than the 127.0.0.1 IP literal, and exact redirect URI matching makes
mcpc's hardcoded 127.0.0.1 fail against them. The new login flag
switches the host used in the redirect URI, restricted to loopback
values (127.0.0.1, localhost) so the authorization code can never be
redirected off-machine.

The callback server still binds only the loopback IP literal per
RFC 8252 section 8.3; the flag changes nothing but the URI string.
Combining --callback-host localhost with the default hosted CIMD is
rejected early with guidance, since the hosted document registers
only 127.0.0.1 redirect URIs and the hostname-resolution attack
surface of localhost should not be authorized globally for all
installs.

Also fix the stale --callback-port help text that claimed a port
range 13316-13325; the actual default is three fixed ports, now
derived from MCPC_OAUTH_CALLBACK_PORTS so it cannot drift again.

Fixes #269

https://claude.ai/code/session_01DfrRBieZsA9zumF4UV6XdT
@jancurn jancurn changed the title Add --callback-host option for OAuth redirect URI customization Add login --callback-host flag and required client_id in hosted CIMD Jun 12, 2026
The five flag-validation cases added to basic/auth-errors pushed that
suite past its 180s watchdog budget on the loaded Node CI runner (the
suite passed locally and on Bun). Move them to a dedicated
basic/login-flags file, which needs no test server and gets its own
time budget, restoring auth-errors to its pre-PR runtime.

Also normalize --callback-host case-insensitively: URI hosts are
case-insensitive per RFC 3986, but redirect_uri matching at the
authorization server is an exact string comparison, so LOCALHOST is
accepted and lowercased rather than passed through or rejected.

Refs #269

https://claude.ai/code/session_01DfrRBieZsA9zumF4UV6XdT
@jancurn jancurn merged commit fbfc9fc into main Jun 12, 2026
6 checks passed
@jancurn jancurn deleted the claude/hopeful-clarke-6c4xv8 branch June 12, 2026 12:07
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.

Hosted CIMD Document is not Spec-Compliant Specify callback host on OAuth callback redirects. e.g. localhost

3 participants