Spaces:
Sleeping
Sleeping
Update server.js
Browse files
server.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
| 1 |
const express = require('express');
|
| 2 |
const { exec } = require('child_process');
|
| 3 |
-
const httpProxy = require('http-proxy-middleware');
|
| 4 |
|
| 5 |
const app = express();
|
| 6 |
|
| 7 |
// Run the MCP server as a CLI command
|
| 8 |
-
const mcpCommand = `npx @rashidazarang/airtable-mcp --token ${process.env.AIRTABLE_API_TOKEN} --base ${process.env.AIRTABLE_BASE_ID}
|
| 9 |
console.log(`Starting MCP server with command: ${mcpCommand}`);
|
| 10 |
exec(mcpCommand, (error, stdout, stderr) => {
|
| 11 |
if (error) {
|
|
@@ -18,20 +17,6 @@ exec(mcpCommand, (error, stdout, stderr) => {
|
|
| 18 |
console.error(`MCP server stderr: ${stderr}`);
|
| 19 |
});
|
| 20 |
|
| 21 |
-
// Proxy requests to /airtable/mcp to the MCP server running on port 7861
|
| 22 |
-
app.use('/airtable/mcp', httpProxy.createProxyMiddleware({
|
| 23 |
-
target: 'http://localhost:7861',
|
| 24 |
-
changeOrigin: true,
|
| 25 |
-
ws: true, // Enable WebSocket (SSE) proxying
|
| 26 |
-
pathRewrite: {
|
| 27 |
-
'^/airtable/mcp': '/airtable/mcp' // Ensure the path matches what the MCP server expects
|
| 28 |
-
},
|
| 29 |
-
onError: (err, req, res) => {
|
| 30 |
-
console.error(`Proxy error: ${err.message}`);
|
| 31 |
-
res.status(500).send('Proxy error');
|
| 32 |
-
}
|
| 33 |
-
}));
|
| 34 |
-
|
| 35 |
app.get('/health', (req, res) => {
|
| 36 |
res.json({ status: 'healthy' });
|
| 37 |
});
|
|
|
|
| 1 |
const express = require('express');
|
| 2 |
const { exec } = require('child_process');
|
|
|
|
| 3 |
|
| 4 |
const app = express();
|
| 5 |
|
| 6 |
// Run the MCP server as a CLI command
|
| 7 |
+
const mcpCommand = `npx @rashidazarang/airtable-mcp --token ${process.env.AIRTABLE_API_TOKEN} --base ${process.env.AIRTABLE_BASE_ID}`;
|
| 8 |
console.log(`Starting MCP server with command: ${mcpCommand}`);
|
| 9 |
exec(mcpCommand, (error, stdout, stderr) => {
|
| 10 |
if (error) {
|
|
|
|
| 17 |
console.error(`MCP server stderr: ${stderr}`);
|
| 18 |
});
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
app.get('/health', (req, res) => {
|
| 21 |
res.json({ status: 'healthy' });
|
| 22 |
});
|