Skip to main content
Glama

Facebook Insights Metrics v23

test-mcp.jsโ€ข3.81 kB
#!/usr/bin/env node /** * MCP Server Test Script * Tests all tools to ensure they work correctly */ const { spawn } = require('child_process'); const path = require('path'); const MCP_SERVER_PATH = path.join(__dirname, 'dist', 'server.js'); console.log('๐Ÿงช Starting MCP Server tests...\n'); // Test cases const tests = [ { name: 'List Tools', request: { jsonrpc: '2.0', id: 1, method: 'tools/list', params: {} } }, { name: 'List Metrics', request: { jsonrpc: '2.0', id: 2, method: 'tools/call', params: { name: 'metrics.list', arguments: {} } } }, { name: 'Search Metrics', request: { jsonrpc: '2.0', id: 3, method: 'tools/call', params: { name: 'metrics.search', arguments: { q: 'page', limit: 5 } } } }, { name: 'Get Specific Metric', request: { jsonrpc: '2.0', id: 4, method: 'tools/call', params: { name: 'metrics.get', arguments: { name: 'page_impressions' } } } }, { name: 'Refresh Data', request: { jsonrpc: '2.0', id: 5, method: 'tools/call', params: { name: 'metrics.refreshNow', arguments: {} } } } ]; async function runTest(test) { return new Promise((resolve, reject) => { console.log(`๐Ÿ” Testing: ${test.name}`); const child = spawn('node', [MCP_SERVER_PATH], { stdio: ['pipe', 'pipe', 'pipe'] }); let output = ''; let error = ''; child.stdout.on('data', (data) => { output += data.toString(); }); child.stderr.on('data', (data) => { error += data.toString(); }); child.on('close', (code) => { if (code !== 0) { console.log(`โŒ Failed: ${test.name}`); console.log(`Error: ${error}`); reject(new Error(`Test failed with code ${code}`)); return; } try { const response = JSON.parse(output); if (response.error) { console.log(`โŒ Response error: ${response.error.message}`); reject(new Error(response.error.message)); return; } console.log(`โœ… Passed: ${test.name}`); if (response.result) { console.log(` Result: ${JSON.stringify(response.result).substring(0, 100)}...`); } resolve(response); } catch (e) { console.log(`โŒ JSON parse error: ${e.message}`); console.log(`Response: ${output}`); reject(e); } }); // Send request child.stdin.write(JSON.stringify(test.request) + '\n'); child.stdin.end(); }); } async function runAllTests() { console.log(`๐Ÿ“ MCP Server path: ${MCP_SERVER_PATH}\n`); // Check if file exists const fs = require('fs'); if (!fs.existsSync(MCP_SERVER_PATH)) { console.log('โŒ MCP Server file not found!'); console.log('Please run: npm run build'); process.exit(1); } let passed = 0; let failed = 0; for (const test of tests) { try { await runTest(test); passed++; } catch (error) { console.log(`โŒ Test failed: ${error.message}`); failed++; } console.log(''); // Empty line } console.log('๐Ÿ“Š Test Results:'); console.log(`โœ… Passed: ${passed}`); console.log(`โŒ Failed: ${failed}`); console.log(`๐Ÿ“ˆ Success Rate: ${Math.round((passed / (passed + failed)) * 100)}%`); if (failed === 0) { console.log('\n๐ŸŽ‰ All tests passed! MCP Server is working perfectly.'); } else { console.log('\nโš ๏ธ Some tests failed. Please check the configuration.'); } } // Run tests runAllTests().catch(console.error);

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/KarimTarekDev/facebook-insights-metrics-v23'

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