@mcp-z/server
    Preparing search index...

    Function connectHttp

    • Sets up HTTP transport for an MCP server: creates the router, mounts it at /mcp, and binds an HTTP server.

      Parameters

      • mcpServerOrFactory: McpServer | (() => McpServer)

        Either a ready-made McpServer instance or a factory called once per request. A factory is what serves both protocol eras from the same definitions; an instance is served through a factory that always returns it (fine for a stateless server).

      • options: {
            allowedHosts?: string[];
            allowedOrigins?: string[];
            app: Application;
            host?: string;
            logger: Logger;
            port: number;
        }
        • OptionalallowedHosts?: string[]

          Extra Host values to accept, added to the loopback set for port

        • OptionalallowedOrigins?: string[]

          Extra Origin values to accept, added to the loopback set for port

        • app: Application
        • Optionalhost?: string

          Interface to bind to (spec SHOULD: loopback-only); pass '0.0.0.0' only for a deployment that genuinely needs it, e.g. behind a reverse proxy

        • logger: Logger
        • port: number

      Returns Promise<SetupHttpTransportResult>

      HTTP server instance