Add client-level connect handshake to stdio transport#133
Merged
a-akimov merged 1 commit intomodelcontextprotocol:mainfrom May 6, 2026
Merged
Add client-level connect handshake to stdio transport#133a-akimov merged 1 commit intomodelcontextprotocol:mainfrom
a-akimov merged 1 commit intomodelcontextprotocol:mainfrom
Conversation
## Motivation and Context Follow-up to modelcontextprotocol/ruby-sdk#336 mcp gem 0.15.0 introduced an explicit `MCP::Client#connect` method for the stdio transport, aligning with the Python and TypeScript SDKs which require explicit handshake calls regardless of transport type: - Python SDK: `ClientSession.initialize()` https://github.com/modelcontextprotocol/python-sdk - TypeScript SDK: `Client.connect(transport)` https://github.com/modelcontextprotocol/typescript-sdk This sample is updated to call `@mcp_client.connect` explicitly after creating the client, demonstrating the recommended initialization pattern. The Gemfile constraint is bumped to `>= 0.15.0` to require the new API. ## How Has This Been Tested? Ran the sample against `weather-server-ruby` and confirmed the connection, tool listing, and chat loop continue to work as expected. ## Breaking Changes None. The change updates the sample to use the new explicit `connect` API, which was added as a non-breaking addition in mcp gem 0.15.0.
4f7f7e5 to
a1838e9
Compare
9 tasks
koic
added a commit
to koic/modelcontextprotocol
that referenced
this pull request
May 6, 2026
## Motivation and Context Follow-up to modelcontextprotocol/ruby-sdk#336 and modelcontextprotocol/quickstart-resources#133. The Ruby example in `docs/docs/develop/build-client.mdx` constructed `MCP::Client` with a stdio transport and immediately called `client.tools`, relying on the implicit `initialize_session` that the stdio transport performed on the first request. ruby-sdk PR modelcontextprotocol#336 added `MCP::Client#connect` for the stdio transport so that the explicit `initialize` plus `notifications/initialized` handshake is exposed at the public API level, matching the Python SDK (`ClientSession.initialize()`) and the TypeScript SDK (`Client.connect(transport)`). The implicit-init path is preserved as a backwards-compatible shim, but new code is expected to call `connect` explicitly. This change updates the Ruby example so readers learn the explicit `@mcp_client.connect` pattern from the start, consistent with how the Python and TypeScript examples present the handshake. ## How Has This Been Tested? - Re-read the surrounding `connect_to_server` example in `docs/docs/develop/build-client.mdx` to confirm `@mcp_client.connect` fits naturally between the client construction and the subsequent `@mcp_client.tools` call. - Ran `npm run prep` to confirm there are no documentation warnings or errors introduced by the change. ## Breaking Changes None. This is a documentation-only change that adds a single explicit `connect` call to the Ruby client example. No schema, navigation, or runtime behavior is affected.
mcp-commander Bot
pushed a commit
to modelcontextprotocol/modelcontextprotocol
that referenced
this pull request
May 6, 2026
## Motivation and Context Follow-up to modelcontextprotocol/ruby-sdk#336 and modelcontextprotocol/quickstart-resources#133. The Ruby example in `docs/docs/develop/build-client.mdx` constructed `MCP::Client` with a stdio transport and immediately called `client.tools`, relying on the implicit `initialize_session` that the stdio transport performed on the first request. ruby-sdk PR #336 added `MCP::Client#connect` for the stdio transport so that the explicit `initialize` plus `notifications/initialized` handshake is exposed at the public API level, matching the Python SDK (`ClientSession.initialize()`) and the TypeScript SDK (`Client.connect(transport)`). The implicit-init path is preserved as a backwards-compatible shim, but new code is expected to call `connect` explicitly. This change updates the Ruby example so readers learn the explicit `@mcp_client.connect` pattern from the start, consistent with how the Python and TypeScript examples present the handshake. ## How Has This Been Tested? - Re-read the surrounding `connect_to_server` example in `docs/docs/develop/build-client.mdx` to confirm `@mcp_client.connect` fits naturally between the client construction and the subsequent `@mcp_client.tools` call. - Ran `npm run prep` to confirm there are no documentation warnings or errors introduced by the change. ## Breaking Changes None. This is a documentation-only change that adds a single explicit `connect` call to the Ruby client example. No schema, navigation, or runtime behavior is affected.
Contributor
|
@koic thank you for your contribution! |
a-akimov
approved these changes
May 6, 2026
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
Follow-up to modelcontextprotocol/ruby-sdk#336
mcp gem 0.15.0 introduced an explicit
MCP::Client#connectmethod for the stdio transport, aligning with the Python and TypeScript SDKs which require explicit handshake calls regardless of transport type:ClientSession.initialize()https://github.com/modelcontextprotocol/python-sdkClient.connect(transport)https://github.com/modelcontextprotocol/typescript-sdkThis sample is updated to call
@mcp_client.connectexplicitly after creating the client, demonstrating the recommended initialization pattern. The Gemfile constraint is bumped to>= 0.15.0to require the new API.How Has This Been Tested?
Ran the sample against
weather-server-rubyand confirmed the connection, tool listing, and chat loop continue to work as expected.Breaking Changes
None. The change updates the sample to use the new explicit
connectAPI, which was added as a non-breaking addition in mcp gem 0.15.0.Types of changes
Checklist