Metadata-Version: 2.4
Name: code-graph-rag-mcp
Version: 0.1.0
Summary: Local-first code knowledge graph MCP server
Author: Andrew
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: mcp>=0.1.0
Requires-Dist: pydantic>=2.6
Requires-Dist: watchfiles>=0.21
Requires-Dist: tree-sitter==0.21.1
Requires-Dist: tree-sitter-languages==1.9.1
Requires-Dist: PyYAML>=6.0
Requires-Dist: sqlite-utils>=3.36
Requires-Dist: typer>=0.9
Requires-Dist: numpy>=1.26
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: ruff; extra == "dev"

# Code GraphRAG MCP Server

This module implements the local-first Code GraphRAG MCP server described in `../docs/code-graph-rag-mcp.md`. The spec covers the full architecture: repository watcher, Tree-sitter based symbol extraction, AST-aligned chunking, EmbeddingGemma integration, SQLite (`sqlite-vec`, `bfsvtab`) storage, and MCP tools for ingest/search/status.

## Next Steps
- Port the spec content into actionable tasks (schema, watcher, parsers, retrieval).
- Initialize the codebase structure (`src/`, `tests/`, configuration) following the deliverables checklist.

Refer back to the spec for detailed requirements and pseudo-code snippets.

## SQLite Extensions
- Wheels built from this project bundle sqlite-vec and bfsvtab automatically; no manual steps are required after `pip install`.
- To rebuild native libraries locally (for development or alternative platforms), run `python scripts/build_sqlite_extensions.py`.
- Override inputs via `--sqlite-vec-src` / `--bfsvtab-src`, and customize discovery with `DATABASE.extensions_dir` in the config.

## Development
- Create and activate a virtualenv: `python -m venv .venv && source .venv/bin/activate`.
- Install dependencies: `pip install -e .[dev]`.
- Build SQLite extensions (sqlite-vec + bfsvtab): `python scripts/build_sqlite_extensions.py`.
- Initialize the database: `code-graph-rag-mcp init-db --config config.yaml` (optional if using defaults).
- Launch the MCP server over stdio: `code-graph-rag-mcp serve`.

## Testing
- Run the pytest suite (includes building extensions in a temp dir): `pytest`.

## Runtime Features
- File watcher + job queue keeps the database in sync with repo changes.
- Hybrid search returns BFS neighbor context using configurable hop depth.
## Environment Overrides
- `CODE_GRAPH_RAG_CONFIG`: optional path to override the default `config.yaml`.
- `CODE_GRAPH_RAG_WATCH_DIR`, `CODE_GRAPH_RAG_DB_PATH`, `CODE_GRAPH_RAG_EXTENSIONS_DIR`, etc., adjust watcher and database settings at runtime.
- `CODE_GRAPH_RAG_SQLITE_VEC` / `CODE_GRAPH_RAG_BFSVTAB` can point to custom extension locations if you don’t want to use the bundled binaries.
- Embedding overrides: `CODE_GRAPH_RAG_EMBED_MODEL`, `CODE_GRAPH_RAG_EMBED_ENDPOINT`, `CODE_GRAPH_RAG_EMBED_DIM`, `CODE_GRAPH_RAG_EMBED_QUANTIZE`.
- Retrieval overrides: `CODE_GRAPH_RAG_RETRIEVAL_K`, `CODE_GRAPH_RAG_RETRIEVAL_HOPS`.

The MCP manifest’s `env` block is the recommended place to set these.
