Documentation
    Preparing search index...

    Function registerMcpControllers

    • Register MCP tools from controllers.

      Registers TypeScript class methods via typia.llm.controller<Class>() or OpenAPI operations via HttpLlm.controller() as MCP tools.

      Every tool call is validated by typia. If LLM provides invalid arguments, returns IValidation.IFailure formatted by LlmJson.stringify so that LLM can correct them automatically. Below is an example of the validation error format:

      {
      "name": "John",
      "age": "twenty", // ❌ [{"path":"$input.age","expected":"number & Type<\"uint32\">"}]
      "email": "not-an-email", // ❌ [{"path":"$input.email","expected":"string & Format<\"email\">"}]
      "hobbies": "reading" // ❌ [{"path":"$input.hobbies","expected":"Array<string>"}]
      }

      If you use McpServer.registerTool() instead, you have to define Zod schema, function name, and description string manually for each tool. Also, without typia's validation feedback, LLM cannot auto-correct its mistakes, which significantly degrades tool calling performance.

      Parameters

      • props: {
            controllers: (IHttpLlmController | ILlmController<any>)[];
            preserve?: boolean;
            server:
                | McpServer
                | Server<
                    {
                        method: string;
                        params?: {
                            _meta?: {
                                "io.modelcontextprotocol/related-task"?: { taskId: string };
                                progressToken?: string | number;
                                [key: string]: unknown;
                            };
                            [key: string]: unknown;
                        };
                    },
                    {
                        method: string;
                        params?: {
                            _meta?: {
                                "io.modelcontextprotocol/related-task"?: { taskId: string };
                                progressToken?: string | number;
                                [key: string]: unknown;
                            };
                            [key: string]: unknown;
                        };
                    },
                    {
                        _meta?: {
                            "io.modelcontextprotocol/related-task"?: { taskId: string };
                            progressToken?: string | number;
                            [key: string]: unknown;
                        };
                        [key: string]: unknown;
                    },
                >;
        }

        Registration properties

        • controllers: (IHttpLlmController | ILlmController<any>)[]

          List of controllers to register as MCP tools.

          • ILlmController: from typia.llm.controller<Class>(), registers all methods of the class as tools
          • IHttpLlmController: from HttpLlm.controller(), registers all operations from OpenAPI document as tools
        • Optionalpreserve?: boolean

          Preserve existing tools registered via McpServer.registerTool().

          If true, typia tools coexist with existing McpServer tools. This uses MCP SDK's internal (private) API which may break on SDK updates.

          If false, typia tools completely replace the tool handlers, ignoring any tools registered via McpServer.registerTool().

          false
          
        • server:
              | McpServer
              | Server<
                  {
                      method: string;
                      params?: {
                          _meta?: {
                              "io.modelcontextprotocol/related-task"?: { taskId: string };
                              progressToken?: string | number;
                              [key: string]: unknown;
                          };
                          [key: string]: unknown;
                      };
                  },
                  {
                      method: string;
                      params?: {
                          _meta?: {
                              "io.modelcontextprotocol/related-task"?: { taskId: string };
                              progressToken?: string | number;
                              [key: string]: unknown;
                          };
                          [key: string]: unknown;
                      };
                  },
                  {
                      _meta?: {
                          "io.modelcontextprotocol/related-task"?: { taskId: string };
                          progressToken?: string | number;
                          [key: string]: unknown;
                      };
                      [key: string]: unknown;
                  },
              >

          Target MCP server to register tools.

          Both McpServer and raw Server are supported. To combine with McpServer.registerTool(), set preserve: true.

      Returns void