Skip to content

Commit 753676f

Browse files
committed
client: add client_info and protocol_version configuration
- Add client_info parameter to configure client name/version - Add protocol_version parameter (defaults to 2025-06-18) - Add @initialized and @session_info instance variables for session tracking - Expose client_info, protocol_version, and session_info as readable attributes
1 parent f312695 commit 753676f

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/mcp/client.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,26 @@ class Client
66
#
77
# @param transport [Object] The transport object to use for communication with the server.
88
# The transport should be a duck type that responds to `send_request`. See the README for more details.
9+
# @param client_info [Hash] Information about the client (name and version)
10+
# @param protocol_version [String] The MCP protocol version to use
911
#
1012
# @example
1113
# transport = MCP::Client::HTTP.new(url: "http://localhost:3000")
12-
# client = MCP::Client.new(transport: transport)
13-
def initialize(transport:)
14+
# client = MCP::Client.new(
15+
# transport: transport,
16+
# client_info: { name: "my-client", version: "1.0.0" }
17+
# )
18+
def initialize(transport:, client_info: nil, protocol_version: "2025-06-18")
1419
@transport = transport
20+
@client_info = client_info || { name: "ruby-mcp-client", version: MCP::VERSION }
21+
@protocol_version = protocol_version
22+
@initialized = false
23+
@session_info = nil
1524
end
1625

1726
# The user may want to access additional transport-specific methods/attributes
1827
# So keeping it public
19-
attr_reader :transport
28+
attr_reader :transport, :client_info, :protocol_version, :session_info
2029

2130
# Returns the list of tools available from the server.
2231
# Each call will make a new request – the result is not cached.

0 commit comments

Comments
 (0)