Skip to content

MCP rate limits - #6911

Merged
RobertJoonas merged 2 commits into
masterfrom
mcp-rate-limits
Nov 25, 2026
Merged

RobertJoonas merged 2 commits into
masterfrom
mcp-rate-limits

Conversation

@RobertJoonas

@RobertJoonas RobertJoonas commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Changes

Implements proper rate limiting on MCP requests

  • The hourly budget between Stats API and MCP remain shared for the time being
  • Plans without Stats API access will have a lower MCP request limit (300 instead of 600 per hour)
  • Only tools/call requests spend the hourly budget, burst limit is checked for every authenticated request
  • Refused tool calls (e.g. invalid query params, or an unknown tool) spend the hourly budget too
  • When tools/call hits a rate limit (either burst or hourly), we respond with a tool error (HTTP 200, isError: true)
    • This lets an agent understand the issue and tell the user what happened, or wait and retry after a burst refusal.
  • Other POST /mcp requests that hit a burst limit get a plain HTTP 429 with {error: "too_many_requests"}.

Tests

  • Automated tests have been added

Changelog

  • This PR does not make a user-facing change

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

@RobertJoonas
RobertJoonas marked this pull request as draft November 23, 2026 12:57

@vinibrsl vinibrsl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback from our call:

  • To simplify things, we can apply the hourly rate limit to tools/call only. It should respond with HTTP 200 + isError: true.
  • Burst rate limit still applies to every other call, and responds with HTTP 429.

@RobertJoonas
RobertJoonas marked this pull request as ready for review November 25, 2026 12:04
end

# A tool error lets the model tell the user why the call failed.
defp check_tool_call_rate_limit(%Plug.Conn{halted: true} = conn, _id), do: conn

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function and check_burst_limit should move into the new MCP.RateLimit module too, but for that we'd need to extract the success_response and text_content utilites out of the controller. A new MCP.Messages module perhaps. Can be tackled as a follow-up.

@RobertJoonas
RobertJoonas added this pull request to the merge queue Nov 25, 2026
Merged via the queue into master with commit 979b44d Nov 25, 2026
31 checks passed
@RobertJoonas
RobertJoonas deleted the mcp-rate-limits branch November 25, 2026 17:18
@vinibrsl vinibrsl mentioned this pull request Nov 25, 2026
4 tasks done
nepalisagun pushed a commit to nepalisagun/Plausible-analytics that referenced this pull request Nov 25, 2026
The upgrade page now lists the MCP rate limits added in plausible#6911.

Plans with the Stats API feature show "600 API/MCP calls/hr" in place of
"Stats API (600 requests per hour)". Plans without it show "AI integration
(300 MCP calls/hr)" on the lowest tier. Enterprise shows "600+ API/MCP
calls/hr".
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.

2 participants