Get Discovered IVR Tree
getMappingTreeGet the discovered IVR tree structure for a mapping job — every node visited, the DTMF/voice paths between them, audio recordings, and (if enrichment ran) IVR menu transcripts and probe classifications.
USE WHEN:
- User asks for the discovered tree / map / structure of an IVR
- User wants leaf-node count, depth, or aggregate tree statistics (use `format=flat`)
- User wants to inspect specific tree-node fields (voice prompts, probe classifications, audio URLs)
- User wants to compare two historical runs (call twice with different `version`)
BEST CALLED: after `currentRun.status === 'completed'` (from getMapping). If you call earlier and
the run is still active, the response will document that via `reason: 'in_progress'` (see below).
QUERY PARAMS (optional):
- format: `tree` (default) = hierarchical nesting; `flat` = array of nodes with depth/path fields
for aggregation. Use `flat` for "how many leaves?" / "how deep?" / "list all voice prompts" questions.
- version: Run number (1-indexed) — fetches the tree of that historical run. Default: latest run.
RESPONSE — SUCCESS (tree built from steps):
- jobId, runId, runNumber, status, stats: identifiers + run-level summary.
- tree (when `format=tree`): a hierarchical TreeNode with .children[] recursion.
- steps (when `format=flat`): an array of TreeNode (each with empty .children, depth, path).
TreeNode fields (each is OPTIONAL — omitted when absent; never null per the AJV contract):
- stepId, digit, label, depth, path, status, transcript, isTerminal, children, duration
- stepType: 'dtmf' | 'voice' — interaction type (Phase 30 voice-agent)
- voicePrompt: spoken prompt text at this node (voice nodes only)
- menuLabel: semantic tag emitted per bot turn (e.g. 'greeting', 'capabilities_listed', 'balance_captured'); from Phase 55 voice-agent enrichment
- spokenResponse: what the agent said back at this turn (Phase 55 voice-agent)
- probeCategory / probeClassification / probeRationale: probe-enrichment fields (Phase 31). Only present
after probe enrichment ran. Trigger probes via REST POST /mapping/{id}/runs/{runId}/probe (not exposed
via MCP today).
- audioUrl: presigned S3 URL for the recorded audio of this step. **Valid for approximately 1 hour.
Do not cache or store** — re-call getMappingTree to refresh URLs for long sessions.
- inputRequired: per-step UX hint when a prompt requires user input. Contains type, description,
formatHint, terminator, startTimeMs.
RESPONSE — EMPTY-STATE ENVELOPE (200 OK, tree: null):
The handler returns 200 with `tree: null` and a `reason` discriminator in three cases:
- `reason: 'no_runs'` — the job has never been started. Message suggests POST /mapping/{id}/start.
- `reason: 'no_steps'` — a run started but no steps recorded yet. May still be initialising; retry shortly.
- `reason: 'in_progress'` — the latest run is still active and only the root step has been recorded.
Don't treat the current tree as complete. Retry shortly OR ask getMapping for `currentRun.status` to confirm.
All three empty-state cases return 200 OK with the same envelope shape; only `reason` + `message` differ.
USAGE PATTERNS:
- "Show me the IVR tree for mapping <id>" → getMappingTree { id }
- "How many leaves does mapping <id> have?" → getMappingTree { id, format: 'flat' } then filter steps where children.length === 0 OR isTerminal === true
- "How deep is the tree?" → getMappingTree { id, format: 'flat' } then max(steps[].depth)
- "What voice prompts did mapping <id> discover?" → getMappingTree { id, format: 'flat' } then filter where stepType === 'voice' or voicePrompt is present
- "Show me run 1's tree" → getMappingTree { id, version: 1 }
- "What probe classifications fired?" → getMappingTree { id } then walk tree filtering nodes where probeClassification is present
RELATED TOOLS:
- getMapping — job + run metadata, including `currentRun.status` (check this before deciding the tree is "done")
- listMappings — find jobs by phoneNumber/status/tag if you don't have the id
- REST GET /mapping/{id}/runs — run history (REST-only today; useful for picking a `version` for historical tree fetches)
ERRORS:
- 404: job does not exist or belongs to another workspace (cross-workspace 404 by design — do not retry)
- 400: invalid version (non-integer or < 1) OR invalid format (not 'tree' or 'flat')
- 404: requested version not found
- 200 + reason: 'no_runs' | 'no_steps' | 'in_progress' — NOT errors; empty-state envelope (see above)Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>"
},
"name": "getMappingTree"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Mapping job UUID. Find via listMappings if unknown. | |
| format | No | Response shape. `tree` = hierarchical nesting (default). `flat` = array of nodes with depth/path fields for aggregation. | tree |
| version | No | Run number (1-indexed) — fetches the tree of that historical run. Default: latest run. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||