Merge pull request #86 from alexandru-calinoiu/account-for-missing-arguments
Account for missing arguments
This commit is contained in:
commit
4f9bc6e316
2 changed files with 24 additions and 1 deletions
|
|
@ -233,7 +233,7 @@ module MCP
|
|||
raise RequestHandlerError.new("Tool not found #{tool_name}", request, error_type: :tool_not_found)
|
||||
end
|
||||
|
||||
arguments = request[:arguments]
|
||||
arguments = request[:arguments] || {}
|
||||
add_instrumentation_data(tool_name:)
|
||||
|
||||
if tool.input_schema&.missing_required_arguments?(arguments)
|
||||
|
|
|
|||
|
|
@ -829,6 +829,29 @@ module MCP
|
|||
assert_equal custom_version, response[:result][:protocolVersion]
|
||||
end
|
||||
|
||||
test "tools/call handles missing arguments field" do
|
||||
server = Server.new(
|
||||
tools: [TestTool],
|
||||
configuration: Configuration.new(validate_tool_call_arguments: true),
|
||||
)
|
||||
|
||||
response = server.handle(
|
||||
{
|
||||
jsonrpc: "2.0",
|
||||
id: 1,
|
||||
method: "tools/call",
|
||||
params: {
|
||||
name: "test_tool",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
assert_equal "2.0", response[:jsonrpc]
|
||||
assert_equal 1, response[:id]
|
||||
assert_equal(-32603, response[:error][:code])
|
||||
assert_includes response[:error][:data], "Missing required arguments"
|
||||
end
|
||||
|
||||
test "tools/call validates arguments against input schema when validate_tool_call_arguments is true" do
|
||||
server = Server.new(
|
||||
tools: [TestTool],
|
||||
|
|
|
|||
Loading…
Reference in a new issue