-
Notifications
You must be signed in to change notification settings - Fork 257
fix(bug): tool params type convert logic #628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi, awesome. Could you please check on the eslint errors before merging? Does it also need addressing via REST API, or is the bug only a problem in the UI? Please see also: #627 |
Hey there, buddy! It's only a bug in the admin web UI, not about the REST API. Moreover, the issue isn't limited to just boolean-type tool input parameters. Apart from array types not being supported at all, when I input a number like 123, the system treats it as a JSON int type. However, in reality, I might intend to pass it as a string "123". Therefore, the changes introduced in #627 don't make much of a difference, as they don't fundamentally resolve the problem. I've already applied the aforementioned patch to my production environment last week, and it's working well. You can feel free to test it. |
Yeah, generally this is better! I'll close my PR. I guess the question is how good this tool testing is supposed to be? |
@reevebarreto could you please take a look at the PR? |
70df652
to
6e0b217
Compare
@crivetimihai looks like it works for basic schemas and basic type coercion. Definitely solid improvement! And how @Cnidarias mentioned, it really depends on how much support this needs to have (nested objects, regex, ...) Lastly @deagon just needs to sign their commit to pass DCO check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Signed-off-by: Guoqiang Ding <[email protected]>
6e0b217
to
239ddba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR enhances the tool testing functionality in the MCP Gateway admin interface by adding support for array input types in the tool testing modal.
Main Features Added:
-
Array Input Support
- Added ability to handle array-type parameters in tool input schemas
- Users can dynamically add/remove array items through the UI
- Each array item gets its own input field with a delete button (×)
- An "Add items" button allows adding more array elements
-
Improved Type Handling
- Better type conversion for arrays based on their item types (number, boolean, string)
- Arrays of numbers are properly converted from strings to numbers
- Arrays of booleans handle checkbox inputs correctly
- Empty arrays are handled gracefully (skipped if empty)
-
Schema Registry
- Added
toolInputSchemaRegistry
to store the tool's input schema - This allows the form submission handler to properly validate and convert values based on the schema
- Added
-
Enhanced Form Processing
- The
runToolTest()
function now uses the schema to properly parse form data - Handles both single values and arrays using
formData.get()
andformData.getAll()
- Respects the schema's type definitions and enum constraints
- Properly handles required vs optional fields
- The
Technical Details:
- The array input container uses flexbox for layout with proper spacing
- Delete buttons are styled in red and positioned to the right of each input
- The code maintains the existing dark mode support and styling consistency
- Input validation and sanitization remain intact with the existing
validateInputName()
function
Use Case:
This enhancement allows tools that accept array parameters (like a list of IDs, multiple search terms, or batch operations) to be properly tested through the admin UI, whereas previously only single-value inputs were supported.
The changes are backward compatible and don't affect tools with non-array parameters.
Closes #620, #622
Using the response json of input schema API to convert params correctly before tool calling.