@gibme/webserver
    Preparing search index...

    Variable RouterConst

    Router: {
        (
            create_server: () => McpServer,
            sessionOptions?: McpSessionOptions,
        ): ProtectedRouter;
        (
            config: McpServerConfig,
            sessionOptions?: McpSessionOptions,
        ): ProtectedRouter;
    } = McpRouter

    Type Declaration

      • (
            create_server: () => McpServer,
            sessionOptions?: McpSessionOptions,
        ): ProtectedRouter
      • Creates a mountable Router that hosts an MCP server over the Streamable HTTP transport. Each client session gets its own McpServer instance and its own transport, keyed by the mcp-session-id header. POST without a session ID initializes a new session; POST with a known session ID dispatches to the existing transport; GET streams server-to-client notifications for an existing session; DELETE terminates a session.

        The returned router is a ProtectedRouter, so callers can install an AuthenticationProvider to gate every MCP request.

        Two ways to specify the per-session server:

        • Pass a () => McpServer factory when the server needs per-session state captured in a closure (DB connections, session-scoped caches, etc.).
        • Pass an McpServerConfig bundle (the same shape create_mcp_server accepts) when the server is fully described by its declarative primitive list.

        Parameters

        • create_server: () => McpServer

          Factory invoked once per new client session to build the McpServer.

        • OptionalsessionOptions: McpSessionOptions

          Optional per-session lifecycle controls (idle timeout, max age, cap).

        Returns ProtectedRouter

      • (config: McpServerConfig, sessionOptions?: McpSessionOptions): ProtectedRouter
      • Parameters

        • config: McpServerConfig

          Declarative McpServerConfig bundle. A fresh McpServer is built per session by passing this config to create_mcp_server.

        • OptionalsessionOptions: McpSessionOptions

          Optional per-session lifecycle controls.

        Returns ProtectedRouter