A C++ replication of the code-graph-rag-mcp TypeScript project, built as a learning exercise.
An MCP server that:
- Parses source code into an Abstract Syntax Tree (AST) using Tree-Sitter
- Stores code entities (functions, classes) and relationships (calls, imports) in a SQLite graph database
- Generates vector embeddings for semantic code search
- Serves 26 tools to AI assistants (Claude, Gemini) via the MCP protocol
code-graph-rag-cpp/
├── CMakeLists.txt ← Open this in Visual Studio
├── config/default.yaml ← Application settings
├── examples/hello.py ← Test files for parser
├── src/
│ ├── main.cpp ← Entry point (milestone tests)
│ ├── types/ ← ⭐ START HERE: Data models
│ │ ├── entity_types.h ← Enums (EntityType, RelationType)
│ │ ├── storage_types.h ← Core structs (Entity, Relationship)
│ │ ├── parser_types.h ← Parser output types
│ │ ├── agent_types.h ← Agent system types
│ │ ├── semantic_types.h ← Embedding/vector types
│ │ └── error_types.h ← Custom exceptions
│ ├── config/ ← YAML config loading
│ ├── storage/ ← SQLite graph database
│ │ ├── sqlite_manager.* ← Connection + pragmas
│ │ ├── schema_migrations.* ← Table creation
│ │ ├── graph_storage.* ← CRUD operations (Facade)
│ │ ├── batch_operations.* ← Bulk inserts
│ │ └── cache_manager.h ← LRU cache (complete!)
│ ├── parsers/ ← [TODO] Tree-sitter parsing
│ ├── agents/ ← [TODO] Multi-agent system
│ ├── semantic/ ← [TODO] Embedding + vector search
│ ├── core/ ← [TODO] Knowledge bus
│ └── tools/ ← [TODO] MCP tool implementations
└── tests/ ← [TODO] Unit tests
- Visual Studio Community 2022 with "Desktop development with C++" workload
- vcpkg for dependency management
# Install vcpkg (one-time setup)
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
# Install project dependencies
.\vcpkg install sqlite3 yaml-cpp nlohmann-json gtest- Open Visual Studio
- File → Open → CMake...
- Navigate to
CMakeLists.txtin this folder - Visual Studio auto-generates the solution
- Build → Build All (Ctrl+Shift+B)
- Debug → Start Debugging (F5)
| Phase | Milestone | What to Implement |
|---|---|---|
| 1 | ✅ Types compile | src/types/ — Already done! |
| 2 | Config loads | src/config/ — Load YAML settings |
| 3 | DB works | src/storage/ — SQLite CRUD |
| 4 | Parser works | src/parsers/ — Tree-sitter AST |
| 5 | Agents run | src/agents/ — Task delegation |
| 6 | Search works | src/semantic/ — Embeddings |
| 7 | Server runs | main.cpp — MCP JSON-RPC |
- F9: Set breakpoint
- F5: Start debugging
- F10: Step over (execute line)
- F11: Step into (dive into function)
- Shift+F11: Step out
- Watch Window: Add variables to monitor
- DB Browser for SQLite: Open .db files to inspect tables