CodeGraph RAG Tutorial: Query and Edit Your Codebase with MCP + AI
Step-by-step tutorial: index a repository with CodeGraph RAG, query it in natural language, and connect it to Claude Code or Cursor via MCP for AI-assisted edits.
CodeGraph RAG does two jobs: it answers questions about your codebase and it lets AI assistants edit code with full context. In this tutorial, you will index a repository and query it β both from the CLI and through an MCP client like Claude Code.
π Want to deploy CodeGraph RAG yourself?
Docker configs, system requirements, and installation guides β all on one page.
View CodeGraph RAG Tool Page βStep 1: Start the stack
You need Docker for Memgraph and Qdrant, plus ripgrep and cmake as prerequisites. Then pull the official image:
docker pull ghcr.io/vitali87/code-graph-rag:latest
Run the CLI against any repository. The indexer parses source files with tree-sitter and builds the graph incrementally:
code-graph-rag index --path ./my-monorepo
Step 2: Query in natural language
Once indexed, ask questions directly. The graph layer resolves relationships that vector search alone would miss:
code-graph-rag query "Which modules import the auth package?"
Results include exact file paths and line numbers β useful for onboarding, refactoring impact analysis, and documentation generation.
Step 3: Connect it to your AI assistant
CodeGraph RAG runs as an MCP server, so Claude Code, Cursor, and other MCP-compatible assistants can query and edit your codebase directly. Configure it as an MCP endpoint and your assistant suddenly has a precise map of the whole monorepo:
| Use case | What you can do |
|---|---|
| Onboarding | Ask "how does checkout work?" and get a real call path |
| Refactoring | Find every caller before renaming a function |
| AI-assisted edits | Let the assistant edit with full dependency context |
| Code review | Verify cross-language impact before merge |
Step 4: Export and share
The CLI can export the graph for visualization, letting teams browse the architecture as an interactive diagram instead of digging through folders.

Final verdict
CodeGraph RAG is one of the strongest local-first code intelligence tools available right now. The hybrid graph+vector design is genuinely different from naive chunked RAG, the MCP integration is polished, and the permissive MIT license makes it a no-brainer for teams that care about code privacy. With 4.6K+ stars and active development, it is a solid foundation for your AI-assisted development workflow.
π Want to deploy CodeGraph RAG yourself?
Docker configs, system requirements, and installation guides β all on one page.
View CodeGraph RAG Tool Page β