
书名:《Agent Runtime 工程化:从工具调用循环到可恢复执行系统》
作者:陈堂会
章节:第六章 MCP 与 Provider 抽象 / 6.3 把 MCP 工具接入 Registry
电子版系列:查看完整目录
第六章 MCP 与 Provider 抽象:6.3 把 MCP 工具接入 Registry
一个实际做法是把 MCP 工具包装成本地统一 ToolDefinition:
function fromMcpTool(serverId: string, tool: McpTool): ToolDefinition {
return {
name: `mcp.${serverId}.${tool.name}`,
title: tool.title ?? tool.name,
description: tool.description ?? "",
version: "mcp-dynamic",
inputSchema: tool.inputSchema,
riskLevel: classifyMcpRisk(serverId, tool),
sideEffects: ["external"],
timeoutMs: 30_000,
outputPolicy: { maxCharsForModel: 12_000, : },
: (input, ctx) => {
ctx..(serverId, tool., input);
},
};
}

