Currently, the shared toolService.mjs contains a hardcoded list of tool names that require their arguments to be passed as a single object to the handler function. This is brittle and not scalable.
This ticket is to refactor the toolService to determine the argument passing strategy dynamically from the OpenAPI specification for each tool. This will be achieved by introducing a custom OpenAPI extension field, x-pass-as-object.
Acceptance Criteria
- A custom field,
x-pass-as-object: true, is added to the OpenAPI specification for operations whose handlers expect a single arguments object.
- The
initializeToolMapping function in ai/mcp/server/toolService.mjs is updated to read this flag and store it with the tool's definition.
- The
callTool function is updated to use this flag to determine whether to pass arguments as a single object or as positional arguments.
- The hardcoded array of tool names is removed from
callTool.
- All tool calls continue to function correctly for both MCP servers.
Currently, the shared
toolService.mjscontains a hardcoded list of tool names that require their arguments to be passed as a single object to the handler function. This is brittle and not scalable.This ticket is to refactor the
toolServiceto determine the argument passing strategy dynamically from the OpenAPI specification for each tool. This will be achieved by introducing a custom OpenAPI extension field,x-pass-as-object.Acceptance Criteria
x-pass-as-object: true, is added to the OpenAPI specification for operations whose handlers expect a single arguments object.initializeToolMappingfunction inai/mcp/server/toolService.mjsis updated to read this flag and store it with the tool's definition.callToolfunction is updated to use this flag to determine whether to pass arguments as a single object or as positional arguments.callTool.