@mseep/supabase-mcp
Version:
MCP server for Supabase CRUD operations
37 lines • 1.33 kB
JavaScript
import express from 'express';
import cors from 'cors';
import bodyParser from 'body-parser';
import { handleManifest, validateApiKey, handleHealthCheck, handleDatabaseOperation, handleListTables, handleJsonRpc } from './handlers/index.js';
export function createServer() {
const app = express();
// Middleware
app.use(cors());
app.use(bodyParser.json());
// Skip API key validation for manifest endpoint
app.use((req, res, next) => {
if (req.path === '/.well-known/mcp-manifest' || req.path === '/mcp') {
return next();
}
validateApiKey(req, res, next);
});
// MCP required endpoints
app.get('/.well-known/mcp-manifest', handleManifest);
// MCP JSON-RPC endpoint
app.post('/mcp', handleJsonRpc);
// Health check
app.get('/health', handleHealthCheck);
// Database operations
app.post('/database/:operation', handleDatabaseOperation);
app.get('/database/tables', handleListTables);
// 404 handler
app.use((req, res) => {
res.status(404).json({ error: 'Not found' });
});
// Error handler
app.use((err, req, res, next) => {
console.error('Server error:', err);
res.status(500).json({ error: `Server error: ${err.message}` });
});
return app;
}
//# sourceMappingURL=server.js.map