Skip to content

Commit f5a3567

Browse files
committed
Internal Release 0.2.5
changes in this release: - fix ping response #17 - add prompts and resources support to init response #18 - Bump json from 2.10.1 to 2.10.2 #14
1 parent c5591be commit f5a3567

File tree

4 files changed

+35
-24
lines changed

4 files changed

+35
-24
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
model_context_protocol (0.2.4)
4+
model_context_protocol (0.2.5)
55
json_rpc_handler (~> 0.1)
66

77
GEM

lib/model_context_protocol/server.rb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def initialize(name: "model_context_protocol", tools: [], prompts: [], resources
2323
"prompts/list" => method(:list_prompts),
2424
"prompts/get" => method(:get_prompt),
2525
"initialize" => method(:init),
26-
"ping" => method(:ping),
26+
"ping" => ->(_) { {} },
2727
}
2828
end
2929

@@ -72,13 +72,10 @@ def prompts_get_handler(&block)
7272

7373
def capabilities
7474
@capabilities ||= {
75-
experimental: nil,
76-
logging: nil,
77-
prompts: nil,
78-
resources: nil,
75+
prompts: {},
76+
resources: {},
7977
tools: {},
80-
model_config: nil,
81-
}.compact
78+
}
8279
end
8380

8481
def server_info
@@ -96,10 +93,6 @@ def init(request)
9693
}
9794
end
9895

99-
def ping(request)
100-
"pong"
101-
end
102-
10396
def list_tools(request)
10497
@tools.map { |_, tool| tool.to_h }
10598
end

lib/model_context_protocol/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module ModelContextProtocol
4-
VERSION = "0.2.4"
4+
VERSION = "0.2.5"
55
end

test/model_context_protocol/server_test.rb

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,23 @@ class ServerTest < ActiveSupport::TestCase
3434
@server = Server.new(name: @server_name, tools: [@tool], prompts: [@prompt], resources: [@resource])
3535
end
3636

37-
test "#handle ping request returns pong" do
37+
# https://spec.modelcontextprotocol.io/specification/2024-11-05/basic/utilities/ping/#behavior-requirements
38+
test "#handle ping request returns empty response" do
3839
request = {
3940
jsonrpc: "2.0",
4041
method: "ping",
41-
id: 1,
42+
id: "123",
4243
}
4344

4445
response = @server.handle(request)
45-
refute_nil response
46-
47-
assert_equal "pong", response[:result]
48-
assert_equal 1, response[:id]
46+
assert_equal(
47+
{
48+
"jsonrpc": "2.0",
49+
"id": "123",
50+
"result": {},
51+
},
52+
response,
53+
)
4954
end
5055

5156
test "#handle initialize request returns protocol info, server info, and capabilities" do
@@ -58,11 +63,24 @@ class ServerTest < ActiveSupport::TestCase
5863
response = @server.handle(request)
5964
refute_nil response
6065

61-
result = response[:result]
62-
assert_equal Server::PROTOCOL_VERSION, result[:protocolVersion]
63-
assert_kind_of Hash, result[:capabilities]
64-
assert_equal @server_name, result[:serverInfo][:name]
65-
assert_equal ModelContextProtocol::VERSION, result[:serverInfo][:version]
66+
expected_result = {
67+
"jsonrpc": "2.0",
68+
"id": 1,
69+
"result": {
70+
"protocolVersion": "2024-11-05",
71+
"capabilities": {
72+
"prompts": {},
73+
"resources": {},
74+
"tools": {},
75+
},
76+
"serverInfo": {
77+
"name": @server_name,
78+
"version": ModelContextProtocol::VERSION,
79+
},
80+
},
81+
}
82+
83+
assert_equal expected_result, response
6684
end
6785

6886
test "#handle returns nil for notification requests" do

0 commit comments

Comments
 (0)