#!/usr/bin/env npx tsx import fs from 'fs'; import path from 'path'; import { MCPService } from '../src/main/services/mcp-service'; /** * Verify current MCP connection status and attempt to refresh tools */ async function verifyMCPStatus() { console.log('šŸ” Verifying MCP Server Status\n'); const configPath = path.join(process.env.HOME!, '.config/hashgraph-online/mcp-servers.json'); const servers = JSON.parse(fs.readFileSync(configPath, 'utf8')); console.log('šŸ“Š Current Server Status:\n'); for (const server of servers) { console.log(`šŸ“Œ ${server.name} (${server.type})`); console.log(` Status: ${server.status}`); console.log(` Command: ${server.config.command || 'N/A'}`); if (server.config.args) { console.log(` Args: ${JSON.stringify(server.config.args)}`); } console.log(` Tools: ${server.tools?.length || 0}`); if (server.tools && server.tools.length > 0) { console.log(` āœ… Tools loaded successfully:`); server.tools.forEach((tool: any) => { console.log(` - ${tool.name}`); }); } else if (server.status === 'connected' || server.status === 'ready') { console.log(` āš ļø Connected but no tools loaded - stuck in "Tools loading..." state`); } console.log(''); } const redditServer = servers.find((s: any) => s.name === 'Reddit'); if (redditServer && redditServer.config.args?.includes('Reddit')) { console.log('āŒ Issue found: Reddit server using incorrect package name "Reddit"'); console.log(' The package "Reddit" doesn\'t exist on npm'); console.log(' You may need to find the correct Reddit MCP package name'); console.log(''); console.log('šŸ’” Suggestions:'); console.log(' 1. Remove the Reddit server from the UI'); console.log(' 2. Search for Reddit MCP servers on npm or GitHub'); console.log(' 3. Add it back with the correct package name'); } console.log('\nšŸ”„ Testing refresh mechanism:\n'); const mcpService = MCPService.getInstance(); try { const loadedServers = await mcpService.loadServers(); console.log(`āœ… Loaded ${loadedServers.length} servers from config`); for (const server of loadedServers) { if (server.status === 'connected' && (!server.tools || server.tools.length === 0)) { console.log(`\nšŸ”§ Attempting to refresh tools for ${server.name}...`); try { const tools = await mcpService.refreshServerTools(server.id); console.log(` Result: ${tools.length} tools loaded`); } catch (error) { console.log(` Error: ${error instanceof Error ? error.message : error}`); } } } } catch (error) { console.log(`āŒ Error loading servers: ${error instanceof Error ? error.message : error}`); } } verifyMCPStatus().catch(console.error);