Expose server tool annotations on MCP::Client::Tool
Client#tools/#list_tools built Tool objects without an annotations field even though the server includes annotations in every tools/list response. Add the reader and pass the raw hash through, mirroring how output_schema is already handled.
This commit is contained in:
parent
61233ed43b
commit
3591acdfaa
2 changed files with 27 additions and 2 deletions
|
|
@ -33,6 +33,24 @@ module MCP
|
|||
assert_nil(@tool.output_schema)
|
||||
end
|
||||
|
||||
def test_annotations_returns_nil_when_not_provided
|
||||
assert_nil(@tool.annotations)
|
||||
end
|
||||
|
||||
def test_annotations_returns_annotations_when_provided
|
||||
tool_with_annotations = Tool.new(
|
||||
name: "test_tool_with_annotations",
|
||||
description: "A test tool with annotations",
|
||||
input_schema: { "type" => "object" },
|
||||
annotations: { "readOnlyHint" => true, "title" => "Test Tool" },
|
||||
)
|
||||
|
||||
assert_equal(
|
||||
{ "readOnlyHint" => true, "title" => "Test Tool" },
|
||||
tool_with_annotations.annotations,
|
||||
)
|
||||
end
|
||||
|
||||
def test_output_schema_returns_output_schema_when_provided
|
||||
tool_with_output = Tool.new(
|
||||
name: "test_tool_with_output",
|
||||
|
|
@ -53,12 +71,14 @@ module MCP
|
|||
description: "A tool with all parameters",
|
||||
input_schema: { "type" => "object" },
|
||||
output_schema: { "type" => "object", "properties" => { "status" => { "type" => "boolean" } } },
|
||||
annotations: { "readOnlyHint" => true },
|
||||
)
|
||||
|
||||
assert_equal("full_tool", tool.name)
|
||||
assert_equal("A tool with all parameters", tool.description)
|
||||
assert_equal({ "type" => "object" }, tool.input_schema)
|
||||
assert_equal({ "type" => "object", "properties" => { "status" => { "type" => "boolean" } } }, tool.output_schema)
|
||||
assert_equal({ "readOnlyHint" => true }, tool.annotations)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ module MCP
|
|||
"description" => "tool1",
|
||||
"inputSchema" => {},
|
||||
"outputSchema" => { "type" => "object", "properties" => { "result" => { "type" => "string" } } },
|
||||
"annotations" => { "readOnlyHint" => true, "title" => "Tool One" },
|
||||
},
|
||||
{ "name" => "tool2", "description" => "tool2", "inputSchema" => {} },
|
||||
],
|
||||
|
|
@ -103,8 +104,10 @@ module MCP
|
|||
assert_equal(2, tools.size)
|
||||
assert_equal("tool1", tools.first.name)
|
||||
assert_equal({ "type" => "object", "properties" => { "result" => { "type" => "string" } } }, tools.first.output_schema)
|
||||
assert_equal({ "readOnlyHint" => true, "title" => "Tool One" }, tools.first.annotations)
|
||||
assert_equal("tool2", tools.last.name)
|
||||
assert_nil(tools.last.output_schema)
|
||||
assert_nil(tools.last.annotations)
|
||||
end
|
||||
|
||||
def test_tools_returns_empty_array_when_no_tools
|
||||
|
|
|
|||
Loading…
Reference in a new issue