/** * MCP server API(百工枢,/tools/mcp-servers,skills-design §5)。 * * 支持两种传输协议:streamable-http / stdio。 * stdio 模式通过 start / stop / restart 控制子进程生命周期。 */ import { apiDelete, apiGet, apiPost, apiPatch } from "./client"; import type { CreateMcpServerRequest, McpServer, McpServerProcessStatus, } from "@/types/api"; /** 列举 MCP server */ export function listMcpServers(status?: string): Promise { return apiGet( "/tools/mcp-servers", status ? { status } : undefined, ); } /** 注册 MCP server */ export function registerMcpServer( body: CreateMcpServerRequest, ): Promise { return apiPost("/tools/mcp-servers", body); } /** 更新 MCP server */ export function updateMcpServer( serverId: string, body: Partial, ): Promise { return apiPatch(`/tools/mcp-servers/${serverId}`, body); } /** 删除 MCP server */ export function deleteMcpServer(serverId: string): Promise { return apiDelete(`/tools/mcp-servers/${serverId}`); } /** 查询 MCP server 进程状态 */ export function getMcpServerStatus( serverId: string, ): Promise { return apiGet( `/tools/mcp-servers/${serverId}/status`, ); } /** 启动 stdio MCP server 子进程 */ export function startMcpServer( serverId: string, ): Promise { return apiPost( `/tools/mcp-servers/${serverId}/start`, ); } /** 停止 stdio MCP server 子进程 */ export function stopMcpServer( serverId: string, ): Promise { return apiPost(`/tools/mcp-servers/${serverId}/stop`); } /** 重启 stdio MCP server 子进程 */ export function restartMcpServer( serverId: string, ): Promise { return apiPost( `/tools/mcp-servers/${serverId}/restart`, ); } /** 刷新 MCP server 工具清单(重新拉取并注册到运行时) */ export function refreshMcpServerTools(serverId: string): Promise { return apiPost(`/tools/mcp-servers/${serverId}/refresh`); }