Skip to main content
Version: Dev

Rate Limits and Budgets

For MCP traffic, the caller API key remains the traffic-control boundary. MCP tool calls share the key's request and concurrency limits with model traffic, but they do not consume model tokens. In AISIX Enterprise and AISIX Cloud, they are also subject to budgets that cover the same caller API key.

A caller API key can additionally carry a limit for each MCP server it reaches. An agent looping on one server then cannot exhaust the allowance the same key needs for the others. Configure these limits in resources.yaml or through the AISIX Cloud Admin API, then verify the behavior on the MCP path. In AISIX Enterprise and AISIX Cloud, budgets remain key-wide and have no per-server setting.

Prerequisites​

Before starting, prepare the following:

  • For AISIX Enterprise or AISIX Cloud, an environment, a caller API key, and a write-scoped admin token. For AISIX Enterprise, follow the AISIX Enterprise getting-started guide. To request AISIX Cloud access, contact API7.
  • For an open-source AISIX gateway, a caller API key and registered MCP servers in resources.yaml. Set Up MCP Gateway provides a working configuration and the validation and reload workflow.
  • cURL for the control-plane examples.

Where Controls Apply​

The gateway applies rate-limit and budget checks only to tools/call requests. The MCP handshake, including initialize, and tool discovery through tools/list are not rate-limited. A throttled caller can still connect and list the tools its key allows, but cannot invoke another tool until the applicable limit has capacity.

When a rate limit or budget rejects a tool call, AISIX returns before contacting the upstream MCP server and still records the rejected call as a usage event.

Applicable Rate Limits​

A caller API key's rate_limit object can define request-rate, token-rate, and concurrency limits. On the MCP path, only request-rate and concurrency limits directly meter tool calls:

LimitApplies to MCP tool callsNotes
rps, rpm, rph, rpdYesEach tools/call counts as one request in the matching window.
concurrencyYesEach in-flight tool call holds one concurrency permit until it returns.
tpm, tpdIndirectlyMCP tool calls carry no model tokens, so they do not add to token windows. If the caller key's model traffic already exhausted a token window, the key's tool calls are still rejected with HTTP 429 until enough recorded usage leaves the window.

Each field is optional. When a field is omitted, AISIX does not enforce that limit.

Use request-rate limits or concurrency to throttle MCP call volume. A token limit alone does not cap MCP tool calls. Use mcp_rate_limits to bound each MCP server separately instead of the caller as a whole.

For the full rate-limit field reference and counter-storage options, see API Key and Model Rate Limits.

Configure Rate Limits​

Configure rate limits using the management path for your deployment.

  1. Open API keys and create or edit the caller key.
  2. Expand Rate limits and set a caller-wide request or concurrency limit.
  3. To limit individual MCP servers, expand Per-MCP-server limits. Select each server and enter its request or concurrency limits.
  4. Save the key.
  5. Call a permitted tool past the configured limit and confirm that the gateway returns HTTP 429.
Caller API key editor with rate limits and per-MCP-server limits

Rename or Delete an MCP Server​

Renaming an MCP server carries its references with it. AISIX updates per-server limits, server-specific allow and deny tool patterns in caller API keys and environment or team access policies, and entries on the anonymous-access server allowlist. Each reference reads back under the new server name. Patterns that can match more than one server, such as a bare * or gh*__read, remain unchanged.

An anonymous allowlist entry always identifies one server, never a pattern. A rename therefore keeps the same server available to anonymous callers without widening or narrowing the ceiling. See Anonymous Access.

Deleting a server leaves its per-server limits, server-specific allow and deny tool patterns, and anonymous allowlist entries under the old name. They match nothing while the server is absent, but apply again if a server is registered under that name. This behavior lets you provision tool access patterns and limits before registering their server. For a per-server limit, the dashboard marks the unresolved name and offers a Remove control.

Anonymous access is stricter when edited: its server list must name servers currently available in the environment. Until you remove an entry left by a deleted server or register a replacement under that name, a PATCH that changes the anonymous block is rejected.

Apply Control-Plane Budgets​

Budgets are configured in the control plane and enforced by the AISIX gateway. When a budget that covers the caller API key is exhausted, the gateway rejects that key's tools/call requests with a budget_exceeded error before contacting the upstream MCP server. This is the same check the model path runs.

MCP tool calls carry no token cost, so they do not add to token-based spend themselves. A budget exhausted by the caller's model traffic still blocks that caller's MCP tool calls when the same budget covers both. See Budgets for budget targets, the rejection response, and caching behavior.

For an open-source AISIX gateway, use caller API key rate limits to govern MCP tool-call volume. For control-plane budget configuration details, see Budgets.

Next Steps​

You have now applied caller API key controls to MCP traffic. Use these guides to observe the result or refine the shared limit and budget settings:

  • Observability: review the usage events and metrics emitted by MCP tool calls.
  • API Key and Model Rate Limits: review the full rate-limit field reference and counter-storage options.
  • Budgets: configure budget targets, rejection behavior, and cache settings.