Repository navigation
Keep an MCP session open while a tool runs - #99
Merged
Merged
Conversation
Cancelled is a codec and a message. The session hub tracks the fiber for a request id, and the engine turns notifications/cancelled into that interrupt. Publishing a notification is ambient on the request, so a tool does not take a transport.
A closed stdin finishes the tool already read and still writes its result. A JSON POST is tracked the same way as an event stream, so cancelling it answers 202 and the next call still runs.
The waiter is McpError.Cancelled even when the POST then ends. OpenCall.notifications is what the reader recorded before the result. The session stream is ZStream.fromHub, which does not retain a value published before subscribe, so the test no longer polls a fiber to guess that it subscribed. The ship line is 0.14.0. McpSession.open and McpError.Cancelled do not fit a patch on 0.13.0.
The Agents page runs a pipe session where a later call finishes first, a tool publishes before its result, and cancel stops only that call. The HTTP sample is the POST event stream. The era table no longer says GET is 405.
scalafmtCheckAll rejected the new specs. The 0.14.0 ship line changed the workflow cache epoch.
A for that is the last expression of the block picks up an end marker. Binding it to a val closes the block on the name.
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.
Closes #98.
An MCP session keeps accepting requests and delivering notifications while a tool is still running. The tool calls
Session.publishand does not name the pipe or HTTP. Answers are matched by JSON-RPC id, so a later call can finish first.What changed
initializeis still answered before the next read. One write permit orders a notification ahead of that tool's result.Acceptcontainstext/event-stream, the POST body is that call's events, then its result. Otherwise the body stays one JSON response andpublishsends nothing.notifications/cancelledinterrupts that request's fiber. No result is written for a call interrupted before the result. An unknown id or a malformed body is ignored.stdio, closing the POST stream, orDELETEinterrupts them.McpClient.openreturns the id, the result, the notifications recorded before that result, andcancel.requestisopenplus the session timeout.Breaks
text/event-streamwhenAcceptasks for it.McpClient.httpalready sends that Accept.McpError.Cancelledis a new case.McpSession.openis new. The ship line is 0.14.0. 0.13.0 is released, and 0.13.1 was only the open patch, so these signatures do not fit it underearly-semver.Session.publishoutside a request succeeds and sends nothing.1can cancel each other.GET stays the session's resource stream. Tool notifications are not delivered there.
Tests
mcp/testFull(85),example/testFull, anddocs/testFull(89), JVM. The cross-transport spec runs the issue's list on stdio and HTTP against the real server: overlap, publish-then-result, cancel one call and leave the other running.