mcp-use inspector shows raw OAuth error stack trace instead of redirecting back
When connecting the mcp-use inspector at http://localhost:8789/inspector to an OAuth-requiring MCP server and denying consent, the callback URL /oauth/callback?error=access_denied&error_description=User+denied+access&state=... renders a raw "Authentication Error" page with a JavaScript stack trace injected into the DOM instead of redirecting back to the inspector. What causes this and is there a fix or workaround?
Originally asked on GitHub: https://github.com/mcp-use/mcp-use/issues/1362
4 answers
Status: fixed — the issue was closed as COMPLETED, but no fix version or patch is mentioned in the thread.
The root cause is in
libraries/typescript/packages/mcp-use/src/auth/callback.ts:31-35: anyerrorquery parameter is thrown immediately with no distinction between error types, and the catch block writes the error (stack trace included) directly into the DOM instead of navigating back to the inspector or closing the popup.Reproduction: open the inspector at
http://localhost:8789/inspector, connect to an OAuth-requiring MCP server, and click Deny on the consent screen. The callback page then shows:Authentication Error OAuth error: access_denied - User denied access ... Error: OAuth error: access_denied - User denied access at onMcpAuthorization (...)Console logs from the reporter confirm the sequence: the callback handler receives
error='access_denied', throws atonMcpAuthorization, the inspector then gets401 Unauthorizedonhttp://localhost:8789/mcp, and the auth URL is stored for a manual retry (pending_authstate).No patch was posted. A commenter offered general advice (not from a maintainer, no code attached): intercept the error query parameter before any DOM rendering and map error types to user-facing messages —
access_deniedto a silent close or soft notice,server_errorto a retry prompt. The issue body's expected behavior additionally liststemporarily_unavailableas a retry prompt and other errors as showingerror_descriptionwithout a stack trace. As general advice, if you cannot patch the source, the raw page is cosmetic: the inspector still stores the auth URL and showspending_auth, so the flow can be retried manually.Did this work for you?What a GitHub user tried on GitHub (Didn't work)
Reporter opened the inspector at http://localhost:8789/inspector, connected to an OAuth-requiring MCP server, and clicked Deny on the consent screen. The callback page rendered a raw Authentication Error with a stack trace at onMcpAuthorization instead of redirecting back to the inspector.
Source: https://github.com/mcp-use/mcp-use/issues/1362 (opens external site)
Did this work for you?What @cswkim tried on GitHub (Outcome unclear)
Reporter captured browser console logs from the callback page, showing the handler received error='access_denied', threw at onMcpAuthorization, then got 401 from http://localhost:8789/mcp and stored the auth URL for manual trigger. Diagnostic only; no fix.
Source: https://github.com/mcp-use/mcp-use/issues/1362#issuecomment-4274330170 (opens external site)
Did this work for you?What @rehan243 tried on GitHub (Outcome unclear)
Commenter suggested intercepting the error query param early and mapping error types to user-facing messages (access_denied to silent close/soft notice, server_error to retry prompt) before any DOM rendering, based on experience with a similar custom auth layer. No patch was attached.
Source: https://github.com/mcp-use/mcp-use/issues/1362#issuecomment-4281540044 (opens external site)
Did this work for you?
Related questions
- How to stream output from mcp-use MCPAgent like LangChain's agent_executor?
- MCPAgent.run() server_name is obsolete: how do I limit a run to specific servers?
- Does mcp-use support the MCP Streamable HTTP transport?
- Can I use mcp-use with Python 3.10?
- mcp-use: tool call with invalid action input fails the whole run and never retries