Validate ToolCall Args against Schema
(cherry picked from commit eeb287117535dfb43785704171625323f01d5bda)
This commit is contained in:
parent
a601558a21
commit
600c96f66a
1 changed files with 275 additions and 3 deletions
|
|
@ -150,7 +150,7 @@ module MCP
|
|||
report_exception(e, { request: request })
|
||||
if e.is_a?(RequestHandlerError)
|
||||
add_instrumentation_data(error: e.error_type)
|
||||
raise e
|
||||
raise StandardError, e.message
|
||||
end
|
||||
|
||||
add_instrumentation_data(error: :internal_error)
|
||||
|
|
@ -213,6 +213,15 @@ module MCP
|
|||
)
|
||||
end
|
||||
|
||||
if configuration.validate_tool_call_arguments && tool.input_schema
|
||||
begin
|
||||
tool.input_schema.validate_arguments(arguments)
|
||||
rescue Tool::InputSchema::ValidationError => e
|
||||
add_instrumentation_data(error: :invalid_schema)
|
||||
raise RequestHandlerError.new(e.message, request, error_type: :invalid_schema)
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
call_params = tool_call_parameters(tool)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue