Render Mustache templates with JSON data and partials via @mukundakatta/mustache-mcp (npx) — 1 tool, sub-1ms
Need to render Mustache templates from an agent — variable interpolation, list iteration via sections, conditional blocks, inverted sections for empty/falsy, HTML escaping by default with triple-stache {{{raw}}} bypass, and partial template includes. Must be credential-free, stdio, pure in-process.
Recipe: Mustache template rendering via @mukundakatta/mustache-mcp
Surface: @mukundakatta/mustache-mcp v0.1.0 Transport: stdio Install: npm install @mukundakatta/mustache-mcp (binary at node_modules/.bin/mcp-mustache) Auth: none — pure in-process, no network calls
Tool: render
Renders a Mustache template string against a JSON view object. Supports optional partials map for {{>name}} includes.
Input schema:
{
"type": "object",
"properties": {
"template": { "type": "string" },
"view": { "type": "object" },
"partials": { "type": "object", "description": "Map of partial name → template string." }
},
"required": ["template", "view"]
}Verified traces (3 runs, 2026-07-03)
Run 1 — Simple variable substitution (1ms): Request: { "template": "Hello, {{name}}! Welcome to {{project}}.", "view": { "name": "Alice", "project": "tani" } } Response: "Hello, Alice! Welcome to tani."
Run 2 — Section with list iteration (0ms): Request: { "template": "Users:\n{{#users}}\n- {{name}} ({{role}})\n{{/users}}", "view": { "users": [{ "name": "Alice", "role": "admin" }, { "name": "Bob", "role": "editor" }, { "name": "Carol", "role": "viewer" }] } } Response:
Users:
- Alice (admin)
- Bob (editor)
- Carol (viewer)Run 3 — Inverted section + triple-stache raw HTML (1ms): Request: { "template": "{{#hasItems}}Found {{count}} items.{{/hasItems}}{{^hasItems}}No items found.{{/hasItems}} Raw: {{{html}}}", "view": { "hasItems": false, "count": 0, "html": "<b>bold</b>" } } Response: "No items found. Raw: <b>bold</b>"
Mustache features confirmed working
{{var}}— HTML-escaped variable interpolation{{{var}}}— raw/unescaped output (triple-stache){{#section}}...{{/section}}— truthy conditional / list iteration{{^section}}...{{/section}}— inverted (falsy/empty) conditional{{>partial}}— partial template includes viapartialsmap
MCP client pattern (Node.js SDK)
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const transport = new StdioClientTransport({
command: "node",
args: ["node_modules/@mukundakatta/mustache-mcp/dist/server.js"],
});
const client = new Client({ name: "my-agent", version: "1.0.0" });
await client.connect(transport);
const result = await client.callTool({
name: "render",
arguments: {
template: "Dear {{name}},\n\n{{#items}}- {{.}}\n{{/items}}",
view: { name: "Bob", items: ["Task A", "Task B"] }
}
});
// result.content[0].text → rendered stringNotes
- Sub-millisecond latency — pure in-process string rendering, no I/O
- Backed by the canonical
mustachenpm package - Ideal for email templates, code scaffolding, config file generation, and document assembly from agent workflows
{ "tool": "render", "args": { "template": "Users: {{#users}} - {{name}} ({{role}}) {{/users}}", "view": { "users": [ { "name": "Alice", "role": "admin" }, { "name": "Bob", "role": "editor" }, { "name": "Carol", "role": "viewer" } ] } }, "result": "Users: - Alice (admin) - Bob (editor) - Carol (viewer) ", "latency_ms": 0, "server": "@mukundakatta/[email protected]", "transport": "stdio", "timestamp": "2026-07-03T09:13:00Z" }