AST MCP

Give AI coding agents less code and more understanding. AST MCP Server

Open Source · MCP · TypeScript & JavaScript

Give AI coding agents less code and more understanding.

AST MCP Server gives coding agents compact, compiler-aware access to TypeScript and JavaScript projects. Retrieve exact symbols, references and diagnostics without loading entire files into the model context.

View on GitHub
yailPeralta/ast-mcp-server·
stars
forks
contributors

Structural reads. Compiler-resolved references. Reviewed AST edits.

ast-mcp-server
0%

Fewer model round-trips

0.00%

Less serialized context

0.00%

Fewer model-facing TOON tokens

Results from reproducible local benchmark scenarios included in the project. These measurements are not universal token, billing, cache, latency or cost guarantees. Actual results depend on the project and workflow.

AI coding agents often read far more code than they need.

[ ... 847 lines ... ]

Too much context

An agent may load hundreds of source lines when it only needs one method signature or implementation. That consumes valuable context without necessarily improving the answer.

diff -u file.ts

Fragile text-based edits

Plain-text patches do not inherently understand declarations, scopes, overloads or TypeScript diagnostics.

grep -r "UserService"

Weak cross-file reasoning

Text search can find matching words, but it cannot reliably determine whether identically named symbols are actually related.

Traditional workflow
1.Search text↓
2.Read complete files↓
3.Guess relationships↓
4.Apply text patch
AST MCP Server workflow
1.Resolve symbol↓
2.Retrieve bounded context↓
3.Review compiler evidence↓
4.Prepare and approve change

Read code structurally, not as undifferentiated text.

AST MCP Server uses the TypeScript compiler project model to expose declarations, references, diagnostics and source selections as structured, bounded tools for AI coding agents.

get_symbol()

Compact structural reads

Return an outline, an exact declaration or a bounded file section instead of loading the complete file by default.

find_references()

Compiler-resolved references

Find project-wide symbol usages using compiler resolution rather than matching identifier text with grep.

inspect_symbol()

Exact symbol inspection

Retrieve the precise source of a function, method, class, interface or type using reusable structural selectors.

prepare_edit()

Reviewed AST edits

Prepare renames, implementation replacements and class scaffolds before anything is written to disk.

diff_diagnostics()

Diagnostic guards

Compare TypeScript diagnostics before and after a proposed change to reveal new compiler errors before applying it.

result.meta.fresh

Freshness and completeness metadata

Every bounded result reports whether the project evidence is fresh, incomplete, truncated or unresolved.

ast-mcp-server --batch

Batch workflows

Combine known structural read operations into a single bounded CLI pipeline and reduce agent round-trips.

Prepare → Review → Apply

A controlled workflow that keeps humans and agents in the loop before any change touches your codebase.

01

Prepare

The agent requests a structural change. AST MCP Server prepares it without writing to disk.

prepare_rename({ symbol: "UserService", newName: "AccountService" })
02

Review

The prepared change is displayed with compiler evidence. Humans or agents verify it.

review_change({ id: "chg_abc123", showDiff: true })
03

Apply

After explicit approval, the change is written. Immutable hashes prevent silent modifications.

apply_change({ id: "chg_abc123", hash: "sha256:..." })

Get started in seconds.

Install via npm and add to your MCP client configuration.

bash
npm install --global ast-mcp-server --ignore-scripts
ast-tool setup
MCP client configuration(Claude Code, Hermes, etc.)
json
{
  "mcpServers": {
    "ast-mcp": {
      "command": "ast-mcp-server"
    }
  }
}

Frequently asked questions