mcpField
J
jsc-typescript-ast-mcp

jsc-typescript-ast-mcp

Local
github.com/jscoobycedDeveloper Tools0Updated 29w ago

About jsc-typescript-ast-mcp

jsc-typescript-ast-mcp is an MCP server for analyzing TypeScript code with ts-morph. It helps developers find references and dependencies, and inspect React component trees as JSON.

Key features

  1. 01Parse TypeScript ASTs with ts-morph
  2. 02Find class method references
  3. 03Locate files importing a dependency
  4. 04Analyze React component trees
  5. 05Return component trees as JSON

Use cases

  1. 01Find usages of a class method across a codebase
  2. 02Identify files that import a library
  3. 03Inspect a React component hierarchy and metadata

MCP support

Exposes three tools to MCP clients: find_reference, find_dependency, and component_tree. The tools analyze the project configured through PROJECT_TSCONFIG_PATH.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"jscoobyced-jsc-typescript-ast": {
"command": "npx",
"args": [
"-y",
"jsc-typescript-ast-mcp"
],
"env": {
"PROJECT_TSCONFIG_PATH": "<PROJECT_TSCONFIG_PATH>"
}
}
}
}
Run commandnpx -y jsc-typescript-ast-mcp
Environment variables to set
PROJECT_TSCONFIG_PATHThe path to your TypeScript project's tsconfig.json file

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npmjsc-typescript-ast-mcp1.1.8

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

TypeScript AST MCP Server

A Model Context Protocol (MCP) server that provides TypeScript AST (Abstract Syntax Tree) analysis capabilities. This server allows you to find references for classes and methods, analyze component trees, and find dependencies in TypeScript code using the ts-morph library. Great to represent JSON structure of your React components.

Features

  • MCP Server: Implements the Model Context Protocol for integration with AI assistants
  • TypeScript Analysis: Uses ts-morph for powerful TypeScript AST parsing and analysis
  • Reference Finding: Find all references to a given class method in your codebase
  • Dependency Finding: Use the find_dependency tool to list all files that import a specified library.
  • Component Tree Analysis: Use the component_tree tool to analyze React component structures in your codebase.
  • The tools are part of the MCP server and can be invoked via Claude Code or other MCP clients.

Prerequisites

  • Node.js (version compatible with the project)
  • Yarn package manager

Setup

  1. Create .env with your project's tsconfig path:
    PROJECT_TSCONFIG_PATH=/path/to/your/project/tsconfig.json
    

How to Run

Add this package as dependency and run

yarn typescript-ast

This will start the MCP server that can be connected to by MCP-compatible clients.

Installing in Claude Code

To use this MCP server in Claude Code:

  1. Configure Claude Code:
  • Copy a .mcp.json (or update your existing one with the content of the MCP configuration):
{
  "mcpServers": {
    "typescript-ast": {
      "type": "stdio",
      "command": "yarn",
      "args": [
        "typescript-ast"
      ],
      "env": {
        "PROJECT_TSCONFIG_PATH": "PATH/TO/YOUR/TYPESCRIPT/PROJECT/tsconfig.json"
      }
    }
  }
}

For the project path, if you're using Vite you might want to use the tsconfig.app.json instead.

  • Edit your .claude/settings.local.json and add the MCP section (or the subset needed if you already have some MCPs configured)
  “enableAllProjectMcpServers”: true,
  “enabledMcpjsonServers”: [
    “typescript-ast”
  ]
  • Start Claude Code
  • Type the /mcp command and check the MCP is connected

Tool Descriptions

The server provides three tools:

1. find_reference

Find all references to a given class method in your codebase.

  • Input:
    • filePath: Path to the file
    • className: Name of the class
    • methodName: Name of the method
  • Output: List of file paths with line numbers where the method is referenced
2. find_dependency

List all files that import a specified library.

  • Input:
    • dependencyName: Name of the dependency to search for
  • Output: List of file paths that import the specified dependency
3. component_tree

Analyze React component structures in your codebase.

  • Input:
    • entryFilePath: Path to the entry file
    • maxDepth: Maximum depth of the component tree (default: 3)
    • data-id (optional): Attribute name to capture into TreeNode.dataId (example: data-attribute-id)
  • Output: JSON representation of the component tree structure, including optional element metadata such as props, dataId, and onClick

License

MIT

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.