From ce212fe660b6724d1287a4defa1f0b59283456cf Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Tue, 7 Jul 2026 15:09:50 -0600 Subject: [PATCH] feat: Improved error messaging for failed MCP starts because of auth issues --- src/mcp/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/mcp/mod.rs b/src/mcp/mod.rs index 2c89fc8..f9aefca 100644 --- a/src/mcp/mod.rs +++ b/src/mcp/mod.rs @@ -6,6 +6,7 @@ use crate::config::paths; use crate::utils::{AbortSignal, abortable_run_with_spinner}; use crate::vault::Vault; use crate::vault::interpolate_secrets; +use anyhow::Error; use anyhow::{Context, Result, anyhow}; use futures_util::{StreamExt, TryStreamExt, stream}; use http::{HeaderName, HeaderValue}; @@ -286,7 +287,8 @@ impl McpRegistry { Err(e) if is_auth_required_error(&e) => { warn!( "MCP server '{id}' requires OAuth authentication. \ - Run `.mcp auth {id}` in the REPL to authenticate, then restart Coyote." + Run `coyote --auth-mcp {id}` or `.mcp auth {id}` in the REPL to authenticate, \ + then restart Coyote." ); return Ok(None); } @@ -407,8 +409,9 @@ fn merge_bearer_token( } } -fn is_auth_required_error(e: &anyhow::Error) -> bool { - e.to_string().contains("Auth required") +fn is_auth_required_error(e: &Error) -> bool { + e.chain() + .any(|cause| cause.to_string().contains("Auth required")) } async fn spawn_http_mcp_server(