Skip to main content
Glama
test-list-services.tsโ€ข3.38 kB
#!/usr/bin/env node import { loadConfigFromEnvOnly } from "../src/config.js"; import { serviceRegistry } from "../src/services/registry.js"; async function testListServices() { console.log("๐Ÿงช Testing list_services functionality...\n"); try { // Load configuration console.log("๐Ÿ“‹ Loading configuration from environment..."); const config = await loadConfigFromEnvOnly(); console.log(`โœ… Found ${Object.keys(config.services).length} services in config`); if (config.downloaders) { console.log(`โœ… Found ${Object.keys(config.downloaders).length} downloaders in config`); } // Initialize service registry console.log("\n๐Ÿ”ง Initializing service registry..."); serviceRegistry.clear(); for (const [name, serviceConfig] of Object.entries(config.services)) { try { serviceRegistry.register(name, serviceConfig); console.log(`โœ… Registered service: ${name}`); } catch (error) { console.error(`โŒ Failed to register service ${name}:`, error instanceof Error ? error.message : error); throw error; } } if (config.downloaders) { for (const [name, downloaderConfig] of Object.entries(config.downloaders)) { try { serviceRegistry.registerDownloader(name, downloaderConfig); console.log(`โœ… Registered downloader: ${name}`); } catch (error) { console.error(`โŒ Failed to register downloader ${name}:`, error instanceof Error ? error.message : error); throw error; } } } // Simulate list_services tool logic console.log("\n๐Ÿ“‹ Testing list_services tool logic..."); const services = serviceRegistry.getAllNames(); const downloaders = serviceRegistry.getAllDownloaderNames(); const result = { ok: true, data: { services: services.map((name) => ({ name, type: serviceRegistry .get(name) ?.constructor.name?.replace("Service", "") .toLowerCase() || "unknown", })), downloaders: downloaders.map((name) => ({ name, type: "sabnzbd", })), summary: { totalServices: services.length, totalDownloaders: downloaders.length, }, }, }; console.log("\n๐ŸŽฏ list_services result:"); console.log(JSON.stringify(result, null, 2)); // Validate result structure console.log("\nโœ… Validation checks:"); console.log(`- Result has 'ok' property: ${result.ok === true ? "โœ…" : "โŒ"}`); console.log(`- Result has 'data' property: ${result.data ? "โœ…" : "โŒ"}`); console.log(`- Services array length: ${result.data.services.length}`); console.log(`- Downloaders array length: ${result.data.downloaders.length}`); console.log(`- Summary totals match: ${ result.data.summary.totalServices === result.data.services.length && result.data.summary.totalDownloaders === result.data.downloaders.length ? "โœ…" : "โŒ" }`); // Test service type detection console.log("\n๐Ÿ” Service type detection:"); for (const service of result.data.services) { console.log(`- ${service.name}: ${service.type}`); } console.log("\n๐ŸŽ‰ list_services test completed successfully!"); } catch (error) { console.error("\n๐Ÿ’ฅ Test failed:", error instanceof Error ? error.message : error); process.exit(1); } } if (import.meta.url === `file://${process.argv[1]}`) { testListServices().catch((error) => { console.error("๐Ÿ’ฅ Test execution failed:", error); process.exit(1); }); }

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/thesammykins/FlixBridge'

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