Skip to content

Fix OAuth login with query string parameters in server URLs#290

Merged
jancurn merged 2 commits into
mainfrom
claude/wonderful-fermi-4j5auq
Jun 24, 2026
Merged

Fix OAuth login with query string parameters in server URLs#290
jancurn merged 2 commits into
mainfrom
claude/wonderful-fermi-4j5auq

Conversation

@jancurn

@jancurn jancurn commented Jun 24, 2026

Copy link
Copy Markdown
Member

mcpc login https://mcp.apify.com/?tools=search-actors,docs failed with HTTP 404 ... POST /register, while the same URL without the query worked. A query like Apify's ?tools= filter is a connection-level concern, not part of the server's OAuth identity — but the MCP SDK copies it onto its .well-known discovery requests, which breaks discovery and makes it fall back to POST <origin>/register on the MCP server.

  • Add getOAuthServerUrl() to strip the query/fragment (keeping the path)
  • Use it for the login flow and OAuth metadata discovery
  • Profile/keychain keys already key on the host, so login/connect lookups stay consistent
  • Add unit tests + a discovery regression test + changelog entry

https://claude.ai/code/session_01HcHZT2MZSUoQi5GHumhiad

claude added 2 commits June 24, 2026 14:34
`mcpc login https://mcp.apify.com/?tools=search-actors,docs` failed with
`HTTP 404 ... POST /register` while the same URL without the query worked.

The query string (e.g. Apify's `?tools=` tool filter) is a connection-level
concern, not part of the server's OAuth identity. The MCP SDK copies it onto
its `/.well-known/oauth-protected-resource` discovery request, which breaks
discovery; the SDK then treats the MCP origin as its own authorization server
and issues `POST <origin>/register`, which the MCP server has no route for.

Add `getOAuthServerUrl()` to strip the query/fragment (keeping the path) and
use it for the login flow and OAuth metadata discovery. Profile and keychain
keys already key on the host, so login/connect lookups stay consistent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HcHZT2MZSUoQi5GHumhiad
It is OAuth-specific by name and purpose and only used by OAuth code, so it
belongs in the shared OAuth utilities module rather than the generic utils.
Pure move (function + tests relocated); no behaviour change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HcHZT2MZSUoQi5GHumhiad
@jancurn jancurn merged commit e166271 into main Jun 24, 2026
6 checks passed
@jancurn jancurn deleted the claude/wonderful-fermi-4j5auq branch June 24, 2026 15:12
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.

3 participants