Skip to main content
Glama

delete_workflow_template

Delete a saved workflow template from ComfyUI by providing its name, enabling you to manage and remove unused templates from your collection.

Instructions

Delete a saved workflow template.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesTemplate name to delete.

Implementation Reference

  • The handler function for the 'delete_workflow_template' tool. It validates the template name, deletes the file using fs.unlink, and returns a success message.
    server.tool(
      "delete_workflow_template",
      "Delete a saved workflow template.",
      deleteSchema,
      async (args) => {
        validateName(args.name);
        try {
          await fs.unlink(templatePath(store.dir, args.name));
        } catch {
          throw new Error(`Template "${args.name}" not found.`);
        }
        return {
          content: [
            { type: "text" as const, text: `Deleted template "${args.name}".` },
          ],
        };
      },
    );
  • Input schema for delete_workflow_template, requiring a 'name' string describing the template name to delete.
    const deleteSchema = {
      name: z.string().describe("Template name to delete."),
    };
  • The tool is registered via server.tool('delete_workflow_template', ...) inside the registerTemplateTools function.
    server.tool(
      "delete_workflow_template",
      "Delete a saved workflow template.",
      deleteSchema,
      async (args) => {
        validateName(args.name);
        try {
          await fs.unlink(templatePath(store.dir, args.name));
        } catch {
          throw new Error(`Template "${args.name}" not found.`);
        }
        return {
          content: [
            { type: "text" as const, text: `Deleted template "${args.name}".` },
          ],
        };
      },
    );
  • The registerTemplateTools function (exported) registers all template tools including delete_workflow_template on the McpServer.
    export function registerTemplateTools(
      server: McpServer,
      client: ComfyUIClient,
      store: TemplateStore,
    ): void {
      server.tool(
        "save_workflow_template",
        "Save a ComfyUI workflow JSON to the server's template registry under a named slot. Overwrites are disabled by default.",
        saveSchema,
        async (args) => {
          validateName(args.name);
          const file = templatePath(store.dir, args.name);
          let existed = false;
          try {
            await fs.access(file);
            existed = true;
          } catch {
            existed = false;
          }
          if (existed && !args.overwrite) {
            throw new Error(
              `Template "${args.name}" already exists. Pass overwrite=true to replace it.`,
            );
          }
          const now = new Date().toISOString();
          let createdAt = now;
          if (existed) {
            try {
              const prior = JSON.parse(
                await fs.readFile(file, "utf-8"),
              ) as StoredTemplate;
              createdAt = prior.createdAt ?? now;
            } catch {
              // ignore parse failure, treat as fresh create
            }
          }
          const record: StoredTemplate = {
            name: args.name,
            description: args.description,
            createdAt,
            updatedAt: now,
            workflow: args.workflow as Workflow,
          };
          await fs.writeFile(file, JSON.stringify(record, null, 2));
          return {
            content: [
              {
                type: "text" as const,
                text: existed
                  ? `Updated template "${args.name}" at ${file}`
                  : `Saved template "${args.name}" at ${file}`,
              },
            ],
          };
        },
      );
    
      server.tool(
        "list_workflow_templates",
        "List all saved workflow templates in the registry.",
        listSchema,
        async () => {
          let entries: string[];
          try {
            entries = await fs.readdir(store.dir);
          } catch {
            return {
              content: [
                {
                  type: "text" as const,
                  text: `No templates directory at ${store.dir} yet.`,
                },
              ],
            };
          }
          const names = entries
            .filter((f) => f.endsWith(".json"))
            .map((f) => f.replace(/\.json$/, ""));
          if (names.length === 0) {
            return {
              content: [
                { type: "text" as const, text: "No templates saved yet." },
              ],
            };
          }
          const rows: string[] = [];
          for (const name of names.sort()) {
            try {
              const raw = await fs.readFile(
                templatePath(store.dir, name),
                "utf-8",
              );
              const t = JSON.parse(raw) as StoredTemplate;
              const desc = t.description ? ` — ${t.description}` : "";
              rows.push(`  ${t.name}${desc} (updated ${t.updatedAt})`);
            } catch {
              rows.push(`  ${name} (unreadable)`);
            }
          }
          return {
            content: [
              {
                type: "text" as const,
                text: `Saved templates (${names.length}) in ${store.dir}:\n${rows.join("\n")}`,
              },
            ],
          };
        },
      );
    
      server.tool(
        "get_workflow_template",
        "Fetch a saved workflow template's JSON and metadata.",
        getSchema,
        async (args) => {
          validateName(args.name);
          let raw: string;
          try {
            raw = await fs.readFile(templatePath(store.dir, args.name), "utf-8");
          } catch {
            throw new Error(`Template "${args.name}" not found.`);
          }
          return {
            content: [{ type: "text" as const, text: raw }],
          };
        },
      );
    
      server.tool(
        "delete_workflow_template",
        "Delete a saved workflow template.",
        deleteSchema,
        async (args) => {
          validateName(args.name);
          try {
            await fs.unlink(templatePath(store.dir, args.name));
          } catch {
            throw new Error(`Template "${args.name}" not found.`);
          }
          return {
            content: [
              { type: "text" as const, text: `Deleted template "${args.name}".` },
            ],
          };
        },
      );
  • validateName helper used to validate template names before deletion.
    function validateName(name: string): void {
      if (!TEMPLATE_NAME_PATTERN.test(name)) {
        throw new Error(
          `Invalid template name "${name}". Must start with alphanumeric; only letters, digits, '-', '_' allowed; max 64 chars.`,
        );
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It does not disclose that deletion is irreversible, whether it requires special permissions, or what happens to existing templates. This is a significant gap for a delete operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise, but it omits important details that could be included without significant bloat (e.g., irreversibility, permission needs). It is adequately sized but under-specified.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool (1 parameter, no output schema, no nested objects), the description is minimally adequate. However, it lacks any mention of consequences or safety considerations, leaving the agent incompletely informed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the parameter 'name' has a description in the schema. The tool description adds no additional semantics beyond what the schema already provides, resulting in a baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (Delete) and the resource (saved workflow template), making the tool's purpose immediately obvious. It distinguishes itself from sibling tools like save or run.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

While the operation is self-evident from the name and description, no explicit guidance is given on when to use this tool over alternatives or any prerequisites (e.g., template existence, permissions).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/miller-joe/comfyui-mcp'

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