/** * Simple MCP endpoint test */ import fetch from 'node-fetch'; const SERVER_URL = 'http://localhost:3001'; async function testMcpEndpoint() { try { console.log('🔍 Testing MCP endpoint with simple request...'); const initMessage = { jsonrpc: '2.0', id: 1, method: 'initialize', params: { protocolVersion: '2024-11-05', capabilities: { tools: {}, }, clientInfo: { name: 'test-simple-mcp-client', version: '1.0.0', }, }, }; console.log('📤 Sending:', JSON.stringify(initMessage, null, 2)); const response = await fetch(`${SERVER_URL}/mcp`, { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json, text/event-stream', }, body: JSON.stringify(initMessage), }); console.log('📥 Status:', response.status); console.log('📥 Headers:', Object.fromEntries(response.headers.entries())); if (response.ok) { const sessionId = response.headers.get('mcp-session-id'); console.log('🆔 Session ID:', sessionId); const text = await response.text(); console.log('📥 SSE Response:', text); } else { const text = await response.text(); console.log('📥 Error response:', text); } } catch (error) { console.error('❌ Error:', error); } } testMcpEndpoint();