HKUDS/nanobot · error · MCPAuthorizationRequiredError

MCP authorization was cancelled

Error message

MCP authorization was cancelled

What it means

Error "MCP authorization was cancelled" thrown in HKUDS/nanobot.

Source

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

    async def redirect_uri(self) -> str | None:
        entry = await asyncio.to_thread(self._read_entry_sync)
        value = entry.get("redirect_uri") if entry is not None else None
        return value if isinstance(value, str) and value else None

    async def prepare_redirect_uri(self, redirect_uri: str, *, reset: bool = False) -> None:
        def update(entry: _StoredServer) -> None:
            changed = entry.get("redirect_uri") != redirect_uri
            if reset:
                entry.pop("tokens", None)
                entry.pop("client_info", None)
            elif changed:
                # Dynamic registrations bind a client to its redirect URI.
                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,

View on GitHub (pinned to 42f37dc4c0)

When it happens

Trigger: Thrown at nanobot/agent/tools/mcp_oauth.py:322 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/08bb486576f8508d. Report an issue: GitHub.