{"record":{"id":"72b4b1aa689b8172","repo":"affaan-m/ECC","slug":"32001","errorCode":"-32001","errorMessage":"Memory tool response exceeds the bounded output limit.","messagePattern":"Memory tool response exceeds the bounded output limit\\.","errorType":"exception","errorClass":"JsonRpcError","httpStatus":null,"severity":"error","filePath":"scripts/memory-mcp.mjs","lineNumber":202,"sourceCode":"    allowUserScope: options.allowUserScope ?? env.ECC_MEMORY_ALLOW_USER_SCOPE === '1',\n  });\n}\n\nfunction assertScopesAuthorized(scopes, security) {\n  const requestedScopes = scopes || DEFAULT_RECALL_SCOPES;\n  if (!security.allowUserScope && requestedScopes.includes('user')) {\n    throw new JsonRpcError(\n      -32602,\n      'The user memory scope is disabled for this MCP server.'\n    );\n  }\n  return requestedScopes;\n}\n\nfunction textResult(payload) {\n  const text = JSON.stringify(payload, null, 2);\n  if (Buffer.byteLength(text, 'utf8') > MAX_RESPONSE_BYTES) {\n    throw new JsonRpcError(-32001, 'Memory tool response exceeds the bounded output limit.');\n  }\n  return {\n    content: [{\n      type: 'text',\n      text,\n    }],\n  };\n}\n\nfunction toolFailure(code, error) {\n  if (code === 'MEMORY_READ_FAILED' && error?.code === 'ECC_MEMORY_INCOMPLETE') {\n    return {\n      ...textResult({ error: {\n        code: 'MEMORY_READ_INCOMPLETE',\n        message: 'Memory lookup is incomplete. Inspect the authorized vault before retrying.',\n      } }),\n      isError: true,\n    };","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/memory-mcp.mjs#L184-L220","documentation":"The memory server bounds tool output size: textResult serializes the payload as pretty JSON and compares its UTF-8 byte length to MAX_RESPONSE_BYTES. Oversized payloads throw JsonRpcError -32001 rather than returning a response that would blow up the agent's context window.","triggerScenarios":"A memory tool call returns a payload (e.g. a recall returning many/large entries, or a save echoing a huge body) whose JSON.stringify output exceeds MAX_RESPONSE_BYTES.","commonSituations":"Recalling memories with a broad query and no limit; saving/reading a memory document that is extremely large; many accumulated session notes returned in one list call.","solutions":["Narrow the recall query or add/limit filters so fewer entries are returned","Paginate: request fewer records per call and iterate","Trim or split the memory content being saved/read","Increase MAX_RESPONSE_BYTES only if the bounded-output policy deliberately allows larger responses"],"exampleFix":"// before\nawait call('memory-recall', { query: 'design' }) // returns hundreds of entries\n// after\nawait call('memory-recall', { query: 'auth design decision', limit: 10 })","handlingStrategy":"try-catch","validationCode":"const size = Buffer.byteLength(JSON.stringify(payload, null, 2), 'utf8'); if (size > MAX_RESPONSE_BYTES) throw new Error(`payload ${size} bytes exceeds ${MAX_RESPONSE_BYTES}`);","typeGuard":null,"tryCatchPattern":"try { const res = await callMemoryTool(tool, args); } catch (e) { if (e.code === -32001) { return callMemoryTool(tool, { ...args, limit: Math.max(1, Math.floor((args.limit || 20) / 2)) }); } throw e; }","preventionTips":["Always set a modest limit on recall/list calls","Keep saved memory documents small; split large notes into multiple entries","Use precise queries rather than broad ones that match hundreds of entries"],"tags":["mcp","limits","response-size"],"backgroundTag":"payload-too-large","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"}