const http = require('http'); const fs = require('fs'); const path = require('path'); const { createProxyServer } = require('http-proxy'); const GATEWAY_PORT = 3100; const PORT = 8000; const proxy = createProxyServer({ target: `http://localhost:${GATEWAY_PORT}`, ws: true }); const serverCard = fs.readFileSync(path.join(__dirname, 'server-card.json')); const server = http.createServer((req, res) => { if (req.url === '/.well-known/mcp/server-card.json') { res.writeHead(200, { 'Content-Type': 'application/json' }); return res.end(serverCard); } proxy.web(req, res); }); server.on('upgrade', (req, socket, head) => { proxy.ws(req, socket, head); }); server.listen(PORT, () => console.log(`Proxy running on port ${PORT}`));