Skip to main content
Glama
test-mcp.js3.08 kB
#!/usr/bin/env node import { spawn } from 'child_process'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Start the MCP server const server = spawn('node', [path.join(__dirname, 'build/index.js')], { stdio: ['pipe', 'pipe', 'pipe'], env: { ...process.env, CLICKUP_ACCESS_TOKEN: process.env.CLICKUP_ACCESS_TOKEN || 'test_token' } }); let requestId = 1; // Function to send a JSON-RPC request function sendRequest(method, params = {}) { const request = { jsonrpc: '2.0', id: requestId++, method, params }; const message = JSON.stringify(request) + '\n'; console.log('Sending:', message.trim()); server.stdin.write(message); } // Collect responses let responseBuffer = ''; server.stdout.on('data', (data) => { responseBuffer += data.toString(); let lines = responseBuffer.split('\n'); responseBuffer = lines.pop(); // Keep incomplete line for (const line of lines) { if (line.trim()) { try { const response = JSON.parse(line); console.log('Received:', JSON.stringify(response, null, 2)); handleResponse(response); } catch (e) { console.error('Failed to parse response:', line); } } } }); server.stderr.on('data', (data) => { console.error('Server stderr:', data.toString()); }); // Handle responses function handleResponse(response) { if (response.id === 1) { // Initialize response console.log('Initialize successful. Tools available:', Object.keys(response.result.capabilities.tools || {})); if (response.result.capabilities.tools && Object.keys(response.result.capabilities.tools).length > 0) { console.log('✓ Tools are properly configured'); // Now test get_tasks if list_id is provided if (process.argv[2]) { sendRequest('tools/call', { name: 'get_tasks', arguments: { list_id: process.argv[2], limit: 5 } }); } else { console.log('No list_id provided for testing get_tasks. Provide as argument: node test-mcp.js <list_id>'); server.kill(); } } else { console.error('✗ No tools available in capabilities'); server.kill(); } } else if (response.id === 2) { // get_tasks response if (response.result && !response.result.isError) { console.log('✓ get_tasks tool works correctly'); const tasks = JSON.parse(response.result.content[0].text); console.log(`Retrieved ${tasks.length} tasks`); } else { console.error('✗ get_tasks tool failed:', response.result?.content?.[0]?.text || 'Unknown error'); } server.kill(); } } // Start testing console.log('Starting MCP server test...'); sendRequest('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'test-client', version: '1.0.0' } }); // Timeout setTimeout(() => { console.error('Test timeout'); server.kill(); }, 10000); // Cleanup process.on('SIGINT', () => { server.kill(); });

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/rubenaguir/clickup-mcp-server'

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