Repository navigation
Description
Problem / motivation
An agent token can scope what a caller may reach (servers, profile, tier) but not how much it may do. The only throttles I found are concurrency-based: the global max_concurrent_requests, per-server concurrency and the queue (queue_timeout, see docs/configuration.md). They bound simultaneous calls, so a caller that issues calls one after another, as an agent stuck in a retry loop does, is never slowed down. internal/ has no per-caller rate or call budget (the rate limiters that exist cover diagnostics fixes, OAuth refresh and telemetry feedback).
That matters for autonomous agents, which are the callers agent tokens exist for: a looping agent with a write-tier token can send hundreds of create_issue, send_message or paid-API calls before anyone looks, and the only remedy is revoking the token by hand. Profiles and tiers bound the blast radius by capability; nothing bounds it by volume.
Proposed solution
A per-token (and/or per-profile) call budget enforced at the same gate that already decides token_scope / profile_scope, before dispatch. Sketch, open to your preferred shape:
- Token create / profile config accepts a limit such as
--rate 60/min, optionally a burst and a tighter cap for the write and destructive tiers (--rate-destructive 5/hour). Unset means unlimited, as today. - Token-bucket in memory per token (a restart resets it; that is fine for a safety net, and I would say so in the docs).
- Over the limit: a normal refusal with
block_reason: rate_limited, aRetry-After-style hint in the text, and no upstream call. - Audit and activity: an
authzdeny line with a new reason (rate_limited) in the closed reason vocabulary, so the "agent hit its budget" event shows up in the audit stream without new event kinds. mcpproxy token list/ the UI show the configured limit;activity summarycan already count the denials.
I'm happy to implement it. The questions I would like your view on: token or profile as the home of the limit (or both, lower one wins), whether the unit should be calls or "weighted" by tier, and whether you want it before or after the per-argument policy work on the roadmap.
Alternatives considered
- Put a rate limiter in front (Caddy/nginx). Works per client IP, not per token, and a proxy cannot tell a read tool from a destructive one, so it cannot apply a tighter limit to writes.
- Short task-lease tokens (Spec 115 leases, 24 h or less). They bound time, not volume.
- Lower
max_concurrent_requests. Bounds parallelism for everyone at once, not one runaway caller.
Which edition?
Both (personal and server).
- I searched existing issues and discussions for a similar request (none for per-token rate limits)
Activity
Dumbris commentedon Oct 20, 2026
Thanks for such a careful write-up and for offering to build it. One design note first: the authz gates are copied per pipeline, so the right place is the shared managed-client admission seam, where the call actually reaches the upstream and which already covers call_tool_*, direct mode, code_execution and REST alike, with the typed 429 and Retry-After path. To keep a first version small I would do one N-per-minute plus burst per token, default off, refused as a rejected tool_call rather than a second authz line. Would that cover your runaway-loop case, or do you need the tighter write and destructive cap from day one?
james-crowley commentedon Oct 20, 2026
Yes, that would cover the case I care about, a runaway agent loop. One N-per-minute plus burst per token, default off, refused as a rejected
tool_callat the managed-client admission seam is enough for a first version. A tighter write and destructive cap can wait; profile tiers already keep most tokens read-only.feat(security): per-token call rate limit for agent tokens (#1746)