code-index-pg
code-index-pg
Unified code index for Hermes: exact + semantic + call graph search over the TGT One monorepo, persisted in postgres. Replaces the code-index fork, cocoindex and CodeGraphContext with one lightweight MCP server.
Stack
postgres-local (port 5432, DB
codeindex) + pgvector 0.8.3Ollama
bge-m3(1024 dims) for embeddings — no torch in this venvtree-sitter-language-pack (21 languages) for symbol extraction
fastmcp — single MCP process, no extra daemons
Install
git clone https://github.com/tgt-technology/code-index-pg.git
cd code-index-pg
uv sync
uv tool install --editable .DB: la infraestructura (postgres + pgvector, ollama + bge-m3, base codeindex) se
levanta con deploy/ — ver Deploy. El esquema de tablas lo
aplica el server al arrancar.
Deploy (entorno desde cero)
El índice vive en postgres, no en archivos: reproducir el entorno es levantar la infra, no
copiar datos. Todo está en deploy/.
Windows (Docker Desktop + uv):
powershell -NoProfile -File deploy\setup.ps1 # -Gpu si hay GPU NVIDIALinux / WSL:
deploy/setup.sh # --gpu si hay GPU NVIDIAEl script levanta postgres (pgvector) + ollama, crea la base codeindex con la extensión
vector, descarga bge-m3, instala el server como uv tool y verifica cada punto al final
(falla con mensaje claro si algo quedó a medias).
Después, una sola vez, el índice inicial (~30 min para ~7K archivos):
uv run python -c "from code_index_pg.indexer_pipeline import index_project; print(index_project('/ruta/a/tu/codigo'))"Registro en Hermes — el wrapper espera a que postgres acepte conexiones antes de lanzar el server (sin eso, el server muere si la BD no está lista):
# Linux / WSL
hermes mcp add codeindex --command /ruta/al/repo/deploy/mcp-wrapper.sh
# Windows
hermes mcp add codeindex --command powershell --args -NoProfile -File C:\ruta\al\repo\deploy\mcp-wrapper.ps1Solo los servicios van en Docker: el server MCP es stdio y corre en el host, usando los
defaults del código (127.0.0.1:5432/codeindex, http://localhost:11434).
Run
# MCP server (stdio — used by the proxy wrapper)
code-index-pg --project-path ~/develop
# Full index (one-time, ~10 min for ~7K files)
python -m code_index_pg.indexer_pipeline # via test harness, or:
uv run python -c "from code_index_pg.indexer_pipeline import index_project; print(index_project('/home/jam/develop'))"MCP tools
Tool | Description |
| Index a project and start the incremental watcher |
| Incremental re-index: add missing files, drop deleted ones (no re-embed) |
| Literal/regex search over symbol names + file paths (paginated) |
| Embedding similarity search (bge-m3, pgvector cosine) |
| Symbols that call the given symbol |
| Symbols called by the given symbol |
| 2-level recursive callers + affected files |
| Glob search over indexed files |
| Signature, docstring, location of a symbol |
| Language, line count, symbols of a file |
| Indexed projects + counts + active project |
| Remove an indexed project and all its data in cascade (rejects the active project) |
Hermes integration
Proxy: port 3104 in
~/.hermes/scripts/mcp-proxies.sh(supervisor systemd)Wrapper:
~/.hermes/scripts/mcp-codeindex-wrapper.shRegister:
hermes mcp add codeindex --url http://127.0.0.1:3104/mcp
Environment
Var | Default | Notes |
|
| local tool |
|
| embeddings |
|
| must match pgvector dims (1024) |
| unset | active project (set via |
Tests
uv run pytest tests/ -q # unit + contract (in-memory MCP client)Spec / OpenSpec
Living spec: openspec/specs/code-index/spec.md — archived changes in
openspec/changes/archive/ (unified-code-index, project-directory-management).
License
MIT — free to use, modify and redistribute. See LICENSE.