Fix missing output_schema argument in 'define_tool' API
This commit is contained in:
parent
ba79d53c97
commit
f6c95a0c97
2 changed files with 9 additions and 4 deletions
|
|
@ -145,8 +145,8 @@ module MCP
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def define_tool(name: nil, title: nil, description: nil, input_schema: nil, annotations: nil, meta: nil, &block)
|
def define_tool(name: nil, title: nil, description: nil, input_schema: nil, output_schema: nil, annotations: nil, meta: nil, &block)
|
||||||
tool = Tool.define(name: name, title: title, description: description, input_schema: input_schema, annotations: annotations, meta: meta, &block)
|
tool = Tool.define(name: name, title: title, description: description, input_schema: input_schema, output_schema: output_schema, annotations: annotations, meta: meta, &block)
|
||||||
tool_name = tool.name_value
|
tool_name = tool.name_value
|
||||||
|
|
||||||
@tool_names << tool_name
|
@tool_names << tool_name
|
||||||
|
|
|
||||||
|
|
@ -1127,11 +1127,16 @@ module MCP
|
||||||
name: "defined_tool",
|
name: "defined_tool",
|
||||||
description: "Defined tool",
|
description: "Defined tool",
|
||||||
input_schema: { type: "object", properties: { message: { type: "string" } }, required: ["message"] },
|
input_schema: { type: "object", properties: { message: { type: "string" } }, required: ["message"] },
|
||||||
|
output_schema: { type: "object", properties: { response: { type: "string" } }, required: ["response"] },
|
||||||
meta: { foo: "bar" },
|
meta: { foo: "bar" },
|
||||||
) do |message:|
|
) do |message:|
|
||||||
Tool::Response.new(message)
|
Tool::Response.new({ "response" => message })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
stored_tool = @server.instance_variable_get(:@tools)["defined_tool"]
|
||||||
|
assert_not_nil(stored_tool)
|
||||||
|
assert_equal(MCP::Tool::OutputSchema.new({ type: "object", properties: { response: { type: "string" } }, required: ["response"] }), stored_tool.output_schema)
|
||||||
|
|
||||||
response = @server.handle({
|
response = @server.handle({
|
||||||
jsonrpc: "2.0",
|
jsonrpc: "2.0",
|
||||||
method: "tools/call",
|
method: "tools/call",
|
||||||
|
|
@ -1139,7 +1144,7 @@ module MCP
|
||||||
id: 1,
|
id: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert_equal({ content: "success", isError: false }, response[:result])
|
assert_equal({ content: { "response" => "success" }, isError: false }, response[:result])
|
||||||
end
|
end
|
||||||
|
|
||||||
test "#define_tool adds a tool with duplicated tool name to the server" do
|
test "#define_tool adds a tool with duplicated tool name to the server" do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue