Skip to content

Commit 91350be

Browse files
committed
Update with code review suggestions
1 parent 41964a6 commit 91350be

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ class WeatherTool < MCP::Tool
563563
)
564564
end
565565
```
566+
566567
Please note: in this case, you must provide `type: "array"`. The default type
567568
for output schemas is `object`.
568569

lib/mcp/tool/output_schema.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# frozen_string_literal: true
22

3-
require "json"
43
require "json-schema"
54

65
module MCP
@@ -33,19 +32,19 @@ def validate_result(result)
3332

3433
private
3534

36-
def deep_transform_keys(hash, &block)
37-
case hash
35+
def deep_transform_keys(schema, &block)
36+
case schema
3837
when Hash
39-
hash.each_with_object({}) do |(key, value), result|
40-
if key.casecmp?("$ref") || key == :$ref
38+
schema.each_with_object({}) do |(key, value), result|
39+
if key.casecmp?("$ref")
4140
raise ArgumentError, "Invalid JSON Schema: $ref is not allowed in tool output schemas"
4241
end
4342
result[yield(key)] = deep_transform_keys(value, &block)
4443
end
4544
when Array
46-
hash.map { |e| deep_transform_keys(e, &block) }
45+
schema.map { |e| deep_transform_keys(e, &block) }
4746
else
48-
hash
47+
schema
4948
end
5049
end
5150

0 commit comments

Comments
 (0)