web_search 从内置工具改为 MCP 服务:新增 server/mcp.js 极简 MCP 客户端(JSON-RPC over HTTP,SSE 帧容错解析),config.yml 新增 mcp_servers(可多个,每项 name?/url/headers,authorization 即普通 header),启动时 tools/list 发现工具转 OpenAI function 格式,随 system prompt 与内置工具一起发给模型(内置 definitions.json 移除 web_search,剩 12 个);executeTool 未命中内置时按注册表经 tools/call 转发,工具重名加服务名前缀;旧 web_search.{url,authorization} 配置自动迁移为一条 mcp_servers;单服务发现失败仅告警不阻塞启动;README/example 配置同步
This commit is contained in:
@@ -4,6 +4,7 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { buildMessages, callModel } = require('./llm');
|
||||
const { executeTool, resolveInTask } = require('./tools/executor');
|
||||
const mcp = require('./mcp');
|
||||
|
||||
const TOOL_DEFINITIONS = require('./tools/definitions.json');
|
||||
|
||||
@@ -303,7 +304,8 @@ async function runLoopInner(sessionId, run) {
|
||||
session.history = loadHistory(sessionId);
|
||||
for (const m of session.history) if (m.id > lastIncludedId) lastIncludedId = m.id;
|
||||
const messages = buildMessages(session);
|
||||
const tools = TOOL_DEFINITIONS;
|
||||
// 内置工具 + 启动时发现的 MCP 工具,一起随 system prompt 发给模型
|
||||
const tools = TOOL_DEFINITIONS.concat(mcp.toolDefinitions());
|
||||
|
||||
let result = null;
|
||||
let lastErr = null;
|
||||
|
||||
Reference in New Issue
Block a user