Skip to content

Commit 7e33e76

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

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ DEPENDENCIES
119119
model_context_protocol!
120120
rake (~> 13.0)
121121
rubocop-shopify
122-
sorbet-static-and-runtime
122+
sorbet-static-and-runtime (~> 0.5.11000)
123123

124124
BUNDLED WITH
125125
2.5.9

model_context_protocol.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
2929

3030
spec.add_dependency("json_rpc_handler", "~> 0.1")
3131
spec.add_development_dependency("activesupport")
32-
spec.add_development_dependency("sorbet-static-and-runtime")
32+
spec.add_development_dependency("sorbet-static-and-runtime", "~> 0.5.11000")
3333
end

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)