Add owned stdio clients for local MCP servers - #16
Merged
Merged
Conversation
Keep notifications ordered while owning legacy request-handler tasks separately. Let callback-initiated close finish process and IO shutdown without waiting on other callbacks, while external close retains and joins unfinished handlers under one deadline.
quinnj
force-pushed
the
feat/stdio-client
branch
from
October 2, 2026 06:26
8760a1c to
2b23657
Compare
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.
Local MCP servers using stdin/stdout cannot currently use this package's client: a manually constructed stdio descriptor fails during initialization with
transport_unsupported. Add the qualifiedModelContextProtocol.prepare_stdio_client(command)constructor, including a do-block form, and reuse the existing initialization, list/call, handler, and termination APIs.The client owns one child process and its protocol pipes. It matches concurrent responses by exact request ID, separates stderr, bounds frames and pending work, and applies one deadline to queued writes and response waits. EOF or invalid output fails pending calls and starts process cleanup. Write failures preserve the original failure; complete responses received before EOF remain available.
Notifications retain arrival order. Legacy server requests run in bounded, owned tasks so a handler's nested call can receive another server request before completing. Request handlers may overlap notifications and other request handlers. External
closewaits for all owned tasks under one deadline. A callback callingclosewaits for process and IO shutdown without waiting on other callbacks, avoiding cycles between callbacks that close concurrently. Unfinished callbacks remain owned for a later external close; arbitrary blocked user code still needs cooperative release.Protocol selection is explicit:
2025-11-25by default, or2026-07-28discovery and request metadata. Automatic version probing/restart/replay, modern subscriptions, and Agentif catalog import are outside this change. Subprocess stdio requires the Julia runtime; the existing static native server remains separate. There are no new dependencies or exports. Existing HTTP behavior and positional client constructors remain covered.MCPClientgains one optional field, changing its exact field layout.Validation on macOS arm64:
AI-driven research and implementation with Codex, followed by independent review.
Co-authored by Codex