affaan-m/ECC · error · JsonRpcError

-32001

-32001

Error message

Memory tool response exceeds the bounded output limit.

What it means

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.

Solutions

  1. Narrow the recall query or add/limit filters so fewer entries are returned
  2. Paginate: request fewer records per call and iterate
  3. Trim or split the memory content being saved/read
  4. Increase MAX_RESPONSE_BYTES only if the bounded-output policy deliberately allows larger responses

Example fix

// before
await call('memory-recall', { query: 'design' }) // returns hundreds of entries
// after
await call('memory-recall', { query: 'auth design decision', limit: 10 })
Defensive patterns

Strategy: try-catch

Validate before calling

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}`);

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/72b4b1aa689b8172. Report an issue: GitHub.

Appendix: source

Thrown at scripts/memory-mcp.mjs:202

    allowUserScope: options.allowUserScope ?? env.ECC_MEMORY_ALLOW_USER_SCOPE === '1',
  });
}

function assertScopesAuthorized(scopes, security) {
  const requestedScopes = scopes || DEFAULT_RECALL_SCOPES;
  if (!security.allowUserScope && requestedScopes.includes('user')) {
    throw new JsonRpcError(
      -32602,
      'The user memory scope is disabled for this MCP server.'
    );
  }
  return requestedScopes;
}

function textResult(payload) {
  const text = JSON.stringify(payload, null, 2);
  if (Buffer.byteLength(text, 'utf8') > MAX_RESPONSE_BYTES) {
    throw new JsonRpcError(-32001, 'Memory tool response exceeds the bounded output limit.');
  }
  return {
    content: [{
      type: 'text',
      text,
    }],
  };
}

function toolFailure(code, error) {
  if (code === 'MEMORY_READ_FAILED' && error?.code === 'ECC_MEMORY_INCOMPLETE') {
    return {
      ...textResult({ error: {
        code: 'MEMORY_READ_INCOMPLETE',
        message: 'Memory lookup is incomplete. Inspect the authorized vault before retrying.',
      } }),
      isError: true,
    };

View on GitHub (pinned to 8321021c54)