TypeScript AST MCP Server
This server provides deep structural analysis of TypeScript/JavaScript code using the TypeScript Compiler API, supporting JSX/TSX and treating arrow functions as first-class. It offers syntactic and semantic tier analysis.
Structural Queries
analyze_file – File-level summary of symbols (classes, interfaces, types, enums, functions)
list_functions – All functions/methods with signatures and line ranges
get_function_body – Extract a function's implementation (supports
Class.method)list_methods – Methods for a class or interface
get_type_definition – Full definition of any type
list_declarations – Module-level const/let/var declarations with types
list_exports – Exported symbols and their kind
list_imports – Import statements with bindings and module paths
find_usages – All occurrences of an identifier (file or directory)
Call Analysis
call_graph – Mermaid call graph diagrams (forward/reverse, file/package scope, focus on function, include external calls)
get_callers – Reverse call graph (file or directory)
Code Quality & Dead Code
code_complexity – Cyclomatic complexity per function
code_smells – Long functions, deep nesting, god classes,
as any, non-null assertionsfind_errors – Floating promises, empty catches, double type assertions
dead_code – Unreferenced unexported symbols
find_implementations – Classes implementing an interface (explicit, inherited, structural via type checker)
Documentation & IDE Integration
get_doc – JSDoc/TSDoc extraction (supports
Class.method)find_node_at_position – AST node at cursor position
Multi-file Analysis
analyze_package – Directory summary of TS/JS files
diff_ast – Structural diff between two file versions (added/removed/modified symbols)
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., "@TypeScript AST MCP Server generate a call graph for processUser in src/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.
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 editArrow function awareness -
const foo = () => {}treated as first-class functions throughoutSignature 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 namesStructural 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 otherTypeScript-specific quality checks -
anycasts, non-null assertions, floating promises, empty catches, double assertionsDead 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
Related MCP server: ts-graph-tools
Tools
Structural Queries
Tool | Description | Parameters |
| High-level summary of the file's own symbols: classes, interfaces, types, enums, namespaces, functions. Class members are left to |
|
| List all functions/methods with full signatures and line ranges, including accessors ( |
|
| Extract a function/method body (supports |
|
| List all methods for a class or interface |
|
| Extract any type definition (interface, type alias, class, enum) |
|
| List module-level const/let/var with types |
|
| List all exported symbols with kind (function, class, type, namespace, re-export). An overloaded function is one symbol |
|
| List all import statements with bindings and module paths |
|
| Find all occurrences of an identifier with source context, in one file or across a directory |
|
Call Analysis
Tool | Description | Parameters |
| Generate a Mermaid call graph diagram |
|
| Reverse call graph - find all callers of a function |
|
* Optional call_graph parameters:
function- Focus on calls reachable from this function onlydirection-TD(top-down, default) orLR(left-right)include_external- Include calls to functions not defined in the file (default:false)scope-file(default) orpackage(cross-file analysis)
* Optional get_callers parameter:
scope-file(default) orpackage(search all files in the directory)
* Optional find_usages parameter:
scope-file(default) orpackage(search all files in the directory). Passing a directory aspathimpliespackage.
Code Quality
Tool | Description | Parameters |
| Cyclomatic complexity per function |
|
| Long functions, deep nesting, god classes, |
|
| Floating promises, empty catches, double type assertions, optional chain + non-null |
|
A floating promise here means a discarded call to a function the same file declares async (or to fetch). Without type resolution that is the limit of what can be claimed soundly - an imported async function is not detected. It under-reports on purpose: the alternative is guessing from the callee's name, which reports map.get(k).
| dead_code | Find module-local symbols never referenced inside their own file: unexported declarations, plus private and #name class members | path (directory), include_tests* |
| find_implementations | Find classes satisfying an interface, labelled explicit / inherited / structural and marked abstract where it applies (semantic tier) | path, interface |
* Optional - omit to report all functions / exclude test files.
Documentation & Metadata
Tool | Description | Parameters |
| Extract JSDoc/TSDoc comments for any symbol (supports |
|
Multi-File Analysis
Tool | Description | Parameters |
| Directory-level summary of all TS/JS files |
|
| Structural diff between two file versions (added/removed/modified) |
|
* Optional - include test files (default: false).
IDE Integration
Tool | Description | Parameters |
| Identify the AST node at a cursor position |
|
Configuration
Claude Code
Add a .mcp.json file to the repository root:
{
"mcpServers": {
"ts-ast": {
"command": "npx",
"args": ["-y", "github:gclluch/ts-ast-mcp"]
}
}
}Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"ts-ast": {
"command": "npx",
"args": ["-y", "github:gclluch/ts-ast-mcp"]
}
}
}GitHub Copilot (VS Code)
Create .vscode/mcp.json in the project root:
{
"mcpServers": {
"ts-ast": {
"command": "npx",
"args": ["-y", "github:gclluch/ts-ast-mcp"]
}
}
}VSCode Extensions (Cline / Roo Code)
Add to the extension's MCP settings:
{
"mcpServers": {
"ts-ast": {
"command": "npx",
"args": ["-y", "github:gclluch/ts-ast-mcp"],
"env": {}
}
}
}Local development
For working on ts-ast-mcp itself, clone and build locally:
git clone https://github.com/gclluch/ts-ast-mcp.git
cd ts-ast-mcp
npm install # prepare script builds automaticallyThen point your .mcp.json at the local build:
{
"mcpServers": {
"ts-ast": {
"command": "node",
"args": ["/path/to/ts-ast-mcp/dist/index.js"]
}
}
}Two-Tier Parsing
Most tools use the syntactic tier - ts.createSourceFile() parses a single file in under 5ms. No tsconfig or type checker needed.
Tools that operate across files (dead_code, analyze_package) and tools with scope: "package" (call_graph, get_callers) do this by re-parsing every file in scope on each call via the syntactic parser - always correct on the latest edit, at the cost of re-parsing repeatedly.
The semantic tier backs find_implementations, the one question that syntax cannot answer: whether a class satisfies an interface depends on member types and call signatures, not member names. loadProgram() (in src/parse.ts) builds a cached ts.Program and hands the tool the real type checker, which then answers via isTypeAssignableTo - the same rule the compiler applies to an implements clause.
Compiler options come from the nearest tsconfig.json; the file list never does. findConfigFile walks up, so the directory you asked about is routinely outside that config's include, and building from the config's own file list would produce a program that doesn't contain the files under analysis. The cache invalidates when the tsconfig's mtime changes or any file feeding the program changes, so an edit is always reflected on the next call while an unchanged tree reuses the Program.
Cost of the semantic tier is real: the first find_implementations call on a directory pays a full parse-bind-check pass. Subsequent calls on an unchanged tree are cache hits.
One walker for "what is a function"
list_functions, code_complexity and call_graph share a single traversal
(src/scopes.ts). They used to carry one each, and each knew a different subset
of the language, so the three tools disagreed about the same file. Everything
that owns executable code is covered in one place:
Construct | Reported as |
|
|
function nested in another |
|
method, constructor |
|
|
|
class arrow property |
|
| marked |
namespace member |
|
object-literal method or arrow |
|
A consequence worth stating: a call written inside a nested function is attributed to that function, not to the one it is written in. A call inside an anonymous callback is attributed to the enclosing named function, because that callback is not a scope anyone can name.
All output is plain text, not JSON.
Development
npm install
npm test # builds, then runs the vitest suiteThe suite covers the pure helpers (listTsFiles, bindingNames) plus an
integration layer that spawns the real stdio server and drives it over JSON-RPC,
so tool wiring is exercised the way a client actually uses it.
How to Verify
Once registered, you can ask your AI assistant to:
"List all functions in
Dashboard.tsxwith their signatures.""Extract the full definition of the
UserConfiginterface.""Show me who calls the
useApiQueryhook.""Generate a call graph for
utils/ErrorUtils.ts.""What's the cyclomatic complexity of functions in
DataTable.tsx?""Which classes implement the
DataProviderinterface?""Compare the old and new versions of
api.tsstructurally.""What AST node is at line 42, column 10?"
"Give me a directory-level summary of
src/hooks/.""Find error patterns in
AuthService.ts.""Run a code smell check on
BigComponent.tsx.""Find dead code in
src/utils/.""What's the JSDoc for the
useApiQueryfunction?""List all exports from
src/types/index.ts."
Available Tools
20 toolsanalyze_fileA
Provides a high-level summary of all symbols (classes, interfaces, types, enums, functions) in a TypeScript/JavaScript file
Inputs: path (required).
analyze_packageB
Analyzes all TypeScript/JavaScript files in a directory, providing a package-level summary
Inputs: path (required), include_tests.
call_graphB
Generates a Mermaid flowchart showing the call graph of functions in a TypeScript/JavaScript file or directory
Inputs: path (required), scope, function, direction, +1 more.
code_complexityA
Computes cyclomatic complexity for functions in a TypeScript/JavaScript file
Inputs: path (required), function.
code_smellsA
Detects code smells: long functions, too many parameters, deep nesting, god classes, 'any' casts, non-null assertions
Inputs: path (required), function.
dead_codeA
Finds unreferenced unexported symbols (functions, types, variables) within a directory
Inputs: path (required), include_tests.
diff_astA
Compares two TypeScript/JavaScript files structurally, reporting added/removed/modified symbols
Inputs: new_path (required), old_path (required).
find_errorsA
Analyzes TypeScript-specific error patterns: floating promises, empty catches, unsafe type assertions, double assertions
Inputs: path (required), function.
find_implementationsA
Finds classes that implement a specified interface - explicit 'implements' plus structural matches, checked by the TypeScript type checker (member types and call signatures, not just names)
Inputs: path (required), interface (required).
find_node_at_positionB
Identifies the AST node at a given cursor position (line and column) in a TypeScript/JavaScript file
Inputs: line (required), path (required), column (required).
find_usagesB
Finds all occurrences of a specific identifier (variable, function, type) within a file
Inputs: path (required), identifier (required).
get_callersB
Finds all functions in a file or package that call the specified function (reverse call graph)
Inputs: path (required), function (required), scope.
get_docA
Extracts JSDoc/TSDoc comments for a symbol (function, type, class, variable). Supports Class.method syntax.
Inputs: name (required), path (required).
get_function_bodyA
Extracts the full body of a specific function or method. Supports Class.method syntax.
Inputs: name (required), path (required).
get_type_definitionA
Extracts the full definition of any type (interface, type alias, class, enum) by name
Inputs: name (required), path (required).
list_declarationsA
Lists package-level constant and variable declarations in a TypeScript/JavaScript file
Inputs: path (required).
list_exportsA
Lists all exported symbols with their kind (function, class, interface, type, variable, re-export)
Inputs: path (required).
list_functionsA
Lists all functions and methods in a TypeScript/JavaScript file with their signatures and line ranges
Inputs: path (required).
list_importsA
Lists all import statements in a TypeScript/JavaScript file with their bindings and module paths
Inputs: path (required).
list_methodsA
Lists all methods for a specific class in a TypeScript/JavaScript file
Inputs: path (required), type (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 20 tools
Each tool targets a distinct aspect of TypeScript AST analysis, such as listing symbols, extracting definitions, analyzing dependencies, or detecting issues. Even related tools like call_graph and get_callers have clearly differentiated scopes, preventing misselection.
The majority of tools follow a consistent verb_noun snake_case pattern (list_functions, get_type_definition, find_usages). Minor deviations exist, such as noun-only names like call_graph, code_complexity, code_smells, and dead_code, but these remain readable and do not disrupt overall coherence.
With 20 tools, the server is slightly above the typical ideal range, but each tool addresses a distinct need within the TypeScript AST analysis domain. The count feels justified given the breadth of operations covered, from symbol enumeration to code quality checks.
The tool set provides comprehensive coverage for static AST analysis, including symbol discovery, detail extraction, relationship mapping, complexity measurement, error detection, and dead code identification. No obvious gaps exist for the server's stated purpose.
Maintenance
Related MCP Connectors
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Stateless TS/JS compiler facts for agents: references, imports, impact. No repo index or OAuth.
AI-powered codebase analysis — call graphs, security, dead code, complexity. 150+ tools.
30+ deterministic dev and delivery tools: linting, metrics, diagrams, model advice, AI-text checks.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables AI coding agents to interact with TypeScript projects through compiler-level code intelligence, providing tools for navigation, type information, diagnostics, refactoring, and semantic search.29179 npm4Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables querying a TypeScript codebase's graph for call flows, type relationships, and symbol locations without reading file bodies.-
- AlicenseNot gradedqualityDmaintenanceEnables MCP-compatible clients to analyze TypeScript code by finding method references, dependency imports, and React component trees.MIT
- AlicenseBqualityBmaintenanceEnables AI coding agents to perform zero-execution, AST-based static analysis of JavaScript/TypeScript codebases, including symbol lookup, dependency tracing, change-impact analysis, dead-code detection, and risk assessment.8750 npmMIT