Render Mustache templates with JSON data, sections, loops, conditionals, and partials via @mukundakatta/mustache-mcp (npx) — 1 tool
Template rendering is essential for agent pipelines that generate emails, reports, notifications, code snippets, or any structured text from data. @mukundakatta/mustache-mcp wraps the Mustache.js engine as a single MCP tool with full spec support: {{variable}} interpolation, {{#section}} blocks for loops/truthy, {{^section}} for inverted/falsy, and {{>partial}} includes via an optional partials map. One tool, sub-millisecond, no auth.
Recipe: Mustache template rendering via @mukundakatta/mustache-mcp
Server: @mukundakatta/mustache-mcp v0.1.0 Transport: stdio Launch: npx @mukundakatta/mustache-mcp (or npm install + node node_modules/@mukundakatta/mustache-mcp/dist/server.js) Tools: 1 — render
Tool: render — render a Mustache template
Schema: { template: string, view: object, partials?: Record<string, string> }
template: Mustache template string with{{var}},{{#section}},{{^inverted}},{{>partial}}view: JSON data object (the "view" — NOT "data")partials: optional map of partial name → template string for{{>name}}includes
Features verified
- Variable interpolation:
{{name}}→ value from view - Sections/loops:
{{#items}}...{{/items}}iterates arrays - Conditionals:
{{#flag}}...{{/flag}}renders if truthy - Inverted sections:
{{^flag}}...{{/flag}}renders if falsy/empty - Partials:
{{>cardTemplate}}includes from partials map
Gotcha
The data parameter is view, NOT data. Using data fails with "Cannot read properties of undefined".
Verified traces
Basic interpolation:
Request: render({ template: "Hello, {{name}}! You have {{count}} new messages.", view: { name: "Alice", count: 5 } })
Response: "Hello, Alice! You have 5 new messages."Sections + loops + conditionals:
Request: render({ template: "Shopping List:\n{{#items}}\n- {{name}} (x{{qty}}){{#onSale}} ★ ON SALE{{/onSale}}\n{{/items}}", view: { items: [{ name: "Apples", qty: 3, onSale: true }, { name: "Bread", qty: 1, onSale: false }, { name: "Milk", qty: 2, onSale: true }] } })
Response: "Shopping List:\n- Apples (x3) ★ ON SALE\n- Bread (x1)\n- Milk (x2) ★ ON SALE\n"Partials:
Request: render({ template: "{{#users}}\n{{> userCard}}\n{{/users}}", view: { users: [{ name: "Bob", role: "admin" }, { name: "Eve", role: "viewer" }] }, partials: { userCard: " [{{name}}] ({{role}})\n" } })
Response: " [Bob] (admin)\n [Eve] (viewer)\n"Inverted section (falsy):
Request: render({ template: "{{#loggedIn}}Welcome back!{{/loggedIn}}{{^loggedIn}}Please log in.{{/loggedIn}}", view: { loggedIn: false } })
Response: "Please log in."All 4 Mustache features work correctly. Sub-millisecond after JIT warmup.
{ "server": "@mukundakatta/mustache-mcp", "version": "0.1.0", "transport": "stdio", "tools": ["render"], "traces": [ { "tool": "render", "label": "basic interpolation", "request": { "template": "Hello, {{name}}! You have {{count}} new messages.", "view": { "name": "Alice", "count": 5 } }, "response": "Hello, Alice! You have 5 new messages.", "success": true }, { "tool": "render", "label": "sections + loops + conditionals", "request": { "template": "Shopping List: {{#items}} - {{name}} (x{{qty}}){{#onSale}} ★ ON SALE{{/onSale}} {{/items}}", "view": { "items": [ { "name": "Apples", "qty": 3, "onSale": true }, { "name": "Bread", "qty": 1, "onSale": false }, { "name": "Milk", "qty": 2, "onSale": true } ] } }, "response": "Shopping List: - Apples (x3) ★ ON SALE - Bread (x1) - Milk (x2) ★ ON SALE ", "success": true }, { "tool": "render", "label": "partials", "request": { "template": "{{#users}} {{> userCard}} {{/users}}", "view": { "users": [ { "name": "Bob", "role": "admin" }, { "name": "Eve", "role": "viewer" } ] }, "partials": { "userCard": " [{{name}}] ({{role}}) " } }, "response": " [Bob] (admin) [Eve] (viewer) ", "success": true }, { "tool": "render", "label": "inverted section (falsy)", "request": { "template": "{{#loggedIn}}Welcome back!{{/loggedIn}}{{^loggedIn}}Please log in.{{/loggedIn}}", "view": { "loggedIn": false } }, "response": "Please log in.", "success": true } ], "gotcha": "Data parameter is 'view' not 'data' — using wrong key causes undefined property error" }