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

Function runInteractiveClient

src/commands/mcp.ts:356–401  ·  view source on GitHub ↗

* 运行交互式客户端

(client: MCPClient, sessionId: string)

Source from the content-addressed store, hash-verified

354 * 运行交互式客户端
355 */
356async function runInteractiveClient(client: MCPClient, sessionId: string): Promise<void> {
357 console.log(chalk.blue('\n🎮 进入交互式模式 (输入 "exit" 退出)'));
358 console.log('');
359
360 while (true) {
361 try {
362 const { action } = await inquirer.prompt([
363 {
364 type: 'list',
365 name: 'action',
366 message: '选择操作:',
367 choices: [
368 { name: '📋 列出资源', value: 'list-resources' },
369 { name: '📖 读取资源', value: 'read-resource' },
370 { name: '🔧 列出工具', value: 'list-tools' },
371 { name: '⚡ 调用工具', value: 'call-tool' },
372 { name: '🚪 退出', value: 'exit' },
373 ],
374 },
375 ]);
376
377 if (action === 'exit') {
378 break;
379 }
380
381 switch (action) {
382 case 'list-resources':
383 await listResources(client, sessionId);
384 break;
385 case 'read-resource':
386 await readResource(client, sessionId);
387 break;
388 case 'list-tools':
389 await listTools(client, sessionId);
390 break;
391 case 'call-tool':
392 await callTool(client, sessionId);
393 break;
394 }
395
396 console.log('');
397 } catch (error) {
398 console.error(chalk.red('❌ 操作失败:'), error instanceof Error ? error.message : error);
399 }
400 }
401}
402
403/**
404 * 显示服务器信息

Callers 1

mcpCommandFunction · 0.85

Calls 6

listResourcesFunction · 0.85
readResourceFunction · 0.85
listToolsFunction · 0.85
callToolFunction · 0.85
logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected