MCPcopy Create free account
hub / github.com/echoVic/blade-code / connectToServer

Method connectToServer

src/agent/MCPComponent.ts:163–176  ·  view source on GitHub ↗

* 连接到单个服务器

(config: MCPConnectionConfig)

Source from the content-addressed store, hash-verified

161 * 连接到单个服务器
162 */
163 async connectToServer(config: MCPConnectionConfig): Promise<MCPSession> {
164 if (!this.client) {
165 throw new Error('MCP 客户端未初始化');
166 }
167
168 this.log(`连接到 MCP 服务器: ${config.name}`);
169 const session = await this.client.connect(config);
170
171 // 获取服务器资源和工具
172 await this.loadServerResources(session.id);
173 await this.loadServerTools(session.id);
174
175 return session;
176 }
177
178 /**
179 * 断开服务器连接

Callers 1

connectToServersMethod · 0.95

Calls 4

logMethod · 0.95
loadServerResourcesMethod · 0.95
loadServerToolsMethod · 0.95
connectMethod · 0.80

Tested by

no test coverage detected