Skip to content
Merged
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 @@ -233,7 +233,7 @@ def call_tool(request)
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)
Expand Down
23 changes: 23 additions & 0 deletions test/mcp/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,29 @@ def call(message:, server_context: nil)
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],
Expand Down