ruby-mcp-client 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +345 -3
- data/lib/mcp_client/auth/browser_oauth.rb +424 -0
- data/lib/mcp_client/auth/oauth_provider.rb +131 -19
- data/lib/mcp_client/auth.rb +1 -1
- data/lib/mcp_client/client.rb +73 -1
- data/lib/mcp_client/json_rpc_common.rb +3 -1
- data/lib/mcp_client/server_factory.rb +4 -2
- data/lib/mcp_client/server_http.rb +8 -0
- data/lib/mcp_client/server_sse/sse_parser.rb +11 -0
- data/lib/mcp_client/server_sse.rb +126 -0
- data/lib/mcp_client/server_stdio.rb +100 -1
- data/lib/mcp_client/server_streamable_http/json_rpc_transport.rb +8 -1
- data/lib/mcp_client/server_streamable_http.rb +132 -6
- data/lib/mcp_client/tool.rb +40 -4
- data/lib/mcp_client/version.rb +2 -2
- metadata +3 -2
data/lib/mcp_client/tool.rb
CHANGED
|
@@ -8,20 +8,28 @@ module MCPClient
|
|
|
8
8
|
# @!attribute [r] description
|
|
9
9
|
# @return [String] the description of the tool
|
|
10
10
|
# @!attribute [r] schema
|
|
11
|
-
# @return [Hash] the JSON schema for the tool
|
|
11
|
+
# @return [Hash] the JSON schema for the tool inputs
|
|
12
|
+
# @!attribute [r] output_schema
|
|
13
|
+
# @return [Hash, nil] optional JSON schema for structured tool outputs (MCP 2025-06-18)
|
|
14
|
+
# @!attribute [r] annotations
|
|
15
|
+
# @return [Hash, nil] optional annotations describing tool behavior (e.g., readOnly, destructive)
|
|
12
16
|
# @!attribute [r] server
|
|
13
17
|
# @return [MCPClient::ServerBase, nil] the server this tool belongs to
|
|
14
|
-
attr_reader :name, :description, :schema, :server
|
|
18
|
+
attr_reader :name, :description, :schema, :output_schema, :annotations, :server
|
|
15
19
|
|
|
16
20
|
# Initialize a new Tool
|
|
17
21
|
# @param name [String] the name of the tool
|
|
18
22
|
# @param description [String] the description of the tool
|
|
19
|
-
# @param schema [Hash] the JSON schema for the tool
|
|
23
|
+
# @param schema [Hash] the JSON schema for the tool inputs
|
|
24
|
+
# @param output_schema [Hash, nil] optional JSON schema for structured tool outputs (MCP 2025-06-18)
|
|
25
|
+
# @param annotations [Hash, nil] optional annotations describing tool behavior
|
|
20
26
|
# @param server [MCPClient::ServerBase, nil] the server this tool belongs to
|
|
21
|
-
def initialize(name:, description:, schema:, server: nil)
|
|
27
|
+
def initialize(name:, description:, schema:, output_schema: nil, annotations: nil, server: nil)
|
|
22
28
|
@name = name
|
|
23
29
|
@description = description
|
|
24
30
|
@schema = schema
|
|
31
|
+
@output_schema = output_schema
|
|
32
|
+
@annotations = annotations
|
|
25
33
|
@server = server
|
|
26
34
|
end
|
|
27
35
|
|
|
@@ -33,10 +41,14 @@ module MCPClient
|
|
|
33
41
|
# Some servers (Playwright MCP CLI) use 'inputSchema' instead of 'schema'
|
|
34
42
|
# Handle both string and symbol keys
|
|
35
43
|
schema = data['inputSchema'] || data[:inputSchema] || data['schema'] || data[:schema]
|
|
44
|
+
output_schema = data['outputSchema'] || data[:outputSchema]
|
|
45
|
+
annotations = data['annotations'] || data[:annotations]
|
|
36
46
|
new(
|
|
37
47
|
name: data['name'] || data[:name],
|
|
38
48
|
description: data['description'] || data[:description],
|
|
39
49
|
schema: schema,
|
|
50
|
+
output_schema: output_schema,
|
|
51
|
+
annotations: annotations,
|
|
40
52
|
server: server
|
|
41
53
|
)
|
|
42
54
|
end
|
|
@@ -74,6 +86,30 @@ module MCPClient
|
|
|
74
86
|
}
|
|
75
87
|
end
|
|
76
88
|
|
|
89
|
+
# Check if the tool is marked as read-only
|
|
90
|
+
# @return [Boolean] true if the tool is read-only
|
|
91
|
+
def read_only?
|
|
92
|
+
@annotations && @annotations['readOnly'] == true
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Check if the tool is marked as destructive
|
|
96
|
+
# @return [Boolean] true if the tool is destructive
|
|
97
|
+
def destructive?
|
|
98
|
+
@annotations && @annotations['destructive'] == true
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Check if the tool requires confirmation before execution
|
|
102
|
+
# @return [Boolean] true if the tool requires confirmation
|
|
103
|
+
def requires_confirmation?
|
|
104
|
+
@annotations && @annotations['requiresConfirmation'] == true
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Check if the tool supports structured outputs (MCP 2025-06-18)
|
|
108
|
+
# @return [Boolean] true if the tool has an output schema defined
|
|
109
|
+
def structured_output?
|
|
110
|
+
!@output_schema.nil? && !@output_schema.empty?
|
|
111
|
+
end
|
|
112
|
+
|
|
77
113
|
private
|
|
78
114
|
|
|
79
115
|
# Recursively remove "$schema" keys that are not accepted by Vertex AI
|
data/lib/mcp_client/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-mcp-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Szymon Kurcab
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -120,6 +120,7 @@ files:
|
|
|
120
120
|
- README.md
|
|
121
121
|
- lib/mcp_client.rb
|
|
122
122
|
- lib/mcp_client/auth.rb
|
|
123
|
+
- lib/mcp_client/auth/browser_oauth.rb
|
|
123
124
|
- lib/mcp_client/auth/oauth_provider.rb
|
|
124
125
|
- lib/mcp_client/client.rb
|
|
125
126
|
- lib/mcp_client/config_parser.rb
|