Support Sorbet typed tools
This commit is contained in:
parent
87cd467c58
commit
84e83841b0
1 changed files with 92 additions and 1 deletions
|
|
@ -1,3 +1,4 @@
|
|||
# typed: true
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
|
|
@ -203,5 +204,34 @@ module ModelContextProtocol
|
|||
tool.annotations(title: "Updated")
|
||||
assert_equal tool.annotations_value.title, "Updated"
|
||||
end
|
||||
|
||||
test "#call with Sorbet typed tools invokes the tool block and returns the response" do
|
||||
class TypedTestTool < Tool
|
||||
tool_name "test_tool"
|
||||
description "a test tool for testing"
|
||||
input_schema({ properties: { message: { type: "string" } }, required: ["message"] })
|
||||
annotations(
|
||||
title: "Test Tool",
|
||||
read_only_hint: true,
|
||||
destructive_hint: false,
|
||||
idempotent_hint: true,
|
||||
open_world_hint: false,
|
||||
)
|
||||
|
||||
class << self
|
||||
extend T::Sig
|
||||
|
||||
sig { params(message: String, server_context: T.nilable(T.untyped)).returns(Tool::Response) }
|
||||
def call(message, server_context: nil)
|
||||
Tool::Response.new([{ type: "text", content: "OK" }])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
tool = TypedTestTool
|
||||
response = tool.call("test")
|
||||
assert_equal response.content, [{ type: "text", content: "OK" }]
|
||||
assert_equal response.is_error, false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue