Skip to content

doc_index

doc_index parses a document file — Markdown, CSV, YAML, JSON, plain text — and breaks it into sections stored as graph nodes. After indexing, use doc_toc, doc_get, and doc_query to read it efficiently without loading the entire file.

doc_index(path="docs/ARCHITECTURE.md")
doc_index(path="/abs/path/to/spec.yaml")
doc_index(path="data.csv", project_root="/home/user/myproject")
ParameterTypeDefaultDescription
pathstringrequiredPath to the file to index (absolute or relative)
project_rootstringOverride the project root for relative path resolution

.md, .markdown, .csv, .txt, .rst, .toml, .yaml, .yml, .json

Code files (.ts, .rs, .py, etc.) are handled by the code graph — use code_get for those.

After indexing, the file is referenced by a doc_id derived from its path with non-alphanumeric characters replaced by _:

Pathdoc_id
docs/ARCHITECTURE.mddocs_ARCHITECTURE_md
/abs/path/to/spec.yamlabs_path_to_spec_yaml
data.csvdata_csv
# 1. Index once
doc_index(path="docs/ARCHITECTURE.md")
# 2. See structure
doc_toc(doc_id="docs_ARCHITECTURE_md")
# 3. Fetch a section (~200 tokens)
doc_get(doc_id="docs_ARCHITECTURE_md", section="Authentication")
# 4. Search across all chunks
doc_query(doc_id="docs_ARCHITECTURE_md", keyword="rate limit")

Re-run doc_index to refresh after the source file changes.