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 @@ -322,7 +322,7 @@ def call_tool(request)
end

arguments = request[:arguments] || {}
add_instrumentation_data(tool_name: tool_name)
add_instrumentation_data(tool_name: tool_name, tool_arguments: arguments)

if tool.input_schema&.missing_required_arguments?(arguments)
add_instrumentation_data(error: :missing_required_arguments)
Expand Down
8 changes: 4 additions & 4 deletions test/mcp/server_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class ServerTest < ActiveSupport::TestCase

response = @server.handle(request)
assert_equal tool_response.to_h, response[:result]
assert_instrumentation_data({ method: "tools/call", tool_name: tool_name })
assert_instrumentation_data({ method: "tools/call", tool_name: tool_name, tool_arguments: tool_args })
end

test "#handle tools/call returns error response with isError true if required tool arguments are missing" do
Expand Down Expand Up @@ -320,7 +320,7 @@ class ServerTest < ActiveSupport::TestCase
raw_response = @server.handle_json(request)
response = JSON.parse(raw_response, symbolize_names: true) if raw_response
assert_equal tool_response.to_h, response[:result] if response
assert_instrumentation_data({ method: "tools/call", tool_name: tool_name })
assert_instrumentation_data({ method: "tools/call", tool_name: tool_name, tool_arguments: { arg: "value" } })
end

test "#handle_json tools/call executes tool and returns result, when the tool is typed with Sorbet" do
Expand Down Expand Up @@ -389,7 +389,7 @@ def call(message:, server_context: nil)
assert response[:result][:isError]
assert_equal "text", response[:result][:content][0][:type]
assert_match(/Internal error calling tool tool_that_raises: /, response[:result][:content][0][:text])
assert_instrumentation_data({ method: "tools/call", tool_name: "tool_that_raises" })
assert_instrumentation_data({ method: "tools/call", tool_name: "tool_that_raises", tool_arguments: { message: "test" } })
end

test "registers tools with the same class name in different namespaces" do
Expand Down Expand Up @@ -446,7 +446,7 @@ class Example < Tool
assert response[:result][:isError]
assert_equal "text", response[:result][:content][0][:type]
assert_match(/Internal error calling tool tool_that_raises: /, response[:result][:content][0][:text])
assert_instrumentation_data({ method: "tools/call", tool_name: "tool_that_raises" })
assert_instrumentation_data({ method: "tools/call", tool_name: "tool_that_raises", tool_arguments: { message: "test" } })
end

test "#handle tools/call returns error response with isError true if input_schema raises an error during validation" do
Expand Down