@gala-chain/launchpad-mcp-server
Version:
MCP server for Gala Launchpad SDK with 55 tools + 14 slash commands - Production-grade AI agent integration with comprehensive validation, optimized performance, and 80%+ test coverage
90 lines (76 loc) • 2.11 kB
JavaScript
/**
* Manual MCP Protocol Test
* Tests the MCP server by sending protocol messages via stdio
*/
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Start the MCP server
const server = spawn('node', [join(__dirname, 'dist/index.js')], {
env: {
...process.env,
PRIVATE_KEY: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
ENVIRONMENT: 'development',
DEBUG: 'true'
},
stdio: ['pipe', 'pipe', 'pipe']
});
let responseBuffer = '';
server.stdout.on('data', (data) => {
responseBuffer += data.toString();
// Try to parse complete JSON-RPC messages
const lines = responseBuffer.split('\n');
responseBuffer = lines.pop(); // Keep incomplete line in buffer
lines.forEach(line => {
if (line.trim()) {
try {
const msg = JSON.parse(line);
console.log('✓ Server Response:', JSON.stringify(msg, null, 2));
} catch (e) {
console.log('Server output:', line);
}
}
});
});
server.stderr.on('data', (data) => {
console.log('Server log:', data.toString());
});
server.on('close', (code) => {
console.log(`Server exited with code ${code}`);
process.exit(code);
});
// Send initialize request
console.log('→ Sending initialize request...');
const initRequest = {
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2024-11-05',
capabilities: {},
clientInfo: {
name: 'test-client',
version: '1.0.0'
}
}
};
server.stdin.write(JSON.stringify(initRequest) + '\n');
// After 2 seconds, request tools list
setTimeout(() => {
console.log('\n→ Sending tools/list request...');
const toolsRequest = {
jsonrpc: '2.0',
id: 2,
method: 'tools/list',
params: {}
};
server.stdin.write(JSON.stringify(toolsRequest) + '\n');
}, 2000);
// Exit after 5 seconds
setTimeout(() => {
console.log('\n✓ Test complete, shutting down...');
server.kill();
}, 5000);