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 "Install 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 Servergenerate 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-language-mcp
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."
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables CLI agents to detect and remove dead code, manage complexity, and enforce hygiene rules in TypeScript/JavaScript projects through tools like scanning, cleansing, and reporting.Last updated58ISC
- Alicense-qualityDmaintenanceEnables AI coding agents to interact with TypeScript projects through compiler-level code intelligence, providing tools for navigation, type information, diagnostics, refactoring, and semantic search.Last updated3593Apache 2.0
- Flicense-qualityDmaintenanceEnables to extract TypeScript methods, functions, and their relevant imports and class properties for code analysis, refactoring, and documentation.Last updated
- Alicense-qualityDmaintenanceEnables AI assistants to analyze code health in TypeScript/JavaScript projects, providing tools to run analysis, start a dashboard, and get summaries.Last updated223MIT
Related MCP Connectors
Enterprise code intelligence for M&A, security audits, and tech debt. Hosted server with 200k free.
AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).
Provide AI-powered real-time analysis and intelligence on NPM packages, including security, depend…
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/gclluch/ts-ast-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server