UNPKG

ultimate-mcp-server

Version:

The definitive all-in-one Model Context Protocol server for AI-assisted coding across 30+ platforms

58 lines 1.85 kB
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { Logger } from "../utils/logger.js"; export var TransportType; (function (TransportType) { TransportType["STDIO"] = "stdio"; TransportType["SSE"] = "sse"; TransportType["HTTP"] = "http"; TransportType["WEBSOCKET"] = "websocket"; TransportType["GRPC"] = "grpc"; })(TransportType || (TransportType = {})); export class BaseTransport { logger; server; config; constructor(server, config) { this.server = server; this.config = config; this.logger = new Logger(`${config.type.toUpperCase()}Transport`); } validateAuth(headers) { if (!this.config.auth || this.config.auth.type === "none") { return true; } if (this.config.auth.type === "api-key") { const apiKey = headers["x-api-key"] || headers["authorization"]?.replace("Bearer ", ""); return apiKey === this.config.auth.apiKey; } // JWT auth would be implemented here return false; } } export class StdioTransport extends BaseTransport { transport; running = false; constructor(server, config) { super(server, config); this.transport = new StdioServerTransport(); } async start() { try { await this.server.connect(this.transport); this.running = true; // No logging in stdio mode - it interferes with the protocol } catch (error) { // No logging in stdio mode - it interferes with the protocol throw error; } } async stop() { this.running = false; // No logging in stdio mode - it interferes with the protocol } isRunning() { return this.running; } } //# sourceMappingURL=base.js.map