Skip to main content
Glama
test-connection.tsโ€ข3.13 kB
#!/usr/bin/env node import { loadConfig, isConfigValid } from '../src/config.js'; import { HueClient } from '../src/hue-client.js'; async function testConnection() { console.log('๐Ÿงช Testing Hue MCP Connection\\n'); // Load configuration console.log('๐Ÿ“‹ Loading configuration...'); const config = loadConfig(); if (!isConfigValid(config)) { console.error('โŒ Invalid configuration. Please run setup first.'); console.log('๐Ÿ’ก Run: npm run setup:web'); process.exit(1); } console.log(`โœ… Configuration loaded for bridge: ${config.HUE_BRIDGE_IP}\\n`); try { // Test connection console.log('๐Ÿ”— Connecting to Hue bridge...'); const client = new HueClient(config); await client.connect(); console.log('โœ… Connected successfully\\n'); // Test basic operations console.log('๐Ÿ” Testing basic operations...'); // List lights console.log(' ๐Ÿ“ก Fetching lights...'); const lights = await client.getLights(); console.log(` โœ… Found ${lights.length} light(s)`); // List rooms console.log(' ๐Ÿ  Fetching rooms...'); const rooms = await client.getRooms(); console.log(` โœ… Found ${rooms.length} room(s)`); // List scenes console.log(' ๐ŸŽญ Fetching scenes...'); const scenes = await client.getScenes(); console.log(` โœ… Found ${scenes.length} scene(s)`); // Get system summary console.log(' ๐Ÿ“Š Getting system summary...'); const summary = await client.getSystemSummary(); console.log(' โœ… Summary generated\\n'); // Display summary console.log('๐Ÿ“Š System Summary:'); console.log('=================='); console.log(`Bridge IP: ${summary.bridge.ip}`); console.log(`Total Lights: ${summary.statistics.totalLights}`); console.log(`Lights On: ${summary.statistics.lightsOn}`); console.log(`Lights Off: ${summary.statistics.lightsOff}`); console.log(`Reachable: ${summary.statistics.reachableLights}`); console.log(`Rooms: ${summary.statistics.rooms}`); console.log(`Zones: ${summary.statistics.zones}`); console.log(`Scenes: ${summary.statistics.scenes}\\n`); // Test natural language parsing console.log('๐Ÿง  Testing natural language parsing...'); const examples = [ 'turn on warm white at 50%', 'stormy dusk', 'bright red', 'turn off', 'dim blue slowly', ]; examples.forEach(example => { const parsed = HueClient.parseNaturalLanguageState(example); console.log(` "${example}" โ†’ ${JSON.stringify(parsed)}`); }); console.log('\\n๐ŸŽ‰ All tests passed! Your Hue MCP server is ready to use.'); } catch (error: any) { console.error('โŒ Connection test failed:', error.message); console.log('\\n๐Ÿ”ง Troubleshooting:'); console.log(' 1. Check that your Hue bridge is powered on'); console.log(' 2. Verify the bridge IP address is correct'); console.log(' 3. Ensure the API key is valid'); console.log(' 4. Try running setup again: npm run setup:web'); process.exit(1); } } testConnection();

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rmrfslashbin/hue-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server