( context: CommandContext, showDescriptions: boolean, showSchema: boolean, showTips: boolean = false, )
| 31 | const RESET_COLOR = '\u001b[0m'; |
| 32 | |
| 33 | const getMcpStatus = async ( |
| 34 | context: CommandContext, |
| 35 | showDescriptions: boolean, |
| 36 | showSchema: boolean, |
| 37 | showTips: boolean = false, |
| 38 | ): Promise<SlashCommandActionReturn> => { |
| 39 | const { config } = context.services; |
| 40 | if (!config) { |
| 41 | return { |
| 42 | type: 'message', |
| 43 | messageType: 'error', |
| 44 | content: 'Config not loaded.', |
| 45 | }; |
| 46 | } |
| 47 | |
| 48 | const toolRegistry = await config.getToolRegistry(); |
| 49 | if (!toolRegistry) { |
| 50 | return { |
| 51 | type: 'message', |
| 52 | messageType: 'error', |
| 53 | content: 'Could not retrieve tool registry.', |
| 54 | }; |
| 55 | } |
| 56 | |
| 57 | const mcpServers = config.getMcpServers() || {}; |
| 58 | const serverNames = Object.keys(mcpServers); |
| 59 | const blockedMcpServers = config.getBlockedMcpServers() || []; |
| 60 | |
| 61 | if (serverNames.length === 0 && blockedMcpServers.length === 0) { |
| 62 | const docsUrl = 'https://goo.gle/anus-cli-docs-mcp'; |
| 63 | return { |
| 64 | type: 'message', |
| 65 | messageType: 'info', |
| 66 | content: `No MCP servers configured. Please view MCP documentation in your browser: ${docsUrl} or use the cli /docs command`, |
| 67 | }; |
| 68 | } |
| 69 | |
| 70 | // Check if any servers are still connecting |
| 71 | const connectingServers = serverNames.filter( |
| 72 | (name) => getMCPServerStatus(name) === MCPServerStatus.CONNECTING, |
| 73 | ); |
| 74 | const discoveryState = getMCPDiscoveryState(); |
| 75 | |
| 76 | let message = ''; |
| 77 | |
| 78 | // Add overall discovery status message if needed |
| 79 | if ( |
| 80 | discoveryState === MCPDiscoveryState.IN_PROGRESS || |
| 81 | connectingServers.length > 0 |
| 82 | ) { |
| 83 | message += `${COLOR_YELLOW}⏳ MCP servers are starting up (${connectingServers.length} initializing)...${RESET_COLOR}\n`; |
| 84 | message += `${COLOR_CYAN}Note: First startup may take longer. Tool availability will update automatically.${RESET_COLOR}\n\n`; |
| 85 | } |
| 86 | |
| 87 | message += 'Configured MCP servers:\n\n'; |
| 88 | |
| 89 | const allTools = toolRegistry.getAllTools(); |
| 90 | for (const serverName of serverNames) { |
no test coverage detected