Understand-Anything MCP Server
This server exposes codebase and business-domain knowledge graphs to MCP-compatible AI assistants, enabling deep, evidence-based code understanding through 17 query tools.
Project discovery & stats:
list_projects,get_graph_stats,get_graph_metadata, andget_tourgive overviews, freshness analysis, and guided walkthroughs.Code graph search:
query_nodesperforms weighted fuzzy search;get_node_detailreturns full node info;get_node_sourceextracts real source code.Relationship & call analysis:
get_relationships,trace_call_chain,find_impact, andfind_entry_pointsmap connections, call trees, blast radius, and API candidates.Architecture & navigation:
get_layer_infolists/explores layers,search_by_file_pathfinds nodes by path,find_pathfinds shortest connections, andget_class_hierarchyshows inheritance trees.Business domain insight:
get_domain_overview,get_domain_detail, andget_domain_flow_detailexplain business domains, flows, steps, and their code cross-references.Multi-project support: Load many projects and let the AI auto-select or explicitly pass a
projectparameter.Freshness & auto-reload: Graph files are checked against git HEAD and reloaded when changed on disk.
Skill integration: A bundled
codebase-explainskill enforces evidence-only, freshness-gated explanations.
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., "@Understand-Anything MCP Server Find all entry points in the project"
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.

