Skip to main content
Glama

Serpex MCP

test-server.js•2.71 kB
#!/usr/bin/env node /** * Test script for Serpex MCP Server * This simulates how Jan AI would interact with the MCP server */ import { spawn } from 'child_process'; import readline from 'readline'; const API_KEY = 'sk_3db213feb43735751791eb8b71a4daf853099913d53de6ccbbc717dc9a048199'; async function testMCPServer() { console.log('šŸš€ Starting Serpex MCP Server Test\n'); // Start the MCP server const server = spawn('node', ['build/index.js'], { env: { ...process.env, SERPEX_API_KEY: API_KEY }, stdio: ['pipe', 'pipe', 'pipe'], }); const rl = readline.createInterface({ input: server.stdout, crlfDelay: Infinity, }); server.stderr.on('data', (data) => { console.log('Server:', data.toString().trim()); }); // Helper to send JSON-RPC request function sendRequest(method, params = {}) { const request = { jsonrpc: '2.0', id: Date.now(), method, params, }; console.log('\nšŸ“¤ Sending request:', JSON.stringify(request, null, 2)); server.stdin.write(JSON.stringify(request) + '\n'); } // Handle responses rl.on('line', (line) => { try { const response = JSON.parse(line); console.log('\nšŸ“„ Received response:', JSON.stringify(response, null, 2)); } catch (e) { console.log('Raw output:', line); } }); // Wait a bit for server to start await new Promise((resolve) => setTimeout(resolve, 1000)); // Test 1: Initialize console.log('\n=== Test 1: Initialize ==='); sendRequest('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'test-client', version: '1.0.0', }, }); await new Promise((resolve) => setTimeout(resolve, 2000)); // Test 2: List tools console.log('\n=== Test 2: List Tools ==='); sendRequest('tools/list'); await new Promise((resolve) => setTimeout(resolve, 2000)); // Test 3: Search for "OpenAI" console.log('\n=== Test 3: Search Query ==='); sendRequest('tools/call', { name: 'serpex_search', arguments: { q: 'OpenAI GPT-4', engine: 'google', time_range: 'month', }, }); await new Promise((resolve) => setTimeout(resolve, 5000)); // Test 4: Search with auto engine console.log('\n=== Test 4: Auto Engine Search ==='); sendRequest('tools/call', { name: 'serpex_search', arguments: { q: 'Model Context Protocol', engine: 'auto', }, }); await new Promise((resolve) => setTimeout(resolve, 5000)); console.log('\nāœ… Tests completed! Shutting down...\n'); server.kill(); process.exit(0); } testMCPServer().catch((error) => { console.error('āŒ Test 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/divyeshradadiya/serpex-mcp'

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