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

Function listResources

src/commands/mcp.ts:434–461  ·  view source on GitHub ↗

* 列出资源

(client: MCPClient, sessionId: string)

Source from the content-addressed store, hash-verified

432 * 列出资源
433 */
434async function listResources(client: MCPClient, sessionId: string): Promise<void> {
435 try {
436 const resources = await client.listResources(sessionId);
437
438 if (resources.length === 0) {
439 console.log(chalk.yellow('📭 没有可用的资源'));
440 return;
441 }
442
443 console.log(chalk.blue(`📁 可用资源 (${resources.length}):`));
444 resources.forEach((resource, index) => {
445 console.log(chalk.green(`${index + 1}. ${resource.name}`));
446 console.log(chalk.gray(` URI: ${resource.uri}`));
447 if (resource.description) {
448 console.log(chalk.gray(` 描述: ${resource.description}`));
449 }
450 if (resource.mimeType) {
451 console.log(chalk.gray(` 类型: ${resource.mimeType}`));
452 }
453 console.log('');
454 });
455 } catch (error) {
456 console.error(
457 chalk.red('❌ 获取资源列表失败:'),
458 error instanceof Error ? error.message : error
459 );
460 }
461}
462
463/**
464 * 读取资源

Callers 1

runInteractiveClientFunction · 0.85

Calls 3

listResourcesMethod · 0.80
logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected