Skip to main content
Glama

WritersLogic agent-infra

token-bucket

Shared token bucket: many agents, one upstream rate limit — One rate limiter shared by every agent in your fleet. take(cost) atomically spends tokens if available and returns allowed plus remaining, or refuses with retryAfterMs until enough tokens refill. capacity and refillPerSecond are fixed when the bucket is first used; a call with different settings is refused so two fleets cannot silently disagree. Use a requestId so a retried take is not charged twi

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "op": "<op>",
      "bucket": "<bucket>",
      "capacity": "<capacity>",
      "refillPerSecond": "<refillPerSecond>"
    },
    "name": "token-bucket"
  }
}

Input Schema

NameRequiredDescriptionDefault
opYes
costNoTokens to spend; default 1.
bucketYesBucket name, e.g. openai:org-123:rpm.
capacityYes
tenantIdNoRequired for API-key callers (namespaced as key:<tenantId>; keep it unguessable). Ignored when a wallet paid: the payer address is the tenant.
requestIdNoCaller-chosen id for this mutation. A retry with the same id and same input returns the stored response (24 h) instead of applying twice; the same id with different input is rejected. Send one on every mutation you may retry: without it a retry is applied again (fleet-memory record appends a duplicate; a repeated spend-ledger commit or release answers NO_HOLD because the first call already took effect).
refillPerSecondYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations supplied, the description carries the full behavioral burden and does substantial work: it discloses atomicity, the immutability of capacity and refillPerSecond after first use, the refusal behavior on mismatched settings, the retryAfterMs refusal contract, and idempotency via requestId with a 24 h stored response. The final sentence is cut off mid-word, so the idempotency guidance is incomplete, and authentication/tenancy behavior from the schema is not restated.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Information is front-loaded and dense with no filler sentences, which suits a low-level primitive. The definition is visibly truncated mid-word ('charged twi'), which is a structural defect that leaves the reader hanging and signals an incomplete definition rather than a stylistic choice.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given seven parameters, four required, no annotations, and no output schema, the description does well to state the return contract (allowed, remaining, retryAfterMs) inline. It is still incomplete: the truncation removes the rest of the idempotency rationale, the peek operation is undefined, and the tenancy/auth requirement present in the schema is never surfaced in prose.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 57%, so the schema already documents many parameters, and the description adds real meaning for the two configuration parameters by explaining they are fixed at first use and that conflicting values are refused. It also explains requestId's intent is retry-safe deduplication. It does not explain the op enum (peek is never mentioned), the bucket naming semantics, or the tenantId requirement, leaving roughly half the surface to the schema alone.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a concrete framing (a single rate limiter shared across a fleet) and names the core operation and its return contract: take(cost) atomically spends tokens and returns allowed plus remaining, or refuses with retryAfterMs. That is specific verb+resource and an agent could act on it without opening the schema. It stops short of a 5 because no sibling tool is named or excluded, so the boundary against adjacent rate-limit style tools is left implicit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is strongly implied: use this when multiple agents must share one upstream rate limit, and the description explains that a mismatched capacity/refillPerSecond call is refused so fleets cannot disagree. It also advises sending a requestId on retryable mutations. However, there is no explicit when-not guidance, no statement of which operation (take vs peek) fits which situation, and no named alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources