fix: 修复 http 输出适配问题

This commit is contained in:
sean
2025-06-12 08:05:34 +08:00
parent 0ff1abecfb
commit a9796806cf

View File

@ -516,19 +516,12 @@ class MCPStreamableHttpCommand {
const result = await cli.execute(toolName.replace('promptx_', ''), cliArgs, true);
this.log(`✅ CLI执行完成: ${toolName}`);
// 返回新 MCP SDK 格式的响应
return {
content: [
{
type: 'text',
text: typeof result === 'string' ? result : JSON.stringify(result, null, 2)
}
]
};
// 使用输出适配器转换为MCP响应格式与stdio模式保持一致
return this.outputAdapter.convertToMCPFormat(result);
} catch (error) {
this.log(`❌ 工具调用失败: ${toolName} - ${error.message}`);
throw error; // 让 MCP SDK 处理错误
return this.outputAdapter.handleError(error);
}
}