{"record":{"id":"7998db63a18bf2b6","repo":"ruvnet/RuView","slug":"32602","errorCode":"-32602","errorMessage":"Invalid arguments for tool \"${rawName}\": ${parsed.error.message}","messagePattern":"Invalid arguments for tool \"(.+?)\": (.+?)","errorType":"error_code","errorClass":"McpError","httpStatus":null,"severity":"error","filePath":"tools/ruview-mcp/src/index.ts","lineNumber":294,"sourceCode":"\n    if (!tool) {\n      return {\n        content: [\n          {\n            type: \"text\" as const,\n            text: JSON.stringify({\n              ok: false,\n              error: `Unknown tool \"${rawName}\". Available tools: ${TOOLS.map((t) => t.name).join(\", \")}`,\n            }),\n          },\n        ],\n        isError: true,\n      };\n    }\n\n    const parsed = tool.schema.safeParse(args ?? {});\n    if (!parsed.success) {\n      throw new McpError(\n        ErrorCode.InvalidParams,\n        `Invalid arguments for tool \"${rawName}\": ${parsed.error.message}`\n      );\n    }\n\n    try {\n      const result = await tool.handler(parsed.data, config);\n      return {\n        content: [\n          {\n            type: \"text\" as const,\n            text: JSON.stringify(result, null, 2),\n          },\n        ],\n      };\n    } catch (e: unknown) {\n      if (e instanceof McpError) throw e; // propagate typed errors unchanged\n      const message = e instanceof Error ? e.message : String(e);","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/tools/ruview-mcp/src/index.ts#L276-L312","documentation":"The RuView MCP server (tools/ruview-mcp/src/index.ts) validates every tool call's arguments with the tool's zod schema via schema.safeParse(args ?? {}). On failure it throws McpError(ErrorCode.InvalidParams), JSON-RPC code -32602, with the zod validation message embedded, so the client gets a structured error instead of tool output.","triggerScenarios":"Calling a ruview MCP tool with arguments that violate its schema: wrong types (limit as string), out-of-range values (ruview_guidance with limit 100), missing required fields, unknown tool-specific keys, or args serialized as a JSON string instead of a JSON object.","commonSituations":"Client/server schema drift after upgrading one side; hand-rolled MCP clients that pass arguments: JSON.stringify(payload); agents guessing parameter names; empty-string vs missing optional fields.","solutions":["Read the tool's inputSchema from the tools/list response and shape arguments to exactly that schema.","Fix the specific field named in the zod message embedded in the error text (it lists the path and the violated constraint).","Make sure the MCP client sends arguments as a JSON object (not a stringified payload), and match client/server versions."],"exampleFix":"// before\nclient.callTool({ name: 'ruview_guidance', arguments: JSON.stringify({ topic: 'overview', limit: 100 }) })\n// after\nclient.callTool({ name: 'ruview_guidance', arguments: { topic: 'overview', limit: 10 } })","handlingStrategy":"validation","validationCode":"// Fetch and enforce the server's own schema before calling\nconst { tools } = await client.listTools();\nconst tool = tools.find((t) => t.name === 'ruview_guidance');\n// shape args strictly from tool.inputSchema (types, enums, min/max), e.g.:\nconst args = { topic: 'overview', limit: Math.min(20, Math.max(1, Number(rawLimit) || 20)) };","typeGuard":null,"tryCatchPattern":"try {\n  const res = await client.callTool({ name: 'ruview_guidance', arguments: args });\n} catch (e) {\n  if (e?.code === -32602 || /Invalid arguments for tool/.test(e?.message ?? '')) {\n    // e.message embeds the zod path + violated constraint; fix that field, do not retry unchanged\n    throw new Error(`schema violation calling ruview_guidance: ${e.message}`);\n  }\n  throw e;\n}","preventionTips":["Derive arguments from the tools/list inputSchema instead of guessing parameter names.","Send arguments as a JSON object, never a stringified payload.","Upgrade MCP client and ruview-mcp server together to avoid schema drift."],"tags":["mcp","json-rpc","zod","validation","error-code-32602"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}