UNPKG

bc_resource_mcp

Version:

MCP server for Baichuan resource

25 lines (24 loc) 809 B
import { APIServer } from "../api/client.js"; import { createToolHandlers } from "../tools/registery.js"; import { Logger } from "../utils/logger.js"; import { ToolNotFoundError } from "../utils/errors.js"; export class APIServerMCP { apiServer; toolHandlers; constructor(config) { this.apiServer = new APIServer(config); this.toolHandlers = createToolHandlers(this.apiServer); } getAPIServer() { return this.apiServer; } async runTool(toolName, args) { const handler = this.toolHandlers.get(toolName); if (!handler) { Logger.error(`工具未找到: ${toolName}`); throw new ToolNotFoundError(toolName); } Logger.debug(`执行工具: ${toolName}`, args); return handler.runTool(args); } }