Repository navigation
feat: give the MCP bridge's attribution resolver a cancellation signal - #374
Merged
Merged
Conversation
`McpHttpRequestInfo.signal` aborts when the bridge stops serving an HTTP request before it has answered it: the MCP client gave up, or the ACP connection closed. A resolver that waits, for example for a subagent's session to be announced, can stop on it. When the signal aborts while the resolver is pending, the bridge stops waiting and forwards nothing. What the resolver returns or throws after that is ignored. Also reword the provider's default reason for a request without a session. It said "Send the sessionId of the ACP session the request is for", which a model reads through the bridge as an instruction it cannot follow. It now says that the server needs to know which ACP session the request is for, and the agent did not say.
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.
Summary
Two small follow-ups to the MCP-over-ACP HTTP bridge, both from the Claude Code adapter's use of 2.11.0.
A cancellation signal for the attribution resolver
McpHttpRequestInfogainssignal: AbortSignal. It aborts when the bridge stops serving an HTTP request before it has finished answering it:maxBufferedResponseBytes. That can only happen while the request is being forwarded, after the resolver has returned.It is the signal that already cancels the forwarded
mcp/messagerequest. The bridge created it before calling the resolver and did not pass it on.Why: a resolver can wait before it answers. The Claude Code adapter holds a subagent's request until that subagent's child session is announced. Without the signal it could not tell that its backend had abandoned the HTTP request, so the request stayed held until the tool use ended or the adapter's own limit passed.
When the signal aborts while the resolver is still pending:
The field is additive, on an object the SDK constructs.
The default reason for a request without a session
requireSession()in anadmitcheck, andrejectSession()without a message on a request that names no session, said:Through the bridge a model reads that as an instruction it cannot follow. It now says:
The error code, its
data, and the other default (this MCP server rejected sessionId "<id>") are unchanged. A bridge client now sees:Tests
src/mcp/http.test.ts: the resolver's signal aborts when the HTTP client drops the request and when the ACP connection closes. In both cases nothing is forwarded, the resolver's late rejection is not reported, and the bridge keeps serving.src/mcp/core.test.ts,src/mcp/mcp-server.test.ts,src/mcp/http.test.ts: the tests that pin the reason use the new sentence.Verification
npm run checkpasses (24 test files, 796 tests). The two examples run end to end.