{"record":{"id":"35b4728cf7cb6f02","repo":"affaan-m/ECC","slug":"32602","errorCode":"-32602","errorMessage":"Invalid arguments for ${toolName}.","messagePattern":"Invalid arguments for (.+?)\\.","errorType":"validation","errorClass":"JsonRpcError","httpStatus":null,"severity":"error","filePath":"scripts/memory-mcp.mjs","lineNumber":257,"sourceCode":"    isError: true,\n  };\n}\n\nfunction jsonRpcResult(id, result) {\n  return { jsonrpc: JSONRPC_VERSION, id, result };\n}\n\nfunction jsonRpcError(id, code, message) {\n  return {\n    jsonrpc: JSONRPC_VERSION,\n    id: id ?? null,\n    error: { code, message },\n  };\n}\n\nfunction validateArguments(toolName, value) {\n  if (!isRecord(value)) {\n    throw new JsonRpcError(-32602, `Invalid arguments for ${toolName}.`);\n  }\n  const validate = TOOL_VALIDATORS.get(toolName);\n  if (!validate(value)) {\n    const problems = (validate.errors || [])\n      .slice(0, 3)\n      .map(error => `${error.instancePath || '/'} ${error.keyword}`)\n      .join(', ');\n    throw new JsonRpcError(\n      -32602,\n      `Invalid arguments for ${toolName}${problems ? `: ${problems}` : ''}.`\n    );\n  }\n  return { ...value };\n}\n\nfunction executeMemoryTool(name, rawArguments, options = {}) {\n  const security = resolveServiceSecurity(options);\n  const input = validateArguments(name, rawArguments);","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/memory-mcp.mjs#L239-L275","documentation":"Every tools/call's arguments pass through validateArguments, which requires a plain object and dispatches to a per-tool AJV validator from TOOL_VALIDATORS. Non-object arguments or schema violations throw JsonRpcError -32602 with the message 'Invalid arguments for <toolName>.' (optionally appended with up to three problem descriptors: instancePath + keyword).","triggerScenarios":"Calling a memory tool with arguments that are not a record (null, array, string), or an object failing the tool's JSON schema (missing required fields, wrong types, bad enum values).","commonSituations":"Client sends stringified JSON instead of a parsed object; required field like 'query' or 'content' omitted; scope passed as a string instead of an array; tool renamed so its old argument shape no longer validates.","solutions":["Read the appended problem descriptors (instancePath/keyword) to find the offending field","Ensure arguments are a JSON object matching the tool's inputSchema (check the tools/list output)","Add missing required fields or fix types (e.g. scopes must be an array of enum strings)","Update the client to the tool's current schema if the tool evolved"],"exampleFix":"// before\n{ \"name\": \"memory-save\", \"arguments\": \"fix auth bug\" }\n// after\n{ \"name\": \"memory-save\", \"arguments\": { \"content\": \"fix auth bug\", \"scope\": \"project\" } }","handlingStrategy":"type-guard","validationCode":"if (args === null || typeof args !== 'object' || Array.isArray(args)) throw new Error('arguments must be a JSON object matching the tool inputSchema');","typeGuard":"const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);","tryCatchPattern":"try { return await client.callTool({ name: tool, arguments: args }); } catch (e) { if (e.code === -32602 && /Invalid arguments/.test(e.message)) { const schema = (await client.listTools()).tools.find(t => t.name === tool).inputSchema; console.error('Expected schema:', JSON.stringify(schema)); throw e; } throw e; }","preventionTips":["Fetch the tool's inputSchema via tools/list and validate arguments client-side (AJV) before calling","Never send stringified JSON as the arguments value","Keep client tool-call definitions in sync with server tool versions"],"tags":["mcp","validation","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}