Table of Contents
get_tocRetrieve a structured heading outline for a note or folder subtree in a Markdown vault. Use it to see the TOC of a note or aggregate headings across all notes under a folder.
Instructions
Heading outline for a single note or a whole folder subtree.
If 'path' ends in '.md' it is a note: returns a flat ordered list of {heading, level} (the title as a synthetic H1). Otherwise 'path' is a folder: returns {path, notes, truncated} where 'notes' is an ordered list of {path, title, headings} aggregating every note under the subtree. Mirrors the 'toc://vault/{path}' resource, adding the max_level / max_notes controls below.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Note path ("a/b.md") or folder prefix ("a/b"). | |
| max_level | No | Drop headings deeper than this level (e.g. 2 keeps H1-H2); must be >= 1. The synthetic H1 title always survives. Default None returns all levels. | |
| max_notes | No | Folder mode only — cap on distinct notes (default 200, must be >= 1). When more notes match, the first max_notes (by path) are returned and 'truncated' is True. | |
| wait_for_pending_writes | No | Wait for recent index writes. On timeout, answer from the current index with _meta.index_stale=true. Default false. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |