{"record":{"id":"cb36085217438b20","repo":"paperclipai/paperclip","slug":"gateway-rate-limited","errorCode":"gateway_rate_limited","errorMessage":"MCP gateway request was rate limited","messagePattern":"MCP gateway request was rate limited","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":429,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":3611,"sourceCode":"      stdio: [\"pipe\", \"pipe\", \"pipe\"],\n    });\n    let stdout = \"\";\n    let stderr = \"\";\n    let nextId = 1;\n    const pending = new Map<number, {\n      resolve: (value: unknown) => void;\n      reject: (error: Error) => void;\n    }>();\n    const timer = setTimeout(() => {\n      child.kill(\"SIGTERM\");\n      for (const { reject } of pending.values()) {\n        reject(new ToolGatewayHttpError(504, \"Local stdio MCP tool call timed out\", \"tool_timeout\", {\n          connectionId: input.connection.id,\n          catalogEntryId: input.entry?.id ?? null,\n        }));\n      }\n      pending.clear();\n    }, input.timeoutMs);\n    timer.unref?.();\n    child.stdout.setEncoding(\"utf8\");\n    child.stderr.setEncoding(\"utf8\");\n    child.stdout.on(\"data\", (chunk: string) => {\n      stdout += chunk;\n      let newline = stdout.indexOf(\"\\n\");\n      while (newline >= 0) {\n        const line = stdout.slice(0, newline).trim();\n        stdout = stdout.slice(newline + 1);\n        if (line) {\n          try {\n            const message = JSON.parse(line) as Record<string, unknown>;\n            const id = typeof message.id === \"number\" ? message.id : null;\n            if (id !== null && pending.has(id)) {\n              const waiter = pending.get(id)!;\n              pending.delete(id);\n              if (message.error !== undefined) {\n                waiter.reject(stdioProtocolError(\"Local stdio MCP server returned a JSON-RPC error\", {","sourceCodeStart":3593,"sourceCodeEnd":3629,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/server/src/services/tool-gateway.ts#L3593-L3629","documentation":"Gateway protocol rate limiter: the token-bucket keyed by gateway token/actor and action class (session setup vs token requests) was exhausted for the current window, so the MCP protocol request is refused with 429 before handling. Legitimate clients should slow down and honor the reported retry window; sustained trips may indicate a looping client.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:3470 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The gateway request hit rate limits. Back off and retry after the window; reduce request frequency."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}