Fix: Disallow $ref in tool input schemas

This commit is contained in:
Tyler Rowsell 2025-06-09 13:32:20 -04:00
commit 8dee60cfc2
No known key found for this signature in database
GPG key ID: 0B7F267BCD08BF19
2 changed files with 27 additions and 1 deletions

View file

@ -61,6 +61,18 @@ module MCP
end
end
end
test "rejects schemas with $ref references" do
assert_raises(ArgumentError) do
InputSchema.new(properties: { foo: { "$ref" => "#/definitions/bar" } }, required: [:foo])
end
end
test "rejects schemas with symbol $ref references" do
assert_raises(ArgumentError) do
InputSchema.new(properties: { foo: { :$ref => "#/definitions/bar" } }, required: [:foo])
end
end
end
end
end

View file

@ -249,7 +249,7 @@ module MCP
properties: {
foo: { "$ref" => "#/definitions/bar" },
},
required: [],
required: ["foo"],
definitions: {
bar: { type: "string" },
},