Hmbown/CodeWhale · error
MCP server ' ': failed
Error message
MCP server '{server}': {method} failed: {error} What it means
When sending a JSON-RPC request to an MCP server over stdio, the client waits for a response with a matching id. If the server replies with a JSON-RPC error object instead of a result, the client bails with this message embedding the server name, method, and the server's error payload. It surfaces server-side failures (unknown method, bad params, server crash) as a client-side anyhow error.
Solutions
- Read the embedded {error} payload — it is the server's own JSON-RPC error message; fix the request (method name, params) accordingly.
- Verify the server binary/version supports the method being called (check tools/list output).
- Check the MCP server's stderr logs for the underlying server-side panic or error.
- Reconnect/restart the server (spawn_with_timeouts) and retry if the failure was transient.
- Pin a compatible MCP protocol version between client and server.
Example fix
// before: calling a method the server may not implement
let result = client.request("tools/call", params).await?;
// after: verify capability first
let tools = client.request("tools/list", json!({})).await?;
if !supports(&tools, "my_tool") {
anyhow::bail!("server does not expose my_tool");
}
let result = client.request("tools/call", params).await?; Defensive patterns
Strategy: try-catch
Validate before calling
// Before sending, confirm the server exposes the method
capabilities = client.request("tools/list", json!({})).await?;
anyhow::ensure!(capabilities["tools"].as_array().map_or(false, |t| !t.is_empty()), "server exposes no tools"); Type guard
fn is_jsonrpc_error(msg: &Value) -> bool { msg.get("error").is_some() } Try / catch
match client.request(method, params).await {
Ok(result) => use(result),
Err(e) if e.to_string().contains("failed:") => {
log::warn!("MCP server rejected {method}: {e}");
// degrade gracefully or restart the server
}
Err(e) => return Err(e),
} Prevention
- Discover capabilities with tools/list before calling methods
- Keep client and server MCP protocol versions in sync
- Capture and review MCP server stderr logs
- Retry transient server errors with backoff after a reconnect
When it happens
Trigger: Calling an MCP tool/resource method via request() when the server responds with a JSON-RPC error object (e.g. method not found, invalid params, internal server error) for the matching request id.
Common situations: MCP server binary doesn't implement the requested method or version mismatch; tool arguments fail server-side validation; server process partially crashed mid-request; tools/list called against a server that only supports a subset of the protocol.
Related errors
- failed to read bounded stdio JSON-RPC frame
- failed to read bounded stdio JSON-RPC frame
- MCP error in
- MCP error in
- MCP server ' ': received a child message without jsonrpc…
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/cd496bfb9aaba2b3.
Report an issue: GitHub.
Appendix: source
Thrown at crates/mcp/src/stdio_client.rs:924
};
// Servers occasionally emit banners or log lines on stdout. They
// are skipped; only the matching response ends the wait. Valid
// requests and notifications are handled by the reader before
// they reach this rendezvous.
let Ok(message) = serde_json::from_str::<Value>(&line) else {
continue;
};
if message.get("jsonrpc").and_then(Value::as_str) != Some("2.0") {
bail!(
"MCP server '{server}': {method} received a child message without jsonrpc \"2.0\""
);
}
if message.get("id").and_then(Value::as_u64) != Some(id) {
continue;
}
if let Some(error) = message.get("error") {
bail!("MCP server '{server}': {method} failed: {error}");
}
return message.get("result").cloned().with_context(|| {
format!(
"MCP server '{server}': {method} response contained neither result nor error"
)
});
}
}
/// The child's exit status, when it has one, for appending to a failure
/// message. Polls briefly because both callers run at the moment the child
/// is dying: the write can return EPIPE, or stdout can hit EOF, before the
/// kernel has finished reaping the process. Bounded and error-path-only,
/// so the cost buys a real diagnostic ("exited with status 127" is the
/// difference between a crashed server and a missing one).
fn exit_note(&mut self) -> String {
let Some(child) = self.child.as_mut() else {
return String::new();View on GitHub (pinned to 73e0f67d83)