render_prompt
Render prompt templates with specific parameters to generate structured content for automation workflows.
Instructions
Render a prompt template with the given parameters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| templateId | Yes | The ID of the template to render | |
| parameters | Yes | Parameters for the template |
Implementation Reference
- src/prompts/prompts.ts:258-289 (handler)Handler function that executes the render_prompt tool. Renders the specified prompt template with given parameters using the registry, formats the result (templateId, content, parameters) as pretty JSON in text content block, or returns an error message if rendering fails.async (args) => { try { const rendered = registry.prompts.render(args.templateId, args.parameters); return { content: [ { type: "text", text: JSON.stringify( { templateId: rendered.templateId, content: rendered.content, parameters: rendered.parameters, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error rendering prompt: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
- src/prompts/prompts.ts:254-257 (schema)Input schema (Zod) for the render_prompt tool, requiring templateId (string) and optional parameters (record).{ templateId: z.string().describe("The ID of the template to render"), parameters: z.record(z.any()).describe("Parameters for the template"), },
- src/prompts/prompts.ts:251-290 (registration)Registration of the render_prompt MCP tool on the server, specifying name, description, input schema, and handler function.server.tool( "render_prompt", "Render a prompt template with the given parameters", { templateId: z.string().describe("The ID of the template to render"), parameters: z.record(z.any()).describe("Parameters for the template"), }, async (args) => { try { const rendered = registry.prompts.render(args.templateId, args.parameters); return { content: [ { type: "text", text: JSON.stringify( { templateId: rendered.templateId, content: rendered.content, parameters: rendered.parameters, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error rendering prompt: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } } );