UNPKG

sequelae-mcp

Version:

Let Claude, Cursor, and other AI agents run real SQL queries on live Postgres databases. No more copy-pasting SQL, stale schema docs, or hallucinated DB adapters — just raw, real-time access. Now with MCP support!

88 lines 3.67 kB
#!/usr/bin/env node "use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); const mcp_1 = require("../mcp"); const logger_1 = require("../utils/logger"); // Check if running in MCP mode const args = process.argv.slice(2); const isMcpMode = process.env.MCP_MODE === 'true' || args.includes('--mcp'); async function main() { if (isMcpMode) { // Remove --mcp from args if present const filteredArgs = args.filter(arg => arg !== '--mcp'); process.argv = [process.argv[0], process.argv[1], ...filteredArgs]; // Configure rate limiting from environment variables let rateLimiterOptions; if (process.env.MCP_RATE_LIMIT_MAX_REQUESTS) { const maxRequests = parseInt(process.env.MCP_RATE_LIMIT_MAX_REQUESTS); const windowMs = parseInt(process.env.MCP_RATE_LIMIT_WINDOW_MS || '60000'); if (!isNaN(maxRequests) && maxRequests > 0) { rateLimiterOptions = { maxRequests, windowMs, }; // Parse tool-specific limits if provided if (process.env.MCP_RATE_LIMIT_TOOLS) { try { const toolLimits = JSON.parse(process.env.MCP_RATE_LIMIT_TOOLS); rateLimiterOptions.toolSpecificLimits = toolLimits; } catch (_e) { logger_1.logger.warn('Invalid MCP_RATE_LIMIT_TOOLS format, ignoring tool-specific limits'); } } logger_1.logger.info('Rate limiting enabled:', { maxRequests, windowMs, hasToolLimits: !!rateLimiterOptions.toolSpecificLimits, }); } } // Start MCP server const server = new mcp_1.SqlAgentMcpServer(rateLimiterOptions); await server.start(); } else { // Run as CLI - import dynamically to avoid loading unnecessary code const { main: cliMain } = await Promise.resolve().then(() => __importStar(require('../cli'))); await cliMain(); } } main().catch(error => { logger_1.logger.error('Fatal error:', error); process.exit(1); }); //# sourceMappingURL=sequelae.js.map