Repository navigation
Description
Summary
MCP tool calls fail with validation errors when LLMs serialize array parameters as JSON strings (e.g., "tags": "[\"test\",\"debug\"]" instead of "tags": ["test","debug"]). OpenClaw's validateToolArguments cannot coerce stringified JSON arrays/objects back to their expected types, causing all MCP tools with array or object typed parameters to fail with certain providers.
Environment
- OpenClaw version: 2026.6.10 (aa69b12)
- Affected provider: Xiaomi MiMo (mimo-v2.5-pro) via OpenAI-compatible API (
openai-completions) - MCP server: Hindsight (self-hosted, streamable-http transport at
http://127.0.0.1:8888/mcp/hermes/) - OS: Linux 6.18.18-trim (x64)
Steps to Reproduce
- Configure Hindsight MCP server in
openclaw.json:
{
"mcp": {
"servers": {
"hindsight-mcp": {
"enabled": true,
"url": "http://127.0.0.1:8888/mcp/hermes/",
"transport": "streamable-http"
}
}
}
}- Call
hindsight-mcp__retainwithtagsparameter:
{
"name": "retain",
"arguments": {
"content": "test memory",
"tags": ["test", "debug"]
}
}- Observe validation error:
Validation failed for tool "hindsight-mcp__retain":
- tags: must be array
- tags: must be null
- tags: must match a schema in anyOf
Received arguments:
{
"content": "test memory",
"tags": "[\"test\",\"debug\"]"
}
Expected Behavior
MCP tool calls with array/object parameters (e.g., tags: ["test","debug"]) should succeed. OpenClaw's validation layer should coerce stringified JSON values back to their expected types when the schema expects array or object, so tools work across providers regardless of how LLMs serialize complex parameters.
Actual Behavior
Tool calls fail with validation errors when the LLM serializes array parameters as JSON strings. The validateToolArguments() in src-M7TBQdDX.js uses TypeBox Value.Convert and coerceWithJsonSchema, but neither can parse "[\"test\",\"debug\"]" back to ["test","debug"]. Direct MCP protocol calls with proper JSON arrays work fine — the issue is purely in OpenClaw's argument validation/coercion layer.
Root Cause Analysis
The issue spans two layers:
1. LLM Provider (MiMo model)
The Xiaomi MiMo model's OpenAI-compatible API returns tool_calls[].function.arguments where array-typed parameters are serialized as JSON strings. For example, tags: ["test","debug"] becomes tags: "[\"test\",\"debug\"]" in the parsed arguments object.
2. OpenClaw Validation Layer (src-M7TBQdDX.js)
In validateToolArguments():
function validateToolArguments(tool, toolCall) {
const args = structuredClone(toolCall.arguments);
Value.Convert(tool.parameters, args); // TypeBox — only basic type coercion
const coerced = coerceWithJsonSchema(args, tool.parameters); // JSON Schema union coercion
// Neither can parse "[\"test\",\"debug\"]" back to ["test","debug"]
if (validator.Check(args)) return args;
// Throws validation error
}Value.Convert(TypeBox) only handles primitive type coercion (string→number, string→boolean). It cannot deserialize stringified JSON arrays.coerceWithJsonSchemahandlesanyOf/oneOfunion schemas by trying each variant, but doesn't attemptJSON.parseon string values when the target schema expects array/object.
3. MCP Server (not the issue)
Direct MCP protocol calls with proper JSON arrays work perfectly.
Proposed Fix
Add a JSON.parse fallback in validateToolArguments (or coerceWithJsonSchema) that attempts to deserialize stringified values when the schema expects array or object types:
function coerceStringifiedValues(value, schema) {
if (typeof value === "string") {
const schemaTypes = getSchemaTypes(schema);
if (schemaTypes.includes("array") || schemaTypes.includes("object")) {
try {
const parsed = JSON.parse(value);
if (schemaTypes.includes("array") && Array.isArray(parsed)) return parsed;
if (schemaTypes.includes("object") && typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
} catch { /* not valid JSON, skip */ }
}
}
return value;
}This is the same approach proposed in PR #70882 (which was closed without merging) and PR #57455 (also closed).
Related Issues/PRs
- [Bug]: Synology MCP tool calls fail with "params: must be object" — OpenClaw passes params as string #70872 — Original bug report (Synology MCP, same root cause, closed by bot without fix)
- fix(bundle-mcp): coerce stringified object/array params before MCP tool calls #70882 — PR: "coerce stringified object/array params before MCP tool calls" (closed without merge)
- fix(ollama): parse stringified tool call arguments in native provider #57455 — PR: "fix(ollama): parse stringified tool call arguments in native provider" (closed without merge)
Impact
This affects any MCP tool with array or object typed parameters when used with LLM providers that serialize complex types as strings. Known affected providers:
- Xiaomi MiMo (mimo-v2.5-pro, mimo-v2.5, mimo-v2-pro)
- Some Ollama models (as reported in fix(ollama): parse stringified tool call arguments in native provider #57455)
- Potentially other OpenAI-compatible providers with similar serialization behavior
Workaround
Avoid using array/object parameters in MCP tool calls. For Hindsight's retain tool, this means omitting tags, metadata, and document_id parameters — functional but degraded.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 26, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 25, 2026, 11:24 PM ET / 03:24 UTC.
Summary
Keep open: current main still lacks schema-aware parsing for MCP array/object parameters that arrive as JSON strings, and the focused prior fix PR was closed unmerged rather than becoming a canonical implementation.
Reproducibility: yes. source-reproducible but not live-reproduced here: current main never JSON-parses schema-expected object/array strings before validation, so the reported stringified
tagsshape remains invalid.Root-cause cluster
Relationship:
canonicalCanonical: #96916
Summary: This issue is the current open canonical item for the stringified MCP object/array argument validation failure; older related reports or PRs are closed and unmerged.
Members:
superseded: [Bug]: Synology MCP tool calls fail with "params: must be object" — OpenClaw passes params as string #70872 - It reports the same object-parameter string failure but was closed as superseded by a PR that is now closed unmerged.same_root_cause: fix(bundle-mcp): coerce stringified object/array params before MCP tool calls #70882 - It attempted the focused schema-guided MCP object/array coercion fix, but it was closed unmerged and is not a safe canonical implementation target.partial_overlap: fix(ollama): parse stringified tool call arguments in native provider #57455 - It addressed provider-level Ollama stringified tool-call arguments, which overlaps the serialization class but not the shared MCP nested parameter validation bug.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
A focused repair PR is reasonable because the affected validator, MCP boundary, related reports, and validation path are clear, but live provider proof was not run in this read-only review.
Review details
Best possible solution:
Add bounded, schema-aware JSON parsing in shared tool-argument validation for string values only when an object or array schema branch is expected, with regression tests for nullable/union MCP schemas.
Do we have a high-confidence way to reproduce the issue?
Yes, source-reproducible but not live-reproduced here: current main never JSON-parses schema-expected object/array strings before validation, so the reported stringified
tagsshape remains invalid.Is this the best way to solve the issue?
Yes: the narrow maintainable fix belongs in the shared tool-argument validation boundary, not in one MCP server or a single provider-specific adapter.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 448b7c75b669.
Label changes
Label justifications:
P2: This is a concrete MCP/provider interoperability bug with a clear shared validation surface and limited blast radius.impact:other: The issue makes MCP tools with array/object parameters fail for affected providers, which is maintainer-visible but outside the more specific impact labels.Evidence reviewed
Acceptance criteria:
What I checked:
coerceWithJsonSchemahandles unions and primitive conversions, then only descends into object or array schemas when the value already has that runtime shape; it does not JSON-parse string values for object/array branches. (packages/llm-core/src/validation.ts:219, 448b7c75b669)validateToolArgumentsclones model-emitted arguments, runs TypeBox conversion and plain JSON-schema coercion, then throws the reported validation error when the final object does not satisfy the tool schema. (packages/llm-core/src/validation.ts:295, 448b7c75b669)beforeToolCalland before execution, so a schema validation miss prevents the MCP call from reaching the runtime. (packages/agent-core/src/agent-loop.ts:871, 448b7c75b669)runtime.callTool, and the runtime only ensures the top-level input is a record before forwarding it as MCParguments; nested stringified arrays/objects are not normalized there. (src/agents/agent-bundle-mcp-materialize.ts:404, 448b7c75b669)packages/llm-core/src/validation.test.ts:20, 448b7c75b669)mergedAtvalue.Likely related people:
git show -slists Ayaan Zaidi as committer for the commit that introduced the current shared validation and bundle MCP materialization files in this checkout. (role: committer for current shared validator implementation; confidence: medium; commits: 31a0f97dd944; files:packages/llm-core/src/validation.ts,packages/llm-core/src/validation.test.ts,src/agents/agent-bundle-mcp-materialize.ts)git blameattributes the relevant validator and bundle MCP forwarding lines to the bot-authored repair commit; route through a human reviewer for follow-up. (role: authored current validation and MCP materialization behavior; confidence: medium; commits: 31a0f97dd944; files:packages/llm-core/src/validation.ts,src/agents/agent-bundle-mcp-materialize.ts,src/agents/agent-bundle-mcp-runtime.ts)src/agents/pi-bundle-mcp-materialize.ts,src/agents/pi-bundle-mcp-tools.materialize.test.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.fix(llm): coerce stringified JSON arrays/objects in tool argument val…
fix(llm): coerce stringified JSON arrays/objects in tool argument val…
fix(llm): coerce stringified JSON arrays/objects in tool argument val…
fix(llm): coerce stringified JSON arrays/objects in tool argument val…
fix(llm): coerce stringified JSON arrays/objects in tool argument val…
fix(llm): coerce stringified JSON arrays/objects in tool argument val…