get_workflow_template
Retrieve JSON configuration and metadata of a saved workflow template by providing its name.
Instructions
Fetch a saved workflow template's JSON and metadata.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Template name. |
Implementation Reference
- src/tools/templates.ts:180-196 (handler)The handler function for the 'get_workflow_template' tool. It reads a saved workflow template JSON file from disk by name and returns its raw contents as text.
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 }], }; }, ); - src/tools/templates.ts:58-60 (schema)The input schema for 'get_workflow_template': expects a single required string parameter 'name' describing the template name.
const getSchema = { name: z.string().describe("Template name."), }; - src/tools/templates.ts:180-196 (registration)Registration of the 'get_workflow_template' tool on the MCP server via server.tool() inside registerTemplateTools(), with its schema and handler.
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 }], }; }, ); - src/tools/templates.ts:18-20 (helper)Helper function templatePath() used to build the file path for a given template name.
function templatePath(dir: string, name: string): string { return path.join(dir, `${name}.json`); } - src/tools/templates.ts:22-28 (helper)Helper function validateName() used to validate the template name against the allowed pattern.
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.`, ); } }