# Mustache variables list

`mustache-variables-list` · version 1.0.0 · Developer tools · free, no key needed

List the names and partials a Mustache template references, with tag kind, line, column and enclosing sections.

**Use when you need to: list variables in a mustache template · find mustache template placeholders · extract mustache tag names.**

## Decide before calling

Read the [versioned contract](/v1/tools/mustache-variables-list/versions/1.0.0) and the supported scope below. Reuse `mustache-variables-list@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `mustache-variables-list@1.0.0` for list variables in a mustache template. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- list variables in a mustache template
- find mustache template placeholders
- extract mustache tag names
- which data keys does a mustache template need
- list partials referenced by a mustache template
- mustache template variable discovery

## Not supported

- guessing data types or example values for the names
- rendering the template (use mustache-template-render)
- following partials into the context of the tag that includes them
- listing Handlebars helpers or Jinja expressions

## Behavior

- Parses with the Mustache specification v1.4.2 grammar (same rules and reasons as mustache-template-validate); a syntax error throws invalid_input with details {reason, partial, line, column}, and {{$...}}, {{<...}} or {{>*...}} throws unsupported_input.
- references lists every variable ({{x}}), unescaped ({{{x}}} or {{&x}}), section ({{#x}}), inverted ({{^x}}) and partial ({{>x}}) tag in document order: the main template first (partial null), then each supplied partial in code-unit order of its name.
- Each reference carries the trimmed name, 1-based line and column (code points) of its opening delimiter, and enclosing: the open sections around it in that same source, outermost first, written "#name" or "^name".
- names is the code-unit-sorted set of referenced variable and section names (partials and "." excluded); root_names is the sorted set of first dotted parts of names referenced in the main template with no enclosing "#" section, which always resolve against the root data.
- partials_referenced is the sorted set of partial names referenced anywhere; partials_missing is the subset absent from the partials map (omitted map means none supplied).
- Contexts are not composed across partial inclusion: a partial's references are reported relative to the partial itself.

## Input

- `template` (string, required): max length 65536; Mustache template text (at most 65536 UTF-8 bytes).
- `partials` (object, optional): Optional map from partial name to template text; each is scanned. Omitted means none.

## Output

- `references` (array of object, required)
- `names` (array of string, required)
- `root_names` (array of string, required)
- `partials_referenced` (array of string, required)
- `partials_missing` (array of string, required)

## Limits

- max template bytes: 65536
- max partials: 32
- max tags: 10000
- max section depth: 32
- max output bytes: 1048576

## Example

Request input:

```json
{
  "template": "\"{{#a}}{{b.c.d.e.name}}{{/a}}\" == \"Phil\""
}
```

Response:

```json
{
  "result": {
    "references": [
      {
        "partial": null,
        "kind": "section",
        "name": "a",
        "line": 1,
        "column": 2,
        "enclosing": []
      },
      {
        "partial": null,
        "kind": "variable",
        "name": "b.c.d.e.name",
        "line": 1,
        "column": 8,
        "enclosing": [
          "#a"
        ]
      }
    ],
    "names": [
      "a",
      "b.c.d.e.name"
    ],
    "root_names": [
      "a"
    ],
    "partials_referenced": [],
    "partials_missing": []
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "mustache-variables-list",
  "version": "1.0.0",
  "input": {
    "template": "\"{{#a}}{{b.c.d.e.name}}{{/a}}\" == \"Phil\""
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/mustache-variables-list/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"template":"\"{{#a}}{{b.c.d.e.name}}{{/a}}\" == \"Phil\""}'
```

The machine-readable contract is at [/v1/tools/mustache-variables-list/versions/1.0.0](/v1/tools/mustache-variables-list/versions/1.0.0).

### CLI

```sh
node cli.mjs run mustache-variables-list 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Mustache template render](/tools/mustache-template-render): Render a logic-less Mustache template (spec v1.4.2) with JSON data and inline partials; returns the exact text.
- [Mustache template validate](/tools/mustache-template-validate): Check Mustache template syntax (spec v1.4.2) and its partials; returns valid or the first error with line and column.
- [Openapi operation extract](/tools/openapi-operation-extract): Extract one OpenAPI operation, merge inherited parameters, and return its local component-reference closure.
- [Sql statements split](/tools/sql-statements-split): Split SQL text into exact statement spans with explicit PostgreSQL, MySQL, or SQLite lexical rules.
- [Commit conventional parse](/tools/commit-conventional-parse): Parse one Conventional Commits 1.0.0 message into its header, body, footers, and breaking-change status.
- [Editorconfig resolve](/tools/editorconfig-resolve): Resolve EditorConfig properties for one normalized relative POSIX path from caller-supplied file contents.
