openai/codex · error · anyhow::Error

MCP tool returned an error: {text}

Error message

MCP tool returned an error: {text}

What it means

Error "MCP tool returned an error: {text}" thrown in openai/codex.

Source

Thrown at codex-rs/core/src/hook_mcp_executor.rs:50

                    call.environment_id.as_deref(),
                    Some(Value::Object(call.input)),
                    Some(Value::Object(metadata)),
                    Some(call.timeout),
                    /*wait_for_server*/ false,
                )
                .await?;
            let text = result
                .content
                .iter()
                .filter_map(|content| {
                    (content.get("type").and_then(Value::as_str) == Some("text"))
                        .then(|| content.get("text").and_then(Value::as_str))
                        .flatten()
                })
                .collect::<Vec<_>>()
                .join("\n");
            if result.is_error == Some(true) {
                bail!("MCP tool returned an error: {text}");
            }

            Ok(text)
        }
        .boxed()
    }
}

View on GitHub (pinned to 339751715c)

Solutions

  1. Fix the underlying MCP tool error reported in the message text.

When it happens

Trigger: Thrown at codex-rs/core/src/hook_mcp_executor.rs:50 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/8bbab9b20d4dfebb. Report an issue: GitHub.