Skip to content

Feature: MCP: retry a rate-limited call, and list a backend's tools as soon as it is enabled - #500

Draft
cdmo wants to merge 1 commit into
HazAT:mainfrom
cdmo:mcp-retry-relist
Draft

cdmo wants to merge 1 commit into
HazAT:mainfrom
cdmo:mcp-retry-relist

Conversation

@cdmo

@cdmo cdmo commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Two failures with Tool Gateway's MCP server, seen over a week of agent use (221 of 665 mcp calls failed):

  • Rate limits killed whole scripts. Slack behind Tool Gateway answers HTTP 429 with "Wait 1 second before you call slack_read_thread again". The extension returned that as a tool error, so one 429 failed a whole codemode script (32 times).
    Now a 429 is retried up to twice. It waits for the response's "Wait N seconds", or 3 s when there is none. A wait over 10 s, a third refusal, or an abort still comes back as a tool error and keeps the connection.
  • New tools showed up late. tool_gateway_enable_backend sends tools/list_changed only after its result. The next mcp {server} listing raced the refresh and missed the backend's tools, so agents guessed names (161 failures).
    Now a successful call to a tool named like *enable_backend* lists the tools again before it returns, and a listing waits for any refresh still in flight.

Tests: extensions/mcp/test/mcp.test.ts covers a call that succeeds after two 429s, one that fails after three (with the request count), and a listing right after enable_backend that includes the new tool. Without the server change, both new checks fail.

Checked once and not committed: no hint waits 3 s twice (3 requests, ~6 s); "Wait 60 seconds" fails at once (1 request); an abort during the wait stops at once and the server stays connected.

… it is enabled

A 429 is sent again up to twice, after the response's "Wait N seconds" or else 3 s,
so one rate-limited call no longer fails a whole codemode script. A wait over 10 s,
a third refusal or an abort still comes back as a tool error and keeps the connection.

Tool Gateway's tool_gateway_enable_backend sends tools/list_changed only after its
result, so the next listing raced the refresh and missed the backend's tools; agents
then guessed tool names. A successful *enable_backend* call now lists the tools again
before it returns, and a listing waits for a refresh still in flight.
@HazAT HazAT added the feature Reference implementation, left open and unmerged; borrow from it label Dec 3, 2026
@HazAT HazAT changed the title MCP: retry a rate-limited call, and list a backend's tools as soon as it is enabled Feature: MCP: retry a rate-limited call, and list a backend's tools as soon as it is enabled Dec 3, 2026
@HazAT

HazAT commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Thanks, the failure counts are very useful. We're keeping this open as a reference rather than merging: a guessed name after enable_backend is now handled generically by #506, which relists and returns the real tool names, and a 429 already comes back as a tool error carrying the server's wait hint, which a script can retry. We'd rather not keep a vendor-specific name regex and parsing of the wait text in the core. @ultimate assessed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Reference implementation, left open and unmerged; borrow from it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants