Repository navigation
fix(mcpbroker): address the gateway call review follow-ups - #2831
Merged
Merged
Conversation
- A connect link reaches the model only if it holds just the characters RFC 3986 allows and is unchanged when parsed again, so a backend cannot add words to it through a space or a Unicode format character. - The already_sent text no longer claims the outcome is unknown: the call may be in flight or have completed. - A credential renewal runs apart from the lookup that started it, bounded by its own timeout, so one run's cancellation no longer fails another run's call; every lookup still stops waiting when its own context ends. - A registration is checked against the time it returns, so a credential that expired during a slow registration is refused. - A call that returned before its context ended no longer waits five seconds for a cancellation notice the SDK will not send. Co-authored-by: Mecatl <[email protected]>
The send-once record keyed claims by operation and argument hash, so a resumed call whose arguments a hook rewrote was a new claim and was sent again; the design never sends a recorded operation again. Claims are now keyed by operation, holding the hash they were claimed with, and an operation claimed with any arguments refuses another claim. A gateway call is now claimed before it is authorized, so a duplicate is refused without a gateway token being issued and recorded for it. A call refused authorization was not sent and its claim is released. Co-authored-by: Mecatl <[email protected]>
jhrozek
approved these changes
Nov 17, 2026
The SDK sends notifications/cancelled exactly when CallTool returns the context's error. A gateway error or closed connection followed by a late cancel sends nothing, so waiting for the notice then timed out. Co-authored-by: Mecatl <[email protected]>
ChrisJBurns
enabled auto-merge (squash)
November 17, 2026 21:43
Merged
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #2818, from Jakub's review there. Refs #2536.
Summary
internal/adapter/mcp/gatewaycall.go): the link from a -32042 answer reaches the model, and a backend could add words to it through a space or a Unicode format character such as a bidi override. It is now kept only if it holds just the characters RFC 3986 allows and is unchanged when parsed again. The origin rule stays with Connect provider accounts at the embedded gateway #2537.already_senttext: no longer says the outcome is unknown, because the call may still be in flight or have completed.internal/agentcredential): the shared renewal runs apart from the lookup that started it, bounded by its own timeout. One run's cancellation no longer fails another run's call, and every lookup still stops waiting when its own context ends.internal/adapter/mcpbroker/sendonce.go): claims are keyed by operation, holding the argument hash they were claimed with. Before, a resumed call whose arguments a hook rewrote was a new claim and was sent again; the design ("Pauses and restart") never sends a recorded operation again. It getsalready_sentinstead.Deferred: the delete-then-reattach race in the send-once cleanup is now a requirement on #2730.
Testing
tools/call;task lint: 0 issues.mcp,mcpbroker,agentcredentialandadapter/server, and thecmd/mecak8sidentity broker slice test passes.task test:race: everything passes except two tests that also fail onorigin/mainin this environment: a unix socket path too long incmd/mecated, and nobashinenvironment/microvm/gitexec.go run ./cmd/mecademoshows the tool call, the permission ask and approval, and the result.API compatibility
Assessment: compatible, no major bump, no feature identifier. The changes are reachable only on gateway routes, which production doesn't configure until #2533. There, one model-visible tool-error text changes (
already_sent, same code), a resumed call with rewritten arguments now getsalready_sentinstead of being sent, and a connect link with characters outside RFC 3986 is dropped from theconnection_requiredtext. No wire schema, request-level error or stored data changes. Upgrade implications: none.