{"record":{"id":"8f4c166e342d9f3f","repo":"tinyhumansai/openhuman","slug":"mcp-stdio-error-err","errorCode":null,"errorMessage":"MCP stdio error: {err}","messagePattern":"MCP stdio error: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/openhuman/mcp/config_servers/stdio.rs","lineNumber":244,"sourceCode":"                anyhow::bail!(\"stdio MCP server closed stdout while waiting for `{method}`\");\n            }\n            let trimmed = response.trim();\n            if trimmed.is_empty() {\n                continue;\n            }\n            if !trimmed.starts_with('{') && !trimmed.starts_with('[') {\n                tracing::debug!(\n                    target: \"[mcp_client::stdio]\",\n                    command = %self.command,\n                    line = %trimmed,\n                    \"ignoring non-JSON stdout line from stdio MCP server\"\n                );\n                continue;\n            }\n            let payload: Value = serde_json::from_str(trimmed)\n                .with_context(|| format!(\"parsing stdio MCP response: {trimmed}\"))?;\n            if let Some(err) = payload.get(\"error\") {\n                anyhow::bail!(\"MCP stdio error: {err}\");\n            }\n            return payload\n                .get(\"result\")\n                .cloned()\n                .ok_or_else(|| anyhow::anyhow!(\"stdio MCP response missing `result`: {payload}\"));\n        }\n    }\n\n    async fn send_notification_on_session(\n        &self,\n        session: &mut StdioSession,\n        method: &str,\n        params: Value,\n    ) -> anyhow::Result<()> {\n        let line = serde_json::to_string(&json!({\n            \"jsonrpc\": \"2.0\",\n            \"method\": method,\n            \"params\": params,","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/mcp/config_servers/stdio.rs#L226-L262","documentation":"The stdio MCP server answered the JSON-RPC request with a response containing an `error` object, and the client surfaces it verbatim (`MCP stdio error: {err}` — the serialized JSON-RPC error with code and message). This is a well-formed protocol-level failure from the server itself, not a transport failure: the request reached the server and the server refused/failed it.","triggerScenarios":"`tools/call` with invalid arguments (server-side validation), calling a tool that does not exist on that server, auth-required tools without credentials, or any server-side internal error returned as a JSON-RPC error.","commonSituations":"Argument schema drift after a server update (renamed/now-required params); calling a tool with a stale name; upstream API inside the server failing (rate limit, expired token) and being mapped to a JSON-RPC error; protocol misuse like wrong method names.","solutions":["Read the embedded JSON-RPC code/message — `-32602` means invalid params (fix the arguments), `-32700`/`-32603` indicate parse/internal errors on the server.","Re-fetch `tools/list` and re-check the tool name and its `inputSchema` before retrying.","If the server wraps an upstream API, fix the credential/rate-limit problem the message names.","Pin the server package version if the error started after an update (e.g. `npx -y pkg@1.2.3`)."],"exampleFix":"// before\nlet result = stdio.call_tool(\"search\", json!({ \"query\": \"rust async\" })).await?;\n\n// after — align arguments with the tool's inputSchema from tools/list\nlet result = stdio.call_tool(\"search\", json!({\n    \"query\": \"rust async\",\n    \"max_results\": 10, // param previously named \"limit\" before server update\n})).await?;","handlingStrategy":"try-catch","validationCode":"null","typeGuard":null,"tryCatchPattern":"match stdio_client.call_tool(tool, args).await {\n    Err(e) => {\n        let msg = e.to_string();\n        if msg.contains(\"-32602\") { /* invalid params: fix args against inputSchema */ }\n        else if msg.contains(\"Unknown tool\") { /* refresh tools/list */ }\n        else { return Err(e); }\n    }\n    ok => ok,\n}","preventionTips":["Validate arguments against the tool's inputSchema from tools/list before calling.","Re-fetch tool metadata after server upgrades; pin versions to avoid schema drift.","Log the full JSON-RPC error object — code and message identify the server-side cause."],"tags":["mcp","stdio","json-rpc","server-error"],"backgroundTag":"json-rpc-error","analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}