#!/usr/bin/env node
const SERVER_URL = process.argv[2] || 'http://localhost:3000';
const SSE_ENDPOINT = `${SERVER_URL}/sse`;
console.log(`🧪 Testing MCP SSE transport at ${SSE_ENDPOINT}\n`);
async function testSseTransport() {
try {
// Test if SSE endpoint is available
console.log('1️⃣ Testing SSE connection...');
const response = await fetch(SSE_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'text/event-stream',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'tools/list'
})
});
if (response.ok) {
console.log('✓ SSE endpoint is responding');
// Read the response
const text = await response.text();
console.log('📝 Response preview:', text.substring(0, 200) + '...');
console.log('\n🎉 SSE transport test completed!');
console.log('ℹ️ For full SSE functionality, ensure Redis is configured');
} else {
console.log('❌ SSE endpoint not available');
console.log('ℹ️ This might be because Redis is not configured');
}
} catch (error) {
console.error('❌ SSE test failed:', error.message);
console.log('ℹ️ SSE transport requires Redis. Run "npm run setup" to configure Redis.');
}
}
testSseTransport();