affaan-m/ECC · error · JsonRpcError
-32602
-32602
Error message
Invalid arguments for ${toolName}. What it means
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).
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
Example fix
// before
{ "name": "memory-save", "arguments": "fix auth bug" }
// after
{ "name": "memory-save", "arguments": { "content": "fix auth bug", "scope": "project" } } Defensive patterns
Strategy: type-guard
Validate before calling
if (args === null || typeof args !== 'object' || Array.isArray(args)) throw new Error('arguments must be a JSON object matching the tool inputSchema'); Type guard
const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
Try / catch
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; } Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- MCP config must include an mcpServers object
- artifact path must be a non-empty relative path
- assets must be a nonempty list
- built an invalid spec
- Canonical session snapshot must be an object
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/35b4728cf7cb6f02.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/memory-mcp.mjs:257
isError: true,
};
}
function jsonRpcResult(id, result) {
return { jsonrpc: JSONRPC_VERSION, id, result };
}
function jsonRpcError(id, code, message) {
return {
jsonrpc: JSONRPC_VERSION,
id: id ?? null,
error: { code, message },
};
}
function validateArguments(toolName, value) {
if (!isRecord(value)) {
throw new JsonRpcError(-32602, `Invalid arguments for ${toolName}.`);
}
const validate = TOOL_VALIDATORS.get(toolName);
if (!validate(value)) {
const problems = (validate.errors || [])
.slice(0, 3)
.map(error => `${error.instancePath || '/'} ${error.keyword}`)
.join(', ');
throw new JsonRpcError(
-32602,
`Invalid arguments for ${toolName}${problems ? `: ${problems}` : ''}.`
);
}
return { ...value };
}
function executeMemoryTool(name, rawArguments, options = {}) {
const security = resolveServiceSecurity(options);
const input = validateArguments(name, rawArguments);View on GitHub (pinned to 8321021c54)