list-templates
Retrieve paginated lists of instance or serverless templates from private, community, or official channels for efficient resource management on the Novita MCP Server.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel | No | Channels of template to return | |
| pageNum | No | Page number to return, start from 1 | |
| pageSize | No | Number of templates to return in each page | |
| type | No | Type of template to return |
Implementation Reference
- src/tools.ts:304-326 (handler)Inline asynchronous handler function for the 'list-templates' tool. It constructs URL query parameters based on input (pageSize, pageNum, type, channel), fetches data from the '/templates' endpoint using novitaRequest, and returns the result as a text content block with JSON stringification.}, async (params) => { const queryParams = new URLSearchParams(); if (params.pageSize) queryParams.append("pageSize", params.pageSize.toString()); if (params.pageNum) queryParams.append("pageNum", params.pageNum.toString()); if (params.type) queryParams.append("type", params.type); if (params.channel) queryParams.append("channel", params.channel.join(",")); const queryString = queryParams.toString() ? `?${queryParams.toString()}` : ""; const result = await novitaRequest(`/templates${queryString}`); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; });
- src/tools.ts:283-303 (schema)Zod-based input schema definition for the 'list-templates' tool, defining optional parameters for pagination (pageSize, pageNum), filtering by type (instance/serverless), and channel (private/community/official as array).pageSize: z .number() .min(0) .default(20) .optional() .describe("Number of templates to return in each page"), pageNum: z .number() .min(0) .default(1) .optional() .describe("Page number to return, start from 1"), type: z .enum(["instance", "serverless"]) .optional() .describe("Type of template to return"), channel: z .enum(["private", "community", "official"]) .array() .optional() .describe("Channels of template to return"),
- src/tools.ts:282-326 (registration)Registration of the 'list-templates' tool on the MCP server within registerTemplateTools function, including inline schema validation and handler implementation.server.tool("list-templates", { pageSize: z .number() .min(0) .default(20) .optional() .describe("Number of templates to return in each page"), pageNum: z .number() .min(0) .default(1) .optional() .describe("Page number to return, start from 1"), type: z .enum(["instance", "serverless"]) .optional() .describe("Type of template to return"), channel: z .enum(["private", "community", "official"]) .array() .optional() .describe("Channels of template to return"), }, async (params) => { const queryParams = new URLSearchParams(); if (params.pageSize) queryParams.append("pageSize", params.pageSize.toString()); if (params.pageNum) queryParams.append("pageNum", params.pageNum.toString()); if (params.type) queryParams.append("type", params.type); if (params.channel) queryParams.append("channel", params.channel.join(",")); const queryString = queryParams.toString() ? `?${queryParams.toString()}` : ""; const result = await novitaRequest(`/templates${queryString}`); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; });