{"record":{"id":"12d75660b10d13fc","repo":"Hmbown/CodeWhale","slug":"oauth-logout-is-only-supported-for-url-based-mcp-s","errorCode":null,"errorMessage":"OAuth logout is only supported for URL-based MCP servers","messagePattern":"OAuth logout is only supported for URL-based MCP servers","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/mcp/oauth.rs","lineNumber":1373,"sourceCode":"2. The call blocks (up to 5 minutes) until the browser flow completes on the \\\nlocal callback listener, is declined, or times out. Do not assume success \\\nbefore the call returns.\\n\\\n3. On success the server reconnects and its real MCP tools replace this \\\nsynthetic authenticate tool, becoming callable from the next model request \\\nin this session.\\n\\n\\\nTreat the URL as sensitive — do not modify it or strip query parameters. If \\\nthe flow is declined, cancelled, or times out, the call returns an error; \\\nrelay it truthfully and suggest `/mcp login {server_name}` in the TUI or \\\n`codewhale mcp login {server_name}` from a terminal.\"\n    )\n}\n\npub fn delete_oauth_tokens_for_server(name: &str, server: &McpServerConfig) -> Result<bool> {\n    if server.reviewed_plugin.is_some() {\n        bail!(\"OAuth storage is disabled for plugin-contributed MCP servers\");\n    }\n    let Some(url) = server.url.as_deref() else {\n        bail!(\"OAuth logout is only supported for URL-based MCP servers\");\n    };\n    delete_oauth_tokens(name, url)\n}\n\npub(crate) fn server_has_manual_authorization(server: &McpServerConfig) -> bool {\n    server.bearer_token_env_var.is_some()\n        || contains_authorization_header(&server.headers)\n        || contains_authorization_header(&server.env_headers)\n}\n\npub fn build_default_headers(\n    http_headers: &HashMap<String, String>,\n    env_headers: &HashMap<String, String>,\n) -> Result<HeaderMap> {\n    let mut headers = HeaderMap::new();\n    for (name, value) in http_headers {\n        insert_header(&mut headers, name, value)?;\n    }","sourceCodeStart":1355,"sourceCodeEnd":1391,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/mcp/oauth.rs#L1355-L1391","documentation":"`delete_oauth_tokens_for_server` removes stored OAuth tokens for an MCP server, but OAuth storage only makes sense for servers configured by URL. When the server config has no `url` (e.g. it is launched via a command/stdio transport), there is no OAuth endpoint to which tokens belong, so the function fails loudly instead of silently doing nothing.","triggerScenarios":"Calling `delete_oauth_tokens_for_server(name, server)` with an `McpServerConfig` whose `url` field is `None` — typically a stdio/command-based MCP server.","commonSituations":"A generic 'logout/clear all MCP credentials' routine that iterates over every configured server including stdio-launched ones; configs migrated from command-based servers; users trying to log out of a server that never used OAuth.","solutions":["Skip servers without a `url` before calling the function (only URL-based servers can have OAuth tokens)","Branch on `server.url.is_some()` and handle command-based servers separately","Check `server_has_manual_authorization` / `bearer_token_env_var` if the intent is clearing other credential types"],"exampleFix":"// before\ndelete_oauth_tokens_for_server(name, server)?;\n// after\nif server.url.is_some() {\n    delete_oauth_tokens_for_server(name, server)?;\n}","handlingStrategy":"validation","validationCode":"if server.url.is_none() {\n    return Ok(false); // nothing to log out for command-based servers\n}\ndelete_oauth_tokens_for_server(name, &server)?;","typeGuard":"fn is_url_based(server: &McpServerConfig) -> bool {\n    server.url.as_deref().map_or(false, |u| !u.is_empty())\n}","tryCatchPattern":null,"preventionTips":["Filter server lists to URL-based entries before OAuth operations","Remember command/stdio servers never hold OAuth tokens"],"tags":["mcp","oauth","config"],"backgroundTag":"unsupported-operation","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}