mcp-remote OAuth callback never starts when /sse is public, auth fails
Using mcp-remote (punkpeye/mcp-remote) with an OAuth-protected MCP backend where /sse and /tools/call are public, but a tool method like getOrders() returns 401 Unauthorized, the OAuth callback listener at localhost:6082/oauth/callback is never started. After the user authorizes in the browser, the redirect to that callback fails because no listener is running, and the flow dies with UnauthorizedError. Was this fixed, and how do I make the OAuth flow work?
Originally asked on GitHub: https://github.com/punkpeye/mcp-remote/issues/133
3 answers
Status: fixed. This issue was resolved in mcp-remote 0.3.3. The release is available on npm (@latest dist-tag) and on GitHub releases (v0.3.3); the release announcement only confirms the issue is resolved and doesn't describe the internal fix.
Root cause per the report: mcp-remote only starts the local OAuth callback listener after the first endpoint it contacts returns 401. When /sse and /tools/call are public but the actual tool method is protected, the 401 arrives too late — the browser has already redirected the authorization code to localhost:6082/oauth/callback, where no listener is running, so the token exchange fails with UnauthorizedError.
Workaround attempt from the thread: one user running Claude said they could only authenticate by calling mcp-remote directly from the CLI, because Claude does not integrate with the OAuth flow mcp-remote triggers. They also noted they found no way to call a specific authenticated tool from the CLI to start that flow, so this doesn't cover per-tool authentication (for example, securitySchemes per the OpenAI Apps SDK).
General advice: upgrade to 0.3.3 and retest before relying on workarounds. Keep the callback port bound to localhost so authorization codes are not exposed over your network.
Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Reporter set up a server with public /sse and /tools/call, a protected getOrders() method returning 401, and a valid OAuth config (client_id, auth_url, token_url, redirect_uri pointing to localhost:6082/oauth/callback). The browser launched and the user authorized, but the redirect failed because no callback listener was running, ending in UnauthorizedError.
Source: https://github.com/punkpeye/mcp-remote/issues/133 (opens external site)
Did this work for you?What @Jackman3005 tried on GitHub (Outcome unclear)
Another user, using Claude, tried authenticating via a direct CLI call to mcp-remote since Claude doesn't integrate with the OAuth flow mcp-remote starts. They found no way to call a specific authenticated tool from the CLI to initiate the OAuth flow.
Source: https://github.com/punkpeye/mcp-remote/issues/133#issuecomment-3403850216 (opens external site)
Did this work for you?