MCPcopy Create free account
hub / github.com/anus-dev/ANUS / getMcpStatus

Function getMcpStatus

packages/cli/src/ui/commands/mcpCommand.ts:33–312  ·  view source on GitHub ↗
(
  context: CommandContext,
  showDescriptions: boolean,
  showSchema: boolean,
  showTips: boolean = false,
)

Source from the content-addressed store, hash-verified

31const RESET_COLOR = '\u001b[0m';
32
33const 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) {

Callers 1

mcpCommand.tsFile · 0.85

Calls 11

getMCPServerStatusFunction · 0.85
getMCPDiscoveryStateFunction · 0.85
getToolRegistryMethod · 0.80
getMcpServersMethod · 0.80
getBlockedMcpServersMethod · 0.80
getAllToolsMethod · 0.80
getPromptRegistryMethod · 0.80
getPromptsByServerMethod · 0.80
getTokenMethod · 0.80
isTokenExpiredMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected