ast-impact-mapper-mcp
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., "@ast-impact-mapper-mcp find tests affected by changes in src/utils/auth.ts"
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.
πΊοΈ ast-impact-mapper-mcp β¨
"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.
Related MCP server: lsp-intelligence
π‘ 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:
// Tool Call: get_affected_tests({ changed_files: ["src/utils/auth.ts"] })
{
"changed_files": ["/project/src/utils/auth.ts"],
"affected_tests": ["/project/tests/checkout.spec.ts"],
"total_affected": 1
}2. Explain the Connection
To understand why checkout.spec.ts depends on auth.ts, the agent calls explain_impact:
// Tool Call: explain_impact({ changed_file: "src/utils/auth.ts", test_file: "tests/checkout.spec.ts" })
{
"found": true,
"import_chain": [
"/project/tests/checkout.spec.ts",
"/project/src/fixtures/user-fixture.ts",
"/project/src/utils/auth.ts"
]
}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:
{
"files": [{ "file": "/project/src/utils/auth.ts", "runtime_impact": false }],
"total_tests_must_run": 0,
"total_tests_skippable": 1
}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:
// Tool Call: generate_test_command({ changed_files: ["src/utils/auth.ts"], runner: "vitest" })
{
"command": "npx vitest run tests/checkout.spec.ts"
}π οΈ 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.
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.
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.
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)
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)
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)
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)
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)
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)
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)
detect_architectural_cyclesLocates circular dependency loops (e.g.
A β B β C β A) which cause unpredictable module initialization orders.Arguments:
project_root(string, required)
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)
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)
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)
refresh_projectInvalidates AST and dependency graphs cache. Run this after checking out branches or pulling remote git updates.
Arguments:
project_root(string, required)
π Installation & Setup
1. Global Installation
npm install -g ast-impact-mapper-mcp2. Configure Editor / Agent Client
VS Code / Cursor
Add the following to your .cursor/mcp.json or .vscode/mcp.json:
{
"mcpServers": {
"ast-impact-mapper": {
"command": "npx",
"args": ["-y", "ast-impact-mapper-mcp"]
}
}
}Claude Code CLI
claude mcp add ast-impact-mapper npx -- -y ast-impact-mapper-mcp㪠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
npm run build # Compile TypeScript to dist/
npm run lint # Run ESLint validation
npm run format # Format files via Prettier
npm test # Run unit tests via Vitestπ License
MIT Β© vola-trebla πΈ
Available Tools
15 toolsanalyze_api_surface_mutationA
Compares a file against its HEAD version and classifies the change as breaking_api_change (exported function signature changed, parameter removed/added, interface field removed) or internal_refactor (only implementation body changed). Use to answer: is this PR a breaking change or a safe refactor?
Inputs: file_path (required), project_root (required).
detect_architectural_cyclesA
Detects circular import dependencies β A imports B which imports C which imports A. Cycles cause unpredictable module initialization order and indicate tight coupling. Use to answer: are there circular dependencies I need to break before refactoring?
Inputs: project_root (required).
differentiate_type_impactA
Classifies each changed file as type-only or runtime, then splits affected tests into "must run" vs "skippable". A test is skippable when the changed file contains only TypeScript type declarations (interfaces/type aliases) or the test imports it via import type. Use to answer: which tests can I skip after a type-only refactor?
Inputs: project_root (required), changed_files (required).
explain_impactA
Finds the exact import chain that connects a changed source file to a test file. Use to answer: why does changing file X cause test Y to be affected? Returns the step-by-step import path from the test to the changed file.
Inputs: test_file (required), changed_file (required), project_root (required).
generate_skeleton_viewA
Generates a token-optimized representation of a source file by stripping function and method bodies, keeping only JSDocs and declarations with line numbers.
Inputs: file_path (required), project_root (required), include_jsdoc, include_private_members.
generate_test_commandA
Outputs the optimal test execution command for Jest, Vitest, or Playwright based on changed files.
Inputs: project_root (required), changed_files (required), runner.
get_affected_testsA
Given a list of changed source files, returns which test files are affected β directly or transitively through the import graph. Use to answer: which tests should I run after this code change?
Inputs: project_root (required), git_diff, changed_files.
get_affected_tests_by_branchA
Runs git diff --name-only <base_branch>...HEAD internally and returns affected test files. Use instead of get_affected_tests when you want the server to handle the git diff automatically.
Inputs: project_root (required), base_branch.
get_coverage_gapsA
Finds source files that are not reachable from any test file through the import graph β i.e. completely untested code. Use to answer: which parts of the codebase have zero test coverage?
Inputs: project_root (required), limit, source_dirs.
get_dependency_graphA
Returns the direct import graph for a specific file: what it imports, and what imports it. Use to answer: what depends on this file? What does this file depend on?
Inputs: file_path (required), project_root (required), format.
get_rename_aware_diffA
Like get_affected_tests_by_branch, but correctly handles renamed and moved files. Uses --find-renames to detect file moves and --ignore-all-space to skip whitespace-only changes. Use instead of get_affected_tests_by_branch when the branch contains refactors or file moves.
Inputs: project_root (required), base_branch, similarity_threshold.
get_symbol_dependency_graphA
Retrieves a bidirectional or directed dependency graph mapped to individual declarations, functions, and variables.
Inputs: file_path (required), project_root (required), direction, symbol_name.
get_test_summaryA
Returns a bird's-eye view of the project's test structure: coverage rate, most-imported source files (highest risk to change), and tests with the deepest import chains. Use to answer: what is the overall test health of this project?
Inputs: project_root (required).
identify_unreachable_modulesA
Finds source files that are never imported by any other file β dead code candidates safe to delete. Automatically excludes known entry points (index.ts, main.ts, pages/, routes/, app/, api/, bin/). Use to answer: which files in this codebase are orphaned and can be safely removed?
Inputs: project_root (required), limit, entry_points.
refresh_projectA
Clears the cached AST for a project root, forcing a full re-parse on the next call. Use after switching branches, running git pull, or adding/removing files.
Inputs: project_root (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 15 tools
Several tools overlap in purpose: get_affected_tests, get_affected_tests_by_branch, and get_rename_aware_diff all return affected test files, differing only in how they compute changed files. get_dependency_graph and get_symbol_dependency_graph also overlap at different granularities. The descriptions clarify the distinctions, but the close purposes could cause misselection.
All tools use lowercase snake_case with a verb-noun pattern, such as refresh_project, get_affected_tests, explain_impact, identify_unreachable_modules, and generate_test_command. The verbs vary by action but the convention is consistent and predictable.
15 tools is at the upper boundary of the well-scoped range and covers many facets of AST impact mapping. The count feels slightly heavier due to three variants of affected-tests tools, but overall each tool has a distinct role and the breadth is justified.
The tool set provides comprehensive coverage for impact analysis: affected tests (multiple methods), import chains, dependency graphs, coverage gaps, dead code, architecture cycles, type-only changes, API breaking changes, skeleton views, and test command generation. No critical gaps are evident for the stated domain.
Maintenance
Related MCP Connectors
MCP server for building and testing AI agents with multi-model experimentation and insights.
Repository knowledge graph MCP server for codebase understanding and debugging.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Coding agents in multi-service codebases routinely rebuild existing helpers, trust stale type definitions, and modify API contracts without knowing who consumes them. Carrick solves this by indexing your entire TypeScript ecosystem across service and repository boundaries. By integrating deeply with the TypeScript compiler, Carrick traces every route, type, and cross-service call while recording function behaviour so agents search by intent rather than name. Delivered via MCP for AI agents and LSP for IDEs, Carrick ensures models see existing endpoints and utilities before generating new code. The scanner is source-available and runs from your CLI or CI pipeline.
Related MCP Servers
- AlicenseAqualityDmaintenanceA TypeScript-aware MCP server that provides coding agents with repository discovery, code intelligence, and web project context for local codebases. It enables deep symbol navigation, diagnostic reporting, and structural analysis of monorepos without requiring full IDE integration.716 npm1MIT
- AlicenseNot gradedqualityDmaintenanceMCP server providing 29 tools across 5 layers for semantic TypeScript/JavaScript code intelligence, enabling AI agents to find references, trace impacts, guard APIs, and explain errors without text-search false positives.4 npm1MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides tools to query a TypeScript/JavaScript/Vue codebase's dependency graph, enabling agents to find impacted files, hubs, orphans, and symbol relationships through natural language.306 npmMIT
- AlicenseNot gradedqualityDmaintenanceCompiler-exact TypeScript code graph MCP server exposing find-references, change impact analysis, and repo map tools for AI agents, powered by the TypeScript compiler via ts-morph.MIT