{"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":6605,"sourceCode":"        ? protocolLimits.sessionSetup\n        : protocolLimits.tokenRequests;\n    const tokenKey = `mcp_gateway_protocol:token:${session.gatewayTokenId ?? session.actorId ?? \"unknown\"}:${action}`;\n    const tokenState = await consumeProtocolRateLimit({\n      companyId: session.companyId,\n      counterKey: tokenKey,\n      config: tokenLimit,\n    });\n    if (tokenState.limited) {\n      await writeProtocolRateLimitAudit({\n        session,\n        method,\n        limiterKeyClass: \"token\",\n        count: tokenState.count,\n        limit: tokenLimit,\n        retryAfterMs: tokenState.retryAfterMs,\n        clientMetadata,\n      });\n      throw new ToolGatewayHttpError(\n        429,\n        \"MCP gateway request was rate limited\",\n        \"gateway_rate_limited\",\n        {\n          reasonText:\n            \"The MCP gateway request was rate limited before the protocol action ran.\",\n          limiterKeyClass: \"token\",\n          protocolMethod: method,\n          retryAfterMs: tokenState.retryAfterMs,\n        },\n      );\n    }\n\n    const gatewayLimit =\n      method === \"initialize\"\n        ? protocolLimits.sessionSetup\n        : protocolLimits.gatewayRequests;\n    const gatewayKey = `mcp_gateway_protocol:gateway:${session.gatewayId ?? session.gatewayPublicId ?? \"unknown\"}:${action}`;","sourceCodeStart":6587,"sourceCodeEnd":6623,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/tool-gateway.ts#L6587-L6623","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":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}