fixes input schema validation for schemas without required fields
This commit is contained in:
parent
b94a938d95
commit
271ccb43d0
2 changed files with 9 additions and 1 deletions
|
|
@ -16,7 +16,9 @@ module MCP
|
|||
end
|
||||
|
||||
def to_h
|
||||
{ type: "object", properties:, required: }
|
||||
{ type: "object", properties: }.tap do |hsh|
|
||||
hsh[:required] = required if required.any?
|
||||
end
|
||||
end
|
||||
|
||||
def missing_required_arguments?(arguments)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ module MCP
|
|||
end
|
||||
end
|
||||
|
||||
test "schema without required arguments is valid" do
|
||||
assert_nothing_raised do
|
||||
InputSchema.new(properties: { foo: { type: "string" } })
|
||||
end
|
||||
end
|
||||
|
||||
test "validate arguments with valid data" do
|
||||
schema = InputSchema.new(properties: { foo: { type: "string" } }, required: [:foo])
|
||||
assert_nil(schema.validate_arguments({ foo: "bar" }))
|
||||
|
|
|
|||
Loading…
Reference in a new issue