Common Questions

MCP Unauthorized After Login: Trace the Token

Trace MCP unauthorized errors through token audience, scopes, expiry and downstream credentials after a browser login appears successful.

··5 min read

The essentials

  • A completed browser login does not prove that every later request has the right credential.
  • The MCP client may need a token for the MCP server, while the server needs a separate authorization to call an external service.
On this page

A completed browser login does not prove that every later request has the right credential. The MCP client may need a token for the MCP server, while the server needs a separate authorization to call an external service. Trace which request returns the error before reconnecting accounts.

First identify the connection type

For an HTTP server using MCP OAuth, inspect the client-to-server authorization flow. A local stdio server may instead receive provider credentials through its launch environment. A successful browser login in another application does not establish what credential that local process received. Check the selected server entry and supported credential mechanism before reconnecting.

Identify the failing boundary

Write down the sequence: browser authorization, token exchange, client request to MCP, and server request to the downstream provider. Capture status codes and sanitized error categories at each boundary.

Never paste bearer tokens or refresh tokens into a ticket. Record issuer, intended resource, scope names and expiry only where those fields can be inspected safely.

The MCP authorization specification explains resource-oriented authorization. Use the specification revision negotiated by your client and server; a legacy example may not match a newer implementation.

Separate authentication from permission

A user can be correctly signed in but lack access to the requested project. A token can also be valid for one service and invalid for another.

Pattern Investigation
Every MCP call fails immediately Token delivery, intended resource, issuer
Discovery succeeds, one tool fails Scope or tool-specific downstream access
Works initially, later fails Expiry, refresh or revoked access
One account works Account membership or resource selection

Status codes help narrow the search, but read the provider's error response: implementations do not always classify authorization failures identically.

HTTP 401, HTTP 403 or a tool error?

For the HTTP authorization flow described in the linked specification, an invalid or expired token produces HTTP 401; insufficient scope produces HTTP 403. Inspect the authentication challenge and requested resource before changing access. Use the client's supported authorization flow rather than manually moving tokens between services.

A successful HTTP response does not mean the tool succeeded. The MCP tools specification permits tool execution failures in a result marked isError: true. Inspect the tool result and server logs to distinguish downstream denial from rejection at the MCP endpoint.

Worked example: discovery works, repository read fails

Suppose the client lists tools successfully, then a repository read fails. The following trace is synthetic; names and correlation IDs are placeholders, not actual server log fields:

request audit-001: client -> MCP tools/list: success
request audit-002: client -> MCP tools/call: HTTP transport succeeded
request audit-002: tool result: isError=true
request audit-002: MCP server -> provider: access denied
credential value: never recorded

This trace points toward provider access, but does not identify the missing permission by itself. Check the repository identifier, provider account, credential repository selection and any organization authorization requirement. Compare a known-access read using the same connection. Do not infer that successful discovery validated every downstream credential.

If the MCP endpoint instead returns 401 before executing the tool, investigate token delivery, intended audience and expiry at that boundary. If the tool is missing entirely, use MCP connected but no tools; granting broader provider access may not change tool discovery.

Test the smallest permitted action

Choose a harmless read operation against a resource the user is known to access. Compare it with the failing operation using the same identity.

If the read works and a write fails, do not request an all-powerful credential by default. Determine the missing scope or application permission and whether the user's task requires it.

The MCP security guidance explains why blindly passing a client's token through to another service is unsafe. Fix the appropriate authorization flow.

Handle expiry deliberately

Check whether the client refreshes credentials through its supported mechanism. Compare machine clocks when timestamps appear inconsistent. If access was revoked, reauthorization may be appropriate; repeated reconnecting will not fix a server that requests the wrong resource.

Keep old and new configuration records free of secret values so you can identify what changed.

Confirm a stable result

Repeat the read test, then the authorized target action. Test again across the expected credential-refresh boundary in a controlled environment. Record the client and server versions and any provider-specific requirement.

Use the permissions audit to document effective access. The goal is a correctly scoped working action, not a login screen that merely reports success.

This guide draws on the linked documentation. Examples are illustrative unless explicitly identified as measured results.

Marcus Vance

Editorial contributor covering foundational AI models, agentic workflows, and systems engineering for Lucivo.

The Weekly Breakdown

High signal AI & software stories.
Direct to your inbox. No hype.

Independent analysis of AI models, developer tools, and computing architectures. Delivered every Sunday morning. 100% free.

Zero spam·One-click unsubscribe·Sunday delivery