fix(MCPService): Tool call failure caused by incorrect tool parameters

This commit is contained in:
karl
2025-04-27 18:06:11 +08:00
committed by 亢奋猫
parent 2e0d315ce4
commit dfd957434c
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -394,6 +394,13 @@ class McpService {
): Promise<MCPCallToolResponse> {
try {
Logger.info('[MCP] Calling:', server.name, name, args)
if (typeof args === 'string') {
try {
args = JSON.parse(args)
} catch (e) {
Logger.error('[MCP] args parse error', args)
}
}
const client = await this.initClient(server)
const result = await client.callTool({ name, arguments: args }, undefined, {
timeout: server.timeout ? server.timeout * 1000 : 60000 // Default timeout of 1 minute