Merge pull request #126 from koic/fix_errors_when_title_is_not_specified
Fix errors when `title` is not specified
This commit is contained in:
commit
dd5b318b11
4 changed files with 12 additions and 4 deletions
|
|
@ -222,7 +222,7 @@ module MCP
|
||||||
name:,
|
name:,
|
||||||
title:,
|
title:,
|
||||||
version:,
|
version:,
|
||||||
}
|
}.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
def init(request)
|
def init(request)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ module MCP
|
||||||
title: title_value,
|
title: title_value,
|
||||||
description: description_value,
|
description: description_value,
|
||||||
inputSchema: input_schema_value.to_h,
|
inputSchema: input_schema_value.to_h,
|
||||||
}
|
}.compact
|
||||||
result[:annotations] = annotations_value.to_h if annotations_value
|
result[:annotations] = annotations_value.to_h if annotations_value
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -771,7 +771,7 @@ module MCP
|
||||||
assert_equal Configuration::DEFAULT_PROTOCOL_VERSION, response[:result][:protocolVersion]
|
assert_equal Configuration::DEFAULT_PROTOCOL_VERSION, response[:result][:protocolVersion]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "server uses default title when not configured" do
|
test "server response does not include title when not configured" do
|
||||||
server = Server.new(name: "test_server")
|
server = Server.new(name: "test_server")
|
||||||
request = {
|
request = {
|
||||||
jsonrpc: "2.0",
|
jsonrpc: "2.0",
|
||||||
|
|
@ -780,7 +780,7 @@ module MCP
|
||||||
}
|
}
|
||||||
|
|
||||||
response = server.handle(request)
|
response = server.handle(request)
|
||||||
assert_nil response[:result][:serverInfo][:title]
|
refute response[:result][:serverInfo].key?(:title)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "server uses default version when not configured" do
|
test "server uses default version when not configured" do
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,14 @@ module MCP
|
||||||
assert_equal({ name: "mock_tool", title: "Mock Tool", description: "a mock tool for testing", inputSchema: { type: "object" } }, tool.to_h)
|
assert_equal({ name: "mock_tool", title: "Mock Tool", description: "a mock tool for testing", inputSchema: { type: "object" } }, tool.to_h)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "#to_h does not have `:title` key when title is omitted" do
|
||||||
|
tool = Tool.define(
|
||||||
|
name: "mock_tool",
|
||||||
|
description: "a mock tool for testing",
|
||||||
|
)
|
||||||
|
refute tool.to_h.key?(:title)
|
||||||
|
end
|
||||||
|
|
||||||
test "#to_h includes annotations when present" do
|
test "#to_h includes annotations when present" do
|
||||||
tool = TestTool
|
tool = TestTool
|
||||||
expected_annotations = {
|
expected_annotations = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue