Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mcp/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def server_info
name:,
title:,
version:,
}
}.compact
end

def init(request)
Expand Down
2 changes: 1 addition & 1 deletion lib/mcp/tool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def to_h
title: title_value,
description: description_value,
inputSchema: input_schema_value.to_h,
}
}.compact
result[:annotations] = annotations_value.to_h if annotations_value
result
end
Expand Down
4 changes: 2 additions & 2 deletions test/mcp/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ def call(message:, server_context: nil)
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",
Expand All @@ -780,7 +780,7 @@ def call(message:, server_context: nil)
}

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
Expand Down
8 changes: 8 additions & 0 deletions test/mcp/tool_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ def call(message:, server_context: nil)
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 = {
Expand Down