UNPKG

@mseep/falkordb-mcpserver

Version:

Model Context Protocol server for FalkorDB

24 lines (23 loc) 856 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.authenticateMCP = void 0; const config_1 = require("../config"); /** * Middleware to authenticate MCP API requests */ const authenticateMCP = (req, res, next) => { const apiKey = req.headers['x-api-key'] || req.query.apiKey; // Skip authentication for development environment if (config_1.config.server.nodeEnv === 'development' && !config_1.config.mcp.apiKey) { console.warn('Warning: Running without API key authentication in development mode'); return next(); } if (!apiKey) { return res.status(401).json({ error: 'Missing API key' }); } if (apiKey !== config_1.config.mcp.apiKey) { return res.status(403).json({ error: 'Invalid API key' }); } next(); }; exports.authenticateMCP = authenticateMCP;