Skip to main content
Glama

VSCode Language Server MCP Extension

by aaddrick
test-connection.js•3.77 kB
// Simple test to check if MCP server is accessible const http = require('http'); function makeRequest(method, params = {}) { return new Promise((resolve, reject) => { const data = JSON.stringify({ jsonrpc: '2.0', id: Math.floor(Math.random() * 10000), method, params }); const options = { hostname: 'localhost', port: 3100, path: '/', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': data.length } }; const req = http.request(options, (res) => { let body = ''; res.on('data', (chunk) => { body += chunk; }); res.on('end', () => { try { const response = JSON.parse(body); resolve(response); } catch (error) { reject(new Error('Invalid JSON response')); } }); }); req.on('error', (error) => { reject(error); }); req.write(data); req.end(); }); } async function testConnection() { try { console.log('šŸ”Œ Testing connection to MCP HTTP server at http://localhost:3100...\n'); // Test health endpoint const healthCheck = new Promise((resolve, reject) => { http.get('http://localhost:3100', (res) => { let body = ''; res.on('data', (chunk) => { body += chunk; }); res.on('end', () => { try { const data = JSON.parse(body); console.log('āœ… Health check passed:', data); resolve(data); } catch (error) { reject(error); } }); }).on('error', reject); }); await healthCheck; // Send initialize request console.log('\nšŸ“¤ Sending initialize request...'); const initResponse = await makeRequest('initialize', {}); console.log('šŸ“„ Initialize response:', JSON.stringify(initResponse, null, 2)); // Send tools/list request console.log('\nšŸ“¤ Sending tools/list request...'); const toolsResponse = await makeRequest('tools/list', {}); console.log('šŸ“„ Tools response:'); console.log('\nāœ… Available tools:', toolsResponse.result.tools.length); toolsResponse.result.tools.forEach(tool => { console.log(` - ${tool.name}: ${tool.description}`); }); console.log('\nāœ… Test complete! MCP HTTP server is working correctly.'); process.exit(0); } catch (error) { console.error('\nāŒ Connection error:', error.message); console.log('\nāš ļø Extension may not be activated yet.'); console.log(' To activate:'); console.log(' 1. Open VSCode'); console.log(' 2. Press Ctrl+Shift+P'); console.log(' 3. Run "Developer: Reload Window"'); console.log(' 4. Check status bar for "MCP LS:3100"'); process.exit(1); } } // Timeout after 5 seconds setTimeout(() => { console.error('āŒ Connection timeout'); console.log('\nāš ļø Extension is not running. Steps to activate:'); console.log(' 1. Open VSCode'); console.log(' 2. Press Ctrl+Shift+P'); console.log(' 3. Run "Developer: Reload Window"'); console.log(' 4. Check status bar (bottom-right) for "MCP LS:3100"'); console.log(' 5. If not showing, run "VSCode MCP LS: Show Status"'); process.exit(1); }, 5000); testConnection();

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/aaddrick/vscode-mcp-language-server'

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