LiLBrain
Correlate OpenTelemetry traces with static call graph for runtime correlation, identifying hot paths and dead code.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LiLBrain what functions call parse_request?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
LiLBrain
Instant codebase knowledge graph MCP server.
Drop it into any project. It auto-detects languages, indexes every function, class, and call chain, then serves it all through MCP (Model Context Protocol) — so your LLM can navigate code in milliseconds instead of reading thousands of lines.
Why
Reading 5,000 lines to understand a call chain costs ~50K tokens. One graph query costs ~200 tokens. That's a 250x cost reduction.
LiLBrain turns any codebase into a queryable knowledge graph with zero configuration.
Related MCP server: Orihime
Supported Languages (20+)
Python, Rust, Go, TypeScript, JavaScript, Java, C, C++, C#, Ruby, PHP, Swift, Kotlin, Scala, Zig, Lua, Elixir, Dart, Vortex — plus aliases (.jsx, .tsx, .mjs, .hpp, .cc, .exs).
Install
pip install lilbrainOr clone:
git clone https://github.com/MangoByteLabs/LiLBrain.git
cd LiLBrain
pip install -e .Quick Start
As MCP Server (for Claude, etc.)
Add to your .mcp.json:
{
"mcpServers": {
"lilbrain": {
"command": "lilbrain",
"args": ["/path/to/your/project"]
}
}
}Or with Python directly:
{
"mcpServers": {
"lilbrain": {
"command": "python3",
"args": ["-m", "lilbrain", "/path/to/your/project"]
}
}
}CLI Mode
# Stats overview
lilbrain /path/to/project --stats
# Quick function lookup
lilbrain /path/to/project --query main
# Dump full graph JSON
lilbrain /path/to/project --dumpWhat It Indexes
Feature | Description |
Functions | Name, params, return type, location, docstring, complexity scores |
Classes | Structs, enums, traits, interfaces, modules |
Call Graph | Who calls whom — full caller/callee edges |
Subsystems | Auto-classified from directory structure |
Pipelines | Auto-detected from function naming patterns |
Constants | UPPER_CASE constants, typed consts, finals |
Cross-edges | Cross-subsystem dependency map |
Sections | Code sections marked with |
Complexity | Cyclomatic + cognitive complexity per function |
Semantic Index | TF-IDF vectors for meaning-based search |
MCP Tools (24)
Core Graph (12)
Tool | Description |
| Project summary: files, functions, languages, subsystems |
| Look up any function — signature, location, callers, callees |
| Full call graph for a function |
| Search everything: functions, classes, sections, constants |
| File info: functions, classes, sections, language |
| Read source code of a function or file region |
| Deep dive into a subsystem |
| Trace a pipeline (parse, validate, compile, etc.) |
| Upstream callers and downstream callees |
| Depth-limited call chain trace |
| Most connected functions (highest fan-in + fan-out) |
| Architecture map: subsystems and cross-dependencies |
Impact & Quality (4)
Tool | Description |
| Blast radius analysis — change a function, see everything affected |
| Find functions with zero callers + LOC waste estimate |
| Detect near-duplicate functions (token Jaccard similarity) |
| Auto-generate Mermaid or D2 architecture diagrams |
Intelligence (4)
Tool | Description |
| Cyclomatic + cognitive complexity ranking |
| Track complexity changes over git history |
| Semantic search — find functions by meaning, not name |
| Multi-repo federated search across codebases |
Tier 3 — AI-Native (4)
Tool | Description |
| Natural language questions — auto-routes to the right analysis |
| Git-aware graph diff: changed functions, blast radius, risk |
| Auto-generate PR review context with risk assessment |
| Correlate OpenTelemetry traces with static call graph |
Features
Impact Analysis
Change a function? LiLBrain tells you exactly what breaks:
lilbrain_impact("parse_request")
→ 47 functions affected across 5 subsystems
→ Risk: HIGH
→ Subsystems: api, auth, middleware, handlers, testsAuto Architecture Diagrams
Generate always-accurate Mermaid diagrams from live code:
lilbrain_diagram("architecture")
→ graph TD
api["api\n120 fns | 3400 LOC"]
auth["auth\n45 fns | 1200 LOC"]
api -->|12| authDead Code & Clone Detection
lilbrain_deadcode()
→ 847/3200 functions unreachable (26.5%)
→ 12,400 LOC wasted
lilbrain_clones()
→ adam_step <-> adamw_step (88.5% similar)
→ tcp_recv <-> udp_recv (83.3% similar)Semantic Search
Find functions by what they do, not what they're named:
lilbrain_semantic("handle user authentication")
→ verify_token (auth/jwt.py:45) score=14.2
→ check_session (middleware/session.rs:120) score=11.8
→ validate_credentials (api/login.go:33) score=9.4Natural Language Queries
lilbrain_ask("what is the most complex code?")
→ eval_stmt: cyclomatic=189, cognitive=198
→ lex: cyclomatic=171, cognitive=182
lilbrain_ask("show me dead code")
→ 847 functions with zero callers...
lilbrain_ask("who calls parse_request?")
→ handle_http, route_api, middleware_chain...Git Time-Travel & PR Review
lilbrain_diff("main", "feature-branch")
→ 12 files changed, 34 functions modified
→ Blast radius: 156 functions affected
→ Risk: HIGH
→ New cross-subsystem edge: api -> payments (didn't exist before!)
lilbrain_pr_review()
→ **8 files changed**, **23 functions modified**
→ **Blast radius**: 89 functions potentially affected
→ **Risk**: MEDIUM
→ **New cross-subsystem edges**: auth -> billing
→ **Complexity in changed code**: 45Multi-Repo Federation
Search across all your repos at once:
lilbrain_federation(query="authenticate", repos=["/app/api", "/app/auth", "/app/gateway"])
→ api: 3 matches
→ auth: 12 matches
→ gateway: 5 matchesRuntime Correlation
Connect static analysis to production reality:
lilbrain_runtime(trace_dir="traces/")
→ Hot paths: handle_request (45,000 calls, avg 2.3ms)
→ Cold code: legacy_handler (0 invocations — truly dead)Auto-Reindex
LiLBrain watches for file changes and a .graph-dirty sentinel file. Touch .graph-dirty in your project root (e.g., from a git post-commit hook) and the graph rebuilds automatically on the next query.
# Add to .git/hooks/post-commit:
touch .graph-dirtyPerformance
Project Size | Files | Functions | Index Time |
Small (1K LOC) | ~10 | ~40 | <0.1s |
Medium (50K LOC) | ~200 | ~2,000 | ~0.5s |
Large (360K LOC) | ~550 | ~16,800 | ~2.2s |
Zero dependencies. Pure Python 3.10+. Works everywhere.
How It Works
Walk — recursively finds all source files, skipping
node_modules,.git,__pycache__, etc.Detect — identifies language from file extension, loads the right regex patterns
Extract — pulls out functions, classes, sections, constants from each file
Connect — builds a call graph by scanning function bodies for known function names
Analyze — computes complexity scores, builds TF-IDF semantic index
Classify — auto-groups files into subsystems based on directory structure
Serve — exposes everything through 24 MCP tools over JSON-RPC stdin/stdout
License
MIT
Available Tools
24 toolslilbrain_architectureC
Architecture: subsystems, cross-subsystem dependencies, language mix.
Inputs: no named parameters.
lilbrain_askA
Ask a natural language question about the codebase. Auto-routes to the right analysis tool.
Inputs: question (required).
lilbrain_callersB
Call graph for a function: who calls it and what it calls.
Inputs: name (required).
lilbrain_clonesA
Detect near-duplicate functions using token similarity. Finds copy-paste code.
Inputs: threshold.
lilbrain_complexityB
Cyclomatic + cognitive complexity analysis. Per-function detail or top-N ranking.
Inputs: n, name.
lilbrain_complexity_velocityB
Track complexity changes over recent git history. Shows which commits touched complex code.
Inputs: n_commits.
lilbrain_dataflowB
Data flow: upstream callers and downstream callees for a function.
Inputs: name (required).
lilbrain_deadcodeA
Find dead code: functions with zero callers, grouped by subsystem, with LOC waste estimate.
Inputs: no named parameters.
lilbrain_diagramB
Auto-generate Mermaid or D2 architecture diagrams. Target: "architecture", subsystem name, or function name.
Inputs: format, target.
lilbrain_diffA
Git-aware graph diff: changed functions, blast radius, risk level between any two refs.
Inputs: base, head.
lilbrain_federationA
Multi-repo federated search: query across multiple codebases at once.
Inputs: query (required), repos.
lilbrain_fileB
Get info about a file: functions, classes, sections, language.
Inputs: path (required).
lilbrain_functionA
Look up any function by name. Returns signature, location, callers, callees, language.
Inputs: name (required).
lilbrain_hotspotsB
Most connected functions (highest fan-in + fan-out).
Inputs: n.
lilbrain_impactA
Blast radius: if you change this function, what breaks? Affected callers, subsystems, risk level.
Inputs: name (required), depth.
lilbrain_overviewA
Project overview: files, functions, classes, languages, subsystems, pipelines. Start here.
Inputs: no named parameters.
lilbrain_pipelineB
Trace a named pipeline or pattern (parse, validate, handle, compile, etc.).
Inputs: name (required).
lilbrain_pr_reviewB
Auto-generate PR review context: changes, blast radius, new cross-subsystem edges, complexity delta, risk.
Inputs: base_branch.
lilbrain_readB
Read source code of a function (by name) or file region (by path + line range).
Inputs: name (required), end, start.
lilbrain_runtimeB
Correlate OpenTelemetry/Jaeger traces with static call graph. Find hot production paths and cold code.
Inputs: trace_dir, trace_file.
lilbrain_searchB
Search everything: functions, classes, sections, constants.
Inputs: query (required).
lilbrain_semanticA
Semantic search: find functions by meaning, not just name. "handle authentication" finds verify_token, check_session, etc.
Inputs: query (required), n.
lilbrain_subsystemB
Deep dive into a subsystem: files, top functions, languages.
Inputs: name (required).
lilbrain_traceB
Depth-limited call chain trace from a function.
Inputs: name (required), depth.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 24 tools
Several tools cover overlapping call-graph and impact territory: callers, dataflow, trace, impact, diff, and pr_review all involve upstream/downstream callers and blast radius. Overview, architecture, and subsystem also blur boundaries, while search, semantic, and ask offer vaguely differentiated discovery paths.
All tools share the lilbrain_ prefix and use snake_case, which gives a consistent visual pattern. However, naming mixes noun-style resources (function, callers, hotspots) with verb-style actions (read, search, ask), so the convention is not perfectly uniform.
24 tools is at the heavy end of the borderline range. The domain is broad enough to justify many specialized analyses, but the overlapping call-graph and discovery tools suggest the set could be consolidated without losing capability.
The toolset is remarkably complete for read-only code intelligence: it covers navigation, call graphs, dataflow, impact analysis, architecture, code quality, dead code, clone detection, semantic search, diffs, PR review, and runtime correlation. There are no obvious dead ends for typical codebase understanding workflows.
Maintenance
Related MCP Connectors
Repository knowledge graph MCP server for codebase understanding and debugging.
Shared context for your codebase: a hosted code knowledge graph over MCP. Free plan, OAuth sign-up.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
An MCP server that gives your AI access to the source code and docs of all public github repos
Related MCP Servers
- AlicenseAqualityAmaintenanceFramework-aware code intelligence MCP server that builds a cross-language dependency graph from source code. 53 integrations (Laravel, Django, Rails, Spring, NestJS, Next.js, and more) across 68 languages. 100+ tools for navigation, impact analysis, refactoring, security scanning, session memory, and CI/PR reports — up to 97% token reduction.294,769 npm204MIT
- AlicenseAqualityDmaintenanceCross-repository code knowledge graph MCP server for Java, Kotlin, JavaScript, and TypeScript. Indexes source code into embedded KuzuDB via tree-sitter and exposes 30+ tools for call-flow tracing, multi-hop taint analysis (OWASP/CWE/PCI/STIG), entry-point reachability filtering, performance hotspot detection, and license compliance — without reading source files. 95% fewer tokens vs source-read332MIT
- AlicenseBqualityBmaintenanceHigh-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 159 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.1748,570MIT
- AlicenseNot gradedqualityDmaintenanceMCP server for semantic code search and dependency graph analysis. Indexes codebases into a knowledge graph with vector embeddings for AI-powered code understanding.21 npmMIT