Documentation
    Preparing search index...

    Class McpAdaptor

    MCP (Model Context Protocol) adaptor.

    McpAdaptor exposes every method decorated with McpRoute as an MCP tool, reachable by LLM clients through a stateless Streamable HTTP endpoint.

    At bootstrap the adaptor walks the NestContainer, collects every controller method carrying "nestia/McpRoute" metadata, and caches a tool registry. A fresh MCP server and transport pair is spun up per incoming HTTP request, following MCP stateless Streamable HTTP mode. This adaptor intentionally does not manage Mcp-Session-Id state.

    Typia-generated JSON Schemas flow through unchanged; the Zod-based high-level registration API of McpServer is bypassed by accessing the low-level .server handler.

    Error mapping follows the MCP specification:

    • Unknown tool name: JSON-RPC -32601.
    • Typia validation failure: JSON-RPC -32602 with structured diagnostics.
    • Handler throws HttpException: success response with isError: true, so the LLM can read the message and recover.
    • Any other throw: JSON-RPC -32603.
      import core from "@nestia/core";
    import { NestFactory } from "@nestjs/core";

    const app = await NestFactory.create(AppModule);
    await core.McpAdaptor.upgrade(app, { path: "/mcp" });
    await app.listen(3000);
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Upgrade a running Nest application with a stateless MCP endpoint.

      Scans the application container for methods decorated with McpRoute, then registers a catch-all HTTP route at the configured path. Each incoming request builds a fresh MCP server + transport on demand, wires the registered tools into it, and delegates handling.

      Must be called after NestFactory.create(...) but before app.listen(...) if you want the MCP endpoint to be reachable alongside your regular HTTP routes.

      Parameters

      • app: INestApplication

        Running Nest application instance.

      • options: McpAdaptor.IOptions = {}

        Transport and identity overrides.

      Returns Promise<void>