Documentation
    Preparing search index...

    Function McpRoute

    • MCP (Model Context Protocol) route decorator.

      @McpRoute() marks a controller method as a callable MCP tool. When the application bootstraps, every method annotated with this decorator is registered on the MCP server built by McpAdaptor.upgrade, making it reachable by LLM clients (Claude Desktop, Cursor, OpenAI function calling, etc.) through the standard Streamable HTTP transport.

      The public form takes only the tool's name (string). Human-readable description and title are read from the method's JSDoc:

      • description: the JSDoc comment body.
      • title: the value of an optional @title JSDoc tag.

      For type-safe tool inputs, decorate exactly one parameter of the method with McpRoute.Params. The parameter type T is analyzed at compile time by the nestia transformer, which generates both a runtime validator (powered by typia) and the JSON Schema attached to inputSchema in tools/list responses.

      For the MCP endpoint to actually be served, you must call McpAdaptor.upgrade on the INestApplication instance at bootstrap. The decorator alone only stores reflection metadata.

      Parameters

      • name: string

        Unique tool identifier exposed to MCP clients via tools/list.

      Returns MethodDecorator

      Method decorator.

        import core from "@nestia/core";

      @Controller()
      export class WeatherController {
      /**
      * Return current weather for a city.
      *
      * @title Get weather
      */
      @core.McpRoute("get_weather")
      public async get(
      @core.McpRoute.Params() params: { city: string },
      ): Promise<{ temp: number }> {
      return { temp: 22 };
      }
      }