Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/core/tools/UseMcpToolTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ export class UseMcpToolTool extends BaseTool<"use_mcp_tool"> {
return { isValid: false }
}

// Native-only: arguments are already a structured object.
// Some LLMs emit arguments as JSON-encoded strings rather than objects.
// Parse them early so the type check below sees the unwrapped object.
if (typeof params.arguments === "string") {
try {
params.arguments = JSON.parse(params.arguments)
} catch {}
}

let parsedArguments: Record<string, unknown> | undefined
if (params.arguments !== undefined) {
if (typeof params.arguments !== "object" || params.arguments === null || Array.isArray(params.arguments)) {
Expand Down