{"record":{"id":"17076a8e81ecc866","repo":"Kuberwastaken/claurst","slug":"no-stored-token-for","errorCode":null,"errorMessage":"No stored token for {}","messagePattern":"No stored token for (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src-rust/crates/mcp/src/oauth.rs","lineNumber":524,"sourceCode":"            .duration_since(std::time::UNIX_EPOCH)\n            .unwrap_or_default()\n            .as_secs()\n            + secs\n    });\n\n    Ok(McpToken {\n        access_token: tr.access_token,\n        refresh_token: tr.refresh_token,\n        expires_at,\n        scope: tr.scope,\n        server_name: String::new(), // caller should set this\n    })\n}\n\n/// Refresh an existing MCP token using the stored refresh token.\npub async fn refresh_mcp_token(server_name: &str, token_endpoint: &str) -> anyhow::Result<McpToken> {\n    let existing = get_mcp_token(server_name)\n        .ok_or_else(|| anyhow::anyhow!(\"No stored token for {}\", server_name))?;\n    let refresh = existing\n        .refresh_token\n        .as_deref()\n        .ok_or_else(|| anyhow::anyhow!(\"Token for {} has no refresh token\", server_name))?\n        .to_string();\n\n    let client = reqwest::Client::new();\n    let params = [(\"grant_type\", \"refresh_token\"), (\"refresh_token\", refresh.as_str())];\n\n    let resp = client\n        .post(token_endpoint)\n        .form(&params)\n        .send()\n        .await\n        .map_err(|e| anyhow::anyhow!(\"refresh: request failed: {}\", e))?;\n\n    if !resp.status().is_success() {\n        let status = resp.status();","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/Kuberwastaken/claurst/blob/b0637c97ec34144387cbf2f74f65df6d16a6cef1/src-rust/crates/mcp/src/oauth.rs#L506-L542","documentation":"refresh_mcp_token looked up a stored token for the named MCP server and found none in the local token store. The caller (get_valid_mcp_token) reached the refresh path without an existing stored credential — the server was never authenticated, or its stored token was deleted/cleared.","triggerScenarios":"Thrown at src-rust/crates/mcp/src/oauth.rs:524 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the OAuth authentication flow for this MCP server first","Check whether the token store was cleared or is pointing at a different location"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b0637c97ec34144387cbf2f74f65df6d16a6cef1","analyzedAt":"2026-09-10T00:24:58.650Z","contentChangedAt":"2026-09-10T00:24:58.650Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}