Hmbown/CodeWhale · error

OAuth logout is only supported for URL-based MCP servers

Error message

OAuth logout is only supported for URL-based MCP servers

What it means

`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.

Solutions

  1. Skip servers without a `url` before calling the function (only URL-based servers can have OAuth tokens)
  2. Branch on `server.url.is_some()` and handle command-based servers separately
  3. Check `server_has_manual_authorization` / `bearer_token_env_var` if the intent is clearing other credential types

Example fix

// before
delete_oauth_tokens_for_server(name, server)?;
// after
if server.url.is_some() {
    delete_oauth_tokens_for_server(name, server)?;
}
Defensive patterns

Strategy: validation

Validate before calling

if server.url.is_none() {
    return Ok(false); // nothing to log out for command-based servers
}
delete_oauth_tokens_for_server(name, &server)?;

Type guard

fn is_url_based(server: &McpServerConfig) -> bool {
    server.url.as_deref().map_or(false, |u| !u.is_empty())
}

Prevention

When it happens

Trigger: Calling `delete_oauth_tokens_for_server(name, server)` with an `McpServerConfig` whose `url` field is `None` — typically a stdio/command-based MCP server.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/12d75660b10d13fc. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/mcp/oauth.rs:1373

2. The call blocks (up to 5 minutes) until the browser flow completes on the \
local callback listener, is declined, or times out. Do not assume success \
before the call returns.\n\
3. On success the server reconnects and its real MCP tools replace this \
synthetic authenticate tool, becoming callable from the next model request \
in this session.\n\n\
Treat the URL as sensitive — do not modify it or strip query parameters. If \
the flow is declined, cancelled, or times out, the call returns an error; \
relay it truthfully and suggest `/mcp login {server_name}` in the TUI or \
`codewhale mcp login {server_name}` from a terminal."
    )
}

pub fn delete_oauth_tokens_for_server(name: &str, server: &McpServerConfig) -> Result<bool> {
    if server.reviewed_plugin.is_some() {
        bail!("OAuth storage is disabled for plugin-contributed MCP servers");
    }
    let Some(url) = server.url.as_deref() else {
        bail!("OAuth logout is only supported for URL-based MCP servers");
    };
    delete_oauth_tokens(name, url)
}

pub(crate) fn server_has_manual_authorization(server: &McpServerConfig) -> bool {
    server.bearer_token_env_var.is_some()
        || contains_authorization_header(&server.headers)
        || contains_authorization_header(&server.env_headers)
}

pub fn build_default_headers(
    http_headers: &HashMap<String, String>,
    env_headers: &HashMap<String, String>,
) -> Result<HeaderMap> {
    let mut headers = HeaderMap::new();
    for (name, value) in http_headers {
        insert_header(&mut headers, name, value)?;
    }

View on GitHub (pinned to 73e0f67d83)