Index Content
ctx_indexIndex documentation, API references, or skill prompts into a searchable knowledge base so agents retrieve raw sections on demand instead of loading everything into context.
Instructions
Store content in a searchable knowledge base (BM25 over FTS5). Splits markdown by headings, keeps code blocks intact, persists the raw chunks. The full content stays in storage — retrieve any section on-demand via ctx_search; nothing is summarized or truncated.
WHEN:
Documentation from Context7, Skills, or MCP tools (API docs, framework guides, code examples)
API references (endpoint details, parameter specs, response schemas)
MCP tools/list output (exact tool signatures and descriptions)
Skill prompts and instructions too large to keep verbatim in conversation
README files, migration guides, changelog entries
WHEN NOT:
Log files, test output, CSV, or build output — use ctx_execute_file, which processes in-sandbox without persisting bytes
Single-use ephemeral content you will not query later — keep it inline if it fits, or ctx_execute_file it
RETURNS:
Indexing metadata: chunk counts, source label, and the exact ctx_search call shape. Raw content is NOT echoed back. With path, a content hash lets ctx_search auto-flag staleness later.
EXAMPLE: ctx_index(content: "# React useEffect\n\nThe Effect Hook lets you ...", source: "react-useeffect-docs") EXAMPLE: ctx_index(path: "/path/to/large-spec.md", source: "openapi-v2-spec")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | File OR directory path to read and index (content never enters context). Provide this OR content. Directory paths trigger a bounded recursive walk (#687). | |
| source | No | Label for the indexed content (e.g., 'Context7: React useEffect', 'Skill: frontend-design') | |
| content | No | Raw text/markdown to index. Provide this OR path, not both. | |
| exclude | No | Directory-only: glob patterns to exclude. Merged with defaults (node_modules, .git, dist, build, .next, coverage, .venv, __pycache__, .DS_Store). | |
| include | No | Directory-only: glob patterns to include (default: all matching extensions). | |
| maxDepth | No | Directory-only: max recursion depth from root (default: 5). | |
| maxFiles | No | Directory-only: hard cap on files indexed (default: 200) — FTS5 blow-up guard. | |
| extensions | No | Directory-only: allowed file extensions (default: .md .mdx .txt .json .yaml .yml .ts .tsx .js .jsx .py .rs .go .sh). | |
| followSymlinks | No | Directory-only: follow directory symlinks (default: false — cycle hazard + escape risk). | |
| respectGitignore | No | Directory-only: apply nearest .gitignore (default: true). |