Skip to content

fix(mcp): add request rate limiting for MCP tool calls#1243

Merged
chaliy merged 1 commit intomainfrom
fix/1168-mcp-rate-limiting
Apr 12, 2026
Merged

fix(mcp): add request rate limiting for MCP tool calls#1243
chaliy merged 1 commit intomainfrom
fix/1168-mcp-rate-limiting

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 12, 2026

Summary\n\n- Add --max-requests-per-minute CLI flag for MCP subcommand (0 = unlimited, default)\n- Track tool/call timestamps in sliding 1-minute window\n- Return JSON-RPC error -32000 when rate limit exceeded\n- Non-tool methods (tools/list, initialize, shutdown) bypass rate limit\n\n## Test plan\n\n- [x] test_rate_limit_blocks_excess_requests — 3rd request blocked at limit=2\n- [x] test_rate_limit_zero_means_unlimited — 10 rapid requests succeed at limit=0\n- [x] test_rate_limit_does_not_block_non_tool_calls — tools/list works after limit reached\n- [x] cargo clippy and cargo fmt clean\n\nCloses #1168

Add --max-requests-per-minute flag for MCP mode. Tracks tool/call
request timestamps in a sliding 1-minute window. Returns JSON-RPC
error -32000 when limit is exceeded. Non-tool methods (tools/list,
initialize) are not rate-limited.

Closes #1168
@chaliy chaliy force-pushed the fix/1168-mcp-rate-limiting branch from a67a67a to bea18b3 Compare April 12, 2026 09:52
@chaliy chaliy merged commit 1c02434 into main Apr 12, 2026
11 checks passed
@chaliy chaliy deleted the fix/1168-mcp-rate-limiting branch April 12, 2026 09:59
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