Skip to content

Make MCP rate limits configurable and raise the global ceiling to 128 - #14

Merged
NielsRogge merged 1 commit into
mainfrom
codex/mcp-configurable-limits
Sep 17, 2026
Merged

NielsRogge merged 1 commit into
mainfrom
codex/mcp-configurable-limits

Conversation

@NielsRogge

Copy link
Copy Markdown
Collaborator

Summary

With per-chat-session identities (#13), the per-client limits already protect fairness; the process-wide ceiling of 32 concurrent requests is what binds when many chat turns run at once (each turn issues bursts of three parallel catalog calls). This raises the default global ceiling to 128, sizes anyio's synchronous tool thread pool from it (anyio's default of 40 tokens would otherwise cap throughput silently below the ceiling), and makes all four limits overridable:

Variable Default
PWC_MCP_REQUEST_LIMIT 60 per client per minute
PWC_MCP_SEMANTIC_LIMIT 10 per client per minute
PWC_MCP_CONCURRENCY_LIMIT 4 per client
PWC_MCP_GLOBAL_CONCURRENCY_LIMIT 128 (was 32)

Invalid values fail at startup. README and SPEC updated. Pairs with huggingface/paperswithcode#252 (64-turn chat capacity tier).

Verification

uv run --project mcp_server pytest mcp_server/tests: 45 passed, including env parsing, defaults, thread-pool sizing, and a middleware-level check that the configured limits reach the rate limiter.

🤖 Generated with Claude Code

Per-client limits now protect fairness between chat sessions, so the process
ceiling is what binds under load. Default the global concurrency limit to 128,
size anyio's synchronous tool thread pool from it (its default of 40 would
otherwise cap throughput silently), and read all four limits from
PWC_MCP_*_LIMIT environment variables for other deployments.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@NielsRogge
NielsRogge merged commit 0270ed0 into main Sep 17, 2026
2 checks passed
@NielsRogge
NielsRogge deleted the codex/mcp-configurable-limits branch September 17, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant