Rebasely Beta: data may be purged

examples/MCP-tools Public

Limit tool calls per client with a Durable Object #1

Changed files

21 files changed335 additions21 deletionssince main at fcaf000

A client over its rate limit

Added by this pull request.

  • Added
  • Rerouted, relabelled or moved
  • Removed

An agent stuck in a loop has spent its 30 calls. The refusal comes back as a tool result, so the model reads how long to wait instead of the client reporting an HTTP error.

A client over its rate limit: 7 steps between 5 participants Step 1: agent to mcp-client, call convert_units again, the 31st time this minute (added)call convert_units again, the…Step 2: mcp-client to mcp-server, POST /mcp: tools/call convert_units (added)POST /mcp: tools/call convert…Step 3: mcp-server to mcp-sdk, check the arguments against the input schema (added)check the arguments against t…Step 4: mcp-server to rate-limiter, take a token from this client's bucket (added)take a token from this client's bucketStep 5: rate-limiter to mcp-server, refused: next token in 2 seconds (added)refused: next token in 2 secondsStep 6: mcp-server to mcp-client, isError result: wait 2 seconds before the next call (added)isError result: wait 2 second…Step 7: mcp-client to agent, the refusal as a tool message, so the model can back off (added)the refusal as a tool message…agent (added in this flow)agentActor · addedmcp-client (added in this flow)mcp-clientActor · addedmcp-server (added in this flow)mcp-serverWorker · addedmcp-sdk (added in this flow)mcp-sdkExternal · addedrate-limiter (added in this flow)rate-limiterDurable Object · added

The flow rate-limited-call at the head of this pull request, numbered in its order, with the steps it adds, reroutes, relabels, moves and removes. A removed step has no number.

Steps

  1. Step 1, added: agent → mcp-client call convert_units again, the 31st time this minute Added
  2. Step 2, added: mcp-client → mcp-server POST /mcp: tools/call convert_units Added
  3. Step 3, added: mcp-server → mcp-sdk check the arguments against the input schema Added
  4. Step 4, added: mcp-server → rate-limiter take a token from this client's bucket Added
  5. Step 5, added: rate-limiter → mcp-server refused: next token in 2 seconds Added
  6. Step 6, added: mcp-server → mcp-client isError result: wait 2 seconds before the next call Added
  7. Step 7, added: mcp-client → agent the refusal as a tool message, so the model can back off Added

Knowledge base

Back to the conversation