Ask your AI coding tool "who injects AuthService?" or "what calls ValidateToken?" and get answers backed by real Roslyn AST analysis — not guesswork.
dotnet-graph indexes your .NET solution into a structured SQLite database and exposes it over MCP (for AI agents) or a REST API (for anything else). Works with Claude Code, Cursor, and any other MCP-compatible tool.
- Python 3.11+ — verify with
python --version - .NET SDK 8+ — verify with
dotnet --version
pip install dotnet-graphmacOS with uv: If
pip installfails because uv intercepts it, useuv tool install dotnet-graphinstead. This creates an isolated environment and putsdotnet-graphon your PATH.
Windows: If
dotnet-graphis not found after install, pip'sScriptsfolder is likely missing from your PATH. The quickest fix is to use pipx instead — it handles PATH automatically:pipx install dotnet-graphAlternatively, add
%APPDATA%\Python\Python3xx\Scriptsto your user PATH via System → Environment Variables, then restart your terminal.
Run once from anywhere inside your .NET repo:
# Claude Code (default)
dotnet-graph install
# Cursor
dotnet-graph install --agent cursor
# Both at once
dotnet-graph install --agent allThis auto-detects your solution root and:
- Builds the knowledge graph (SQLite DB at
.dotnet-graph/knowledge.db) - Registers the MCP server with your AI coding tool
- Patches the agent rules file with dotnet-graph tool instructions
| Agent | MCP config | Rules file |
|---|---|---|
| Claude Code | .mcp.json + claude mcp add |
CLAUDE.md |
| Cursor | .cursor/mcp.json |
.cursorrules + AGENTS.md |
Restart your AI coding tool and you're done.
Optional: install Claude Code hooks
For an even tighter workflow, add Claude Code hooks that nudge the AI to use dotnet-graph before falling back to Grep and remind it to keep knowledge notes up to date:
dotnet-graph configure-claude # write to .claude/settings.json (shared)
dotnet-graph configure-claude --scope local # personal, git-ignored
dotnet-graph configure-claude --dry-run # preview without writingSolution not at repo root? Pass the path explicitly:
dotnet-graph install --root /path/to/your/repo
Skip rules file patching:
dotnet-graph install --skip-claude-md
Subsequent builds are incremental — only changed files are re-analyzed. Force a full rebuild with
dotnet-graph build --full.
find_type → locate any class or interface
get_type_members → methods, properties, fields, constructor injections
find_injectors → who depends on this type (DI graph)
find_implementors → subclasses and interface implementations
get_method_calls → trace execution flow from a method
find_callers → who calls this method across the codebase
get_di_registrations → MvvmCross / DI registration lifetimes
get_endpoints → HTTP endpoints
get_features → ViewModel-centric feature index
get_stats → build metadata and row counts for the knowledge graph
search → keyword search across everything
build_graph → trigger an incremental or full rebuild from inside the agent
build_obsidian_vault → export the graph as an Obsidian vault for visual exploration
get_or_create_note → get or create a persistent knowledge note for a type
update_note → write the ## Notes section (purpose, behaviours, work log)
sync_note_structure → refresh a note's structure after a graph rebuild
AI agents can accumulate domain knowledge about types as they work, persisting it across sessions in .dotnet-graph/notes/<Domain>/<Project>/<TypeName>.md.
Each note has two parts:
- Structure — auto-generated from the graph (methods, DI, inheritance). Refreshed on demand via
sync_note_structure. - Notes section — maintained by the agent (purpose, business logic, gotchas, work log). Never overwritten.
Typical agent workflow:
- Read or modify a source file
- Call
get_or_create_note("TypeName")— creates the note if new - Edit the
## Notessection with purpose, key behaviours, and a work log entry - After a
build_graph, callsync_note_structure("TypeName")to refresh structure without losing notes
Rebuilds are incremental by default — only changed files are re-analyzed.
From the terminal:
dotnet-graph build # incremental
dotnet-graph build --full # full rebuildFrom inside the agent — just ask it to run build_graph:
rebuild the graph
Generate an Obsidian vault for a visual map of your codebase:
dotnet-graph obsidianOr ask your agent: "export the graph to Obsidian" — it calls build_obsidian_vault directly.
git clone https://github.com/dationguyen/dotnet-graph
cd dotnet-graph
uv sync --extra dev
uv run --with pytest --with httpx pytest tests/integration_test.py -vRequires .NET SDK 8+ for the Roslyn analyzer.
Docs