
ts-ast-mcp
by gclluch
TypeScript AST MCP Server
A Model Context Protocol (MCP) server for deep structural analysis of TypeScript and JavaScript source code. Unlike text-based search, this server parses your code with the TypeScript Compiler API and walks the real AST - types, functions, call relationships, interface satisfaction, and more.
Most tools run on the syntactic tier (ts.createSourceFile, no type resolution) because it is fast and needs no build. find_implementations runs on the semantic tier - a full ts.Program and its type checker - because deciding whether a class satisfies an interface cannot be done from syntax alone. Each tool's tier is stated in the table below.
Companion to py-ast-mcp, the same idea applied to Python; a Go AST MCP server by another author served as prior art for this one.
Features
- 20 analysis tools covering file-level, directory-level, and cross-file structural queries
- Fast syntactic parsing -
ts.createSourceFile()per file, under 5ms; cross-file tools re-parse in scope, so results always reflect the latest edit - Arrow function awareness -
const foo = () => {}treated as first-class functions throughout - Signature extraction - parameters, class-qualified names, and return types as written. These come from the annotation, so an unannotated return reads as blank rather than as the inferred type
- Call graph generation with Mermaid diagrams, forward and reverse traversal, file or package scope
- Cyclomatic complexity computation per function
- Interface implementation discovery - explicit
implementsplus structural matches decided by the type checker's own assignability rules, so member types and call signatures count, not just member names - Structural diffing between file versions (added/removed/modified symbols)
- Cursor-position awareness for IDE integrations
- JSX/TSX parsing -
.tsx/.jsxfiles parse under the rightScriptKind, so every tool works on React source. There is no React-specific analysis: a component is a function like any other - TypeScript-specific quality checks -
anycasts, non-null assertions, floating promises, empty catches, double assertions - Dead code detection - unexported symbols never referenced within their own file. Unexported means file-local, so that is the whole search space. A same-named binding in another scope of the same file still reads as a use, which makes this under-report rather than over-report
- JSDoc/TSDoc extraction for any symbol
Tools
Structural Queries
| Tool | Description | Parameters |
|---|---|---|
analyze_file | High-level summary of the file's own symbols: classes, interfaces, types, enums, namespaces, functions. Class members are left to list_methods | path |
list_functions | List all functions/methods with full signatures and line ranges, including accessors (get/set), static members and class arrow properties | path |
get_function_body | Extract a function/method body (supports Class.method syntax). Returns the implementation, not an overload signature | path, name |
list_methods | List all methods for a class or interface | path, type |
get_type_definition | Extract any type definition (interface, type alias, class, enum) | path, name |
list_declarations | List module-level const/let/var with types | path |
list_exports | List all exported symbols with kind (function, class, type, namespace, re-export). An overloaded function is one symbol | path |
list_imports | List all import statements with bindings and module paths | path |
find_usages | Find all occurrences of an identifier with source context, in one file or across a directory | path, identifier, scope* |
Call Analysis
| Tool | Description | Parameters |
|---|---|---|
call_graph | Generate a Mermaid call graph diagram | path, `functio |
Related servers

n8n
Updated todayby n8n-io
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

mcp-server-fetch
OfficialUpdated todayA Model Context Protocol server providing tools to fetch and convert web content for usage by LLMs

@modelcontextprotocol/server-filesystem
OfficialUpdated todayMCP server for filesystem access