
Ast Impact Mapper Mcp
io.github.vola-trebla由 GitHub 帳號 vola-trebla 發布v0.3.1更新於 Oct 24, 2026
MCP server that uses TypeScript AST to find which tests are affected by a code change
概覽
本機 MCP 伺服器,以 AST 解析 TypeScript/JavaScript 專案,找出程式碼變更影響哪些測試,並檢查相依圖。
- 可以做什麼
- 將變更檔案或 git 分支差異對應到間接匯入它們的測試,並解釋每個符合項目背後的匯入鏈,支援重新命名感知差異與產生 jest、vitest、playwright 執行指令。區分僅型別變更與執行期變更,判斷檔案是公開 API 變更還是內部重構。追蹤宣告層級的符號相依性,並以 JSON 或 Mermaid 流程圖呈現檔案的直接匯入與匯入者。找出死程式碼、循環相依、未被測試匯入的檔案,並彙總測試覆蓋率與高風險模組。產生精簡的檔案骨架,並重新整理快取的 AST 與相依圖。
- 適用情境
- 適合助理在 TypeScript 或 JavaScript 儲存庫中工作時使用,例如只執行受變更影響的測試、說明某個測試為何相關,或檢視匯入關係、死程式碼與循環相依。
- 執行需求
- 以本機 stdio 程序執行,從 npm 套件 ast-impact-mapper-mcp 安裝(例如透過 npx)並在用戶端設定。需要 Node.js 與本機 TypeScript/JavaScript 專案;分支差異工具需要 git。未宣告驗證、環境變數或標頭。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Ast Impact Mapper Mcp,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
🗺️ ast-impact-mapper-mcp ✨
[npm version] [npm downloads] [CI] [License: MIT]
"Stop boiling the ocean. Run only the tests that actually care about your changes." 🐸
ast-impact-mapper-mcp is an advanced Model Context Protocol (MCP) server that analyzes your TypeScript/JavaScript codebase using AST parsing (ts-morph) and dependency graph tracing. It helps AI agents (like Claude or Cursor) target only the relevant tests, find dead code, identify circular import dependencies, and trace API mutations.
🧐 Why import graphs?
Guessing affected tests based on matching filenames (e.g. auth.ts -> auth.test.ts) is highly inaccurate. Running the entire test suite on every minor change is extremely slow.
Import graphs do not lie. If a test file transitively imports a modified source file, it must be run. ast-impact-mapper-mcp builds a bidirectional file dependency graph and answers "which tests should I run?" in milliseconds.
💡 Quick Showcase (Real-World e2e Flow)
Imagine your AI agent modifies a shared helper: src/utils/auth.ts. Instead of blindly running all tests or guessing by name, the agent uses this MCP server:
1. Identify Affected Tests
The agent calls get_affected_tests with the changed file:
2. Explain the Connection
To understand why checkout.spec.ts depends on auth.ts, the agent calls explain_impact:
Aha! The checkout spec imports the user-fixture, which imports auth!
3. Check for Runtime Impact
If the change in auth.ts was only adding a TypeScript interface (type-only change), calling differentiate_type_impact tells the agent:
Success! Since it is a type-only change, the agent can skip running tests entirely, saving precious CPU cycles and time.
4. Run Minimal Tests
If it does contain runtime changes, the agent requests the execution command:
🛠️ MCP Tools Reference
All tools are configured with consistent, type-safe schemas (arguments in snake_case).
1. Impact Mapping & Tracing
-
get_affected_testsFinds all test files transitively importing changed source files.
- Arguments:
project_root(string, required): Absolute path to the TypeScript project.changed_files(string[], optional): Modified file paths.git_diff(string, optional): Raw stdout ofgit diff --name-only.
- Returns: Detailed map of changed files, affected tests, and totals.
- Arguments:
-
get_affected_tests_by_branchAutomatically diffs the current state against a base branch using git to find affected tests.
- Arguments:
project_root(string, required)base_branch(string, default:"main"): Branch to compare against.
- Arguments:
-
get_rename_aware_diffHighly robust branch impact analysis that tracks file moves/renames (via
git diff -M) and ignores formatting/whitespace changes.- Arguments:
project_root(string, required)base_branch(string, default:"main")similarity_threshold(number, default:90): % similarity threshold to declare a move.
- Arguments:
-
explain_impactTraces and explains the exact chain of imports showing why a changed source file affects a specific test.
- Arguments:
project_root(string, required)changed_file(string, required)test_file(string, required)
- Arguments:
-
generate_test_commandConstructs CLI commands for test runners (
vitest,jest, orplaywright) matching the affected tests subset.- Arguments:
project_root(string, required)changed_files(string[], required)runner(enum:jest,vitest,playwright, default:vitest)
- Arguments:
2. TypeScript-specific Deep Code Analysis
-
differentiate_type_impactInspects imports and types to isolate type-only changes (interfaces, types, or
import typeexports). Helps skip test execution entirely if the changes do not impact the runtime bundle!- Arguments:
project_root(string, required)changed_files(string[], required)
- Arguments:
-
analyze_api_surface_mutationCompares a file against its
HEADversion and determines if it modifies the public API (breaking_api_change) or only contains internal implementation edits (internal_refactor).- Arguments:
project_root(string, required)file_path(string, required)
- Arguments:
-
generate_skeleton_viewGenerates a token-optimized skeleton of a file by stripping out function and method bodies, keeping only signatures, JSDocs, and line numbers.
- Arguments:
project_root(string, required)file_path(string, required)include_jsdoc(boolean, default:true)include_private_members(boolean, default:false)
- Arguments:
-
get_symbol_dependency_graphTraces declaration-level dependencies (functions, classes, variables) across files, finding internal declarations usage.
- Arguments:
project_root(string, required)file_path(string, required)symbol_name(string, optional): Specific export symbol to map.direction(enum:forward,reverse,bidirectional, default:bidirectional)
- Arguments:
3. Codebase Health & Graph Insights
-
identify_unreachable_modulesFinds orphaned source files that have zero incoming imports (dead code safe to prune). Automatically respects standard entry points.
- Arguments:
project_root(string, required)entry_points(string[], optional): Explicit entry-points to exclude from warning.limit(number, default:50)
- Arguments:
-
detect_architectural_cyclesLocates circular dependency loops (e.g.
A → B → C → A) which cause unpredictable module initialization orders.- Arguments:
project_root(string, required)
- Arguments:
-
get_dependency_graphReturns direct imports/importers of a file in JSON format or as a visual Mermaid TD flowchart.
- Arguments:
project_root(string, required)file_path(string, required)format(enum:json,mermaid, default:json)
- Arguments:
-
get_coverage_gapsIdentifies files with zero import coverage — those that are never imported by any test file.
- Arguments:
project_root(string, required)source_dirs(string[], optional)limit(number, default:50)
- Arguments:
-
get_test_summaryProvides a high-level view of test coverage rate, deepest import chains, and high-risk most-imported modules.
- Arguments:
project_root(string, required)
- Arguments:
-
refresh_projectInvalidates AST and dependency graphs cache. Run this after checking out branches or pulling remote git updates.
- Arguments:
project_root(string, required)
- Arguments:
🚀 Installation & Setup
1. Global Installation
2. Configure Editor / Agent Client
VS Code / Cursor
Add the following to your .cursor/mcp.json or .vscode/mcp.json:
Claude Code CLI
💬 Example Scenario
Imagine you modify a shared page component: src/pages/login-page.ts.
- AI Agent runs
get_rename_aware_diff: It detects that onlytests/auth.spec.tsimports the page object transitively. - AI Agent runs
differentiate_type_impact: It sees you only added a type definition interface, classifying it astype_only_change-> it skips running the test execution completely, saving developer cycles! - AI Agent runs
explain_impact: If asked whytests/auth.spec.tsdepends on it, it renders the path:tests/auth.spec.ts→src/fixtures/app.ts→src/pages/login-page.ts.
🔗 The Ecosystem
ast-impact-mapper-mcpanswers: "Which tests are affected by my changes?" 🗺️flakiness-graph-mcpanswers: "Of those affected tests, which ones are historically unstable?" 📊- Together, they form a perfect feedback loop for running a prioritized, resilient, and minimal test suite.
🛠️ CLI Development
📄 License
MIT © vola-trebla 🐸
來源:README.md,提交 f895ef2
工具
0版本歷史
1- v0.3.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分