Require calling MCP::Client#connect before sending requests on stdio transport#427
Open
koic wants to merge 1 commit into
Open
Require calling MCP::Client#connect before sending requests on stdio transport#427koic wants to merge 1 commit into
MCP::Client#connect before sending requests on stdio transport#427koic wants to merge 1 commit into
Conversation
…o transport ## Motivation and Context The MCP specification requires an `initialize` request followed by `notifications/initialized` before any other interaction. Issue modelcontextprotocol#334 makes that handshake explicit on the stdio client, matching the Python SDK (`ClientSession.initialize()`) and TypeScript SDK (`Client.connect(transport)`). The change was staged to avoid a hard break. Phase 1 (modelcontextprotocol#336) added `MCP::Client::Stdio#connect` while keeping an implicit-init compatibility shim on the first `send_request`. Phase 2 (modelcontextprotocol#338) emitted a deprecation warning when that shim ran. The warning has shipped since 0.16.0, so this final phase removes the shim. ## How Has This Been Tested? `send_request` now raises a `RuntimeError` when `connect` has not been called, and no longer auto-starts the subprocess. `connect` is the sole entry point that spawns the process and performs the handshake, which avoids leaving an orphaned subprocess behind. The stdio test suite was reworked to call `connect` explicitly, a regression test was added for the new guard, and `rake test` passes (1145 runs, 0 failures). ## Breaking Changes Stdio clients that send requests without calling `MCP::Client#connect` now raise a `RuntimeError` instead of silently initializing. Call `client.connect` before the first request. Closes modelcontextprotocol#334
3 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.
Motivation and Context
The MCP specification requires an
initializerequest followed bynotifications/initializedbefore any other interaction. Issue #334 makes that handshake explicit on the stdio client, matching the Python SDK (ClientSession.initialize()) and TypeScript SDK (Client.connect(transport)).The change was staged to avoid a hard break. Phase 1 (#336) added
MCP::Client::Stdio#connectwhile keeping an implicit-init compatibility shim on the firstsend_request. Phase 2 (#338) emitted a deprecation warning when that shim ran. The warning has shipped since 0.16.0, so this final phase removes the shim.How Has This Been Tested?
send_requestnow raises aRuntimeErrorwhenconnecthas not been called, and no longer auto-starts the subprocess.connectis the sole entry point that spawns the process and performs the handshake, which avoids leaving an orphaned subprocess behind.The stdio test suite was reworked to call
connectexplicitly, a regression test was added for the new guard, andrake testpasses (1145 runs, 0 failures).Breaking Changes
Stdio clients that send requests without calling
MCP::Client#connectnow raise aRuntimeErrorinstead of silently initializing. Callclient.connectbefore the first request.Closes #334
Types of changes
Checklist