Skip to content

feat: give the MCP bridge's attribution resolver a cancellation signal - #374

Merged
benbrandt merged 1 commit into
mainfrom
feat/mcp-bridge-signal
Nov 24, 2026
Merged

benbrandt merged 1 commit into
mainfrom
feat/mcp-bridge-signal

Conversation

@benbrandt

Copy link
Copy Markdown
Member

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

McpHttpRequestInfo gains signal: AbortSignal. It aborts when the bridge stops serving an HTTP request before it has finished answering it:

  • The HTTP connection closed, as when the MCP client gives up on the request.
  • The ACP connection closed.
  • The response buffered for a slow HTTP reader exceeded 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/message request. 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 bridge stops waiting and forwards nothing. There is no HTTP response left to write.
  • Whatever the resolver returns or throws after that is ignored, and is not reported as a bridge failure.
  • A resolver that ignores the signal only keeps its own work running.

The field is additive, on an object the SDK constructs.

The default reason for a request without a session

requireSession() in an admit check, and rejectSession() without a message on a request that names no session, said:

this MCP server needs a sessionId on the request. Send the sessionId of the ACP session the request is for

Through the bridge a model reads that as an instruction it cannot follow. It now says:

this MCP server needs to know which ACP session the request is for, and the agent did not say

The error code, its data, and the other default (this MCP server rejected sessionId "<id>") are unchanged. A bridge client now sees:

The MCP server refused this request before running it. Reason: this MCP server needs to know which ACP session the request is for, and the agent did not say. Changing the tool arguments will not help.

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 check passes (24 test files, 796 tests). The two examples run end to end.

`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.
@benbrandt
benbrandt enabled auto-merge (squash) November 24, 2026 15:11
@benbrandt
benbrandt merged commit e6441af into main Nov 24, 2026
6 checks passed
@benbrandt
benbrandt deleted the feat/mcp-bridge-signal branch November 24, 2026 15:12
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.

1 participant