Spaces:
Sleeping
Sleeping
Update server.js
Browse files12334568789106 unmodified lines1718192122232425262728293031323334202122const express = require('express');const { exec } = require('child_process');const httpProxy = require('http-proxy-middleware');
const app = express();
// Run the MCP server as a CLI commandconst mcpCommand = `npx @rashidazarang/airtable-mcp --token ${process.env.AIRTABLE_API_TOKEN} --base ${process.env.AIRTABLE_BASE_ID} --port 7861`;const mcpCommand = `npx @rashidazarang/airtable-mcp --token ${process.env.AIRTABLE_API_TOKEN} --base ${process.env.AIRTABLE_BASE_ID}`;console.log(`Starting MCP server with command: ${mcpCommand}`);exec(mcpCommand, (error, stdout, stderr) => { if (error) {6 unmodified lines console.error(`MCP server stderr: ${stderr}`);});
// Proxy requests to /airtable/mcp to the MCP server running on port 7861app.use('/airtable/mcp', httpProxy.createProxyMiddleware({ target: 'http://localhost:7861', changeOrigin: true, ws: true, // Enable WebSocket (SSE) proxying pathRewrite: { '^/airtable/mcp': '/airtable/mcp' // Ensure the path matches what the MCP server expects }, onError: (err, req, res) => { console.error(`Proxy error: ${err.message}`); res.status(500).send('Proxy error'); }}));
app.get('/health', (req, res) => { res.json({ status: 'healthy' });});server.js+1-16