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
This commit is contained in:
parent
c5591be30b
commit
f5a3567494
4 changed files with 35 additions and 24 deletions
|
|
@ -1,7 +1,7 @@
|
|||
PATH
|
||||
remote: .
|
||||
specs:
|
||||
model_context_protocol (0.2.4)
|
||||
model_context_protocol (0.2.5)
|
||||
json_rpc_handler (~> 0.1)
|
||||
|
||||
GEM
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ module ModelContextProtocol
|
|||
"prompts/list" => method(:list_prompts),
|
||||
"prompts/get" => method(:get_prompt),
|
||||
"initialize" => method(:init),
|
||||
"ping" => method(:ping),
|
||||
"ping" => ->(_) { {} },
|
||||
}
|
||||
end
|
||||
|
||||
|
|
@ -72,13 +72,10 @@ module ModelContextProtocol
|
|||
|
||||
def capabilities
|
||||
@capabilities ||= {
|
||||
experimental: nil,
|
||||
logging: nil,
|
||||
prompts: nil,
|
||||
resources: nil,
|
||||
prompts: {},
|
||||
resources: {},
|
||||
tools: {},
|
||||
model_config: nil,
|
||||
}.compact
|
||||
}
|
||||
end
|
||||
|
||||
def server_info
|
||||
|
|
@ -96,10 +93,6 @@ module ModelContextProtocol
|
|||
}
|
||||
end
|
||||
|
||||
def ping(request)
|
||||
"pong"
|
||||
end
|
||||
|
||||
def list_tools(request)
|
||||
@tools.map { |_, tool| tool.to_h }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ModelContextProtocol
|
||||
VERSION = "0.2.4"
|
||||
VERSION = "0.2.5"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -34,18 +34,23 @@ module ModelContextProtocol
|
|||
@server = Server.new(name: @server_name, tools: [@tool], prompts: [@prompt], resources: [@resource])
|
||||
end
|
||||
|
||||
test "#handle ping request returns pong" do
|
||||
# https://spec.modelcontextprotocol.io/specification/2024-11-05/basic/utilities/ping/#behavior-requirements
|
||||
test "#handle ping request returns empty response" do
|
||||
request = {
|
||||
jsonrpc: "2.0",
|
||||
method: "ping",
|
||||
id: 1,
|
||||
id: "123",
|
||||
}
|
||||
|
||||
response = @server.handle(request)
|
||||
refute_nil response
|
||||
|
||||
assert_equal "pong", response[:result]
|
||||
assert_equal 1, response[:id]
|
||||
assert_equal(
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": "123",
|
||||
"result": {},
|
||||
},
|
||||
response,
|
||||
)
|
||||
end
|
||||
|
||||
test "#handle initialize request returns protocol info, server info, and capabilities" do
|
||||
|
|
@ -58,11 +63,24 @@ module ModelContextProtocol
|
|||
response = @server.handle(request)
|
||||
refute_nil response
|
||||
|
||||
result = response[:result]
|
||||
assert_equal Server::PROTOCOL_VERSION, result[:protocolVersion]
|
||||
assert_kind_of Hash, result[:capabilities]
|
||||
assert_equal @server_name, result[:serverInfo][:name]
|
||||
assert_equal ModelContextProtocol::VERSION, result[:serverInfo][:version]
|
||||
expected_result = {
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": {
|
||||
"protocolVersion": "2024-11-05",
|
||||
"capabilities": {
|
||||
"prompts": {},
|
||||
"resources": {},
|
||||
"tools": {},
|
||||
},
|
||||
"serverInfo": {
|
||||
"name": @server_name,
|
||||
"version": ModelContextProtocol::VERSION,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assert_equal expected_result, response
|
||||
end
|
||||
|
||||
test "#handle returns nil for notification requests" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue