feat: add opt-in tool output validation
This commit is contained in:
parent
d1e0afa158
commit
407b064140
1 changed files with 245 additions and 2 deletions
|
|
@ -74,6 +74,14 @@ module MCP
|
|||
assert_equal("validate_tool_call_arguments must be a boolean", exception.message)
|
||||
end
|
||||
|
||||
test "raises ArgumentError when validate_tool_call_results is not a boolean value" do
|
||||
config = Configuration.new
|
||||
exception = assert_raises(ArgumentError) do
|
||||
config.validate_tool_call_results = "true"
|
||||
end
|
||||
assert_equal("validate_tool_call_results must be a boolean", exception.message)
|
||||
end
|
||||
|
||||
test "merges protocol version from other configuration" do
|
||||
config1 = Configuration.new(protocol_version: "2025-03-26")
|
||||
config2 = Configuration.new(protocol_version: "2025-06-18")
|
||||
|
|
@ -123,6 +131,40 @@ module MCP
|
|||
refute merged.validate_tool_call_arguments
|
||||
end
|
||||
|
||||
test "defaults validate_tool_call_results to false" do
|
||||
config = Configuration.new
|
||||
refute config.validate_tool_call_results
|
||||
end
|
||||
|
||||
test "can set validate_tool_call_results to true" do
|
||||
config = Configuration.new(validate_tool_call_results: true)
|
||||
assert config.validate_tool_call_results
|
||||
end
|
||||
|
||||
test "validate_tool_call_results? returns false when not set" do
|
||||
config = Configuration.new
|
||||
refute config.validate_tool_call_results?
|
||||
end
|
||||
|
||||
test "validate_tool_call_results? returns true when set" do
|
||||
config = Configuration.new(validate_tool_call_results: true)
|
||||
assert config.validate_tool_call_results?
|
||||
end
|
||||
|
||||
test "merge preserves validate_tool_call_results from other config" do
|
||||
config1 = Configuration.new(validate_tool_call_results: true)
|
||||
config2 = Configuration.new
|
||||
merged = config1.merge(config2)
|
||||
refute merged.validate_tool_call_results?
|
||||
end
|
||||
|
||||
test "merge preserves validate_tool_call_results from self when other set" do
|
||||
config1 = Configuration.new(validate_tool_call_results: true)
|
||||
config2 = Configuration.new
|
||||
merged = config2.merge(config1)
|
||||
assert merged.validate_tool_call_results
|
||||
end
|
||||
|
||||
test "initializes with a default pass-through around_request" do
|
||||
config = Configuration.new
|
||||
called = false
|
||||
|
|
@ -183,5 +225,12 @@ module MCP
|
|||
end
|
||||
assert_equal("validate_tool_call_arguments must be a boolean", exception.message)
|
||||
end
|
||||
|
||||
test "raises ArgumentError when validate_tool_call_results is not a boolean" do
|
||||
exception = assert_raises(ArgumentError) do
|
||||
Configuration.new(validate_tool_call_results: "true")
|
||||
end
|
||||
assert_equal("validate_tool_call_results must be a boolean", exception.message)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue