Skip to content
Projects

Regsorm/code-index-mcp

View on GitHub

About

Поиск по коду для ИИ-агентов: 32 инструмента MCP, индекс на SQLite, один бинарник без зависимостей. Разбирает выгрузки 1С:Предприятие — Конфигуратор и EDT; конфигурация на 88 тыс. файлов индексируется за 6 минут, ответ на запрос — 10 мс. Code index MCP server: tree-sitter AST for 14 languages, 20 universal tools + 12 for 1C/BSL.

Developer Tools

How these counts are measured

Measured star growth

in 24h
+3
in 7 days
+6
in 15 days
+9
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README_EN.md

Original
Infostart

Published on Infostart: Code Index — структурный поиск по выгрузке кода 1С через MCP


code-index-mcp

Русская витрина · Full Russian manual

Rust-native code index for AI agents. Static binary. Production-grade BSL/1C support.

One static binary for Windows/Linux/macOS — no runtime, no dependencies. Indexes large repositories in seconds, returns results to AI agents over MCP in milliseconds. 42 tools: 25 universal + 17 BSL-specific for 1C:Enterprise configurations.

What's inside

  • Performance. An 88K-file accounting configuration indexes from scratch in 5 min 51 s, starts up on an existing index in 5.3 s, and answers a query in about 10 ms. Production-grade for 100K+ file monorepos.
  • 37 MCP tools. 20 universal (functions, classes, callers/callees, file content, grep) + 17 BSL-tools (object structure & profile, form handlers, event subscriptions, call graph, call-site context and code skeleton (query_call_sites, get_node_structure, get_line_context), data links, register writers, posting mechanism map, role rights, impact map, data composition schema, read-only SQL).
  • Native BSL/1C. Parses both Configurator (XML) and 1C:EDT (.mdo) exports of 1C:Enterprise 8.3 configurations. Data-link graph (object→object edges via reference types in attributes) — 65,421 edges for a typical accounting configuration.
  • Federation. One MCP server can serve multiple repositories across machines — pass repo: "alias" in each tool call.
  • Compressed content storage. File contents stored in SQLite via zstd, cheap random-access reads for AI agents.
  • Tree-sitter AST. 14 languages with full parsing (Python, JavaScript, TypeScript, Java, Rust, Go, PHP, C, C++, C#, Ruby, Swift, 1C (BSL), HTML) + full-text indexing for 50+ text formats.

Connects to Claude Code, Cursor, any MCP client over HTTP.

Object names and paths account for Unicode NFC and NFD forms, including those found on macOS. Physical paths retain their on-disk spelling; when several files share a normalized name, use the exact path. To recover structures and links missed by an older indexer in an NFD export, run bsl-indexer index <path> --force (data version 6) after stopping processes using the index.

Problem

AI models waste enormous time on repeated grep/find calls just to locate a single symbol. A real example: finding RuntimeErrorProcessing in a Java project required 14 sequential grep/find calls, each scanning thousands of files. With Code Index, that is one query returning results in under a millisecond.

Solution

A compiled Rust binary with one-writer / many-readers architecture:

  1. Parses source code into AST via tree-sitter
  2. Indexes everything into SQLite with FTS5 full-text search
  3. A separate background daemon is the sole writer: one process per machine watches a list of folders from its config and keeps .code-index/index.db up to date.
  4. The MCP server is a thin read-only client: any number of Claude Code / VS Code / subagent sessions can connect to the same project in parallel — no pidlock conflicts, no per-session re-indexing.

Supported Languages

Language Parser Extensions
Python tree-sitter-python .py
JavaScript tree-sitter-javascript .js, .jsx
TypeScript tree-sitter-typescript .ts, .tsx
Java tree-sitter-java .java
Rust tree-sitter-rust .rs
Go tree-sitter-go .go
PHP tree-sitter-php .php, .php5, .phtml (v0.46.0)
C tree-sitter-c .c, .h (v0.46.0)
C++ tree-sitter-cpp .cpp, .cxx, .cc, .hpp, .hxx, .hh (v0.46.0)
C# tree-sitter-c-sharp .cs (v0.46.0)
Ruby tree-sitter-ruby .rb (v0.46.0)
Swift tree-sitter-swift .swift (v0.46.0)
1C (BSL) tree-sitter-bsl .bsl, .os
XML (1C) quick-xml .xml (configuration metadata)
1C:EDT metadata quick-xml .mdo, .form, .rights (v0.53.0), .dcs — composition schemas and template passports (v1.3.0)
HTML tree-sitter-html .html, .htm (v0.7.1, by user request — see HTML-specific mapping below)

.h is ambiguous between C and C++: it is parsed as C++ when the repository language is cpp, otherwise as C. The repository language is taken from daemon.toml or auto-detected by the prevailing extension.

PHP, C, C++, C#, Ruby and Swift are dual-indexed (like HTML): AST parsing plus raw content in text_files, so search_text / grep_text keep working on them alongside structured queries.

Text files (.md, .json, .yaml, .toml, .xml, .sql, .env, etc.) are also indexed for full-text search.

HTML — entity mapping (v0.7.2)

HTML has no native concept of "function" or "class", so the mapping is conventional. Dual-indexing: html files go through both AST parser AND text_files (so search_text / grep_text / read_file keep working alongside the new structural queries).

HTML → code-index table Name
<element id="X">…</element> → classes X (body=outerHTML, bases=tag_name)
`<form id name="X">` → classes
<form> without id/name → classes form_<line>
<input/select/textarea name="Y"> → variables Y
<a href="URL"> → imports module=URL, kind="link"
<link href="URL" rel="X"> → imports module=URL, kind=X (or "stylesheet")
<script src="URL"> → imports module=URL, kind="script"
<img/iframe/video/audio/source/embed src="URL"> → imports module=URL, kind=tag
<script>…inline JS…</script> → functions inline_script_<line> (body=content)
<style>…inline CSS…</style> → functions inline_style_<line> (body=content)
Attribute class="foo bar baz" → variables class:foo, class:bar, class:baz (one record per class)

All MCP tools that work for HTML files after re-indexing:

# === Discovery & metadata ===
list_files(repo="X", pattern="**/*.html")                # all html (returns language="html")
list_files(repo="X", path_prefix="src/templates/")
stat_file(repo="X", path="src/templates/base.html")      # returns language="html", category="text"
get_stats(repo="X")                                       # totals

# === Structural (AST) — new in 0.7.x ===
# Elements with id, forms, css-classes, links, inline blocks → AST tables
get_class(repo="X", name="cart")                          # outerHTML of <... id="cart">
get_class(repo="X", name="form_login")                    # full <form id="login">
search_class(repo="X", query="container", language="html")
get_function(repo="X", name="inline_script_42")           # body of <script> at line 42
search_function(repo="X", query="inline_script", language="html")
find_symbol(repo="X", name="form_login")                  # exact-name lookup across all 4 tables
find_symbol(repo="X", name="class:htmx-indicator")        # CSS class usage
get_imports(repo="X", module="https://unpkg.com/[email protected]")  # who depends on this CDN
get_file_summary(repo="X", path="src/templates/base.html")         # full map (functions/classes/imports/variables)

# === Body-level grep (works on inline_script bodies) ===
grep_body(repo="X", regex="fetch\\(", language="html")    # in <script> blocks
grep_body(repo="X", pattern="color:", language="html")    # in <style> blocks
grep_body(repo="X", regex="hx-target", language="html", path_glob="src/templates/**", context_lines=2)

# === Text-level (still works via dual-indexing) ===
read_file(repo="X", path="src/templates/base.html", line_start=1, line_end=20)
search_text(repo="X", query="DOCTYPE", language="html")
grep_text(repo="X", regex="\\{%\\s*include", path_glob="**/*.html", context_lines=1)  # Jinja includes

get_callers / get_callees are not populated for HTML (the parser does not extract call edges between scripts).

Template engines (Jinja/Django/EJS): {{ … }} and {% … %} are tolerated as text content; surrounding HTML elements are still parsed normally.

Quick Start

Install via npm (easiest)

npm install -g @regsorm/code-index-mcp

The postinstall step downloads the prebuilt native binary for your platform (Windows x64, Linux x64, macOS arm64) from GitHub Releases — nothing is compiled. Then run it as an MCP server:

npx @regsorm/code-index-mcp serve --path /path/to/your/repo

Also published to the official MCP Registry as io.github.Regsorm/code-index. This wrapper ships only the public code-index binary (no 1C support); for bsl-indexer take the release archive from GitHub or build from source.

serve only reads the index — the background daemon builds it. Without a running daemon (npx @regsorm/code-index-mcp daemon run) and the CODE_INDEX_HOME variable, tools answer daemon_offline; see Set up the background daemon.

Manual installation, step by step (Windows)

No npm, no scripts: download the release archive, put the file into a folder, create daemon.toml, start, connect a client, set up autostart — docs/manual-install_EN.md.

Build from source

git clone https://github.com/Regsorm/code-index-mcp.git
cd code-index-mcp
cargo build --release -p code-index               # public binary for Python/Rust/Go/Java/JS/TS
cargo build --release -p bsl-indexer --features enrichment   # extra build with 1C support + LLM enrichment

Binaries:

  • target/release/code-index[.exe] — main binary (no 1C support).
  • target/release/bsl-indexer[.exe] — full 1C support (XML metadata parsers, BSL call graph, data-links graph, MCP tools get_object_structure / get_form_handlers / find_path_bsl / search_terms / get_data_links / find_data_path / get_register_writers, optional LLM enrichment under cargo feature enrichment).

GitHub Releases publish 6 ready artifacts per tag: code-index × {Win, Linux, macOS} + bsl-indexer × {Win, Linux, macOS}.

Set up the background daemon (v0.5+)

Portable layout: one folder for everything (binary + config + runtime files). Pointed to by CODE_INDEX_HOME env var.

  1. Create the daemon folder and drop code-index.exe into it (e.g. C:\tools\code-index\).

  2. Set the CODE_INDEX_HOME environment variable to point at that folder:

    Windows (persistent, user scope):

    setx CODE_INDEX_HOME "C:\tools\code-index"
    # Reopen your shell so the variable is visible.
    

    Linux — add to ~/.bashrc or ~/.zshrc:

    export CODE_INDEX_HOME="$HOME/.local/code-index"
    

    macOS — same as Linux for shells; for launchd agents use launchctl setenv.

    Any OS — per-project fallback via .mcp.json (no system env var needed):

    {
      "mcpServers": {
        "code-index": {
          "command": "C:\\tools\\code-index\\code-index.exe",
          "args": ["serve", "--path", "."],
          "env": { "CODE_INDEX_HOME": "C:\\tools\\code-index" }
        }
      }
    }
    
  3. Create daemon.toml inside that folder and list the paths to watch:

    [daemon]
    http_port = 0                  # 0 = pick free port automatically
    max_concurrent_initial = 1     # folders processed sequentially during initial indexing
    
    [[paths]]
    path = "C:\\Repo1C"
    
    [[paths]]
    path = "C:\\Repo1C-2"
    debounce_ms = 500              # per-folder override: react faster than the default 1500 ms
    batch_ms    = 1000
    

    Per-folder debounce_ms / batch_ms are optional. If omitted, the daemon falls back to .code-index/config.json inside that project, and then to built-in defaults (1500 ms / 2000 ms).

  4. Start the daemon (foreground):

    code-index daemon run
    

    Or install it as a Windows Scheduled Task (auto-start at user logon; the script also sets CODE_INDEX_HOME via setx):

    powershell -ExecutionPolicy Bypass -File scripts\install-daemon-autostart.ps1 `
      -BinaryPath "C:\tools\code-index\code-index.exe" `
      -CodeIndexHome "C:\tools\code-index" `
      -StartNow
    
  5. Check status:

    code-index daemon status        # human-readable
    code-index daemon status --json # JSON
    code-index daemon reload        # re-read daemon.toml after edits
    code-index daemon stop
    

CODE_INDEX_HOME is required — there is no fallback. If it is unset, daemon run exits with an error showing how to set it. serve still starts, but answers every tool call with daemon_offline carrying the same explanation.

Troubleshooting — "daemon not running / runtime-info missing" even though the daemon IS running.

The serve process and the daemon find each other only through $CODE_INDEX_HOME/daemon.json. If serve sees a different (or empty) CODE_INDEX_HOME than the daemon, it looks for daemon.json in the wrong place and reports the daemon as offline — while it is actually alive.

The most common cause on Linux/macOS: GUI MCP clients (VS Code, Continue, Cline) do not read ~/.bashrc / ~/.zshrc, so a serve they launch with an empty env never sees the CODE_INDEX_HOME you exported in your shell. Meanwhile the daemon, started from a terminal, does — so they end up pointing at different folders.

Fix: set CODE_INDEX_HOME explicitly in the env section of the client's MCP config, using the same absolute path the daemon uses ($HOME is not expanded there — use a real path). Restart the client and verify with code-index daemon status.

One-shot indexing (no daemon)

code-index index /path/to/project
code-index stats --path /path/to/project --json

The CLI commands read the ready index. The MCP server (serve) still needs the daemon: without it tools answer daemon_offline even when .code-index/index.db is already built.

Run as MCP server (read-only)

code-index serve --path /path/to/project

This is a thin read-only client of the daemon. It does not index anything itself — the daemon does. If the folder is still being indexed or not in daemon.toml, tools return a structured {status, message, progress} response instead of failing.

Transports (stdio vs HTTP)

serve supports two transports. In both, the daemon builds the index and must be running. The HTTP server is built into the binary itself — no separate web server is needed; it binds to 127.0.0.1 by default.

Transport Process model When to use
stdio (default) One serve process per MCP session Simple setups, single client, ad-hoc runs
http (streamable) One shared serve process, many clients over http://host:port/mcp Multi-project setups, supervisor-managed services, avoiding per-session CLI duplication
# stdio — per-session, alias set at CLI
code-index serve --path ut=/repos/ut --path bp=/repos/bp

# HTTP — shared process, aliases come from daemon.toml
code-index serve --transport http --port 8011 --config /etc/code-index/daemon.toml

--path can be repeated in alias=dir form (multi-repo mode). Each tool call takes a repo parameter to select which repository to query. Without =, the single path uses alias=default (backward-compatible).

For stdio, each folder in --path must be listed in daemon.toml (path letter case does not matter), otherwise the answer is not_started asking to add the path and run daemon reload. The alias comes from --path, not from daemon.toml; a call with an alias the server does not know gets unknown_repo with the list of available ones.

In HTTP mode, if --config is provided, aliases are taken from [[paths]] entries of daemon.toml: explicit alias = "...", or derived from the path's last segment (lowercased, spaces → _) when not set. CLI --path takes precedence over the config file.

For a shared HTTP server on a dedicated machine there is a repository admin web panel: repositories with status and sizes, adding from git, ZIP or a directory, deletion — without editing daemon.toml by hand.

Connecting to Claude Code

Add to .mcp.json in your project root. For stdio (daemon running, project folder listed in daemon.toml):

{
  "mcpServers": {
    "code-index": {
      "command": "npx",
      "args": ["-y", "@regsorm/code-index-mcp", "serve", "--path", "."],
      "env": { "CODE_INDEX_HOME": "C:\\tools\\code-index" }
    }
  }
}

CODE_INDEX_HOME in env is the same absolute path the daemon uses: the client may not see the system variable.

For a shared HTTP process:

{
  "mcpServers": {
    "code-index": {
      "type": "http",
      "url": "http://127.0.0.1:8011/mcp"
    }
  }
}

Guard: reading through the index (optional)

code-index-guard is a PreToolUse hook for Claude Code and Codex CLI from the same workspace (crates/code-index-guard). It denies native Read/Grep/Glob and shell reads (cat, rg, Get-Content, …) only for files the index actually serves, and points the model to the code-index tool instead. A new, not yet indexed, excluded or oversized file is read as usual. Indexed folders come from daemon.toml; hook events can optionally be written to an SQLite database (the events_db key). Build: cargo build --release -p code-index-guard; install and configuration — crates/code-index-guard/README.md (in Russian).

Copying a project with its ready index

code-index-copy from the same workspace (crates/code-index-copy) copies the root of a git working tree — the files under version control with their modification times, or a git worktree on a new branch — and carries .code-index/index.db over via SQLite backup. On start the copy's daemon only reconciles files against the database and re-parses nothing. Source files outside git are removed from the copy's database with their cells overwritten; the copy's index configs (daemon.toml with [[cache_targets]], serve.toml) are written with --index-home. The report is one JSON line. Build: cargo build --release -p code-index-copy; options and exit codes — crates/code-index-copy/README.md (in Russian).

MCP Tools

For 1C, find_symbol matches variable names case-insensitively and returns file paths for variables and imports. get_role_rights accepts a role such as role="Роль.полныеправа". get_form_handlers matches the owner, form and element regardless of case or Unicode normalization form. get_event_subscriptions does the same for events and handler modules. Responses retain spelling from the index.

Tool Description
search_function Full-text search across functions (name, docstring, body)
search_class Full-text search across classes
get_function Get function by exact name (case-insensitive fallback; (v0.44.0) on 0 matches returns did_you_mean with similar names)
get_class Get class by exact name (case-insensitive fallback; (v0.44.0) on 0 matches returns did_you_mean with similar names)
get_object_structure Structure of a 1C object. v0.63.0: object templates are now in the registry — a row Catalog.X.Template.Y with the owner, the template kind and a content_indexed flag (large templates stay out of the index, yet the template itself is visible and findable by name)
get_callers Who calls this function? (v0.35.0) each row carries the caller's source path (distinguishes same-named callers from different files). v0.62.0: for 1C configurations, form event handler bindings (kind: form_binding) are added to the code callers — such a procedure is run by the platform per an entry in the form description and has no call in the code; when the name belongs to several procedures, a single record with a sample get_form_handlers call arrives instead of a list. v1.2.0: for 1C configurations, qualified calls are found as well — CommonModule.Method, Catalogs.Object.Method, and Variable.Method from a form module when the method is exported from the object module of that form (a variable holding FormAttributeToValue("Object")); previously a bare name found only unqualified calls. v1.10.0: bindings now also cover event subscriptions (kind: subscription, listing the source objects), extension overrides in both directions (extension_override — "this procedure overrides a base one", extension_override_target — "this procedure is overridden by an extension") and handlers the platform calls by naming convention (kind: platform_convention: document posting and unposting, fill, write events, command handler, manager form choice). The file path identifies the module kind in both Designer and EDT exports, including common forms, so a same-named procedure in a common module is not treated as a platform handler. v1.13.0: path_glob scopes the result by the caller's file path (SQL pushdown); when several functions share the name, the response carries ambiguous_name — how many definitions there are, their qualified_name, path and line
get_callees What does this function call? (v0.35.0) each row carries the source path. v1.2.0: in 1C, for a call with a receiver (ОбработкаОбъект.Метод, CommonModule.Method) callee_path/callee_line come from the call graph binding. v1.13.0: path_glob filters by the calling file's path; on an ambiguous name the response carries ambiguous_name with the definitions
find_path (v0.23.0) Shortest path in the call graph between two functions from→to (iterative cycle-safe BFS over unique calls nodes, max_depth=5, any language). Returns path edges [{caller, callee, line}]. v0.57.0: an empty answer carries walk cut-off flags walk_depth_exhausted / walk_nodes_capped, and the hint distinguishes «hit the node cap», «ran out of depth» and «exhausted the reachable subgraph» — all three used to look like «no path». v1.2.0: in 1C the path continues through a call with a receiver — with the procedure the call graph bound it to
get_call_tree (v0.23.0) Call tree from a root function up to max_depth (default 3). direction: callees/down (downstream) or callers/up. Flat edge list [{caller, callee, line, depth, path}] ((v0.35.0) path = source file of each edge) + nested {name, children} tree; max_nodes cap. v1.2.0: in 1C qualified calls are added upwards (as in get_callers), and downwards a call with a receiver continues with the bound procedure; tree nodes are procedure names. v1.2.2: the response is size-limited (48 KB by default): the farthest edges are dropped, there is no tree field, the response carries truncated, edges_total, edges_shown and a hint on how to get the rest; max_response_bytes — the budget for one call. v1.13.0: depth is accepted as a synonym of max_depth
find_symbol Search everywhere (functions, classes, variables, imports)
get_imports Imports by module or file
get_file_summary Complete file map without reading source
get_stats Index statistics
search_text Full-text search across text files
grep_body Substring or regex search in function/class bodies. Returns match_lines (first 3 line numbers) and match_count (total, if > 3). v0.7.0: optional path_glob, context_lines. v1.13.0: glob is accepted as a synonym of path_glob
stat_file (v0.7.0) Metadata of a single file: exists, size, mtime, language, lines_total, content_hash, indexed_at, category (text/code). (v0.8.0) adds oversize: bool for code files
list_files (v0.7.0) Flat file listing with optional pattern (glob like **/*.py), path_prefix, language, limit. v0.49.8: limit defaults to 500; when more files match, the response carries {truncated, total, shown, limit} — previously the listing was cut off silently and looked complete
read_file (v0.7.0) Read content of a file. Optional line_start/line_end (1-based, inclusive; v1.13.0 — synonyms start_line/end_line). Soft-cap 5000 lines or 500 KB, hard-cap 2 MB. (v0.8.0) works for code files too (.py, .bsl, .rs, .ts, etc.) — content stored in file_contents table (zstd). Oversize files (default > 5 MB) return oversize: true with an empty content and a hint
grep_text (v0.7.0) Regex search over text-file content (REGEXP). Closes the FTS5 special-character gap. Optional path_glob, language, context_lines. Hard-cap 1 MB on response size. v1.13.0: glob is accepted as a synonym of path_glob
grep_code (v0.8.0) Regex search over code-file content (.py, .bsl, .rs, .ts, etc.) via file_contents table (zstd-decode in Rust). Same parameters as grep_text: regex, path_glob?, language?, limit?, context_lines?. Since v0.66.0 both tools also accept pattern — a literal, case-insensitive substring (escaped before the search), the same meaning it has in grep_body. Complements grep_body (which searches only inside function/class bodies). Oversize files are skipped. v1.13.0: glob is accepted as a synonym of path_glob
health MCP server health and connected repos. brief=true returns the version, daemon status and repos_summary counts by status. Remote repos are counted as remote, and local repos are counted as unknown when the daemon is offline
git_log (v1.15.0) Commit history: repo, rev? (hash/branch/tag/local date, default HEAD), path? (literal index-root path), limit? (default 20). Returns the resolved revision {input, resolved_hash, hash, date, subject, resolved_as, timezone, resolved_at} and commits[] with hash/short/date/author/subject; total counts the whole matching history before truncation
git_changed_files (v1.15.0) Changed files between from/to snapshots (revision or local date): A/M/D/R/C statuses (T reported as M), old_path for renames, insertions/deletions (binary files: binary: true, zero contribution), path_glob?, limit? (default 200). files_changed and sums are computed after filtering and before truncation; equal hashes yield empty_range: true
git_changes_by_object (v1.15.0) The same changes grouped by 1C metadata objects: metadata_modules (index-root-relative code_path, rows stored under REPO_DEFAULT), otherwise the base/<Category>/<Name>/…, extensions/<Name>/… and External/<Name>/… layout, unknown paths become ungrouped. meta_type only from a known category (Extension for extensions, first name segment for metadata_modules). limit? (default 100), include_files? (default false); totals and objects_total are always complete, paths carry paths_truncated
git_diff (v1.15.0) Unified diff of one file: required path, from/to, context_lines? (default 3), max_chars? (default 20000). Returns status/insertions/deletions/patch; renames include both sides, binary content is not decoded; a path absent from both snapshots is an error, an unchanged one gives an empty patch
git_show_file (v1.15.0) Historical file content show <rev>:<path>: rev? (default HEAD), line_start?/line_end? (1-based inclusive), max_chars? (default 20000). lines_total is counted before the range and truncation; a directory, a missing path and binary/undecodable content are structured errors

All search tools (search_function, search_class, get_function, get_class, find_symbol, search_text, grep_body) accept an optional path_glob parameter (v0.7.0) to scope results to a subtree (e.g., src/auth/**, Documents/**/*.bsl). Implementation: post-filter via the globset crate after the SQL query. Since v0.32.0, path_glob/pattern support {a,b} brace alternates (**/*.{bsl,xml}) — including in grep_code/grep_text/grep_body/list_files, where the filter runs at the SQLite GLOB level (the pattern is expanded into an OR group of conditions). In search_function/search_class/search_text the post-filter runs after records are fetched by relevance, so a scoped result may be incomplete; since v0.49.8 such a response carries prefilter_exhausted together with prefetched/shown — on non-empty results too, not only on empty ones.

Git layer: history and changes (v1.15.0)

Git tools are enabled per [[paths]] entry with git = true. git_path points at the repository when it differs from path (for example, the index is built from an export subdirectory while the work tree lives above). Without git = true the tools answer with “git layer for repository is not enabled”, and a configured git_path is ignored with a warning in the log.

[[paths]]
path = "/srv/export/base"        # index root
alias = "ut"
git = true
git_path = "/srv/export"         # optional: where the work tree lives
  • Dates and timezone. Besides a revision (rev, from, to) the tools accept strictly YYYY-MM-DD, YYYY-MM-DD HH:MM and YYYY-MM-DDTHH:MM. The zone can be set with the tz parameter (+03:00 or UTC); without it a date is expanded in the local zone of the executing machine (UTC inside the node container): to/rev — 23:59:59, from — 00:00:00. to is resolved first against HEAD, then from against the resolved to; no implicit merge-base is used. A non-existent or ambiguous local moment is an error, and so is the absence of a commit before the bound (the error names the date and the upper bound). Every response carries the original input, resolved_hash (plus the compatible hash duplicate), date, subject, resolved_as (rev/date), timezone and resolved_at. Note: inside the node container the local zone is UTC, so the day boundary is shifted relative to the Moscow time of the auto-commits — check timezone in the response.
  • Coordinates. All paths are literal, relative to the index root; absolute paths, NUL and .. escapes are rejected, and a historical path need not exist on disk. For a subdirectory the commands run from the index root with --relative, so changes outside the indexed subdirectory never appear. For a bare repository (--git-dir) paths are relative to the repository root — the only exception.
  • Shallow. A truncated history (rev-parse --is-shallow-repository) is refused with a git fetch --unshallow hint; the tool never runs fetch and never touches the network.
  • No restart needed. Editing git/git_path in daemon.toml is applied by the watcher: local entries are updated atomically, clearing the flag or removing git_path returns the disabled state. A TOML error keeps the previous snapshot; git itself is not probed while loading the configuration — a wrong git_path produces a tool error, not a serve failure.

Unknown keys no longer vanish silently (v1.13.0). A key the tool does not have was dropped while parsing the arguments, so a call with a foreign filter name (glob instead of path_glob, start_line instead of line_start) looked healthy: the answer came back without the filter applied. Common foreign names are now accepted as synonyms — glob for path_glob (grep_code, grep_text, grep_body), start_line/end_line for line_start/line_end (read_file), depth for max_depth (get_call_tree) — and anything else unrecognised is visible in the response itself: unknown_params (what was not recognised) and unknown_params_note (what the tool does accept). The call is not rejected: the server still answers with data.

The path alias and the path in records. path is accepted as a synonym of path_glob in get_function, get_class and find_symbol — previously the key was dropped silently and the file filter did not apply. Every FunctionRecord/ClassRecord now carries path: with several same-named bodies, line numbers without a file address nothing, and the answer read as two functions in one module.

Freshness of a read copy. read_file and stat_file report the indexed copy's indexed_at in RFC 3339 (UTC, trailing Z) and mtime in Unix seconds when known. Both accept indexed paths with / or \. list_files accepts glob as an alias for pattern. When a search is empty, grep_code and grep_text explain when their filters selected no files in that category. Search XML descriptors such as Catalogs/Name.xml with grep_code and Ext/Form.xml markup with grep_text.

Empty grep_code hint. If the search went through pattern= and the value contains regex metacharacters (|, (, [, ., {, ?, \), the hint says pattern is a literal substring and only regex= searches for an alternative. The oversize caveat now carries the number of files skipped by size (zero means size is not the reason).

Conflicting grep criteria (#34). When grep_code or grep_text receives multiple search criteria, search_param_conflict appears next to result: used identifies the selected key and value, ignored lists ignored keys and values, and note explains the conflict. grep_code and grep_text keep the existing priority regex → query → pattern, skipping empty and whitespace-only strings. null means absent. Even identical values in two keys produce a warning. Diagnostic values are limited to 256 Unicode characters (value_truncated marks a shortened preview); the search uses the full value. Diagnostics survive empty results, cache hits, session deduplication, federation and the outer multi-repository response, including byte-budget truncation. A single criterion produces no warning. Booleans are still rejected; the string "true" remains a valid regex.

Code-file content storage (v0.8.0)

Starting with v0.8.0, code-file content is stored in the file_contents table (zstd-compressed) and returned by read_file and searched by grep_code. Large files can be excluded from storage via max_code_file_size_bytes (default 5 MB):

[indexer]
max_code_file_size_bytes = 5242880   # 5 MB global override

[[paths]]
path = "C:/Repo1C"
max_code_file_size_bytes = 10485760  # 10 MB for this repo only

Priority: per-path → [indexer] section → 5 MB default. Files exceeding the limit are stored with oversize=1 and content_blob=NULL; AST parsing, FTS, and call-graph edges still work for them in full. read_file and grep_code return a hint explaining how to query such files via get_function/get_class/grep_body.

Connection pool (v0.24.0)

In serve, each repo is read through a pool of read-only SQLite connections instead of a single connection behind a mutex. Concurrent requests to the same repo now run in parallel — a heavy query (bsl_sql, a full grep_code, recursive find_path/get_call_tree) no longer blocks a fast get_function on that repo. Tune via an optional [pool] section in serve.toml:

[pool]
pool_size = 4               # connections per repo (default 4)
per_conn_cache_kib = 16384  # page-cache per connection, KiB (default 16384 = 16 MB)
busy_timeout_ms = 5000      # SQLite busy_timeout per connection, ms (default 5000)

All fields are optional; omitting the section uses the defaults. The default is memory-neutral: 4 × 16 MB = 64 MB per active repo, the same as the previous single connection. Connections open lazily up to pool_size and return to the pool when a request finishes; 0 is clamped to a safe value. WAL mode (already used by the index) makes the multiple readers safe alongside the indexing daemon's writes.

Every tool in tools/list declares readOnlyHint, so a client that honours the hint (Claude Code, for example) sends the calls of one model turn at once, and the pool serves them in parallel.

Re-reading serve.toml without a restart (v1.1.0)

In federation mode serve watches serve.toml and daemon.toml itself: half a second after a save the repository table is rebuilt as a whole, and a new alias is served without a restart — MCP sessions that are already open see it right away. An edit is applied all or nothing: a parse error, a database that fails to open, or a local alias in serve.toml without an entry in daemon.toml keeps the previous table. For a new local alias, add a [[paths]] entry to both files. Set the path in daemon.toml and the alias and IP in serve.toml. To reload manually, send POST /reload to the serve HTTP port. The result appears in config_reload in the full health response. Changing [me].ip, [pool], and also the [mcp], [tools] and [cap] sections requires a restart of serve: they are read once, when the server is built, and a re-read names them in the restart_required field — previously an edit to mass_mode_tools looked applied, with "re-read without changes" in the log. A new directory starts being indexed when the daemon reloads daemon.toml. The daemon's daemon reload command controls indexing. The alias list is managed by serve. Outside federation mode, change --path or the configuration passed via --config, then restart serve. Both health.aliases_note and unknown_repo describe these steps.

Which Host values /mcp accepts (v1.8.6)

The /mcp route is protected against DNS rebinding: a request passes only with a Host header that is allowed explicitly. Before v1.8.6 the list was hard-wired to loopback (localhost, 127.0.0.1, ::1), so a node listening on a network address (--host 0.0.0.0 or [me].ip) rejected every external MCP client — 403 Forbidden: Host header is not allowed — while its own /federate/* kept working. Now the defaults are extended with:

  • the bind address (--host or [me].ip) — added automatically, except 0.0.0.0 and ::;
  • [me].allowed_hosts in serve.toml — host or host:port values (the port is checked only in the second form);
  • CODE_INDEX_ALLOWED_HOSTS — the same values, comma-separated; it also works in single-repository mode, where serve.toml is not read.
[me]
ip = "192.0.2.10"
allowed_hosts = ["192.0.2.10:8011", "ci.internal"]

The check is never disabled: a value neither listed nor among the defaults still gets 403. The list is baked into the service at startup, so editing it requires a serve restart — as with [me].ip and [pool]. With --host 0.0.0.0 the operator lists the addresses: guessing under which name clients will arrive is not safe.

Additional tools for 1C repos (only in bsl-indexer, v0.6+)

When BSL repos are present in daemon.toml (language = "bsl"), 17 BSL-specific tools are auto-registered:

Tool Description
query_call_sites Calls with their place in the code: where exactly a procedure is called from — inside a loop (in_loop), inside a Попытка/try block (in_exception), and at which nesting depth (depth). Answers "what runs in a loop during posting" and "what happens in the exception handler", which get_callees does not distinguish: a flat call list does not say whether the call happens once or on each of 10,000 tabular-section rows. Narrowing is mandatory — callee, caller or path. For example, query_call_sites(callee="ЗаписьЖурналаРегистрации", in_loop=true) selects modules from calls and checks their context in the source code. files_candidates is the total number of modules and files_scanned is the number parsed. Exceeding files_limit (50 modules) sets candidates_truncated. Output is capped by limit (default 50, max 500)
get_node_structure Skeleton of a procedure: loops, try blocks and branches with line numbers and nesting depth — without reading the body in full. Useful when a procedure spans 300–2000 lines and its shape matters: where the loops are, where exceptions are handled, how many branches. max_depth (default 3) bounds the depth; when cut, the answer carries depth_truncated and a hint to raise the limit; limit caps the number of blocks
get_line_context What is on a line: the enclosing procedure, every block containing the line (loop, try, branch) with line numbers and depth, and the in_loop/in_exception/depth flags. Useful when the line is already known from another tool's answer or from an error message and its place in the code must be understood without reading the module
get_object_structure Full structure of a 1C metadata object by full_name (Document.SalesInvoice): attributes with 1C-notation types (+synonym — UI label, +required — fill checking, v0.32.0; +indexing — indexing flag Index/IndexWithAdditionalOrder, v0.45.1), tabular sections with columns, register dimensions/resources; enum_values for enumerations (+enum_synonyms — UI labels of values); predefined for objects with predefined items (catalogs, charts of accounts); posting for documents (posting properties from root <Properties>); owners — owners of a subordinate catalog; value_types — value type of a CCT/constant (for a CCT — available analytics); properties — header properties (register periodicity, write mode, numbering, hierarchy); commands — object commands with synonyms (all — v0.32.0). Base sections (attributes/dimensions/resources/tabular_sections) are always present (empty as []). sections parameter (v0.29.0) — narrow selection: return only the requested sections (e.g. ["posting"] — ~0.2 KB instead of the full object). Criterion selector (v0.41.0): name_like (object-name substring) + optional meta_type return the structures of ALL matching objects in one call ({matched, truncated, results}, cap 50) — for a thematic set (e.g. name_like="EDI") instead of calling one by one. v0.49.0: names_only=true — only each object's passport (full_name/meta_type/name/synonym) without the structure, the cheapest search mode; max_response_bytes — a size budget for this response on top of the server-wide one, when the full sections are needed. v0.55.0: offset — pages over ONE requested section (sections=['enum_values']): the page is filled by response size, with <section>_shown/_total/_offset/_has_more alongside and a ready-to-copy call for the next page. Before that a section of hundreds of values was dropped by the guard entirely and was unreachable
get_form_handlers Managed-form event handlers by (owner_full_name, form_name). Owner accepted in both formats — Document.X and export-folder Documents.X (v0.31.0). v0.54.0: returns (event, handler, element) triples — element is the form item the handler belongs to (absent for form-level handlers); an optional element filter narrows the response to one item, an empty string — form-level handlers only (a large form: 308 records → 8), and handlers_shown/handlers_total are added. Event names are normalized to Russian in both dump formats — a dictionary of 91 events. Unknown form → error with available_forms of the owner. v0.55.0: form_name is optional — without it, handlers of ALL forms of the object in one call (it used to be 255 calls for an object with 255 forms); a max_response_bytes budget was added. When it does not fit — a listing of forms with handler counts, or per-item counts within one form, and in both cases a ready-to-copy call for the piece you need
get_event_subscriptions Event subscriptions, including extensions at any depth beneath a Configuration.xml root. Filters: handler module, event (Russian/English), and source, resolved against explicit types, type sets and defined types. Document.X includes Object/Manager/RecordSet; an explicit suffix restricts the role. Short names resolve sets only when the metadata kind is unambiguous. With source, exact_only=true keeps explicit types. matched_via (exact/type_set/defined_type), matched_source, defined_type, owner and extension explain the match and scope; without source, returns sources and type_sets. Unresolved sources and old indexes produce complete=false, warnings and warnings_count. Same-named subscriptions in different scopes are stored separately. Paged output: offset plus a max_response_bytes budget (or the server-wide [mcp].max_response_bytes); limit caps rows per page (default 50); subscriptions_shown/_total/_offset/_has_more and a hint with the ready next call come along — the full list is walked page by page instead of being lost to truncation. Unknown parameters are rejected. Rebuild older indexes for the new sources (index --force, data version 5)
find_path_bsl Call-chain between two procedures via proc_call_graph (recursive CTE, max_depth=3). BSL-specific variant of the universal find_path — proc_call_graph carries call_type and procedure keys. (v0.35.0) from/to and procedure keys are <rel_path>::<name> (a bare name is accepted for unresolved leaves); walks by resolved callee_proc_key. (v0.36.0) BSL callees are stored glued (Module.Method, like Python's obj.method); call targets resolve precisely to common-module (…/CommonModules/X/Ext/Module.bsl::M) and manager-module (…/Catalogs/X/Ext/ManagerModule.bsl::M) addresses, object-method noise is pruned — direct-edge resolution ~80-82%
search_terms Meaning-based procedure search (v0.30.0): terms are filled mechanically at index time — words of the procedure name (CamelCase split), the owner object's name and synonym, the comment above the procedure; no LLM needed. Trigram FTS: word forms and 3+ character substrings work, case and ё/е are irrelevant; a multi-word query is searched as an OR of words (best matches first). The first choice for "where is feature X implemented". LLM enrichment (bsl-indexer enrich) remains an optional add-on
get_data_links Data-links graph (v0.10.0): what an object references / what references it, via reference-typed attributes, register dimensions and tabular-section attributes (data_links table). direction=out|in|both, depth=1..4. Replaces a series of get_object_structure calls when tracing relations. Targets like *CatalogRef/*AnyRef/*DefinedType.X are generalized refs (terminal, not expanded). v0.56.0: the walk is a breadth-first search with a visited set instead of a recursive path-based query (on a central catalog, «what references it» at depth 4: 42.9 s → a fraction of a second), an 8-second time cut-off with a walk_stopped_by_time flag, and an edge cap. Edges come as a page sized by the response budget (offset, <dir>_shown/_total/_offset/_has_more), with <dir>_by_kind counts alongside so you can narrow the query instead of paging through everything. At depth 1 the total edge count is exact; deeper, if the walk hit the cap or the deadline, it is marked <dir>_total_partial Accepts Document.X, Documents.X, and Документы.X. found indicates membership in the metadata inventory.
find_data_path Data-links graph (v0.10.0): chain of reference links from one object to another (BFS over data_links, like find_path but for data, not calls). v0.57.0: on failure the answer distinguishes «no path» from «not enough hops» — flags depth_exhausted, visited_nodes and a ready call with a larger depth
get_register_writers Register recorders / document movements (v0.16.0): for a register (AccumulationRegister.Stock) returns writers — documents writing movements; for a document — writes_to (target registers). From the declarative <RegisterRecords> set (recorder edges of data_links). One call covers both directions
posting_map Posting mechanism map (v1.9.0): for a document (Document.SalesInvoice) — what it writes per metadata (declared, recorder edges of data_links), which code is reachable from the posting handler over the call graph (path, depth 1..6), where movements are actually written (writes — Движения.<Register>.Добавить/.Записать calls from the calls table, with procedure, file and line, level=register; a whole-set Движения.Записать is flagged whole_set, a set-adding Движения.Добавить is level=collection) and where registers are merely mentioned (mentions — usages from metadata_code_usages; the manager module is excluded by default as it holds balance queries). The layers never mix: a mention is not a write. If neither the object module nor the manager module holds a posting handler — heuristic=true, the graph constraint is dropped and writes keeps working. registers_without_code lists registers absent from code entirely (movements are formed by a generic mechanism by metadata name)
get_object_profile Object passport in one call (v0.21.0): the full portrait of an object — structure + forms + modules + data links — instead of a series of get_object_structure/get_form_handlers/get_data_links. The sections parameter (['structure'|'forms'|'modules'|'data_links']) narrows the response. v0.55.0: an overview instead of a dump — forms come as a listing with handler counts, modules as counts by type, data links as counts by kind only (no edges: their volume is set by the whole configuration, not by the object). Content is fetched via expand (forms.handlers, modules.list) or arrives on its own when the response fits the budget (flags forms_handlers_included, modules_listed); every folded section carries a ready-to-copy call for its content. On an object with 255 forms the response went 336 KB → 19 KB. v1.10.0: the data-links section gained usage_channels — how many references came from code and through which channels (manager, query, ref_type, template_call, common_template_call, common_picture, style_item, etc.) and how many platform entry points lead into the object's modules (form events, subscriptions, overrides); an empty channel means "not collected", not "the object is unused"
find_references Impact map (v0.21.0): everything that references an object, in one call — reverse data_links (structural refs from metadata) + metadata_code_usages (usages in .bsl code) + role_rights (roles holding rights on it), broken down by kind with samples (limit). v0.55.0: section (data_refs/code_usages/role_rights) + offset — one section in full, paged by response size, with a ready-to-copy call for the next page: on a central catalog 2,443 code usages are collected in 10 turns, whereas nothing could take you past 200 samples before
get_role_rights Lists explicitly granted rights for an object or role. Accepts Russian and English object prefixes. Index data version 8 adds explicit denials, restricted_rights for row-level security, and default role settings. roles_with_new_object_defaults lists roles with that flag. For a role query, use limit (1–100) and pass objects_next_offset as the next page's offset. Omitting both parameters preserves the previous response. Effective access follows platform and extension rules
get_dcs_schema Data composition schema in one call (v1.4.0): given a template name (Report.MyReport.Template.Schema), an owner name (Report.MyReport) or a common template (CommonTemplate.Schema) — the parsed schema: data sets with fields (name, presentation, type, role) and query texts, nested union sets, set links, calculated fields, totals, parameters, setting variants and counters. The reads section lists objects the schema reads in its query texts (dcs_query edges of the data-links graph). The data is parsed at index time into dcs_schemas/dcs_datasets, so reading Template.xml piece by piece is unnecessary. Parameters: sections for a narrow selection, include_query=false for query lengths only, max_response_bytes for a response budget (when space runs short, query texts go first, then set fields, then whole sections; identification and counters are never truncated). Both export formats: Designer and 1C:EDT
bsl_sql Arbitrary read-only SQL (v0.21.0): a SELECT/WITH query over the repo's index.db for the long tail of metadata/graph questions that have no dedicated tool (roles/RLS, joins, aggregations). Guard: SELECT/WITH only + Statement::readonly() + row cap + timeout. Tables: metadata_objects, metadata_modules, metadata_forms, event_subscriptions, data_links, role_rights, proc_call_graph, core functions/files. An empty result over the procedure tables auto-falls back to search_terms normalized_literals lists the rewritten type prefixes. Set normalize_object_literals: false to disable rewriting. Values from params are preserved.

Object name case no longer matters (v0.57.0). 1C object names are Cyrillic and SQLite does not fold their case, so Catalog.организации used to return a silent zero: data links answered «nothing references this object», recorders — «no recorders». The name is now resolved to the spelling stored in the configuration at the entry of the object-keyed tools (get_data_links, find_data_path, get_register_writers, get_object_structure, get_object_profile, find_references) and echoed back canonically. Did-you-mean matching stopped depending on case as well. The schema gained a key column and an index; no reindex is required — the migration fills the keys on the first daemon start.

These tools appear in tools/list only when at least one BSL repo is configured (conditional registration). When the repo set changes in daemon.toml, the server emits notifications/tools/list_changed. On Claude Code 2.1.120 this notification is currently ignored; workaround — manual /mcp Reconnect.

Write pages in posting_map. When writes.has_more is true, call posting_map with the same repo, object, and depth, passing writes.next_offset as writes_offset. Use writes_offset=0 to read only writes from the start. Each page contains up to 200 rows and accepts max_response_bytes. writes.count is the number of delivered rows and writes.total is the number of matching writes. registers_without_code accounts for matches beyond the visible rows. If registers_without_code_complete=false, coverage of the underlying data is incomplete.

Since v0.8.1, these BSL-tools work in all scenarios (was broken in v0.8.0, see CHANGELOG):

  • via bsl-indexer.exe daemon run — daemon now applies schema_extensions and index_extras for each BSL repo on startup (creates metadata_objects / metadata_forms / event_subscriptions / proc_call_graph and fills them from Configuration.xml).
  • via federation — extension-tools are forwarded over the universal POST /federate/extension route. Both peers must be on ≥ 0.8.1; older peers will return 404 on the new route.
  • on repos without Configuration.xml (e.g. partial dumps containing only forms/processors) — the tables are created empty and the tools return [] instead of throwing no such table: metadata_objects.

Full instructions: docs/bsl-indexer.md.

All tools support a language filter: search_function(query="X", language="python")

grep_body

Unlike FTS search, grep_body supports literal substrings (including dots and special characters) and regular expressions. This is essential for finding references like Catalog.Contractors or Справочники.Контрагенты that break FTS5 syntax.

grep_body(pattern="Справочники.Контрагенты", language="bsl")
grep_body(regex="Catalog\\.(Contractors|Organizations)", language="bsl")

Returns [{file_path, name, kind, line_start, line_end, match_lines, match_count}] — concrete functions/classes containing the match.

Each result includes match_lines — up to 3 absolute line numbers in the file where the pattern was found. If there are more than 3 matches, match_count shows the total.

[
  {
    "file_path": "src/Catalogs/Products/ObjectModule.bsl",
    "name": "OnWrite",
    "kind": "function",
    "line_start": 45,
    "line_end": 82,
    "match_lines": [51, 63, 78]
  }
]

CLI Reference

# Background daemon (writer — one per machine)
code-index daemon run                          # foreground, for Scheduled Task / systemd
code-index daemon status [--json]              # query GET /health via loopback
code-index daemon reload                       # re-read daemon.toml
code-index daemon stop                         # POST /stop

# MCP server (read-only client; used by Claude Code, VS Code, subagents)
code-index serve --path /project

# One-shot indexing (no daemon)
code-index index /project [--force]

# Project management
code-index init --path /project          # Create config
code-index clean --path /project         # Remove stale entries
code-index stats --path /project [--json]

# Symbol search
code-index query "name" --path /project [--language rust] [--json]

# Full-text search (JSON output)
code-index search-function "query" --path /project [--language python] [--limit 20]
code-index search-class "query" --path /project [--language python] [--limit 20]
code-index search-text "query" --path /project [--limit 20]

# Exact lookup (JSON output)
code-index get-function "exact_name" --path /project
code-index get-class "exact_name" --path /project

# Call graph (JSON output)
code-index get-callers "function_name" --path /project [--language python]
code-index get-callees "function_name" --path /project [--language python]

# Navigation (JSON output)
code-index get-imports --path /project [--module "name"] [--file-id 42]
code-index get-file-summary "src/main.rs" --path /project

# Substring / regex search in function and class bodies (supports dots and special chars)
code-index grep-body --pattern "Catalog.Contractors" --path /project [--language bsl] [--limit 100]
code-index grep-body --regex "Catalog\.(Contractors|Organizations)" --path /project

Using CLI from Subagents

Subagents launched via the Agent tool in Claude Code do not have access to MCP servers — they run in isolated subprocesses with no connection to the parent MCP session. All 12 MCP tools are mirrored as CLI subcommands that output JSON, making code-index fully usable from any subprocess, script, or subagent.

# Instead of an MCP tool call, a subagent runs:
code-index search-function "authenticate" --path /my/project --language python

# Call graph from CLI:
code-index get-callers "process_order" --path /my/project

# File map:
code-index get-file-summary "src/auth/login.py" --path /my/project

Every command outputs valid JSON that the subagent can parse and reason over, identical in structure to what the MCP tools return.

Note: CLI read commands use SQLITE_OPEN_READ_ONLY mode, so they work in parallel with the MCP daemon without database locking conflicts.

CLAUDE.md Setup

Add this block to your project's CLAUDE.md to instruct Claude Code subagents to use the CLI indexer instead of grep, find, or reading files manually:

## Code Index — fast code search

For code search, use the CLI indexer instead of grep/find/Read:
- Search: code-index query "name" --path /path/to/project --json
- FTS search: code-index search-function "query" --path /path/to/project
- Call graph: code-index get-callers "function" --path /path/to/project
- File map: code-index get-file-summary "file" --path /path/to/project
- Stats: code-index stats --path /path/to/project --json
All commands output JSON. This is instant search over an indexed database.

Use an absolute path to the binary and adjust /path/to/project to your setup. On Windows, specify the full path to code-index.exe, for example C:\MCP-Servers\code-index\target\release\code-index.exe.

Daemon Mode (v0.5+)

Starting with v0.5, code-index uses a one-writer / many-readers architecture:

Background daemon (single writer)

code-index daemon run starts a long-running process that:

  1. Loads the list of watched folders from daemon.toml.
  2. For each folder: opens .code-index/index.db, runs full reindex with mtime fast-path (v0.4.0), then switches to a notify watcher that re-indexes on change (1.5s debounce, 2s batch). A file held by another process at read time (a configuration export still writing it) is not lost: the event is deferred and retried with a growing pause of 2 → 5 → 15 → 30 → 60 s, six attempts counting the first. Once they run out, the daemon names the file in the log.
  3. Exposes a local health / management HTTP endpoint on loopback (port written to daemon.json in the state directory).
  4. Holds a global PID-lock (daemon.pid) to prevent two daemons per machine.

Per-folder lifecycle: not_started → initial_indexing → ready ⇄ reindexing_batch → (reindexing_extras →) ready / error. reindexing_extras (1.7.0) means the batch core is committed and the 1C extras layer is still being computed. Each status transition is visible via daemon status.

MCP servers (many read-only readers)

code-index serve opens .code-index/index.db in SQLITE_OPEN_READ_ONLY and exposes MCP tools over stdio or HTTP. Multiple MCP instances on the same project run in parallel without blocking each other. serve never indexes and does not answer queries without the daemon, even when the index is already built.

Before every tool call the MCP asks the daemon for the per-folder status. If it is not ready, the tool returns a structured JSON:

{ "status": "indexing", "progress": {"files_done": 4200, "files_total": 10000, "percent": 42.0}, "message": "Первичная индексация в процессе" }

If the daemon is offline:

{ "status": "daemon_offline", "message": "Демон code-index не доступен (Демон не найден: отсутствует runtime-info файл C:\\tools\\code-index\\daemon.json. CODE_INDEX_HOME = C:\\tools\\code-index. Проверьте: (1) демон запущен — `code-index daemon run`; (2) демон и этот процесс используют ОДИН CODE_INDEX_HOME. …). Запустите 'code-index daemon run' или Scheduled Task / systemd user unit." }

The message is in Russian. It says the daemon was not found because daemon.json is missing, shows the CODE_INDEX_HOME in use, and asks to check that the daemon is running and that both processes share one CODE_INDEX_HOME. If serve has no CODE_INDEX_HOME at all, the parenthesis instead says the variable is not set for this process, with an env example.

Logs: what to attach when indexing appears stuck

The daemon and the serving process keep logs in CODE_INDEX_HOME:

File Written by Contents
daemon.log indexing daemon scan and parse stages, per-folder summaries, change batches, heartbeat
serve.log serving process startup, port, config reload, request errors

Rotation by size: daemon.log.1, .2, .3 (10 MB per file).

Verbosity. [daemon] log_level in daemon.toml (error, warn, info by default, debug, trace). RUST_LOG overrides the config — handy for a one-off deep dive without editing files. debug adds per-file messages (unreadable, unparsable, not written); info deliberately omits them, since a broken export would drown everything else.

A full pass looks like this:

[…/repo] new database — storage mode: in memory (setting "auto", daemon memory 11 MB)
[…/repo] initial indexing started
[stage 1] candidate selection: 49 ms (543 files)
[stage 2] parsing 543 files started, multi-threaded
[stage 3] database write: 86 ms (543 files)
[…/repo] initial indexing summary: 543 files, 232 ms,
         storage mode in memory with flush to disk, daemon memory 22 MB

A change batch looks like this:

[…/repo] change batch: 3 events
[…/repo] extras updated incrementally in 26 ms (changed 3, deleted 0)
[…/repo] batch done: 3 events, 44 ms, storage mode on disk, daemon memory 23 MB

Heartbeat is written once a minute and answers "alive or stuck":

[heartbeat] uptime 1 min 0 s, daemon memory 778 MB, folders 50: ready 50, indexing 0, errors 0, not started 0
[heartbeat] …/repo — initial indexing, 1200/90000 files (1.3%), unchanged for 1 h 1 min

Ready folders are not listed by name; at most ten unready ones are listed plus a count of the rest. A growing "unchanged for" while the stage line stays the same is the signature of a hang — on exactly the stage named above it.

What to attach to a bug report: daemon.log (plus rotated daemon.log.1…3 if relevant), the output of code-index daemon status --json, and your daemon.toml. Note: while the daemon holds the file open, Windows Explorer reports zero size — the file is being written all along, read its contents.

Configuration

.code-index/config.json is created automatically on first run. Full reference:

{
  "exclude_dirs": ["node_modules", ".venv", "__pycache__", ".git", "target", "output"],
  "extra_text_extensions": [],
  "max_file_size": 1048576,
  "max_files": 0,
  "bulk_threshold": 10,
  "languages": ["python", "javascript", "typescript", "java", "rust", "go", "bsl", "php", "c", "cpp", "csharp", "ruby", "swift", "html"],
  "batch_size": 2000,
  "storage_mode": "auto",
  "memory_max_percent": 50,
  "memory_estimate_factor": 2.0,
  "chunk_budget_bytes": 536870912,
  "debounce_ms": 1500,
  "batch_ms": 30000
}

What is excluded by default. On top of whatever exclude_dirs lists, the walk always skips node_modules, .venv, __pycache__, .git, .code-index, target, .mypy_cache, .pytest_cache, .tox, dist, build, obj, out, publish, .vs, .worktrees, venv, env, .env. The list is additive: a custom exclude_dirs extends the built-in set instead of replacing it. bin is deliberately NOT excluded: in Rust (src/bin), Python and Node (bin/cli.js) it is a directory with real code; a .NET repository, where bin is purely an output directory, is better off adding it to its own config. The effective list is returned by get_stats (the exclude_dirs field) and printed by init. get_stats also returns exclude_dirs_note: the list is read from disk now, while the daemon worker applies the configuration it read at its own start — editing config.json needs a daemon restart.

Key fields:

  • storage_mode — auto decides by calculation (see below); memory forces in-memory; disk forces on-disk
  • memory_max_percent — share of FREE memory the in-memory database may use in auto mode (50% by default)
  • memory_estimate_factor — how many times working in RAM costs more than the source files weigh (2.0 by default)
  • chunk_budget_bytes — how many bytes of sources go into one pass of a full parse (512 MB by default); zero turns chunking off

How auto works. Before indexing, the folder is weighed: the size of the files that will be indexed is summed (metadata only, 1–3 seconds for 60,000 files). Then the calculation:

expected usage = source weight × memory_estimate_factor
allowed usage  = free memory × memory_max_percent / 100

expected usage ≤ allowed usage → the database is built in RAM, then flushed to disk
otherwise                      → the database goes straight to disk

Free memory is re-read for every folder, not once at startup. After working in RAM the freed memory is returned to the system, so the next folder gets it back. Both sides of the calculation, the multiplier and the decision are logged.

Parsing runs in chunks (v0.68.0). Peak memory is set by chunk_budget_bytes (512 MB by default), not by how large the folder is. Files are read, parsed, compressed and written to the database in chunks of that size, and the memory of each chunk is released before the next one starts. Previously the entire folder content and its parse trees were held at once, so on a large folder usage hit the ceiling of the machine or container.

Measured on a 1C configuration of 57,072 files (database on disk, initial indexing from scratch):

Chunk budget Peak memory Core time
chunking off (as before) 4.40 GB 49.4 s
512 MB (default) 1.42 GB 52.2 s

On a forced full parse of the same repository a 128 MB budget brings the peak down to 0.67 GB, against 4.46 GB with chunking off.

Chunk boundaries cost a few percent of time: the single-threaded database write does not overlap with parsing the next chunk.

The setting works both in the per-folder settings file and globally in daemon.toml:

[indexer]
chunk_budget_bytes = 134217728   # 128 MB — for a container with a hard memory limit

Zero turns chunking off: the whole tree is read at once, as before. Chunking applies where the whole tree goes into parsing — initial indexing, a forced full parse, and resuming an interrupted load; ordinary edits touch few files and are unaffected.

Resuming an interrupted load. If the process was killed mid-way through initial indexing (out of memory, a reboot), the chunks already written stay in the database along with a marker that the load is unfinished. The next run sees it, reads only the missing files and builds the indexes, instead of starting over. While the marker is set the database is not treated as ready: its indexes and full-text search are not built yet.

When to change memory_estimate_factor. The default 2.0 is the middle of the observed spread, not headroom on top of it. Measurements of initial indexing with the database in RAM:

Source weight Files Memory used Actual factor
1.4 GB 191,417 2.4 GB 1.7
3.7 GB 60,294 4.4 GB 1.2
5.3 GB 92,300 8.8 GB 1.6

Before chunked parsing the same folders ranged from 1.7 to 3.2 and the default was 3.0. The spread depends on the language, on how densely the files are packed with code, and on what the folder contains, so the factor cannot be predicted up front — it is tuned from the log, which records both the estimate and the decision.

Situation Value Result
Little RAM, weak machine 3.0 and up Disk more often: slower, but predictable, with no risk of running out. On weak machines this is the direction that matters
Ordinary machine 2.0 Default
Plenty of RAM, willing to check the log 1.3–1.7 More folders go to RAM, indexing is faster. The risk is real: usage above the estimate is at least as common as below, and running out of memory aborts the folder

Zero, negative or non-numeric values are treated as a typo — the default is used, and the log shows which multiplier was actually applied.

  • debounce_ms — milliseconds to wait after a file change before triggering re-indexing (collects burst edits into one pass)
  • batch_ms — upper bound on how long the watcher keeps accumulating events after the first one in a batch
  • quick_window_ms — single-edit window (ms, default 50): if no event for another file arrives within this window after the first event, the batch is processed right away instead of waiting for debounce_ms; 0 disables single-edit mode
  • batch_size — number of records per SQLite transaction during indexing (higher = faster bulk inserts, higher peak memory)
  • bulk_threshold — minimum number of files that triggers bulk mode (drop indexes, insert, rebuild indexes); faster for large batches

Tuning watcher latency (debounce_ms, batch_ms)

Defaults are 1500 ms / 2000 ms — good for typical IDE save + formatter + linter bursts and for git operations that touch many files at once. For a lively single-user IDE session you can lower the debounce and trade throughput for responsiveness.

Single-edit window (quick_window_ms, 1.7.0). Editing one file no longer waits for debounce_ms: after the first event the daemon waits a short window (50 ms by default). If no event for another file arrives, the one-file batch is processed immediately and the edit shows up in the index in about 50–80 ms instead of ~0.55 s with debounce_ms = 500. Repeated events for the same file (one save produces 2–3 events) do not switch modes. An event for another file switches to the regular collection — debounce_ms of silence capped by batch_ms — so bulk changes (git pull, a 1C configuration dump) are handled as before; at most the first file goes as a separate batch. Set it per folder in [[paths]] of daemon.toml or in the project's .code-index/config.json; 0 restores the old behaviour. A new value for an already watched folder takes effect after a daemon restart.

The daemon resolves these values in this order (first match wins):

  1. Per-folder override in daemon.toml:
    [[paths]]
    path = "C:/Repo1C-2"
    debounce_ms = 500      # react in ~0.6 s instead of ~1.6 s
    batch_ms    = 1000
    
  2. Per-project .code-index/config.json — applies to that project only.
  3. Built-in defaults (1500 / 2000).

Re-read after editing daemon.toml:

code-index daemon reload

Recommended values:

Use case debounce_ms
Interactive IDE, single-file edits 300–500
1C repos / git operations / large bulk edits 1500 (default)
CI or scripted batch edits 3000+

Guarding output against disk offload ([cap], v0.38.0)

The client (claude CLI / Claude Code) caps a single tool_result streamed inline into context (MAX_MCP_OUTPUT_TOKENS ≈ 25,000 tokens). A response over the cap is dumped to a file on disk by the harness, handing the model only a path + preview — structured inline access is lost. To keep large outputs (a big module's map, long arrays of values/sources/attributes) from being offloaded, serve trims them at the source. Configured via an optional [cap] section in daemon.toml:

[cap]
max_response_bytes      = 48000   # response budget in JSON bytes; 0 disables cap_response
max_response_bytes_hard = 192000  # ceiling for a client-supplied max_response_bytes; 0/absent — 4x the budget (v0.49.0)
cap_enabled             = true    # global on/off for cap_response (takes precedence over cap_tools)
cap_tools               = ["bsl_sql", "find_references", "get_register_writers"]
max_function_body_chars = 15000   # get_function/get_class body threshold; 0 keeps the full body

Mechanisms (all optional, act on the serve output layer, require no reindex):

  • cap_response — while the response JSON exceeds max_response_bytes, halves the heaviest array, leaving <key>_total (original count) and <key>_truncated: true. Applied to tools in cap_tools (when cap_enabled = true). Only arrays are trimmed — large strings (read_file/grep) are untouched. get_file_summary (core) is wired in here too: a giant module's map (hundreds of functions) no longer goes to offload.
  • omit_oversize_sections (for get_object_structure) — where an array/map is the full authoritative answer (a 1C object's structure), the heaviest section is dropped WHOLESALE with <section>_omitted: true + <section>_count: N (a partial sample would lie, “here are all the enum values”).
  • shrink_search_results (v0.49.0, for a SEARCH response of get_object_structure via name_like/full_names) — identification of what was found is untouchable. Heavy sections INSIDE the items are dropped first (<section>_omitted + <section>_count); only if that is not enough is the array itself shortened, with results_total/results_shown. The array is never emptied at any budget above zero, and full_name/meta_type/name/synonym stay on every item. Previously the heaviest section was the results array itself, so it went first — the client got {matched: 38, results_omitted: true} without a single name.
  • max_response_bytes as a call parameter (v0.49.0, get_object_structure) — a budget for one response on top of the server-wide one. A request above max_response_bytes_hard is clamped to the ceiling, and the applied value comes back in response_budget_applied. Zero (disable the guard) is not allowed per call — only via server config.
  • Navigational body cap (get_function/get_class) — a body longer than max_function_body_chars is returned as a head+tail+marker stub with a hint to read_file(line_start,line_end) / grep_body.

Benchmarks

Measured on a single Windows machine with a spinning disk, August 2026.

Codebase Files Full index Startup on an existing index
1C:Trade Management 57,072 2 min 41 s 2.3 s
1C:Accounting 88,284 5 min 51 s 5.3 s
PHP website 157,772 13 min 1 s 8.0 s

A full index is a from-scratch parse, done once. For Accounting those 5 min 51 s break down into 2 min 38 s core (syntax trees and writes), 1 min 58 s of the 1C layer (metadata, forms, rights, call graph) and 56 s flushing the database to disk.

Startup on an existing index uses the mtime + file_size fast-path: only stat() per file, zero content reads, zero SHA-256 hashes.

Metric Value
Functions indexed (Trade Management) 261,548
Call graph edges 1,962,941
Query response about 10 ms over HTTP, sub-millisecond when cached
Binary size 39 MB without 1C, 41 MB with 1C

Comparison with grep:

Operation grep Code Index
Find function by name O(n) files, seconds milliseconds
Who calls function X? grep all files milliseconds
File map cat + manual analysis milliseconds
Full-text search grep -r, seconds milliseconds

Architecture

Source Files -> Tree-sitter Parser -> SQLite (in-memory) -> MCP Server -> AI Model
                                           ^
                      File Watcher --------+ (auto re-index)

Key optimizations:

  • In-memory SQLite with event-driven flush — all reads and writes go to RAM; disk is written only when data actually changes (see below)
  • Rayon parallel parsing — files are parsed across all CPU cores simultaneously
  • Bulk mode — for large batches: drop indexes, bulk insert, rebuild indexes; significantly faster than incremental inserts
  • mtime/size fast-path — on restart, each file is checked via stat() (mtime + file_size); if both match the stored values, the file is not read at all — zero I/O, zero SHA-256. Only changed files are read and re-hashed
  • PID-lock — prevents multiple daemon instances from competing for the same index.db

Flush to disk policy

The daemon works in in-memory mode for maximum performance. The database is flushed to disk only when data actually changes — no periodic timers, no unnecessary I/O:

Event Flush? Condition
Initial indexing completes Yes At least 1 file was indexed or deleted
File watcher processes a batch Yes At least 1 write/delete occurred in the batch
File watcher fires but nothing changed No Hash unchanged → no write → no flush
Idle (no file changes) No Zero disk activity
Daemon shutdown (graceful) Yes Always — final safety flush

This means: if you're just chatting with AI and not editing code, the daemon produces zero disk I/O.

  • Batch transactions — 500 records per transaction reduces SQLite overhead by orders of magnitude

For 1C Developers

Code Index has first-class support for 1C:Enterprise source files.

From BSL files, it extracts:

  • Procedures and functions with full body text
  • Compilation directives (&AtServer, &AtClient, &AtServerNoContext)
  • Extension annotations (&Instead, &After, &Before)
  • Bilingual keywords (Russian and English forms are both indexed)

These are stored in two dedicated fields:

  • override_type: "Перед" (Before), "После" (After), or "Вместо" (Instead)
  • override_target: name of the original procedure being overridden

From XML configuration exports, it extracts:

  • Metadata objects: catalogs, documents, registers, and more
  • Attributes and tabular sections
  • Forms and their composition

This makes Code Index suitable as an offline search layer over full 1C configuration exports without requiring a running platform instance.

System Requirements

  • OS: Windows, Linux, macOS
  • RAM: 512 MB for small projects; up to 4 GB for large 1C configurations (60K+ files)
  • Disk: index size is approximately 1-2 GB for projects with 60K+ files
  • Build: Rust 1.77 or later — install from rustup.rs

MCP tool response format (v0.9.0+)

All data tools return a unified JSON envelope:

{
  "result": <previous plain payload>,
  "_meta": {
    "dependent_files": ["src/X.bsl", "src/Y.bsl"],
    "file_mtimes": { "src/X.bsl": 1717689600, "src/Y.bsl": 1717689600 }
  }
}

_meta.dependent_files lists files the response depends on; _meta.file_mtimes (0.20.0+) maps each of them to its indexed mtime (unix seconds). As of 0.42.0 serve strips _meta from the client response itself — the model only ever receives result. _meta is now an internal signal: serve has a built-in result cache (cross-session, local repos only) with per-file freshness. On a file change the daemon sends POST /mark-dirty {repo, files:[{path, mtime}]} (files changed on disk), then after commit POST /invalidate {repo, file_paths}. A response is not cached/served from cache only if one of its source files is dirty (disk mtime newer than the indexed mtime in _meta.file_mtimes); per-file invalidation drops only the cache keys depending on the changed file (a file→keys reverse index). Requests about untouched files are unaffected — no whole-repo coarsening. The channel is wired by [[cache_targets]] in daemon.toml. The same _meta was previously consumed by the companion caching proxy mcp-cache-ci; with serve's own cache the standalone proxy is no longer required for the ci chain. Observability: GET /cache-stats on serve.

Default repository (1.5.0). The repo parameter may be omitted: the server fills in the alias from default_repo under [mcp] in daemon.toml, or the only repository when there is just one. With several repositories and no default, a call without repo is rejected with the list of available aliases; the same list is shown in the parameter description in tools/list.

Session-level re-delivery filter (0.48.0). Rows already delivered within the same session are not sent again: whatever is dropped is marked with rows_elided_already_delivered plus a hint, so a shortened or empty list never silently reads as "no data" — a result that was empty to begin with carries no marker, which keeps the two cases apart. The filter scope is "tool + repository", so identical rows from different bases never cancel each other out. Turn it off with dedup_enabled = false under [mcp] in daemon.toml; clear its memory with POST /dedup-reset — useful when the client has compacted its context, an event not observable from inside MCP.

Tool call time limit (1.7.0). A tool call that does not finish within tool_timeout_sec seconds ([mcp] in daemon.toml, default 120) is aborted: the client gets an error suggesting a narrower query, and the database connection goes back to the pool. Otherwise a hung call would keep a read transaction open and the daemon could not checkpoint that database's WAL. Raise the limit on a slow machine with the database on a slow disk; 0 disables it.

Waiting for a change batch (1.7.0). While the daemon applies a batch of changes to a folder, serve no longer answers "Applying a batch of changes" right away: it waits for the batch to finish — up to batch_wait_ms milliseconds ([mcp] in daemon.toml, default 5000), polling the daemon every 25 ms — and answers with fresh data. The model does not have to spend a turn on a retry: a one-file batch takes milliseconds; in a 1C folder a module edit takes from a fraction of a second to a couple of seconds (measured on a stock trade configuration with 57k files: about 1.9 s, almost all of it the extras layer). If the batch is not done in time, the old answer is returned. Initial indexing (minutes) is not waited for. The wait happens before a database connection is taken and does not hold one. 0 disables waiting; raise the limit on a slow machine with 1C folders.

Two-stage readiness (1.7.0). In a folder with an extras layer (1C) a batch becomes ready in two steps. Right after the core — file text, procedures, calls — is committed, the daemon sets the folder to reindexing_extras and text tools answer without waiting: read_file, get_function, get_class, grep_code, grep_body, grep_text, find_symbol, get_file_summary, list_files, stat_file, search_function, search_class, search_text, get_imports. The rest — the call graph (get_callers, get_callees, find_path, get_call_tree) and all 1C tools — wait for the extras layer (same batch_wait_ms limit) and answer with the edit already reflected; if it is not done in time they refuse instead of silently returning a stale graph. Measured on a stock trade configuration (57k files): an edited module is visible to read_file and get_function in 0.06–0.12 s, the updated graph 1.8–1.9 s later. Folders without an extras layer behave as before. There is no setting — the behaviour is always on.

Early readiness at startup (1.8.0). When the daemon builds or checks a database directly on disk, the folder is declared ready right after the core, without waiting for the full-text index and the extras layer. While the full-text index is being built, search_function, search_class and search_text answer {"status":"indexing","layer":"fts"}; while the extras layer is being computed, extension (1C) tools answer {"status":"indexing","layer":"extras"} — retry the call later. All other tools work right away. A new database in the auto storage mode is usually built in memory by the daemon — such a folder opens all at once at the end of the pass. There is no setting.

Diagnostic tools (health, get_stats, stat_file) are not wrapped — their format is unchanged.

Each get_function record reports mtime and indexed_at for the indexed file. stale: true indicates a difference in on-disk size or modification time, or a deleted file. When the comparison is unavailable, stale is omitted. get_object_structure and get_object_profile report the same fields and the XML or MDO path in descriptor_freshness when the index identifies a single object descriptor. Forms, modules and extension data can have their own sources.

Data version number (1.4.1). A database carries a number describing how its data was built, and that number is compared with the one baked into the binary. The release number is unrelated: the data number is raised only when a change alters what is collected or how it is parsed, so upgrading by itself does not mark a database stale. The number is stored only after a pass that parsed every file (index <path> --force or building an empty database) — a routine update over changed files does not raise it, since the remaining files were parsed the old way.

get_stats and health return a data_version block — what built the database, what the binary has, and whether they differ; on a mismatch an explanation and a ready-to-run rebuild command are added. Responses of tools that read extracted facts (symbols, graphs, 1C object structure) carry the mismatch mark on errors and on success: next to result you get data_version_stale: true, data_version (built, current, message, plus a ready-to-run command for a local repository) and a short data_version_hint. The legacy result.stale_index field on errors is kept for compatibility and the tool's own hint is never replaced. On a fresh index none of these fields appear. For a remote node's folders the decision is made against that node's own database, and the remote machine's path is never handed to the client as an executable command. A rebuild never starts on its own — when to run it is the operator's call.

Cache hits recheck the data version, removing the warning after a rebuild. In a set, the annotation belongs to its own group; an empty list_files alone does not warn about extracted facts.

The mark exists precisely because "nothing found" on a stale database is indistinguishable from an honest zero: an empty list is very often legitimate, and telling "data was not collected" from "this is not in the configuration" is impossible without reading the source files.

Searching multiple repositories (#32)

Exactly five tools support a set: grep_code, grep_text, list_files, find_symbol and get_object_structure. Pass repos: ["app", "app-test"] or a registered-alias mask such as repo: "app-*" (*, ?). An exact registered alias takes precedence over a mask. Lists must be nonempty and contain at most eight entries; duplicates are removed in input order. Masks expand in alphabetical order to at most eight repositories; a mask with no literal part is rejected. Conflicting repo/repos, invalid types, empty entries, unknown aliases and invalid or overly broad masks are rejected before execution with the available aliases listed. A selector never opens a path or address. Other tools reject repos.

In tools/list, the schema description explains the selector rule. Pass either repo or repos when calling a tool. Omit both if a default repository is available.

A list or mask, including a one-repository set, returns result.repos: each group contains repo, status and the original single-search payload. Statuses ok, partial, error, skipped and truncated distinguish success, incompleteness, failures and stops. When byte limits omit findings, warnings remain in warnings alongside the reason. Top-level shown, limit, truncated and complete cover the entire set; an exact overall total is not promised. An ordinary single alias or an omitted selector with default_repo keeps the single-repository response. Sets are not cached; deduplication is scoped to each tool/repository pair. content.text and structuredContent carry identical data.

Fan-out is sequential: repository concurrency is 1. The shared limit defaults to 100 and accepts 1–500; object searches default to and allow at most 50. A unit is a matching grep line, file, symbol location or object; context lines do not count. Shared scan limits are 4096 files, 64 MiB compressed and 64 MiB uncompressed, including the opposite-category pass. The deadline is at most 30 seconds and no greater than tool_timeout. max_response_bytes bounds the entire response: the normal server budget (default 48,000 bytes), clamped by the server ceiling. Sets still have the finite standard budget when the server cap is disabled. A budget too small to retain groups and warnings produces an explicit error. For the four core tools this parameter applies only to sets; get_object_structure also supports it for single-repository responses. Limits are not multiplied by repository count. Measured usage appears in search_usage and header_usage. An older federated node without the internal bounded_search endpoint produces an explicit group error, with no unbounded fallback.

Zero-result grep (#31). With initial shown=0, one opposite-category pass uses the same normalized regex/glob/language: at most 256 files, 8 MiB compressed, 8 MiB uncompressed and 20 matching lines. Next to result, other_category reports category, tool, matched, complete and reasons for incompleteness. With complete=false, the count is only a lower bound. An incomplete zero means an area not fully checked; a complete zero in both categories adds neither the field nor a new hint. Existing hints, regex/query/ pattern precedence, literal pattern semantics and XML classification are retained.

Response annotations: criterion case, derived files, data version

The name_like criterion of get_object_structure (#30). The substring is normalized to NFC and compared Unicode-case-insensitively: Cyrillic and Latin match in any case (контрагенты = Контрагенты = КОНТРАГЕНТЫ). The former SQL LIKE folded case for ASCII only, so a Cyrillic criterion silently found nothing.

LIKE semantics are preserved and remain a search inside the name or synonym:

  • % — any sequence of characters, including an empty one;
  • _ — exactly one Unicode character;
  • every other character is literal, a backslash does not escape;
  • both the object name and its synonym are matched.

The reason of the match travels in every found object as matched_by: ["name"], ["synonym"] or ["name", "synonym"] (in that order). An object that matched both by name and by synonym is returned once. The 50-object cap and truncated are unchanged, as are full_name/full_names, names_only, sections, offset and response budgeting. get_object_profile does not extend the criterion.

Derived files in searches (#35). grep_code, grep_text, grep_body, search_function, search_class, search_text, find_symbol and list_files add file_annotations to their response — keyed by the source paths of the returned findings:

  • {"derived": true, "header_line": N} — the file declares itself derived with an explicit phrase in its leading comment block (НЕ редактировать, DO NOT EDIT, auto-generated, generated file, derived file, АВТОИЗВЛЕЧЕНИЕ);
  • {"derived": false} — the header was read, no explicit phrase found;
  • {"derived_status": "unknown", "derived_reason": "…"} — verification failed (no stored content, oversize, corrupt blob, exhausted budget). A false derived: false never appears in that case.

The header is read from the index only (file_contents for code, text_contents for text); nothing is read from disk and no migrations run. Limits: at most 20 physical lines and 4 KiB of uncompressed text per file, at most 64 KiB of compressed prefix per file, at most 100 paths, 256 KiB compressed and 256 KiB uncompressed per request. Multi-repo groups share these limits. BOM, CRLF, indentation, line (//, #, --) and block (/* … */) comments and a skipped shebang are handled; scanning stops at the first executable text. Therefore the following are not signs: the file name, a lone derived word, a marker inside code (a "DO NOT EDIT" string literal) and a deep comment below the header. source_path is not emitted: a reliable link to the source is not established yet. The hint (file_annotations_hint) is emitted only for confirmed derived files; incomplete header verification is reported separately in file_annotations_incomplete and is never passed off as confirmed derivedness.

Counters and limits. shown, matched and similar numbers say how much was found and returned, not how much exists: with truncated: true or a budget stop the number is a lower bound. complete: false means the area was not verified to the end (unreadable or oversize files, exhausted budget), and an empty tail of the response does not prove absence of data.

License

MIT. See LICENSE.

Acknowledgements

Project contributors are listed in CONTRIBUTORS.md.

Explore related projects

Loading…