// Generated by dts-bundle-generator v9.5.1 import { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js'; import { ErrorCode, JSONRPCError as JSONRPCErrorRaw, JSONRPCMessage, RequestId, ServerCapabilities } from '@modelcontextprotocol/sdk/types.js'; import { Context, Elysia } from 'elysia'; /** * Logger interface that any logger implementation can conform to * Compatible with popular loggers like pino, winston, bunyan, etc. */ export interface ILogger { info(message: string, ...args: unknown[]): void; error(message: string, ...args: unknown[]): void; warn(message: string, ...args: unknown[]): void; debug(message: string, ...args: unknown[]): void; log?(message: string, ...args: unknown[]): void; } /** * Default console logger implementation with color support * Used when no custom logger is provided */ export declare class ConsoleLogger implements ILogger { private readonly colors; info(message: string, ...args: unknown[]): void; error(message: string, ...args: unknown[]): void; warn(message: string, ...args: unknown[]): void; debug(message: string, ...args: unknown[]): void; log(message: string, ...args: unknown[]): void; } /** * Silent logger that does nothing * Used when logging is disabled */ export declare class SilentLogger implements ILogger { info(): void; error(): void; warn(): void; debug(): void; log(): void; } /** * Factory function to create a logger * Returns SilentLogger if logging is disabled, otherwise returns the provided logger or ConsoleLogger */ export declare function createLogger(options?: { enabled?: boolean; logger?: ILogger; }): ILogger; export type StreamId = string; export type EventId = string; export interface EventStore { /** * Stores an event for later retrieval * @param streamId ID of the stream the event belongs to * @param message The JSON-RPC message to store * @returns The generated event ID for the stored event */ storeEvent(streamId: StreamId, message: JSONRPCMessage): Promise; replayEventsAfter(lastEventId: EventId, { send, }: { send: (eventId: EventId, message: JSONRPCMessage) => Promise; }): Promise; } export interface StreamableHTTPServerTransportOptions { /** * Function that generates a session ID for the transport. * The session ID SHOULD be globally unique and cryptographically secure (e.g., a securely generated UUID, a JWT, or a cryptographic hash) * * Return undefined to disable session management. */ sessionIdGenerator: (() => string) | undefined; /** * A callback for session initialization events * This is called when the server initializes a new session. * Useful in cases when you need to register multiple mcp sessions * and need to keep track of them. * @param sessionId The generated session ID */ onsessioninitialized?: (sessionId: string) => void; /** * If true, the server will return JSON responses instead of starting an SSE stream. * This can be useful for simple request/response scenarios without streaming. * Default is false (SSE streams are preferred). */ enableJsonResponse?: boolean; /** * Event store for resumability support * If provided, resumability will be enabled, allowing clients to reconnect and resume messages */ eventStore?: EventStore; /** * @deprecated Use logger option instead * Enable or disable logging */ enableLogging?: boolean; /** * Custom logger instance (pino, winston, etc.) * If not provided and enableLogging is true, will use default console logger */ logger?: ILogger; } export type JSONRPCError = Omit & { id: null; }; export type McpContext = Context & { store: { authInfo?: AuthInfo; }; }; declare class ElysiaStreamingHttpTransport implements Transport { private _started; private _initialized; private _streamMapping; private _requestToStreamMapping; private _requestResponseMap; private _standaloneSseStreamId; private logger; sessionId?: string; onclose?: () => void; onerror?: (error: Error) => void; onmessage?: (message: JSONRPCMessage, extra?: { authInfo?: unknown; }) => void; sessionIdGenerator: (() => string) | undefined; _enableJsonResponse: boolean; _eventStore: EventStore | undefined; _onsessioninitialized: ((sessionId: string) => void) | undefined; private _messageQueue; private _eventIdToMessageMap; private _streamIdToEventIdsMap; constructor(options: StreamableHTTPServerTransportOptions); start(): Promise; private writeSSEEvent; stream(): AsyncGenerator; handleRequest(context: McpContext): Promise<{ method: string; jsonrpc: "2.0"; params?: { [x: string]: unknown; _meta?: { [x: string]: unknown; progressToken?: string | number | undefined; "io.modelcontextprotocol/related-task"?: { taskId: string; } | undefined; } | undefined; } | undefined; } | { jsonrpc: "2.0"; id: string | number; result: { [x: string]: unknown; _meta?: { [x: string]: unknown; progressToken?: string | number | undefined; "io.modelcontextprotocol/related-task"?: { taskId: string; } | undefined; } | undefined; }; } | { jsonrpc: "2.0"; error: { code: number; message: string; data?: unknown; }; id?: string | number | undefined; } | JSONRPCMessage[] | AsyncGenerator | { jsonrpc: string; error: { code: number; message: string; }; id: null; } | null | undefined>; protected handleGetRequest(context: McpContext): Promise | { jsonrpc: string; error: { code: number; message: string; }; id: null; } | undefined>; protected handlePostRequest(context: McpContext): Promise<{ method: string; jsonrpc: "2.0"; params?: { [x: string]: unknown; _meta?: { [x: string]: unknown; progressToken?: string | number | undefined; "io.modelcontextprotocol/related-task"?: { taskId: string; } | undefined; } | undefined; } | undefined; } | { jsonrpc: "2.0"; id: string | number; result: { [x: string]: unknown; _meta?: { [x: string]: unknown; progressToken?: string | number | undefined; "io.modelcontextprotocol/related-task"?: { taskId: string; } | undefined; } | undefined; }; } | { jsonrpc: "2.0"; error: { code: number; message: string; data?: unknown; }; id?: string | number | undefined; } | JSONRPCError | JSONRPCMessage[] | AsyncGenerator | { jsonrpc: string; error: { code: number; message: string; data?: undefined; }; id: null; } | { jsonrpc: string; error: { code: number; message: string; data: string; }; id: null; } | null | undefined>; protected handleDeleteRequest(context: McpContext): Promise; protected handleUnsupportedRequest({ set, }: Context): Promise; private validateSession; close(): Promise; send(message: JSONRPCMessage, options?: { relatedRequestId?: RequestId; }): Promise; private storeEvent; private replayEvents; private logMessage; } /** * Plugin options for the MCP Elysia plugin */ export interface MCPPluginOptions { /** * Base path for MCP endpoints (default: '/mcp') */ basePath?: string; /** * Server information */ serverInfo?: { name: string; version: string; }; /** * MCP server capabilities */ capabilities?: ServerCapabilities; /** * @deprecated Use logger option instead * Enable or disable logging */ enableLogging?: boolean; /** * Custom logger instance (pino, winston, etc.) * If not provided and enableLogging is true, will use default console logger */ logger?: ILogger; /** * Enable JSON response mode instead of SSE streaming */ enableJsonResponse?: boolean; /** * Authentication handler */ authentication?: (context: McpContext) => Promise<{ authInfo?: AuthInfo; response?: unknown; }>; /** * Setup function to configure the MCP server with tools, resources, and prompts */ setupServer?: (server: McpServer) => void | Promise; /** * Enable stateless mode (no session management) */ stateless?: boolean; /** * Provide a custom MCP server instance */ mcpServer?: McpServer; /** * Event store for resumability support */ eventStore?: EventStore; } export declare const transports: Record; export declare const mcp: (options?: MCPPluginOptions) => Elysia<"", { decorator: {}; store: { authInfo: AuthInfo | undefined; }; derive: {}; resolve: {}; }, { typebox: {}; error: {}; }, { schema: {}; standaloneSchema: {}; macro: {}; macroFn: {}; parser: {}; response: {}; }, { [x: string]: { "*": { [x: string]: { body: unknown; params: { "*": string; } & {}; query: unknown; headers: unknown; response: { 200: {} | { jsonrpc: string; error: { code: ErrorCode; message: string; data: string; }; id: null; }; 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }; }; }; }; } & { [x: string]: { [x: string]: { body: unknown; params: {}; query: unknown; headers: unknown; response: { 200: {} | { jsonrpc: string; error: { code: ErrorCode; message: string; data: string; }; id: null; }; }; }; }; }, { derive: {}; resolve: {}; schema: {}; standaloneSchema: {}; response: {}; }, { derive: {}; resolve: {}; schema: {}; standaloneSchema: {}; response: { 200: {} | { jsonrpc: string; error: { code: ErrorCode; message: string; data: string; }; id: null; }; }; }>; export {};