MCP Rate Limiting Guide
Prevent abuse and ensure fair usage of MCP servers with token-bucket rate limiting, per-tier limits, and distributed limiting across multiple instances.
Quick Answer / TL;DR
Rate limit MCP servers with a token-bucket algorithm keyed by user or API key rather than IP address, since IP-based limits can be bypassed by proxies or unfairly affect multiple users behind the same NAT. Return HTTP 429 with a retry-after header, and use a shared store such as Redis once you run more than one server instance.
Key Takeaways
- Token bucket allows short bursts while holding to an average rate, which fits real client behavior better than a fixed window.
- Key limits by authenticated user or API key, not raw IP, for fairness and to resist bypass through proxies.
- Once you run multiple instances, rate-limit state must live in a shared store such as Redis, not in local memory.
Token bucket limiter
A token bucket refills at a constant rate up to a cap and spends one token per request. This allows short bursts while still enforcing a long-run average rate, which suits typical MCP client traffic better than a hard fixed-window counter.
class TokenBucketLimiter {
private buckets = new Map<string, { tokens: number; lastRefill: number }>();
constructor(private maxTokens: number, private refillPerMs: number) {}
isAllowed(key: string): boolean {
const now = Date.now();
const bucket = this.buckets.get(key) ?? { tokens: this.maxTokens, lastRefill: now };
bucket.tokens = Math.min(this.maxTokens, bucket.tokens + (now - bucket.lastRefill) * this.refillPerMs);
bucket.lastRefill = now;
this.buckets.set(key, bucket);
if (bucket.tokens < 1) return false;
bucket.tokens -= 1;
return true;
}
}Per-tier limits and distributed limiting
Different plan tiers should get different bucket sizes. Once the MCP server runs as more than one instance behind a load balancer, move the counters to Redis so every instance enforces the same limit against the same key.
| Tier | Suggested limit |
|---|---|
| Free / readonly | 10 requests/sec |
| Pro | 100 requests/sec |
| Enterprise | 1000 requests/sec |
MCP Rate Limiting Guide FAQs
Direct answers for developers, operators, and Indian teams evaluating MCP.