初始化提交
This commit is contained in:
commit
887c1f449e
963 files changed
+166869
No files matched your search
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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<McpServer[]> {
|
||||
return apiGet<McpServer[]>(
|
||||
"/tools/mcp-servers",
|
||||
status ? { status } : undefined,
|
||||
);
|
||||
}
|
||||
|
||||
/** 注册 MCP server */
|
||||
export function registerMcpServer(
|
||||
body: CreateMcpServerRequest,
|
||||
): Promise<McpServer> {
|
||||
return apiPost<McpServer>("/tools/mcp-servers", body);
|
||||
}
|
||||
|
||||
/** 更新 MCP server */
|
||||
export function updateMcpServer(
|
||||
serverId: string,
|
||||
body: Partial<CreateMcpServerRequest>,
|
||||
): Promise<McpServer> {
|
||||
return apiPatch<McpServer>(`/tools/mcp-servers/${serverId}`, body);
|
||||
}
|
||||
|
||||
/** 删除 MCP server */
|
||||
export function deleteMcpServer(serverId: string): Promise<void> {
|
||||
return apiDelete<void>(`/tools/mcp-servers/${serverId}`);
|
||||
}
|
||||
|
||||
/** 查询 MCP server 进程状态 */
|
||||
export function getMcpServerStatus(
|
||||
serverId: string,
|
||||
): Promise<McpServerProcessStatus> {
|
||||
return apiGet<McpServerProcessStatus>(
|
||||
`/tools/mcp-servers/${serverId}/status`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 启动 stdio MCP server 子进程 */
|
||||
export function startMcpServer(
|
||||
serverId: string,
|
||||
): Promise<McpServerProcessStatus> {
|
||||
return apiPost<McpServerProcessStatus>(
|
||||
`/tools/mcp-servers/${serverId}/start`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 停止 stdio MCP server 子进程 */
|
||||
export function stopMcpServer(
|
||||
serverId: string,
|
||||
): Promise<McpServerProcessStatus> {
|
||||
return apiPost<McpServerProcessStatus>(`/tools/mcp-servers/${serverId}/stop`);
|
||||
}
|
||||
|
||||
/** 重启 stdio MCP server 子进程 */
|
||||
export function restartMcpServer(
|
||||
serverId: string,
|
||||
): Promise<McpServerProcessStatus> {
|
||||
return apiPost<McpServerProcessStatus>(
|
||||
`/tools/mcp-servers/${serverId}/restart`,
|
||||
);
|
||||
}
|
||||
|
||||
/** 刷新 MCP server 工具清单(重新拉取并注册到运行时) */
|
||||
export function refreshMcpServerTools(serverId: string): Promise<McpServer> {
|
||||
return apiPost<McpServer>(`/tools/mcp-servers/${serverId}/refresh`);
|
||||
}
|
||||
Reference in new issue
Block a user