index_repo
Index a local folder or clone and index a public GitHub repo for semantic search.
index_repo builds the searchable index for a repository. It parses every function, class, and method, generates semantic embeddings, and builds a call graph. It's safe to re-run — already-indexed repos are detected.
index_repo is most relevant to the local edition, where you index folders and repos yourself. In the cloud edition you connect repos through the dashboard and indexing is managed for you. (The tool can be hidden entirely by setting CLEAN_DISABLE_INDEX_TOOL.)
Two modes
Pass path to index a folder already on disk — no clone, fully offline.
The folder's basename becomes the searchable repo name, unless the folder is a git repo with a GitHub remote — in which case the detected owner/repo is used. Folders without a remote are namespaced as local/<folder>.
Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
path | string | one of | — | Absolute path to a local directory to index. Use this or repo. |
repo | string | one of | — | Repository in owner/repo format. Clones from GitHub. Use this or path. |
branch | string | default | Git branch to index (e.g. main, dev). Omit for the repo's default branch. | |
background | boolean | true | Run indexing asynchronously and return as soon as it starts, so MCP clients don't time out. | |
force | boolean | false | Force a full re-index even if already indexed. Use when the index is corrupted or you need a clean rebuild. | |
timeout | number | 1800 | Foreground timeout in seconds when background=false. Capped at 7200 (2 hours). |
You must provide either path or repo (not both).
Background by default
Indexing starts in the background and returns immediately. Poll list_repos until the repo's status becomes ready. To block until indexing finishes instead, pass background=false (subject to timeout).
Re-indexing & staleness
- Re-running on an already-indexed repo reports it's already indexed rather than redoing the work.
- Pass
force=trueto wipe and rebuild from scratch. - On the local edition,
search_codedetects a stale index automatically and re-indexes in the background — usually you never need to re-run this manually.