Skip to content

Conversation

deagon
Copy link
Contributor

@deagon deagon commented Jul 29, 2025

Closes #620, #622

Using the response json of input schema API to convert params correctly before tool calling.

@deagon deagon requested a review from crivetimihai as a code owner July 29, 2025 02:46
@deagon
Copy link
Contributor Author

deagon commented Jul 29, 2025

@crivetimihai
Copy link
Member

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

@deagon
Copy link
Contributor Author

deagon commented Jul 29, 2025

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

@crivetimihai

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.

@Cnidarias
Copy link
Contributor

Yeah, generally this is better! I'll close my PR.

I guess the question is how good this tool testing is supposed to be?
It still doesn't support a lot of the JSON schema specs (e.g. nested things, objects, enums, regex validation, probably more)

@crivetimihai
Copy link
Member

@reevebarreto could you please take a look at the PR?

@deagon deagon force-pushed the fix/tool-params-convert branch from 70df652 to 6e0b217 Compare July 29, 2025 08:16
@reevebarreto
Copy link
Collaborator

@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.

Copy link
Collaborator

@reevebarreto reevebarreto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@deagon deagon force-pushed the fix/tool-params-convert branch from 6e0b217 to 239ddba Compare July 29, 2025 09:20
Copy link
Member

@crivetimihai crivetimihai left a 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:

  1. 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
  2. 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)
  3. 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
  4. Enhanced Form Processing

    • The runToolTest() function now uses the schema to properly parse form data
    • Handles both single values and arrays using formData.get() and formData.getAll()
    • Respects the schema's type definitions and enum constraints
    • Properly handles required vs optional fields

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.

@crivetimihai crivetimihai merged commit ed6a0af into IBM:main Jul 29, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Test tool UI passes array inputs as strings
4 participants