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:,
|
||||
title:,
|
||||
version:,
|
||||
}
|
||||
}.compact
|
||||
end
|
||||
|
||||
def init(request)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ module MCP
|
|||
title: title_value,
|
||||
description: description_value,
|
||||
inputSchema: input_schema_value.to_h,
|
||||
}
|
||||
}.compact
|
||||
result[:annotations] = annotations_value.to_h if annotations_value
|
||||
result
|
||||
end
|
||||
|
|
|
|||
|
|
@ -771,7 +771,7 @@ module MCP
|
|||
assert_equal Configuration::DEFAULT_PROTOCOL_VERSION, response[:result][:protocolVersion]
|
||||
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")
|
||||
request = {
|
||||
jsonrpc: "2.0",
|
||||
|
|
@ -780,7 +780,7 @@ module MCP
|
|||
}
|
||||
|
||||
response = server.handle(request)
|
||||
assert_nil response[:result][:serverInfo][:title]
|
||||
refute response[:result][:serverInfo].key?(:title)
|
||||
end
|
||||
|
||||
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)
|
||||
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
|
||||
tool = TestTool
|
||||
expected_annotations = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue