# ast-mcp-server [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/yailPeralta/ast-mcp-server  
**GitHub Stars:** 7  
**npm Downloads (last month):** 5612  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/ast-mcp-server

## Description
Correctness-oriented MCP server and batch CLI for compact structural reads and reviewed TypeScript/JavaScript edits.

## Tools
Capabilities this server exposes over MCP:

- **ast_list_files** — Lists source files included by the project's tsconfig in deterministic, project-relative, paginated form.
- **ast_get_project_status** — Returns bounded, read-only compiler freshness and project status without exposing filesystem identities or credentials.
- **ast_explore** — Composes bounded structural search, exact selectors, source evidence and compiler references without weakening the primitive AST tools. Returns bounded session freshness metadata for fresh, pending, stale, rebuilding or degraded state.
- **ast_get_outline** — Returns body-free declaration signatures for one TypeScript/JavaScript file. Detailed symbol metadata is opt-in because it duplicates signature text.
- **ast_get_symbol_source** — Returns exactly one declaration or implementation with its project-relative location, not the complete file.
- **ast_search_symbols** — Ranks structural declarations and returns exact file/symbol selectors for downstream AST tools.
- **ast_find_references** — Finds type-resolved references and returns bounded project-relative locations, including declaration impact by default.
- **ast_get_impact** — Traverses exact compiler-backed relationships around a symbol with explicit direction, depth, node and edge budgets. Returns bounded session freshness metadata and fails closed when exact relationships are not fresh. Read-only evidence only; it never prepares or applies mutations.
- **ast_find_test_candidates** — Finds deterministic affected test candidates from fresh, complete incoming compiler relationships. Returns bounded whole-candidate proofs and never executes tests or prepares mutations.
- **ast_get_diagnostics** — Returns bounded normalized TypeScript diagnostics for a project or one source file. Existing errors are preserved as evidence for write-operation delta checks.
- **ast_get_file** — Returns exact bounded source lines for one TypeScript/JavaScript file, or body-free symbols when symbols_only is true. Read-only; file snapshot freshness and project freshness are reported separately from compiler diagnostics.
- **ast_rename_symbol** — Prepares an exact hash-bound rename plan without writing. Review the preview and apply its operation_id with ast_apply_operation.
- **ast_replace_symbol_body** — Prepares a hash-bound body replacement while preserving the signature. Supports declarations, methods, accessors and function-valued variables/properties.
- **ast_scaffold_class** — Prepares a hash-bound new TypeScript class file without writing it. Each method body throws an explicit not-implemented error. Review the diff, then apply the returned operation_id and plan_hash with ast_apply_operation.
- **ast_get_operation_preview** — Retrieves exact unified diffs retained for a prepared operation, optionally one affected file at a time.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "ast-mcp-server": {
    "command": "npx",
    "args": ["-y","ast-mcp-server"]
  }
}
```

## Documentation

## What ast-mcp-server does

ast-mcp-server gives coding agents structured access to TypeScript and JavaScript projects. Its read operations return focused evidence rather than requiring an agent to load entire files: exact line ranges, declaration outlines without bodies, source for one symbol, references, diagnostics, and bounded impact relationships.

The server uses the TypeScript compiler project model through ts-morph. That lets it distinguish declarations and references by program structure instead of treating matching names as equivalent text. It also exposes project status, paginated source-file discovery, symbol search, and conservative test-candidate selection.

Write operations are deliberately staged. Symbol renames, method-body replacements, and new class scaffolds produce plans first. A caller can inspect the retained diff and apply one reviewed, hash-bound operation only after the relevant checks pass.

## How it works

Read requests are bounded and structured. `ast_get_file` can return selected zero-based source ranges with one-based line records, a SHA-256 byte hash, snapshot state, and project freshness metadata. Symbol-focused requests can return selectors and signatures without implementation bodies. `ast_explore` combines bounded discovery with optional source and compiler-reference detail, while `ast_get_impact` reports bounded direct or transitive relationships.

Compiler-backed evidence carries provenance and resolution information. Fresh compiler relationships can support impact evidence and test-candidate selection; syntax-only and heuristic results are intended for navigation or discovery, not mutation authority. The server exposes completeness, truncation, unresolved results, and freshness information rather than presenting every result as equally certain.

For changes, the server compares proposed results with baseline diagnostics and retains an immutable plan. Applying a plan requires the caller to explicitly invoke the apply operation. Hash binding, workspace freshness checks, diagnostic guards, and idempotent receipts help prevent a reviewed change from being applied to a different project state.

## Tools and capabilities

- `ast_list_files` inventories project-relative source files with pagination.
- `ast_get_project_status` reports compiler, freshness, index, and operation state.
- `ast_get_outline`, `ast_get_symbol_source`, and `ast_search_symbols` support compact structural inspection.
- `ast_find_references`, `ast_get_impact`, and `ast_find_test_candidates` provide compiler-backed relationship evidence when coverage is complete and fresh.
- `ast_get_diagnostics` returns project- or file-scoped TypeScript diagnostics.
- `ast_rename_symbol`, `ast_replace_symbol_body`, and `ast_scaffold_class` prepare controlled edits.
- `ast_get_operation_preview` returns a prepared plan's retained diff, and `ast_apply_operation` applies one reviewed plan.

## Limitations and notes

The server does not treat all evidence as compiler authority. Heuristic results are discovery hints, syntax provenance supports structural navigation, and index data accelerates queries but still requires compiler validation or fallback. Freshness is separate from diagnostic status: a fresh snapshot can still contain TypeScript errors, so diagnostics must be checked independently.

Impact queries refuse non-fresh compiler relationships. Test-candidate discovery admits only complete incoming evidence for relationships such as references, imports, exports, inheritance, implementation, and calls; it selects candidates but never runs tests. Reads and edits are bounded, so truncation, incomplete coverage, and unresolved relationships should be handled by the caller before relying on a result.

_Full upstream README: https://allmcps.com/mcp/ast-mcp-server/readme_

