Skip to content

Commit 337631f

Browse files
committed
Update ToolTest to use kwargs in example tool call methods
1 parent d309fc9 commit 337631f

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

test/model_context_protocol/tool_test.rb

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestTool < Tool
1818
)
1919

2020
class << self
21-
def call(message, server_context: nil)
21+
def call(message:, server_context: nil)
2222
Tool::Response.new([{ type: "text", content: "OK" }])
2323
end
2424
end
@@ -43,7 +43,7 @@ def call(message, server_context: nil)
4343

4444
test "#call invokes the tool block and returns the response" do
4545
tool = TestTool
46-
response = tool.call("test")
46+
response = tool.call(message: "test")
4747
assert_equal response.content, [{ type: "text", content: "OK" }]
4848
assert_equal response.is_error, false
4949
end
@@ -210,26 +210,19 @@ class TypedTestTool < Tool
210210
tool_name "test_tool"
211211
description "a test tool for testing"
212212
input_schema({ properties: { message: { type: "string" } }, required: ["message"] })
213-
annotations(
214-
title: "Test Tool",
215-
read_only_hint: true,
216-
destructive_hint: false,
217-
idempotent_hint: true,
218-
open_world_hint: false,
219-
)
220213

221214
class << self
222215
extend T::Sig
223216

224217
sig { params(message: String, server_context: T.nilable(T.untyped)).returns(Tool::Response) }
225-
def call(message, server_context: nil)
218+
def call(message:, server_context: nil)
226219
Tool::Response.new([{ type: "text", content: "OK" }])
227220
end
228221
end
229222
end
230223

231224
tool = TypedTestTool
232-
response = tool.call("test")
225+
response = tool.call(message: "test")
233226
assert_equal response.content, [{ type: "text", content: "OK" }]
234227
assert_equal response.is_error, false
235228
end

0 commit comments

Comments
 (0)