feat: Improved error messaging for failed MCP starts because of auth issues
This commit is contained in:
+6
-3
@@ -6,6 +6,7 @@ use crate::config::paths;
|
|||||||
use crate::utils::{AbortSignal, abortable_run_with_spinner};
|
use crate::utils::{AbortSignal, abortable_run_with_spinner};
|
||||||
use crate::vault::Vault;
|
use crate::vault::Vault;
|
||||||
use crate::vault::interpolate_secrets;
|
use crate::vault::interpolate_secrets;
|
||||||
|
use anyhow::Error;
|
||||||
use anyhow::{Context, Result, anyhow};
|
use anyhow::{Context, Result, anyhow};
|
||||||
use futures_util::{StreamExt, TryStreamExt, stream};
|
use futures_util::{StreamExt, TryStreamExt, stream};
|
||||||
use http::{HeaderName, HeaderValue};
|
use http::{HeaderName, HeaderValue};
|
||||||
@@ -286,7 +287,8 @@ impl McpRegistry {
|
|||||||
Err(e) if is_auth_required_error(&e) => {
|
Err(e) if is_auth_required_error(&e) => {
|
||||||
warn!(
|
warn!(
|
||||||
"MCP server '{id}' requires OAuth authentication. \
|
"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);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
@@ -407,8 +409,9 @@ fn merge_bearer_token(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_auth_required_error(e: &anyhow::Error) -> bool {
|
fn is_auth_required_error(e: &Error) -> bool {
|
||||||
e.to_string().contains("Auth required")
|
e.chain()
|
||||||
|
.any(|cause| cause.to_string().contains("Auth required"))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn spawn_http_mcp_server(
|
async fn spawn_http_mcp_server(
|
||||||
|
|||||||
Reference in New Issue
Block a user