Skip to content

Tool calls carry an idempotency key, and are sent again with it (mcp-gateway 1.17.2, R8) - #379

Merged
sdrahn merged 1 commit into
mainfrom
claude/idempotent-calls
Nov 26, 2026
Merged

sdrahn merged 1 commit into
mainfrom
claude/idempotent-calls

Conversation

@sdrahn

@sdrahn sdrahn commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Changes the shared files CONTRACT.md and packaging/suse/custos.spec.

Fixes #378. Uses mcp-gateway 1.17.2's R8.

Changes

  • internal/gateway
    • tagCalls adds the call's idempotency key to each tools/call from an ADK tool. The key is CallToken(invocation, callID), the same value as its progress token; callKey makes it a custos:-prefixed SHA-256 digest where it is longer than 128 characters or has a character outside printable ASCII without spaces, as the gateway requires. The same call always has the same key.
    • idempotent counts a tools/call with a key among the requests sent again when the connection ends without an answer (EOF, reset). The gateway answers the repeat from the first call, waiting for it while it runs (an approval stays one approval).
    • A tools/call without a key, e.g. one not made by an ADK tool, is still never sent again. The comments say so.
    • Agents in OpenShell: each tool call on a connection of its own (#375); mcp-gateway R8 #376's fresh connection per tool call stays: it spares the common case the wait and the repeat.
  • packaging/suse/custos.spec: Requires: mcp-gateway >= 1.17.2. A gateway before it would not recognise the key and would run a repeat. CONTRACT.md §1 and the user guide's chapter 2 say 1.17.2.
  • CONTRACT.md §7: the key next to the progress token, and when an agent sends a call again.
  • docs/requirements/mcp-gateway-for-custos-0.10.md: R8 is in 1.17.2, and Custos uses it.
  • Changelog fragment changes.d/idempotent-calls.changed.md.

Testing

  • make check and make cockpit-test pass.
  • Unit tests:
    • TestCallsCarryKey: an ADK call carries its key; a call from outside ADK none;
    • TestCallKey: plain, too long, a space and a non-ASCII character become digests, stable for the same call and different for different calls;
    • TestDroppedCallWithKeyRetried: a keyed call whose connection is dropped once succeeds;
    • TestDroppedCallNotRetried (unchanged): a call without a key is not sent again.
  • That the gateway answers a repeat from the first call is tested in mcp-gateway's own CI. CI here builds mcp-gateway's main, which has R8.

Generated by Claude Code

mcp-gateway 1.17.2 answers a tools/call sent again with the same
idempotency key, server, tool and arguments from the first call (R8).
Each tool call from an ADK tool carries its own key, the call's
CallToken (a digest of it where it is longer than the gateway takes or
has a character it refuses), next to the progress token. The gateway
client counts a tools/call with a key among the requests it may send
again when the connection ends without an answer: an agent in OpenShell
whose call is cut off at a token renewal gets its outcome instead of an
error for a call that may have run. A call without a key is still never
sent again. Custos requires mcp-gateway 1.17.2.

Fixes #378

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q3sBGb8stQdHScGf2TGtWJ
@sdrahn
sdrahn merged commit 80482d6 into main Nov 26, 2026
18 checks passed
sdrahn added a commit that referenced this pull request Nov 26, 2026
Backport #376 and #379 to release-0.9 for 0.9.18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use mcp-gateway 1.17.2's idempotency keys for tool calls (R8)

2 participants