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

Method readResource

src/agent/MCPComponent.ts:263–281  ·  view source on GitHub ↗

* 读取资源内容

(uri: string)

Source from the content-addressed store, hash-verified

261 * 读取资源内容
262 */
263 async readResource(uri: string): Promise<string | null> {
264 if (!this.client) return null;
265
266 // 查找包含该资源的服务器
267 for (const [sessionId, resources] of this.resources.entries()) {
268 const resource = resources.find(r => r.uri === uri);
269 if (resource) {
270 try {
271 const content = await this.client.readResource(sessionId, uri);
272 return content.text || null;
273 } catch (error) {
274 this.log(`读取资源失败 ${uri}: ${error}`);
275 return null;
276 }
277 }
278 }
279
280 return null;
281 }
282
283 /**
284 * 调用 MCP 工具

Callers

nothing calls this directly

Calls 1

logMethod · 0.95

Tested by

no test coverage detected