{"record":{"id":"08bb486576f8508d","repo":"HKUDS/nanobot","slug":"mcp-authorization-was-cancelled","errorCode":null,"errorMessage":"MCP authorization was cancelled","messagePattern":"MCP authorization was cancelled","errorType":"exception","errorClass":"MCPAuthorizationRequiredError","httpStatus":null,"severity":"error","filePath":"nanobot/agent/tools/mcp_oauth.py","lineNumber":322,"sourceCode":"    async def redirect_uri(self) -> str | None:\n        entry = await asyncio.to_thread(self._read_entry_sync)\n        value = entry.get(\"redirect_uri\") if entry is not None else None\n        return value if isinstance(value, str) and value else None\n\n    async def prepare_redirect_uri(self, redirect_uri: str, *, reset: bool = False) -> None:\n        def update(entry: _StoredServer) -> None:\n            changed = entry.get(\"redirect_uri\") != redirect_uri\n            if reset:\n                entry.pop(\"tokens\", None)\n                entry.pop(\"client_info\", None)\n            elif changed:\n                # Dynamic registrations bind a client to its redirect URI.\n                entry.pop(\"client_info\", None)\n            entry[\"redirect_uri\"] = redirect_uri\n\n        claimed = await asyncio.to_thread(self._update_entry_sync, update, claim=True)\n        if not claimed:\n            raise MCPAuthorizationRequiredError(\"MCP authorization was cancelled\")\n\n    def has_credentials(self) -> bool:\n        entry = self._read_entry_sync()\n        raw_tokens = entry.get(\"tokens\") if entry is not None else None\n        if not isinstance(raw_tokens, dict):\n            return False\n        tokens = cast(dict[str, object], raw_tokens)\n        access_token = tokens.get(\"access_token\")\n        return isinstance(access_token, str) and bool(access_token)\n\n\nasync def _missing_callback() -> tuple[str, str | None]:\n    raise MCPAuthorizationRequiredError(\"MCP server requires browser authorization\")\n\n\nasync def create_mcp_oauth_auth(\n    server_name: str,\n    server_url: str,","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/HKUDS/nanobot/blob/42f37dc4c0e409eac7818a82d165c5f2757bc075/nanobot/agent/tools/mcp_oauth.py#L304-L340","documentation":"Error \"MCP authorization was cancelled\" thrown in HKUDS/nanobot.","triggerScenarios":"Thrown at nanobot/agent/tools/mcp_oauth.py:322 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"42f37dc4c0e409eac7818a82d165c5f2757bc075","analyzedAt":"2026-08-26T00:18:52.276Z","schemaVersion":2},"datasetVersion":"2026-08-26T04:18:47.238Z"}