Compiler-grade code intelligence for AI agents over MCP.
Lifeblood loads a C# / Unity workspace through Roslyn, builds a persistent semantic graph with stable symbol IDs, and exposes it to AI agents over MCP, so an agent can ask "what calls this?", "what breaks if I rename it?", "does this edited file still compile?", "which architecture invariant declares this rule?" and get verified answers instead of grep guesses. Every read side response carries a truth envelope (evidence tier, confidence band, staleness) so the agent knows when an answer is Proven, Advisory, or Speculative.
Roslyn is the engine. Lifeblood is the layer around it: persistent project graph, 26 MCP tools, Unity-aware reachability, incremental re-analysis, CI-wireable export and verify commands.
dotnet tool install --global Lifeblood
dotnet tool install --global Lifeblood.Server.McpRequires .NET 8 SDK.
Add to your project's .mcp.json:
{
"mcpServers": {
"lifeblood": {
"command": "lifeblood-mcp",
"args": []
}
}
}See MCP Setup Guide for Claude Desktop, VS Code, Cursor, and raw stdio configs.
lifeblood_analyze projectPath="/path/to/your/project" → load semantic graph
lifeblood_blast_radius symbolId="type:MyApp.AuthService" → what breaks if I change this?
lifeblood_file_impact filePath="src/AuthService.cs" → what files are affected?
lifeblood_find_references symbolId="type:MyApp.IRepo" → every caller, every consumer
lifeblood_search query="quantize timing to grid" → ranked keyword + xmldoc search
lifeblood_invariant_check id="INV-CANONICAL-001" → query architectural invariants
lifeblood_compile_check filePath="src/MyFile.cs" → does this file still compile?
lifeblood_execute code="typeof(MyApp.Foo).GetMethods()" → run C# against your types
After the first analysis, use incremental: true for fast re-analysis (seconds instead of minutes).
lifeblood analyze --project /path/to/your/project
lifeblood analyze --project /path/to/your/project --rules hexagonal
lifeblood context --project /path/to/your/project
lifeblood export --project /path/to/your/project --out graph.json
lifeblood verify --incremental --project /path/to/your/projectexport --out writes the graph JSON to a file directly (preferred over shell redirection on Windows PowerShell, where > defaults to UTF-16-LE-with-BOM and breaks JSON re-import without the INV-JSON-IMPORT-BOM-001 BOM-aware reader). verify --incremental runs full + incremental analyze in one process and asserts summary.edges are identical (INV-INCREMENTAL-XREF-001); non-zero exit on drift makes it CI-wireable.
git clone https://github.com/user-hash/Lifeblood.git
cd Lifeblood
dotnet build
dotnet testRoslyn (C#) ──┐ ┌── Execute code against project types
TypeScript ──┤ ┌────────────────────────┐ ├── Diagnose / compile-check
JSON graph ──┼→ │ Semantic Graph │ →┤── Find references / rename / format
──┤ │ (symbols / edges / │ ├── Blast radius / file impact
community ──┘ │ evidence / trust) │ └── Context packs / architecture rules
adapters └────────────────────────┘
Connect an MCP client. Load a project. The AI agent gets 26 tools: 16 read, 10 write.
| Tools | |
|---|---|
| Read | Analyze, Context, Lookup, Dependencies, Dependants, Blast Radius, File Impact, Resolve Short Name, Resolve Member, Search, Dead Code, Partial View, Invariant Check, Authority Report, Port Health, Cycles |
| Write | Execute, Diagnose, Compile-check, Find References, Find Definition, Find Implementations, Symbol at Position, Documentation, Rename, Format |
Every read-side tool that takes a symbolId routes through one resolver (canonical id, truncated method form, bare short name, kind correction, wrong-namespace fallback). Every read-side response carries a typed truth envelope: truth tier, confidence band, evidence source, staleness, per-tool limitations.
Full tool reference · What's new
Hexagonal. Pure domain core with zero dependencies. Language adapters on the left, AI connectors on the right.
LEFT SIDE CORE RIGHT SIDE
(Language Adapters) (The Pipe) (AI Connectors)
Roslyn (C#) ──┐ ┌── MCP Server (26 tools)
TypeScript ──┼→ Domain → Application →┤── Context Pack Generator
JSON graph ──┘ ↑ ├── Instruction File Generator
Analysis (optional) └── CLI / CI
26 port interfaces, all wired. Boundaries enforced by architecture invariant tests, 80 typed invariants under docs/invariants/ (queryable via lifeblood_invariant_check), and 11 frozen ADRs.
Full architecture · Interactive diagram
| Adapter | How it works | Confidence |
|---|---|---|
| C# / Roslyn | Compiler-grade semantic analysis. Cross-module resolution. Bidirectional: analysis + code execution. | Proven |
| TypeScript | Standalone Node.js. ts.createProgram + TypeChecker. |
High |
| Python | Standalone ast module. Zero dependencies. |
Structural |
| Any language | Output JSON conforming to schemas/graph.schema.json. |
Varies |
Lifeblood runs as a sidecar alongside Unity MCP. All 26 tools available in the Unity Editor via [McpForUnityTool] discovery — separate process, no assembly conflicts, no domain-reload interference. dead_code recognizes Unity reflection dispatch (MonoBehaviour magic methods, full Editor attribute roster, type-via-child propagation). compile_check filePath=... resolves the file's owning compilation and swaps the existing tree, so module-owned files compile-check against their real reference set. execute auto-injects DLLs from Library/ScriptAssemblies/.
Self-analysis (v0.7.3-candidate, post field-report 2026-05-11 polish wave): 2,513 symbols, 12,446 edges, 11 modules, 284 types, 0 violations, 0 cycles. 776 tests across Lifeblood.Tests, zero regressions. Lifeblood audits its own architectural invariants via lifeblood_invariant_check against docs/invariants/: 80 typed invariants across 43 categories, zero duplicates, zero parse warnings.
Production-verified on a 90-module 400k LOC Unity workspace: 62,134 symbols, 219,548 edges, 123 SCCs. Authority report classifies methods across the full surface and identifies forwarder candidates for any host-with-many-subordinates triage (partial-class hosts, dispatchers, facades, ports). Edge count grew +18% over the prior baseline because enum-member references the dangling-edge filter was silently dropping (R2-3) now resolve. Memory profiles, throughput numbers, and the full dogfood story live in Status. 50+ real bugs surfaced through dogfooding — methodology, examples, and per-finding history live in Dogfood Findings.
- Community adapters: contribution guides for Go and Rust. Contract and checklist ready, no implementation code yet.
- REST / LSP bridge: expose the graph to IDE extensions and web services.
| Page | Description |
|---|---|
| Tools | All 26 tools — symbol ID format, incremental usage, dead_code caveats, file-mode compile_check, smart-dynamic context shaping |
| MCP Setup | Copy-paste configs for Claude Code, Cursor, VS Code, Claude Desktop, Unity |
| Unity Integration | Sidecar architecture, setup, Unity reachability + Editor reflection roster, file-mode compile_check |
| Architecture | Hexagonal structure, dependency flow, 26 port interfaces, invariant tree |
| Architecture Decisions | 11 frozen ADRs |
| Invariants tree | 80 typed architectural invariants, queryable via lifeblood_invariant_check |
| Status | Component table, test counts, self-analysis, production stats, memory profiles |
| Adapters | How to build a language adapter (13-item checklist) |
| Dogfood Findings | 50+ bugs found by self-analysis and reviewer dogfood sessions |
| CHANGELOG | Every release — additions, fixes, known limitations |
- LivingDocFramework — the methodology that shaped the architecture
- Roslyn — the C# compiler platform
- Case study — the 400k LOC Unity project where these ideas were proven
AGPL v3
