Rate Limit

The per-IP rate limit of the Smarter Project MCP server.

The MCP server requires no authentication, so each client IP address may send at most smarter_settings.mcpserver_rate_limit requests a minute, 1200 by default. The requests are counted in fixed one-minute windows, in Redis, so that every pod of the platform shares the count. A request beyond the limit is answered 429 Too Many Requests, with a Retry-After header, until the window ends.

The client’s address is found as SmarterMiddlewareMixin finds it, from X-Forwarded-For, X-Real-IP, CF-Connecting-IP or the connection itself, ignoring private addresses, which are the platform’s own proxies. A request whose public address cannot be determined, e.g. in local development, is not limited.

Note

Experimental. The MCPServer was designed and coded by Claude Code (Anthropic’s Claude Opus 5.5), with Lawrence McDaniel as co-author. It is experimental, and will be documented.

smarter.apps.mcpserver.ratelimit.RATE_LIMITED = -32010

The JSON-RPC error code of a rate-limited request, in the implementation-defined range of MCP’s error codes.

smarter.apps.mcpserver.ratelimit.client_ip(request)[source]

Return the public IP address of a request’s client.

Parameters:

request (HttpRequest) – The request.

Return type:

str | None

Returns:

The address, or None if it cannot be determined.

smarter.apps.mcpserver.ratelimit.is_rate_limited(ip)[source]

Count a request of a client, and return whether the client is over the limit.

Parameters:

ip (str | None) – The client’s IP address, from client_ip().

Return type:

bool

Returns:

True if the client has sent more than smarter_settings.mcpserver_rate_limit requests in the current window. Always False if the limit is 0, or the address is unknown.

smarter.apps.mcpserver.ratelimit.retry_after()[source]

Return the seconds until the current rate limit window ends.

Return type:

int