Skip to main content
Glama

list_templates

Discover available image templates and their slot definitions for rendering with RendrKit's generate_image tool. Filter by tag to find templates for social posts, banners, and OG images.

Instructions

List all available image templates with their slot definitions. Use this to discover which templates exist and what slots they accept for direct rendering with generate_image.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tagNoFilter by tag (e.g. "photo", "gradient", "event", "food", "tech")

Implementation Reference

  • Main implementation of list_templates tool. Contains the registerListTemplatesTool function that registers the tool with the MCP server and includes the handler logic (async function at lines 23-75) that filters templates by tag and formats the response.
    export function registerListTemplatesTool(
      server: McpServer,
      client: RendrKitClient,
    ): void {
      server.registerTool(
        "list_templates",
        {
          description:
            "List all available image templates with their slot definitions. Use this to discover which templates exist and what slots they accept for direct rendering with generate_image.",
          inputSchema: {
            tag: z
              .string()
              .optional()
              .describe(
                'Filter by tag (e.g. "photo", "gradient", "event", "food", "tech")',
              ),
          },
        },
        async ({ tag }) => {
          try {
            const result = await client.listTemplates();
            const templates = tag
              ? result.templates.filter((t) => t.tags?.includes(tag))
              : result.templates;
    
            const lines = [
              `${templates.length} templates${tag ? ` matching tag "${tag}"` : ""} available:`,
              "",
            ];
    
            for (const t of templates) {
              const requiredSlots = t.slots
                .filter((s) => s.required)
                .map((s) => s.name);
              const optionalSlots = t.slots
                .filter((s) => !s.required)
                .map((s) => s.name);
    
              lines.push(
                `**${t.id}** — ${t.description}`,
                `  Best for: ${t.bestFor}`,
                `  Needs photo: ${t.needsPhoto}`,
                `  Tags: ${t.tags?.join(", ") || "none"}`,
                `  Required: ${requiredSlots.join(", ") || "none"}`,
                `  Optional: ${optionalSlots.join(", ") || "none"}`,
                "",
              );
            }
    
            return {
              content: [
                {
                  type: "text" as const,
                  text: lines.join("\n"),
                },
              ],
            };
          } catch (error) {
            const message =
              error instanceof Error ? error.message : String(error);
            return {
              content: [
                {
                  type: "text" as const,
                  text: `Failed to list templates: ${message}`,
                },
              ],
              isError: true,
            };
          }
        },
      );
    }
  • src/server.ts:7-22 (registration)
    Registration of the list_templates tool. Imports the registerListTemplatesTool function and calls it with the server and client instances.
    import { registerListTemplatesTool } from "./tools/list-templates.js";
    import { registerUploadImageTool } from "./tools/upload-image.js";
    import { registerBatchRenderTool } from "./tools/batch-render.js";
    import { registerCloneTemplateTool } from "./tools/clone-template.js";
    
    export function createServer(client: RendrKitClient): McpServer {
      const server = new McpServer({
        name: "rendrkit",
        version: "0.3.0",
      });
    
      registerGenerateImageTool(server, client);
      registerGetImageTool(server, client);
      registerListBrandKitsTool(server, client);
      registerGetUsageTool(server, client);
      registerListTemplatesTool(server, client);
  • Type definitions for the list_templates tool response. Includes TemplateSlot, Template, and TemplatesResponse interfaces that define the structure of template data returned by the API.
    /** A single slot definition within a template */
    export interface TemplateSlot {
      name: string;
      required: boolean;
      description: string;
    }
    
    /** A template definition */
    export interface Template {
      id: string;
      name: string;
      description: string;
      bestFor: string;
      needsPhoto: boolean;
      tags: string[];
      slots: TemplateSlot[];
      exampleSlots: Record<string, string>;
    }
    
    /** Response from the upload endpoint */
    export interface UploadResult {
      url: string;
      filename: string;
      size: number;
      mimeType: string;
    }
    
    /** Response from the templates endpoint */
    export interface TemplatesResponse {
      count: number;
      templates: Template[];
    }
  • API client helper method that makes the actual HTTP GET request to /api/v1/templates endpoint to fetch template data from the RendrKit API.
    async listTemplates(): Promise<TemplatesResponse> {
      return this.request<TemplatesResponse>("GET", "/api/v1/templates");
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vbiff/rendr-kit'

If you have feedback or need assistance with the MCP directory API, please join our Discord server