Skip to main content
Glama
jscoobyced

TypeScript AST MCP Server

by jscoobyced

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 包管理器

设置

  1. 克隆仓库

  2. 安装依赖:

    yarn install
  3. 复制示例配置文件:

    cp .env.example .env
  4. 更新 .env 中的项目 tsconfig 路径:

    PROJECT_TSCONFIG_PATH=/path/to/your/project/tsconfig.json

如何运行

构建项目:

yarn build

测试 MCP 服务器:

yarn test:mcp

这将启动 MCP 服务器,可由兼容 MCP 的客户端连接。

在 Claude Code 中安装

要在 Claude Code 中使用此 MCP 服务器:

  1. 构建服务器

    yarn build
  2. 配置 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 是否已连接

开发

更新代码:

  1. 修改 src/ 中的 TypeScript 源文件

  2. 构建项目:

    yarn build
  3. 测试更改:

    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 表示,包括可选的元素元数据,如 propsdataIdonClick

许可证

MIT

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
0dRelease cycle
5Releases (12mo)
Commit activity

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

View all related MCP servers

Related MCP Connectors

  • A TypeScript MCP server for Home Assistant, enabling programmatic management of entities, automati…

  • Scan any public GitHub MCP-server repo for security issues. 37 MCP-specific L1 rules, 8 languages.

  • Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.

View all MCP Connectors

Latest Blog Posts

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/jscoobyced/jsc-typescript-ast-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server