Skip to main content
Glama
mcp-servers.test.tsβ€’6.73 kB
#!/usr/bin/env node /** * Integration Test Suite for All MCP Servers * * Tests: * - Connection to all configured MCP servers * - Tool availability and schema validation * - Basic functionality of each server * - Shadcn MCP server integration * * Run with: npx tsx tests/integration/mcp-servers.test.ts */ import { MCPOrchestrator } from '../../src/orchestrator/MCPOrchestrator.js'; import type { MCPServerConfig } from '../../src/types/index.js'; // Test configuration for all servers const TEST_SERVERS: MCPServerConfig[] = [ { name: 'context7', transport: 'stdio', command: 'npx', args: ['-y', '@upstash/context7-mcp'], env: {}, }, { name: 'playwright', transport: 'stdio', command: 'npx', args: ['@playwright/mcp@latest'], env: {}, }, { name: 'bright-data', transport: 'stdio', command: 'npx', args: ['@brightdata/mcp'], env: { API_TOKEN: process.env.BRIGHT_DATA_API_TOKEN || '83ca9984ed40d7edc01326acf1c4326c3b09ea906db764a56e1d0f421b1c22d5', }, }, { name: 'chrome-devtools', transport: 'stdio', command: 'npx', args: ['chrome-devtools-mcp@latest'], env: {}, }, { name: 'firecrawl-mcp', transport: 'stdio', command: 'npx', args: ['-y', 'firecrawl-mcp'], env: { FIRECRAWL_API_KEY: process.env.FIRECRAWL_API_KEY || 'fc-418ad2bf8944494dbc52cc8a001feda5', }, }, { name: 'shadcn', transport: 'stdio', command: 'npx', args: ['-y', 'mcp-remote', 'https://www.shadcn.io/api/mcp'], env: {}, }, ]; interface TestResult { name: string; status: 'PASS' | 'FAIL' | 'SKIP'; message: string; error?: Error; tools?: number; } const results: TestResult[] = []; async function runTests() { console.log('πŸ§ͺ MCP Servers Integration Test Suite\n'); console.log(`πŸ“‘ Testing ${TEST_SERVERS.length} MCP servers...\n`); const orchestrator = new MCPOrchestrator(); const connectionResults = new Map<string, boolean>(); // Test 1: Server Connectivity console.log('Test 1: Server Connectivity'); console.log('─'.repeat(50)); for (const serverConfig of TEST_SERVERS) { try { console.log(` Testing ${serverConfig.name}...`); await orchestrator.connectServer(serverConfig); connectionResults.set(serverConfig.name, true); results.push({ name: `Connection: ${serverConfig.name}`, status: 'PASS', message: `Successfully connected to ${serverConfig.name}`, }); console.log(` βœ… Connected\n`); } catch (error) { connectionResults.set(serverConfig.name, false); results.push({ name: `Connection: ${serverConfig.name}`, status: 'FAIL', message: `Failed to connect to ${serverConfig.name}`, error: error instanceof Error ? error : new Error(String(error)), }); console.log(` ❌ Failed: ${error instanceof Error ? error.message : String(error)}\n`); } } // Test 2: Tool Availability console.log('\nTest 2: Tool Availability'); console.log('─'.repeat(50)); const allTools = orchestrator.getAllTools(); const toolsByServer = new Map<string, number>(); for (const tool of allTools) { const [serverName] = tool.name.split('__'); toolsByServer.set(serverName, (toolsByServer.get(serverName) || 0) + 1); } console.log(` Total tools found: ${allTools.length}\n`); for (const [serverName, count] of toolsByServer) { const isConnected = connectionResults.get(serverName); const status = isConnected ? 'PASS' : 'SKIP'; results.push({ name: `Tools: ${serverName}`, status, message: isConnected ? `Found ${count} tools from ${serverName}` : `Skipped (server connection failed)`, tools: count, }); if (isConnected) { console.log(` ${serverName}: ${count} tools βœ…`); } else { console.log(` ${serverName}: ${count} tools (skipped - connection failed)`); } } // Test 3: Shadcn-specific tests console.log('\nTest 3: Shadcn MCP Server Specific Tests'); console.log('─'.repeat(50)); const shadcnTools = allTools.filter(tool => tool.name.startsWith('shadcn__')); if (shadcnTools.length > 0) { console.log(` βœ… Shadcn tools found: ${shadcnTools.length}\n`); console.log(' Available shadcn tools:'); for (const tool of shadcnTools) { console.log(` - ${tool.name}`); results.push({ name: `Shadcn Tool: ${tool.name}`, status: 'PASS', message: `Tool schema valid`, }); } console.log(); } else { results.push({ name: 'Shadcn: Tool Discovery', status: 'FAIL', message: 'No shadcn tools found', }); console.log(' ❌ No shadcn tools found\n'); } // Test 4: Server Integration Summary console.log('\nTest 4: Server Integration Summary'); console.log('─'.repeat(50)); const connected = Array.from(connectionResults.values()).filter(v => v).length; const disconnected = Array.from(connectionResults.values()).filter(v => !v).length; console.log(` Connected: ${connected}/${TEST_SERVERS.length}`); console.log(` Failed: ${disconnected}/${TEST_SERVERS.length}\n`); // Results Summary console.log('\nπŸ“Š Test Results Summary'); console.log('═'.repeat(50)); let passCount = 0; let failCount = 0; let skipCount = 0; for (const result of results) { if (result.status === 'PASS') passCount++; else if (result.status === 'FAIL') failCount++; else skipCount++; } console.log(`\nβœ… PASSED: ${passCount}`); console.log(`❌ FAILED: ${failCount}`); console.log(`⊘ SKIPPED: ${skipCount}`); console.log(`πŸ“ˆ TOTAL: ${results.length}`); // Detailed results console.log('\nπŸ“‹ Detailed Results:'); console.log('─'.repeat(50)); for (const result of results) { const icon = result.status === 'PASS' ? 'βœ…' : result.status === 'FAIL' ? '❌' : '⊘'; const toolInfo = result.tools ? ` (${result.tools} tools)` : ''; console.log(`${icon} ${result.name}${toolInfo}`); if (result.message) { console.log(` ${result.message}`); } if (result.error) { console.log(` Error: ${result.error.message}`); } } // Final status const hasFailures = failCount > 0; console.log('\n' + '═'.repeat(50)); if (!hasFailures) { console.log('\nπŸŽ‰ All tests passed!\n'); await orchestrator.disconnect(); process.exit(0); } else { console.log('\n⚠️ Some tests failed.\n'); await orchestrator.disconnect(); process.exit(1); } } // Run tests runTests().catch((error) => { console.error('❌ Fatal error during tests:'); console.error(error); process.exit(1); });

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/blas0/code2mcp'

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