Skip to content

Commit a3a3026

Browse files
committed
[Doc] Update Ruby client example to use explicit connect
## 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.
1 parent 8bf5b7d commit a3a3026

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

docs/docs/develop/build-client.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,7 @@ def connect_to_server(server_script_path)
17911791
17921792
@transport = MCP::Client::Stdio.new(command: command, args: [server_script_path])
17931793
@mcp_client = MCP::Client.new(transport: @transport)
1794+
@mcp_client.connect
17941795
17951796
tool_names = @mcp_client.tools.map(&:name)
17961797
puts "\nConnected to server with tools: #{tool_names}"

0 commit comments

Comments
 (0)