TypeScript AST MCP Server
TypeScript AST MCP Server
一个提供 TypeScript AST(抽象语法树)分析能力的 Model Context Protocol (MCP) 服务器。该服务器允许你使用 ts-morph 库在 TypeScript 代码中查找类和方法的引用、分析组件树以及查找依赖。
功能
MCP 服务器:实现 Model Context Protocol,用于与 AI 助手集成
TypeScript 分析:使用 ts-morph 进行强大的 TypeScript AST 解析和分析
引用查找:在代码库中查找给定类方法的所有引用
依赖查找:使用
find_dependency工具列出所有导入指定库的文件。组件树分析:使用
component_tree工具分析代码库中的 React 组件结构。这些工具是 MCP 服务器的一部分,可以通过 Claude Code 或其他 MCP 客户端调用。
Related MCP server: agent-workspace-mcp
前提条件
Node.js(与项目兼容的版本)
Yarn 包管理器
设置
克隆仓库
安装依赖:
yarn install复制示例配置文件:
cp .env.example .env更新
.env中的项目 tsconfig 路径:PROJECT_TSCONFIG_PATH=/path/to/your/project/tsconfig.json
如何运行
构建项目:
yarn build测试 MCP 服务器:
yarn test:mcp这将启动 MCP 服务器,可由兼容 MCP 的客户端连接。
在 Claude Code 中安装
要在 Claude Code 中使用此 MCP 服务器:
构建服务器:
yarn build配置 Claude Code:
将
.mcp.example.json复制为.mcp.json(或使用 MCP 配置的内容更新现有的.mcp.json)编辑你的
.claude/settings.local.json并添加 MCP 部分(如果你已经配置了一些 MCP,则只需添加所需的部分)
“enableAllProjectMcpServers”: true,
“enabledMcpjsonServers”: [
“typescript-ast”
]启动 Claude Code
输入
/mcp命令并检查 MCP 是否已连接
开发
更新代码:
修改
src/中的 TypeScript 源文件构建项目:
yarn build测试更改:
yarn test:mcp
环境变量
服务器使用以下环境变量:
PROJECT_TSCONFIG_PATH:用于项目分析的 tsconfig.json 文件路径(默认为 'tsconfig.json')
示例配置文件
.env.example:示例环境变量文件.mcp.example.json:示例 MCP 配置文件(如果适用)
工具描述
服务器提供三个工具:
1. find_reference
在代码库中查找给定类方法的所有引用。
输入:
filePath:文件路径className:类名methodName:方法名
输出:引用该方法的所有文件路径及行号列表
2. find_dependency
列出所有导入指定库的文件。
输入:
dependencyName:要搜索的依赖名称
输出:导入指定依赖的所有文件路径列表
3. component_tree
分析代码库中的 React 组件结构。
输入:
entryFilePath:入口文件路径maxDepth:组件树的最大深度(默认:3)data-id(可选):要捕获到TreeNode.dataId中的属性名称(示例:data-attribute-id)
输出:组件树结构的 JSON 表示,包括可选的元素元数据,如
props、dataId和onClick
许可证
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Stateless TS/JS compiler facts for agents: references, imports, impact. No repo index or OAuth.
A TypeScript MCP server for Home Assistant, enabling programmatic management of entities, automati…
Hosted code graph over MCP: exact callers, dependencies, and cross-repo blast radius for AI agents.
Coding agents in multi-service codebases routinely rebuild existing helpers, trust stale type definitions, and modify API contracts without knowing who consumes them. Carrick solves this by indexing your entire TypeScript ecosystem across service and repository boundaries. By integrating deeply with the TypeScript compiler, Carrick traces every route, type, and cross-service call while recording function behaviour so agents search by intent rather than name. Delivered via MCP for AI agents and LSP for IDEs, Carrick ensures models see existing endpoints and utilities before generating new code. The scanner is source-available and runs from your CLI or CI pipeline.
Related MCP Servers
- AlicenseBqualityDmaintenanceTypeScript-based MCP server designed to enhance code editing experiences by providing features such as hover information, code completion, and diagnostics.328 npm26MIT
- AlicenseAqualityDmaintenanceA TypeScript-aware MCP server that provides coding agents with repository discovery, code intelligence, and web project context for local codebases. It enables deep symbol navigation, diagnostic reporting, and structural analysis of monorepos without requiring full IDE integration.715 npm1MIT
- AlicenseNot gradedqualityCmaintenanceAST-aware TypeScript/JavaScript codebase exploration for AI agents, providing high-precision symbol resolution, reference finding, and structural analysis via MCP tools.228 npmMIT
- FlicenseBqualityDmaintenanceMCP server for TypeScript type resolution and dependency graph analysis using ts-morph and madge.81-