NT

nendotools/tree-sitter-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

33 stars 6 forks 质量 68 趋势 11GPL-3.0

该仓库展示由树木坐者生成的代码结构数据,供AI系统吸收,以便更明智地分析和改进代码。

概览

快速的语义代码搜索和分析常见编程语言。搜索函数和类,追踪代码使用情况,并分析整个项目中的代码质量。 既可以作为独立的CLI工具,也可以作为像Claude Code这样的AI工具的MCP服务器。 - - 通过15+语言的名称查找函数、类和变量 - - 在修改前查看代码使用位置 - - 检测复杂函数、死代码和架构问题 - - 通过解析代码结构实现低于100毫秒的搜索,而非扫描文本 - - 在任何项目中立即生效 JavaScript、TypeScript、Python、Go、Rust、Java、C/C++、Ruby、C#、PHP、Kotlin、Scala、Elixir 作为MCP服务器使用时,为AI助手提供以下工具: - search_code - 按名称搜索函数、类、变量 - find_usage - 查找项目中所有标识符的使用情况 - analyze_code - 全面的代码质量与结构分析 - check_errors - 查找带有详细上下文的可操作语法错误 请看完整......

概述(AI 翻译)

快速的语义代码搜索和分析常见编程语言。搜索函数和类,追踪代码使用情况,并分析整个项目中的代码质量。

既可以作为独立的CLI工具,也可以作为像Claude Code这样的AI工具的MCP服务器。

开始

安装:

搜索代码:

分析代码质量:

查找语法错误:

使用 Claude Desktop 设置:

或者手动添加添加到~/.config/claude-desktop/claude_desktop_config.json:

特色

  • 语义搜索 - 跨15+语言按名称查找函数、类和变量
  • 使用追踪 - 在进行修改前查看代码的使用位置
  • 质量分析 - 检测复杂函数、死代码和架构问题
  • 快速结果 - 通过解析代码结构而非扫描文本,搜索速度低于100毫秒
  • 无配置 - 在任何项目上立即生效

支持的语言

JavaScript、TypeScript、Python、Go、Rust、Java、C/C++、Ruby、C#、PHP、Kotlin、Scala、Elixir

配置文件:JSON、YAML、TOML、.env

CLI 使用

搜索代码元素:

查找标识符的使用情况:

分析代码质量:

查找语法错误:

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Tree-Sitter MCP

Fast semantic code search and analysis for common programming languages. Search for functions and classes, trace code usage, and analyze code quality across your entire project.

Works as both a standalone CLI tool and an MCP server for AI tools like Claude Code.

Getting Started

Install:

npm install -g @nendo/tree-sitter-mcp

Search for code:

tree-sitter-mcp search "handleRequest" --type function

Analyze code quality:

tree-sitter-mcp analyze --analysis-types quality deadcode structure

Find syntax errors:

tree-sitter-mcp errors --output text

Setup with Claude Desktop:

tree-sitter-mcp setup --auto

Or configure manually by adding to ~/.config/claude-desktop/claude_desktop_config.json:

{
  "mcpServers": {
    "tree-sitter-mcp": {
      "command": "npx",
      "args": ["@nendo/tree-sitter-mcp", "--mcp"],
      "cwd": "/path/to/your/project"
    }
  }
}

Features

  • Semantic search - Find functions, classes, and variables by name across 15+ languages
  • Usage tracing - See where code is used before making changes
  • Quality analysis - Detect complex functions, dead code, and architectural issues
  • Fast results - Sub-100ms searches by parsing code structure, not scanning text
  • No configuration - Works immediately on any project

Supported Languages

JavaScript, TypeScript, Python, Go, Rust, Java, C/C++, Ruby, C#, PHP, Kotlin, Scala, Elixir

Config files: JSON, YAML, TOML, .env

CLI Usage

Search for code elements:

tree-sitter-mcp search "DatabaseManager" --exact
tree-sitter-mcp search "handle.*Request" --type function method

Find usage of identifiers:

tree-sitter-mcp find-usage "UserService" --exact
tree-sitter-mcp find-usage "API_KEY" --case-sensitive

Analyze code quality:

tree-sitter-mcp analyze --analysis-types quality structure deadcode
tree-sitter-mcp analyze src/components --analysis-types quality

Find syntax errors:

tree-sitter-mcp errors --output text
tree-sitter-mcp errors src/components --max-results 10

Setup MCP integration:

tree-sitter-mcp setup --auto
tree-sitter-mcp setup  # Manual setup instructions

MCP Tools

When used as an MCP server, provides these tools for AI assistants:

  • search_code - Search for functions, classes, variables by name
在 GitHub 查看完整 README

安装

npx @nendo/tree-sitter-mcp --mcp
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "tree-sitter-mcp": { "command": "npx", "args": ["@nendo/tree-sitter-mcp", "--mcp"], "cwd": "/path/to/your/project" } } }