HKUDS/nanobot · error · MCPAuthorizationRequiredError

MCP server requires browser authorization

Error message

MCP server requires browser authorization

What it means

Raised via _missing_callback when an MCP server has stored credentials incomplete and no authorization callback URL is registered — the OAuth flow has not been completed, so the user must authorize in a browser before the server can connect.

Solutions

  1. Open the MCP authorization URL and complete the browser consent flow
  2. Supply client credentials for the MCP server in config so no OAuth is needed
  3. Disable the OAuth-requiring MCP server until credentials are set up
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at nanobot/agent/tools/mcp_oauth.py:335 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26). Data as JSON: /api/errors/54496a39721fa365. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/agent/tools/mcp_oauth.py:335

                entry.pop("client_info", None)
            entry["redirect_uri"] = redirect_uri

        claimed = await asyncio.to_thread(self._update_entry_sync, update, claim=True)
        if not claimed:
            raise MCPAuthorizationRequiredError("MCP authorization was cancelled")

    def has_credentials(self) -> bool:
        entry = self._read_entry_sync()
        raw_tokens = entry.get("tokens") if entry is not None else None
        if not isinstance(raw_tokens, dict):
            return False
        tokens = cast(dict[str, object], raw_tokens)
        access_token = tokens.get("access_token")
        return isinstance(access_token, str) and bool(access_token)


async def _missing_callback() -> tuple[str, str | None]:
    raise MCPAuthorizationRequiredError("MCP server requires browser authorization")


async def create_mcp_oauth_auth(
    server_name: str,
    server_url: str,
    handlers: MCPOAuthHandlers | None = None,
) -> OAuthClientProvider:
    """Build the official MCP SDK OAuth provider for one configured server."""
    storage = MCPOAuthStorage(server_name, server_url)
    if handlers is not None:
        await storage.prepare_redirect_uri(
            handlers.redirect_uri,
            reset=handlers.reset_credentials,
        )
        redirect_uri = handlers.redirect_uri
        redirect_handler = handlers.redirect_handler
        callback_handler = handlers.callback_handler
    else:

View on GitHub (pinned to 42f37dc4c0)