openai/codex · error · anyhow::Error
MCP tool arguments must be a JSON object, got
Error message
MCP tool arguments must be a JSON object, got {other} What it means
Validation guard in call_tool: the caller passed tool arguments as a non-object JSON value (string, array, number, etc.). MCP tool arguments must be a JSON object (map) of parameter names to values; the offending value is echoed in the message.
Solutions
- Pass arguments as a JSON object (serde_json::Value::Object) or None
- Fix the caller serializing arguments to a JSON string instead of an object
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at codex-rs/rmcp-client/src/rmcp_client.rs:782 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/0f425253b513f7e9.
Report an issue: GitHub.
Appendix: source
Thrown at codex-rs/rmcp-client/src/rmcp_client.rs:782
.boxed()
})
.await?;
self.persist_oauth_tokens().await;
Ok(result)
}
pub async fn call_tool(
&self,
name: String,
arguments: Option<serde_json::Value>,
meta: Option<serde_json::Value>,
timeout: Option<Duration>,
) -> Result<CallToolResult> {
self.refresh_oauth_if_needed().await?;
let arguments = match arguments {
Some(Value::Object(map)) => Some(map),
Some(other) => {
return Err(anyhow!(
"MCP tool arguments must be a JSON object, got {other}"
));
}
None => None,
};
let meta = match meta {
Some(Value::Object(map)) => Some(RequestMetaObject::from(map)),
Some(other) => {
return Err(anyhow!(
"MCP tool request _meta must be a JSON object, got {other}"
));
}
None => None,
};
let mut rmcp_params = CallToolRequestParams::new(name);
rmcp_params.arguments = arguments;
let requested_modern = self.protocol_mode == McpProtocolMode::V20260728;
let result = selfView on GitHub (pinned to 339751715c)