#!/usr/bin/env node
// Test to isolate transport layer exception handling
const https = require('https');
console.log('Testing MCP Transport Exception Handling');
const mcpRequest = {
jsonrpc: '2.0',
id: 1,
method: 'tools/call',
params: {
name: 'get_customer_divisions',
arguments: {
userQuery: 'show me leumi customers'
}
}
};
const postData = JSON.stringify(mcpRequest);
const url = 'https://editorial-wants-socket-equal.trycloudflare.com/mcp';
const urlParts = new URL(url);
const options = {
hostname: urlParts.hostname,
port: 443,
path: urlParts.pathname,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(postData),
'Authorization': 'Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJkYXZpZCthbGxjbG91ZEDgBjOm9t...',
'User-Agent': 'MCP-Exception-Test/1.0'
},
rejectUnauthorized: false
};
console.log(`Making POST request to: ${url}`);
console.log('Waiting for response or exception...');
const req = https.request(options, (res) => {
console.log(`✅ STATUS: ${res.statusCode}`);
console.log(`✅ HEADERS RECEIVED`);
let data = '';
let chunks = 0;
res.on('data', (chunk) => {
chunks++;
data += chunk;
console.log(`✅ DATA CHUNK ${chunks}: ${chunk.length} bytes`);
});
res.on('end', () => {
console.log(`✅ RESPONSE END: Total ${data.length} bytes`);
console.log('✅ RESPONSE BODY:', data.substring(0, 500), data.length > 500 ? '...[truncated]' : '');
});
res.on('error', (err) => {
console.error('❌ RESPONSE ERROR:', err.message);
});
});
req.on('error', (e) => {
console.error(`❌ REQUEST ERROR: ${e.message}`);
});
req.on('timeout', () => {
console.error('❌ REQUEST TIMEOUT');
req.destroy();
});
req.on('close', () => {
console.log('🔌 CONNECTION CLOSED');
});
// Set shorter timeout to catch hanging responses
req.setTimeout(15000);
// Send the request
req.write(postData);
req.end();
console.log('📤 Request sent, monitoring for exceptions...');