🧠 Understand-Anything MCP Server
MCP Server giúp trợ lý AI hiểu sâu bất kỳ codebase nào thông qua Knowledge Graph.
Giới thiệu
MCP Server này tải các Knowledge Graph được tạo bởi Understand-Anything và cung cấp chúng dưới dạng các tool có thể truy vấn cho bất kỳ trợ lý AI tương thích MCP nào (Gemini CLI, Claude Desktop, Cursor, v.v.).
Server hỗ trợ hai loại đồ thị đồng thời cho mỗi dự án:
Đồ thị | Tệp | Nội dung |
Code Graph |
| Files, functions, classes, imports, chuỗi gọi hàm, các tầng kiến trúc |
Domain Graph |
| Nghiệp vụ (domains), luồng xử lý (flows), bước (steps), thực thể, quy tắc nghiệp vụ |
Hỗ trợ đa dự án — Tải N dự án cùng lúc và truy vấn bất kỳ dự án nào. AI tự động nhận diện dự án phù hợp dựa trên ngữ cảnh workspace.
Tính năng nổi bật
🔍 Tìm kiếm mờ (Fuzzy search) — Tìm kiếm có trọng số (tên 3x > mô tả 1.5x > tags 1x) sử dụng
rapidfuzz🏗️ Tầng kiến trúc — Truy vấn theo layer (controller, service, repository, v.v.)
🌊 Truy vết chuỗi gọi hàm — Duyệt BFS theo các lời gọi hàm
💥 Phân tích vùng ảnh hưởng — Tìm tất cả node bị ảnh hưởng khi thay đổi một node (BFS ngược)
🎯 Phát hiện entry point — Nhận diện API endpoint và các hàm không được gọi bởi hàm khác
🏢 Tri thức nghiệp vụ — Domains, flows, steps, thực thể và quy tắc nghiệp vụ
📖 Trích xuất mã nguồn đa ngôn ngữ — Đọc source code thực tế của bất kỳ node nào, hỗ trợ trích xuất symbol-level cho Java, Kotlin, TypeScript, JavaScript, Python, Go, Rust, C#
🔗 Tìm đường ngắn nhất — BFS vô hướng giữa hai node bất kỳ trong đồ thị
🏛️ Cây kế thừa — Truy vết extends/implements lên và xuống toàn bộ hệ thống phân cấp class
📁 Tìm kiếm theo đường dẫn — Tìm tất cả node theo package/module/thư mục path (O(P) qua path index)
🌉 Domain↔Code Cross-reference — Tự động bridge từ domain step → code node qua
_nodes_by_pathindex O(1), semantic ranking khi prefix match (penalize boilerplate, ưu tiên class liên quan theo tên/mô tả/tags)🔄 Tự động tải lại — Phát hiện khi file graph thay đổi trên đĩa và tự động reload
✅ Phân tích độ mới — So sánh commit hash của graph với HEAD hiện tại qua
git diff⚡ Edge Resolution Layer — Class và function node tự động kế thừa quan hệ từ file cha, tra cứu O(degree) qua edge index
🧪 59 unit tests — Bộ test toàn diện bảo vệ regressions, chạy trong <0.1s
📚 Skill kèm theo —
codebase-explain: hướng dẫn AI giải thích sâu file/symbol/module/business flow bằng evidence read-only từ server (output có cấu trúc, gắn freshness, không bịa node ID)
Related MCP server: PT-MCP (Paul Test Man Context Protocol)
Bắt đầu nhanh
Yêu cầu
Python ≥ 3.12
Trình quản lý package
uvMột dự án đã được tạo graph bởi Understand-Anything (thư mục
.understand-anything/)
Cài đặt & Chạy
# Clone repository
git clone https://github.com/VIethoangnguyenle/Understand-Anything-MCP.git
cd Understand-Anything-MCP
# Cài đặt dependencies
uv sync
# Chạy với MCP Inspector (để test/debug)
PROJECT_ROOTS=/đường/dẫn/tới/dự-án npx @modelcontextprotocol/inspector uv run server.py
# Chạy MCP dev server
PROJECT_ROOTS=/đường/dẫn/tới/dự-án mcp dev server.pyĐa dự án
Đặt PROJECT_ROOTS là danh sách đường dẫn phân cách bằng dấu phẩy:
PROJECT_ROOTS=/đường/dẫn/dự-án-a,/đường/dẫn/dự-án-b uv run server.pyMỗi tool đều nhận tham số project tùy chọn. Nếu chỉ có một dự án được tải, nó sẽ được sử dụng tự động.
Chạy bằng Docker
Repo kèm sẵn Dockerfile và compose.example.yaml để chạy server trong container — không cần cài Python hay uv trên máy, và dự án được mount chỉ đọc.
Dựng ảnh
docker build -t ua-mcp:local .Chạy một lần
Server nói MCP qua stdio, không mở cổng nào. Vì vậy phải chạy với -i, và đừng docker compose up -d — container sẽ khởi động rồi thoát ngay vì không ai nối vào stdin.
docker run -i --rm \
-v /đường/dẫn/dự-án:/data/du-an:ro \
-e PROJECT_ROOTS=/data/du-an \
-e GIT_CONFIG_COUNT=1 \
-e GIT_CONFIG_KEY_0=safe.directory \
-e GIT_CONFIG_VALUE_0='*' \
ua-mcp:localHoặc chép compose.example.yaml thành compose.yaml, sửa đường dẫn, rồi:
docker compose run --rm -T ua-mcpNối vào MCP client
Trỏ client thẳng vào docker, thay vì uv:
{
"mcpServers": {
"understand-anything": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-v", "/đường/dẫn/dự-án:/data/du-an:ro",
"-e", "PROJECT_ROOTS=/data/du-an",
"-e", "GIT_CONFIG_COUNT=1",
"-e", "GIT_CONFIG_KEY_0=safe.directory",
"-e", "GIT_CONFIG_VALUE_0=*",
"ua-mcp:local"
]
}
}
}Hai cái bẫy khiến FRESHNESS luôn UNKNOWN
Cả hai đều fail trong im lặng — server chạy bình thường, tool trả lời bình thường, chỉ có FRESHNESS âm thầm về UNKNOWN mãi mãi. Nhìn từ ngoài giống hệt như dự án không phải git checkout, nên rất dễ bỏ qua.
Ảnh phải có
git.check_freshnessgọigit rev-parse HEADvàgit diffbên trong thư mục dự án. Basepython:3.12-slimkhông kèmgit; thiếu nó thìFileNotFoundErrorbị nuốt và mọi dự án đều báoUNKNOWN.Dockerfiletrong repo đã cài sẵn.Phải khai báo
safe.directory. Dự án mount vào container thường thuộc uid khác với user chạy trong container, git từ chối với dubious ownership và mọi lệnh đều fail. Dùng biến môi trườngGIT_CONFIG_COUNT/GIT_CONFIG_KEY_0/GIT_CONFIG_VALUE_0thay vì ghi~/.gitconfig— container chạyread_onlynên không ghi file config được.
Kiểm nhanh sau khi dựng ảnh:
docker run --rm ua-mcp:local git --versionRồi gọi get_graph_stats và xem mục FRESHNESS có thoát khỏi UNKNOWN không.
Ghi chú bảo mật
compose.example.yaml mặc định bật read_only: true, cap_drop: ALL, no-new-privileges, và chạy bằng uid không phải root (1001). Server chỉ đọc graph rồi trả lời truy vấn nên không cần ghi gì; chỉ khi bật usage metrics mới cần đúng một mount ghi được.
Cấu hình MCP Client
Gemini CLI / Antigravity
Thêm vào ~/.gemini/antigravity/mcp_config.json:
{
"understand-anything": {
"command": "uv",
"args": ["--directory", "/đường/dẫn/tuyệt/đối/tới/Understand-Anything-MCP", "run", "server.py"],
"env": {
"PROJECT_ROOTS": "/đường/dẫn/tới/dự-án-a,/đường/dẫn/tới/dự-án-b"
}
}
}Claude Desktop
Thêm vào claude_desktop_config.json:
{
"mcpServers": {
"understand-anything": {
"command": "uv",
"args": ["--directory", "/đường/dẫn/tuyệt/đối/tới/Understand-Anything-MCP", "run", "server.py"],
"env": {
"PROJECT_ROOTS": "/đường/dẫn/tới/dự-án"
}
}
}
}Cursor / Các MCP Client khác
Sử dụng cùng cấu trúc — đặt command là uv, truyền đường dẫn server qua --directory, và cấu hình PROJECT_ROOTS trong env.
Danh sách Tools (17 tools)
Khám phá & Tổng quan
Tool | Mô tả |
| Liệt kê tất cả dự án đã đăng ký kèm số lượng node/edge và thông tin domain |
| Thống kê toàn diện: phân bố type, layers, phân tích độ mới của graph |
| Snapshot JSON có cấu trúc: counts, graph commit, repository HEAD, freshness (bản machine-readable của |
| Tour hướng dẫn dự án — các điểm dừng được chọn lọc giải thích các thành phần chính |
Truy vấn Code Graph
Tool | Mô tả |
| Tìm kiếm mờ có trọng số theo từ khóa. Hỗ trợ lọc |
| Chi tiết đầy đủ của một node theo ID: đường dẫn, layer, độ phức tạp, tags, số lượng quan hệ |
| Đọc mã nguồn thực tế của node. Trích xuất symbol-level đa ngôn ngữ (Java/Kotlin/TS/Python/Go/...) |
| Tất cả node liên kết kèm loại quan hệ. Class/function tự động kế thừa edge từ file cha |
| Cây gọi hàm BFS từ một function (theo edge |
| Liệt kê các tầng kiến trúc hoặc lấy tất cả node trong một layer cụ thể |
| Các function không được gọi bởi function khác — tiềm năng là API endpoint |
| Vùng ảnh hưởng: tất cả node bị ảnh hưởng nếu node này thay đổi (BFS ngược) |
Truy vấn nâng cao
Tool | Mô tả |
| Tìm đường đi ngắn nhất giữa hai node (BFS vô hướng, tối đa 10 hop) |
| Cây kế thừa extends/implements — hỗ trợ hướng |
| Tìm node theo pattern đường dẫn file (O(P) qua path index, case-insensitive) |
Truy vấn Domain Graph
Tool | Mô tả |
| Tổng quan tất cả domain nghiệp vụ kèm flows, thực thể, và mô tả |
| Chi tiết sâu về một domain: thực thể, quy tắc nghiệp vụ, flows, steps, code cross-ref |
| Deep-dive vào một flow cụ thể: entry point, ordered steps, code cross-references |
Skills
Thư mục skills/ chứa các Claude Code skill tương tác với server này.
codebase-explain
Giải thích sâu một file, symbol, module, class, function hoặc business flow bằng evidence read-only từ server — không đọc source local, không bịa node ID/path/line.
/codebase-explain [project-name] [file-path|symbol|module|business-flow]Skill quy định:
Freshness gate — luôn kiểm tra
get_graph_statsvà gánFRESH|STALE|UNKNOWNtrước mọi claim quan trọng.Exact-match validation — kết quả fuzzy chỉ là candidate; phải khớp đúng path/symbol/flow name mới được deep dive, nếu không chuyển sang ambiguity review.
9-section output — output tiếng Việt có cấu trúc, mọi claim gắn
Source/Project/Freshness/Tool/Claim.Ambiguity gate — target mơ hồ sinh file review HTML thay vì đoán.
Skill là markdown thuần — thêm vào
.claude/skills/của project hoặc cài làm plugin để dùng/codebase-explain.
Kiến trúc
flowchart TD
Client["MCP Client<br/>Gemini CLI · Claude · Cursor"]
subgraph Server["server.py"]
FastMCP["FastMCP · 17 tools<br/>list_projects · query_nodes · find_impact<br/>find_path · get_class_hierarchy · get_domain_flow_detail · ..."]
Registry["Multi-Project Registry<br/>cache theo mtime · tự động reload · resolve"]
end
subgraph Loader["kg_loader.py"]
direction TB
DataLayer["Tầng Dữ liệu<br/>Node · Edge · LayerInfo · TourStop<br/>DomainNode · DomainEdge · ProjectGraph"]
EdgeRes["Edge Resolution Layer<br/>class/function → file edge inheritance<br/>O(1) node index · O(degree) edge index"]
Query["Query Engine<br/>fuzzy search · BFS traversal · impact analysis<br/>shortest path · class hierarchy · path search"]
Source["Source Extraction<br/>brace-counting Java/Kotlin/TS/JS/Go/Rust/C#<br/>indent-tracking Python"]
DataLayer --> EdgeRes --> Query --> Source
end
subgraph UA[".understand-anything/"]
KG["knowledge-graph.json<br/>đồ thị code-level"]
DG["domain-graph.json<br/>đồ thị nghiệp vụ"]
Meta["meta.json<br/>metadata phân tích"]
end
Client -->|"stdio · MCP Protocol"| Server
FastMCP --> Registry
Registry --> DataLayer
Source -->|"đọc JSON"| KG
Source -.->|"đọc JSON"| DG
Source -.->|"đọc JSON"| MetaCấu trúc tệp
Understand-Anything-MCP/
├── server.py # MCP server — định nghĩa 17 tools, registry đa dự án
├── kg_loader.py # Bộ tải graph & query engine — data models, search, traversal, resolution
├── metrics.py # Usage metrics — 1 JSON line / tool call, rotating file, fail-safe
├── pyproject.toml # Cấu hình dự án — dependencies: mcp[cli], rapidfuzz, pytest (dev)
├── Dockerfile # Build đa tầng, chạy non-root, có sẵn git cho check_freshness
├── compose.example.yaml # Mẫu compose — chép thành compose.yaml rồi sửa đường dẫn
├── .dockerignore # Loại .venv/, tests/, cache ra khỏi build context
├── scripts/ # Bộ script vận hành — clone, pull, re-index, gitignore
│ ├── clone-repos.sh # Clone repo từ manifest CSV vào REPO_ROOT (idempotent)
│ ├── git-pull.sh # Pull toàn bộ repo + report JSON
│ ├── git-pull-run.sh # Wrapper systemd: lưu JSON, alert webhook
│ ├── sync-graph.sh # Re-index graph incremental bằng claude agent trong docker
│ ├── sync-graph-run.sh # Wrapper cron: pull + sync + alert
│ ├── check-graph-ignore.sh # Kiểm tra .understand-anything/ được ignore đúng
│ ├── revert-gitignore-graph.sh # Hoán .gitignore sang .git/info/exclude
│ └── test/ # Harness test (git repo giả + docker giả)
├── skills/ # Claude Code skills
│ └── codebase-explain/
│ └── SKILL.md # Giải thích sâu codebase bằng evidence read-only
├── tests/ # Bộ test tự động
│ ├── test_kg_loader.py # Unit tests cho core loader, query engine & cross-ref
│ ├── test_graph_metadata.py # Tests cho get_graph_metadata
│ ├── test_path_safety.py # Tests cho path containment
│ ├── test_metrics.py # Unit tests cho metrics writer
│ ├── test_metrics_integration.py # Wiring metrics vào FastMCP tool surface
│ ├── test_symbol_coverage.py # Tests cho compute_symbol_coverage
│ └── fixtures/ # Dữ liệu test JSON mẫu
│ ├── knowledge-graph.json
│ └── domain-graph.json
├── uv.lock # Dependencies đã khóa phiên bản
└── README.mdBiến môi trường
Biến | Bắt buộc | Mô tả |
| Có | Danh sách đường dẫn tuyệt đối phân cách bằng dấu phẩy tới các dự án có thư mục |
| Không | Danh sách đường dẫn tới thư mục gốc của thư viện upstream/dùng chung (để resolve source code của upstream node) |
| Không | Đường dẫn file JSONL cho usage metrics. Rỗng = disable hoàn toàn (mặc định). Xem section Usage Metrics |
Usage Metrics
Module metrics.py đo usage của tool surface — 1 JSON line cho mỗi tool call, append vào file rotating có size cap. Dữ liệu trả lời ba câu hỏi:
Adoption — ua-mcp có thực sự được dùng không? Tool nào được gọi, bao nhiêu lần?
Điểm yếu — Chỗ nào trả về kết quả rỗng, lỗi, hay tool nào không ai gọi (dead tool)?
Hỏi lặp — Cùng một caller có đang hỏi cùng một câu hỏi không? (detection qua
caller + arg_hashtrong time window)
Thiết kế an toàn
Hard rule: ghi metrics không bao giờ được phá tool call. Mọi failure path đều được swallow (file không ghi được, disk full, JSON không serialize được), và writer tự disable vĩnh viễn sau 5 lần lỗi liên tiếp — không còn retry, không còn log spam, tool call chạy tiếp bình thường.
Caller key — hash
ip + user_agent, không lưu IP raw (tránh PII)Arg hash — SHA-256 của
(tool, args), args dài được truncate trước khi ghi nhưng hash vẫn tính trên bản đầy đủOutcome classification — phân loại
ok/empty/error/exceptiondựa trên giá trị trả vềRotating file — size cap, không tăng vô hạn
Kích hoạt
# Mặc định: metrics TẮT (không ghi gì)
PROJECT_ROOTS=/đường/dẫn/dự-án uv run server.py
# Bật metrics: set UA_MCP_METRICS_FILE
UA_MCP_METRICS_FILE=/var/log/ua-mcp/metrics.jsonl \
PROJECT_ROOTS=/đường/dẫn/dự-án uv run server.pyWiring
server.py gọi metrics.install(mcp) trước tool đầu tiên được khai báo bằng @mcp.tool(). Vì decorator chạy khi import theo thứ tự source, tool nào khai báo trên dòng install sẽ không bị đo — test test_every_registered_tool_is_instrumented bảo vệ invariant này.
# Chạy test metrics
uv sync --group dev
uv run pytest tests/test_metrics.py tests/test_metrics_integration.py -vCách hoạt động
Khi khởi động, server quét
PROJECT_ROOTSvà tảiknowledge-graph.json+domain-graph.jsontừ thư mục.understand-anything/của mỗi dự án.Index được xây dựng trong bộ nhớ:
_node_index: tra cứu node theo ID — O(1)_edges_by_source/_edges_by_target: tra cứu edge — O(degree)_domain_edges_by_source: index riêng cho domain graph_nodes_by_path: ánh xạ file_path → nodes — O(1), dùng cho cross-ref và path searchLayer enrichment: gán
layervào từng node dựa trên ánh xạ layer
Edge Resolution Layer — Khi truy vấn quan hệ của class/function node:
Resolve tới parent file qua edge
containsKế thừa outgoing edges từ file cha (imports, contains, v.v.)
Loại bỏ self-reference và deduplicate
Khi một tool được gọi, server kiểm tra mtime của file graph trên đĩa và tự động tải lại nếu cần.
Tìm kiếm mờ sử dụng
rapidfuzzvới điểm số có trọng số — kết quả khớp tên được đánh trọng số cao gấp 3 lần so với khớp mô tả, kèm bonus cho khớp chính xác chuỗi con.Trích xuất mã nguồn đa ngôn ngữ — Tự động nhận diện ngôn ngữ qua extension và chọn chiến lược phù hợp:
Brace-counting: Java, Kotlin, TypeScript, JavaScript, Go, Rust, C#
Indent-tracking: Python (word-boundary regex, shallowest-indent preferred)
Domain↔Code Cross-reference —
resolve_domain_to_code()bridge domain steps tới code nodes:Strategy 1: Exact file_path match qua
_nodes_by_pathindex (O(1))Strategy 2: Directory prefix match với semantic ranking — khi
filePathtrỏ vào package directory:Collect tất cả class/file nodes trong package (không early exit)
Scoring: +20 cho tên token khớp summary, +15 khớp step name, +10 khớp tags, +50 cho full class name match
Penalty: −50 cho boilerplate patterns (
Application,Config,Interceptor,Test,Utils, v.v.)Bonus: +2/level cho files nằm sâu trong subdirectory (thường cụ thể hơn)
Priority: class > file > function
Domain edge type constants —
DOMAIN_REL_CONTAINS_FLOW,DOMAIN_REL_FLOW_STEP, v.v. — single source of truth, tránh typoKiểm tra độ mới chạy lệnh
git diff <commit_phân_tích>..HEADđể phát hiện số lượng file code đã thay đổi kể từ lần tạo graph gần nhất.
Vận hành đồ thị (scripts/)
Bộ script trong scripts/ giúp vận hành graph ở quy mô nhiều repo trên một server — clone, pull, re-index, và giữ git status sạch. Tất cả script:
Mặc định dry-run khi cần ghi — phải truyền
--applymới thực thi.JSON ra stdout, log người đọc ra stderr — parse được bằng
jq, logtail -fđược.Không ghi gì vào repo sản phẩm — graph là runtime state, ignore qua
.git/info/exclude(per-clone, sống qua mọi lần pull).Chạy được trên macOS (bash 3.2) và Linux — harness test trong
scripts/test/không cần VM, docker thật, hay LLM.
Kịch bản điển hình
# 1. Clone repo theo manifest CSV vào REPO_ROOT
./scripts/clone-repos.sh --apply
# 2. Pull toàn bộ repo (git-pull.sh) rồi re-index graph incremental (sync-graph.sh)
./scripts/sync-graph-run.sh
# 3. Kiểm tra .understand-anything/ được ignore đúng cách
./scripts/check-graph-ignore.sh --fixCác script
Script | Chức năng |
| Clone các repo trong |
| Pull toàn bộ repo với |
| Wrapper systemd: chạy |
| Re-index knowledge-graph incremental: đọc |
| Wrapper cron: pull + sync, alert khi có repo cần can thiệp. |
| Kiểm tra 3 trạng thái |
| Hoàn tác sửa tay |
Biến môi trường chính
Biến | Mặc định | Ý nghĩa |
|
| Manifest |
|
| Thư mục chứa các repo con |
|
| Danh sách repo bỏ qua, 1 dòng 1 tên |
|
| Docker image chứa claude CLI + plugin understand-anything |
|
| Docker network agent dùng để gọi LLM API |
| — | Kết nối LLM (script không quan tâm model nào, chỉ cần CLI tương thích |
|
| Timeout từng bước (index / rebuild / domain) |
|
| Bỏ qua repo có số file đổi vượt ngưỡng |
|
| Ngôn ngữ summary trong graph |
| rỗng | Webhook nhận JSON khi có repo lỗi |
Harness test
scripts/test/sync-graph-test.sh tạo repo git giả + docker giả (trong scripts/test/bin/) để chạy hết các nhánh kết quả của sync-graph.sh không cần VM, container thật, hay LLM. Các case tương ứng các sự cố thực tế đã gặp (agent thoát 0 nhưng không ghi meta, stderr lẫn vào stream-json, timeout, bước domain bị bỏ trong báo cáo).
./scripts/test/sync-graph-test.sh # pass=N fail=0Ví dụ sử dụng
Sau khi kết nối với MCP client, AI có thể sử dụng các tool một cách tự nhiên:
Người dùng: "Luồng xác thực hoạt động như thế nào?"
AI sử dụng: query_nodes(query="authentication") → tìm các node liên quan
AI sử dụng: get_domain_detail(domain_name="authentication") → lấy thông tin domain đầy đủ
AI sử dụng: trace_call_chain(start_node_id="...loginUser") → truy vết cây gọi hàmNgười dùng: "Nếu tôi thay đổi PaymentService thì ảnh hưởng gì?"
AI sử dụng: query_nodes(query="PaymentService") → tìm node
AI sử dụng: find_impact(node_id="...PaymentService") → phân tích vùng ảnh hưởngNgười dùng: "PaymentService kế thừa từ class nào?"
AI sử dụng: query_nodes(query="PaymentService") → tìm node
AI sử dụng: get_class_hierarchy(class_id="class:PaymentService", direction="up") → cây kế thừaNgười dùng: "AuthService và PaymentGateway liên quan thế nào?"
AI sử dụng: find_path(source_id="class:AuthService", target_id="class:PaymentGateway") → đường đi ngắn nhấtNgười dùng: "Tất cả file trong package transfer?"
AI sử dụng: search_by_file_path(path_pattern="transfer", node_type="file") → danh sách fileNgười dùng: "Luồng xử lý lương chi tiết thế nào?"
AI sử dụng: get_domain_flow_detail(flow_name="payroll") → entry point, ordered steps, code refsPhát triển
# Cài đặt dependencies
uv sync
# Chạy unit tests
uv run pytest tests/ -v
# Chạy test với MCP Inspector
PROJECT_ROOTS=/đường/dẫn/tới/dự-án npx @modelcontextprotocol/inspector uv run server.py
# Log được ghi ra stderr (stdout được dành riêng cho MCP stdio protocol)Giấy phép
MIT
Được xây dựng cho hệ sinh thái Understand-Anything
Giúp trợ lý AI hiểu sâu bất kỳ codebase nào 🚀
Available Tools
18 toolsfind_entry_pointsA
Find functions that are NOT called by any other function (potential API endpoints / entry points).
Args: project: Project name.
Returns: List of entry point functions with their layer and summary.
Inputs: project. Returns: result
find_impactA
Blast radius analysis: find all nodes that would be affected if this node changes.
Follows incoming imports, calls, extends, and implements edges in reverse.
Args: node_id: Node ID to analyze impact for. max_depth: Max traversal depth (default 3, max 10). project: Project name.
Returns: List of affected nodes grouped by depth level.
Inputs: node_id (required), project, max_depth. Returns: result
find_pathA
Find the shortest path between two nodes in the knowledge graph.
Uses undirected BFS — traverses both outgoing and incoming edges. Useful for understanding how two components are connected.
Args: source_id: Starting node ID. target_id: Destination node ID. max_depth: Maximum path length (default 6, max 10). project: Project name.
Returns: Path from source to target showing each hop and relation.
Inputs: source_id (required), target_id (required), project, max_depth. Returns: result
get_class_hierarchyA
Show the inheritance hierarchy for a class (extends/implements tree).
Args: class_id: Class node ID to analyze. direction: "up" (parents/supertypes), "down" (children/subtypes), "both". max_depth: Max traversal depth (default 5, max 10). project: Project name.
Returns: Inheritance tree showing parent and child classes with relation types.
Inputs: class_id (required), project, direction, max_depth. Returns: result
get_domain_detailA
Get detailed info about a specific business domain: entities, rules, flows, steps.
Args: domain_name: Domain name (e.g., "authentication", "transfer", "payroll"). Fuzzy matching supported. project: Project name.
Returns: Full domain details with entities, business rules, flows and their steps.
Inputs: domain_name (required), project. Returns: result
get_domain_flow_detailA
Deep-dive into a specific business flow: entry point, all steps with ordering, and linked code nodes for each step.
Use this for detailed understanding of a single flow's implementation. For an overview of all domains/flows, use get_domain_overview or get_domain_detail.
Args: flow_name: Flow name (e.g., "SAGA Xử lý Lương", "init payroll", "recovery retry"). Fuzzy matching supported. project: Project name.
Returns: Full flow details with entry point, ordered steps, step summaries, and cross-referenced code nodes for each step.
Inputs: flow_name (required), project. Returns: result
get_domain_overviewB
Get summary of all business domains and their flows (from domain-graph.json).
Args: project: Project name.
Returns: List of domains with flow names, entity counts, and summaries.
Inputs: project. Returns: result
get_graph_metadataA
Structured JSON snapshot of a project's graph state: identity, node/edge counts, graph commit, repository HEAD and freshness. Machine counterpart of get_graph_stats — parse it instead of the text output.
Args: project: Project name. Leave empty if only one project is loaded.
Returns: JSON string: {"ok": true, ...metadata} or {"ok": false, "error": {"code", "message", "remediation"}}.
Inputs: project. Returns: result
get_graph_statsB
Get comprehensive statistics about a project's knowledge graph.
Args: project: Project name. Leave empty if only one project is loaded.
Returns: Statistics: node/edge counts, type distributions, top domains, layers. Includes FRESHNESS ANALYSIS: whether the graph is up-to-date with the current codebase (uses git diff against the commit when the graph was last analyzed).
Inputs: project. Returns: result
get_layer_infoA
List architectural layers, or get nodes belonging to a specific layer.
Args: layer_name: Layer name to inspect. Leave empty to list all layers. project: Project name.
Returns: Layer listing or nodes within a specific layer.
Inputs: project, layer_name. Returns: result
get_node_detailA
Get full details of a specific node by its ID.
Args: node_id: Unique node ID (e.g., "upstream:function:src/auth/login.ts::loginUser"). Use query_nodes to find IDs. project: Project name. Leave empty if only one project.
Returns: Complete node details including path, layer, tags, complexity.
Inputs: node_id (required), project. Returns: result
get_node_sourceA
Get the actual source code for a knowledge graph node.
For function/class nodes: extracts just the method or class block with annotations. For file/config nodes: returns the whole file content (truncated if too large). Includes line numbers for easy reference.
Args: node_id: Node ID (use query_nodes to find IDs). max_lines: Max lines for whole-file reads (default 200). Does not affect function/class extraction. project: Project name.
Returns: Source code with line numbers, file path, and extraction metadata.
Inputs: node_id (required), project, max_lines. Returns: result
get_relationshipsA
Get all nodes connected to a given node, with relationship types.
Args: node_id: Node ID to inspect. direction: "out" (this node calls/imports others), "in" (others call/import this), "both". relation_filter: Filter by relation: "calls", "imports", "contains", "implements", "extends". Leave empty for all. project: Project name.
Returns: List of relationships in format: "source --[relation]--> target".
Inputs: node_id (required), project, direction, relation_filter. Returns: result
get_tourA
Get the guided project tour — a curated walkthrough of the most important parts of the codebase.
Tour stops are ordered sequences that explain the project's key components, each linking to specific nodes in the knowledge graph.
Args: stop_index: Specific tour stop number (1-based) to expand with full node details. Leave empty to list all stops. project: Project name.
Returns: Tour overview or detailed stop with linked nodes.
Inputs: project, stop_index. Returns: result
list_projectsA
List all registered projects with basic statistics.
No parameters required. Call this first to see available projects.
Returns: List of projects with node/edge counts and domain info.
Inputs: no named parameters. Returns: result
query_nodesA
Search for nodes in the knowledge graph by keyword (weighted fuzzy matching).
Scoring: name (3x weight) > summary (1.5x) > tags (1x). Exact name matches get a bonus. Supports pagination via offset/limit.
Args: query: Search keyword (e.g., "authentication", "login", "PaymentService"). node_type: Filter by type: "file", "function", "class", "config", "service". Leave empty for all. limit: Max results per page (default 10). offset: Starting offset for pagination (default 0). Use with limit for paging. project: Project name. Leave empty if only one project.
Returns: List of matching nodes with id, type, name, summary, layer, and tags.
Inputs: query (required), limit, offset, project, +1 more. Returns: result
search_by_file_pathA
Find nodes by file path pattern (substring match).
Useful for finding all nodes in a package, module, or directory. Case-insensitive.
Args: path_pattern: Substring to match in file paths (e.g., "payroll", "com/vietbank/sme", "auth"). node_type: Optional filter by type: "file", "function", "class". Leave empty for all. limit: Max results (default 30, max 50). project: Project name.
Returns: List of matching nodes sorted by file path.
Inputs: path_pattern (required), limit, project, node_type. Returns: result
trace_call_chainA
Trace the function call chain starting from a node (BFS on 'calls' edges).
For class/file nodes: automatically resolves to contained functions and traces call chains from them.
Args: start_node_id: ID of the starting node (function, class, or file). max_depth: Max traversal depth (default 3, max 10). project: Project name.
Returns: Call tree as indented text.
Inputs: start_node_id (required), project, max_depth. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Each tool targets a distinct aspect of the knowledge graph (entry points, stats, node search/detail/source, relationships, layers, domains, flows, impact, paths, hierarchy, file path). The two stats tools are clearly separated by intended audience (human-readable vs machine-readable), so there is no meaningful overlap.
All tool names follow an imperative verb_noun pattern (find_, get_, list_, query_, trace_, search_). The consistent use of snake_case and a predictable verb prefix makes the toolset easy to navigate.
18 tools is slightly above the ideal range, but each tool serves a distinct query need for a code understanding server. The count is justifiable given the breadth of analysis features, though it borders on heavy.
The toolset covers the full lifecycle of codebase exploration: listing projects, searching and inspecting nodes, retrieving source, tracing relationships and call chains, analyzing impact, exploring layers and business domains, and getting guided tours. No obvious gaps for the stated purpose.
Maintenance
Related MCP Connectors
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Related MCP Servers
- FlicenseCqualityDmaintenanceEnables AI assistants to analyze codebases through semantic search, call graph generation, and function metadata extraction. Provides real-time code analysis with persistent vector storage for understanding complex code structures and relationships.136-
- FlicenseBqualityNot gradedmaintenanceProvides comprehensive codebase analysis and semantic understanding through integrated knowledge graphs, enabling AI assistants to understand project structure, patterns, dependencies, and context through multiple analysis tools and format generators.9-
- AlicenseAqualityDmaintenanceEnables AI to analyze, query, and manage a graph-based representation of software architecture for impact analysis, dependency tracking, and design.207 npm1AGPL 3.0
- AlicenseAqualityBmaintenanceSelf-hosted semantic code search for AI coding agents. Indexes many repositories at once with tree-sitter AST chunking, local llama.cpp embeddings and Qdrant, so Claude Code, Cursor, Codex and any MCP client can find code by meaning, trace usages and callers, and read the git history behind each chunk. No API keys, and your code never leaves your machine.21834MIT