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

Method loadServerTools

src/agent/MCPComponent.ts:216–236  ·  view source on GitHub ↗

* 加载服务器工具

(sessionId: string)

Source from the content-addressed store, hash-verified

214 * 加载服务器工具
215 */
216 async loadServerTools(sessionId: string): Promise<void> {
217 if (!this.client) return;
218
219 try {
220 const tools = await this.client.listTools(sessionId);
221 const session = this.getSessionById(sessionId);
222
223 if (session) {
224 const toolsWithServer = tools.map(tool => ({
225 ...tool,
226 serverId: sessionId,
227 serverName: session.config.name,
228 }));
229
230 this.tools.set(sessionId, toolsWithServer);
231 this.log(`加载了 ${tools.length} 个工具从 ${session.config.name}`);
232 }
233 } catch (error) {
234 this.log(`加载服务器工具失败: ${error}`);
235 }
236 }
237
238 /**
239 * 获取所有可用资源

Callers 1

connectToServerMethod · 0.95

Calls 4

getSessionByIdMethod · 0.95
logMethod · 0.95
listToolsMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected