@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 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 and the JSON
Schema attached to inputSchema in tools/list responses.
For the MCP endpoint to actually be served, call McpAdaptor.upgrade on
the INestApplication instance at bootstrap. The decorator alone only
stores reflection metadata.
Example:
importcorefrom"@nestia/core";
@Controller() exportclassWeatherController { /** * Return current weather for a city. * * @title Get weather */ @core.McpRoute("get_weather") publicasyncget( @core.McpRoute.Params() params: { city: string }, ): Promise<{ temp: number }> { return { temp:22 }; } }
Parameters
name: string
Unique tool identifier exposed to MCP clients via tools/list.
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 through the standard Streamable HTTP transport.The public form takes only the tool's
name(string). Human-readabledescriptionandtitleare read from the method's JSDoc:description: the JSDoc comment body.title: the value of an optional@titleJSDoc tag.For type-safe tool inputs, decorate exactly one parameter of the method with McpRoute.Params. The parameter type
Tis analyzed at compile time by the nestia transformer, which generates both a runtime validator and the JSON Schema attached toinputSchemaintools/listresponses.For the MCP endpoint to actually be served, call McpAdaptor.upgrade on the INestApplication instance at bootstrap. The decorator alone only stores reflection metadata.
Example: