Spaces:
Sleeping
Sleeping
Update server.js
Browse files12345678910116 unmodified lines1819202122232425262728293031323334353637const 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`;console.log(`Starting MCP server with command: ${mcpCommand}`);exec(mcpCommand, (error, stdout, stderr) => {if (error) {6 unmodified linesconsole.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) proxyingpathRewrite: {'^/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' });});123456789106 unmodified lines171819202122const express = require('express');const { exec } = require('child_process');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}`;console.log(`Starting MCP server with command: ${mcpCommand}`);exec(mcpCommand, (error, stdout, stderr) => {if (error) {6 unmodified linesconsole.error(`MCP server stderr: ${stderr}`);});app.get('/health', (req, res) => {res.json({ status: 'healthy' });});
server.js+1-16