UNPKG

@kya-os/mcp-i

Version:

The TypeScript MCP framework with identity features built-in

52 lines (51 loc) 1.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js"); const server_1 = require("../../utils/server"); class StdioTransport { mcpServer; transport; debug; constructor(mcpServer, debug = false) { this.mcpServer = mcpServer; this.transport = new stdio_js_1.StdioServerTransport(); this.debug = debug; } start() { try { this.mcpServer.connect(this.transport); if (this.debug) { console.error("[STDIO] MCP Server running with STDIO transport"); } this.setupShutdownHandlers(); } catch (error) { if (this.debug) { console.error("[STDIO] Error starting STDIO transport:", error); } process.exit(1); } } setupShutdownHandlers() { const shutdownHandler = () => { if (this.debug) { console.error("[STDIO] Shutting down STDIO transport"); } process.exit(0); }; process.on("SIGINT", shutdownHandler); process.on("SIGTERM", shutdownHandler); } shutdown() { if (this.debug) { console.error("[STDIO] Shutting down STDIO transport"); } process.exit(0); } } // @ts-expect-error: injected by compiler const debug = STDIO_CONFIG.debug || false; (0, server_1.createServer)().then((mcpServer) => { const stdioTransport = new StdioTransport(mcpServer, debug); stdioTransport.start(); });