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

Method loadServerResources

src/agent/MCPComponent.ts:191–211  ·  view source on GitHub ↗

* 加载服务器资源

(sessionId: string)

Source from the content-addressed store, hash-verified

189 * 加载服务器资源
190 */
191 async loadServerResources(sessionId: string): Promise<void> {
192 if (!this.client) return;
193
194 try {
195 const resources = await this.client.listResources(sessionId);
196 const session = this.getSessionById(sessionId);
197
198 if (session) {
199 const resourcesWithServer = resources.map(resource => ({
200 ...resource,
201 serverId: sessionId,
202 serverName: session.config.name,
203 }));
204
205 this.resources.set(sessionId, resourcesWithServer);
206 this.log(`加载了 ${resources.length} 个资源从 ${session.config.name}`);
207 }
208 } catch (error) {
209 this.log(`加载服务器资源失败: ${error}`);
210 }
211 }
212
213 /**
214 * 加载服务器工具

Callers 1

connectToServerMethod · 0.95

Calls 4

getSessionByIdMethod · 0.95
logMethod · 0.95
listResourcesMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected