/** * MCP Gateway service that aggregates tools from multiple MCP servers and provides a unified interface. * * This service acts as the central hub for MCP (Model Context Protocol) communication, * exposing both system tools and aggregated tools from connected MCP servers through * a single stdio transport endpoint. * * This is a thin wrapper around modular handlers for better maintainability. * * @example * ```typescript * const gateway = new GatewayService(); * await gateway.start(); // Start on stdio transport * * // Or create connection server for HTTP transport * const server = gateway.createConnectionServer(); * ``` */ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import type { ToolMapEntry, GatewayTool } from './types.js'; export declare class GatewayService { private server; private transport; private readonly appVersion; constructor(); private initToolCache; private createServerWithHandlers; private registerHandlers; /** * Generates a unified list of gateway tools with proper naming and collision resolution. * * @param {Map} toolMap - Map to populate with gateway tool name to actual tool mappings * @returns {Array} Array of gateway tools with resolved names and descriptions */ generateGatewayToolsList(toolMap: Map): Array; /** * Safely formats tool arguments for logging with circular reference handling and size limits. * * @param {unknown} args - Tool arguments to format * @returns {string} Safe formatted string representation of the arguments */ formatToolArgs(args: unknown): string; /** * Safely formats tool responses for logging with size limits. * * @param {unknown} response - Tool response to format * @returns {string} Safe formatted string representation of the response */ formatToolResponse(response: unknown): string; /** * Creates a new MCP server instance with all handlers registered for connection-based transports. * * @returns {McpServer} New MCP server instance with all handlers registered */ createConnectionServer(): McpServer; /** * Returns the singleton McpServer instance used for HTTP transport. */ getServer(): McpServer; /** * Subscribes to EventBus events and pushes MCP notifications * (notifications/resources/list_changed, notifications/tools/list_changed) * to connected SSE clients via the singleton transport. * * Tools are aggregated by ServerName (multi-instance deduplication). * Resources are per-instance (Category 1: hub://servers/{name}, Category 2: hub://servers/{name}/{idx}/{path}). */ private initNotifications; /** * Starts the MCP gateway service on stdio transport. * * @returns {Promise} Resolves when the gateway is successfully started on stdio */ start(): Promise; } export declare const gateway: GatewayService; //# sourceMappingURL=gateway.service.d.ts.map