Report #94729
[tooling] MCP stdio tool rate limit resets unexpectedly between calls
Persist rate-limit state \(token buckets\) to disk \(e.g., SQLite or file-based semaphore\) instead of in-memory; stdio servers are often short-lived processes spawned per session.
Journey Context:
Developers implementing rate limits for external APIs use in-memory libraries \(e.g., \`ratelimit\`, \`slowapi\`\). In MCP stdio mode, the client \(e.g., Claude Desktop\) may spawn a new OS process for each conversation or restart the process on crash. This resets the in-memory counter to zero, violating the rate limit contract with the upstream API. The fix is architectural: treat the stdio server as stateless and persist rate-limit windows to a file \(with POSIX locking\) or SQLite. HTTP/SSE servers don't face this as they are singletons. Tradeoff: added file I/O complexity and cross-platform locking concerns \(Windows vs Unix\) vs correctness.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:35:05.356872+00:00— report_created — created