diff --git a/dat-gateway/src/main/resources/static/tester.html b/dat-gateway/src/main/resources/static/tester.html index fbb6eade..fa469e2f 100644 --- a/dat-gateway/src/main/resources/static/tester.html +++ b/dat-gateway/src/main/resources/static/tester.html @@ -513,8 +513,24 @@ } } - async function executeRawCall(name, payload) { - const reqPayload = { jsonrpc: "2.0", method: "tools/call", params: { name: name, arguments: payload }, id: Date.now() }; +async function executeRawCall(name, payload) { + // Auto-coerce payload types based on schema to prevent JSON validation errors + const tool = allTools.find(t => t.name === name); + if (tool && tool.inputSchema && tool.inputSchema.properties) { + const props = tool.inputSchema.properties; + for (const key in payload) { + if (props[key]) { + const type = props[key].type; + if ((type === 'integer' || type === 'number') && typeof payload[key] === 'string') { + const parsed = Number(payload[key]); + if (!isNaN(parsed)) payload[key] = parsed; + } else if (type === 'boolean' && typeof payload[key] === 'string') { + payload[key] = payload[key].toLowerCase() === 'true'; + } + } + } + } + const reqPayload = { jsonrpc: "2.0", method: "tools/call", params: { name: name, arguments: payload }, id: Date.now() }; const startTime = Date.now(); try { const response = await fetch('/mcp/api/v1/tools/call', {