#!/usr/bin/env node /** * Test MCP Server CLI Agent Integration */ const { HiveClient } = require('../../mcp-server/dist/hive-client.js'); const { HiveTools } = require('../../mcp-server/dist/hive-tools.js'); async function testMCPIntegration() { console.log('๐Ÿงช Testing MCP Server CLI Agent Integration...\n'); try { // Initialize Hive client const hiveClient = new HiveClient({ baseUrl: 'https://hive.home.deepblack.cloud/api', wsUrl: 'wss://hive.home.deepblack.cloud/socket.io', timeout: 15000 }); console.log('โœ… HiveClient initialized'); // Test connection try { await hiveClient.testConnection(); console.log('โœ… Connection to Hive backend successful'); } catch (error) { console.log('โš ๏ธ Connection test failed (backend may be offline):', error.message); console.log(' Continuing with tool definition tests...\n'); } // Initialize tools const hiveTools = new HiveTools(hiveClient); console.log('โœ… HiveTools initialized'); // Test tool definitions const tools = hiveTools.getAllTools(); console.log(`โœ… Loaded ${tools.length} MCP tools\n`); // Check for CLI agent tools const cliTools = tools.filter(tool => tool.name.includes('cli') || tool.name.includes('predefined') ); console.log('๐Ÿ” CLI Agent Tools Available:'); cliTools.forEach(tool => { console.log(` โ€ข ${tool.name}: ${tool.description}`); }); // Test tool schema validation const registerCliTool = tools.find(t => t.name === 'hive_register_cli_agent'); if (registerCliTool) { console.log('\nโœ… hive_register_cli_agent tool found'); console.log(' Required fields:', registerCliTool.inputSchema.required); const properties = registerCliTool.inputSchema.properties; if (properties.host && properties.node_version && properties.specialization) { console.log('โœ… CLI agent tool schema validated'); } else { console.log('โŒ CLI agent tool schema missing required properties'); } } else { console.log('โŒ hive_register_cli_agent tool not found'); } // Test agent enumeration const agentEnums = tools .filter(t => t.inputSchema.properties && (t.inputSchema.properties.specialization || t.inputSchema.properties.type)) .map(t => { const spec = t.inputSchema.properties.specialization; const type = t.inputSchema.properties.type; return { tool: t.name, enum: spec?.enum || type?.enum }; }) .filter(t => t.enum); console.log('\n๐Ÿ” Agent Type Enumerations:'); agentEnums.forEach(({ tool, enum: enumValues }) => { const cliTypes = enumValues.filter(e => e.includes('cli') || e.includes('general') || e.includes('reasoning') ); if (cliTypes.length > 0) { console.log(` โ€ข ${tool}: includes CLI types [${cliTypes.join(', ')}]`); } }); console.log('\n๐ŸŽ‰ MCP Integration Test Complete!'); console.log('โœ… CLI agent tools are properly integrated'); console.log('โœ… Schema validation passed'); console.log('โœ… Mixed agent type support confirmed'); return true; } catch (error) { console.error('โŒ MCP Integration test failed:', error.message); return false; } } // Run the test testMCPIntegration() .then(success => { process.exit(success ? 0 : 1); }) .catch(error => { console.error('โŒ Test execution failed:', error); process.exit(1); });