Token导航 LogoToken导航TokenDH.com
Code Tree (Thinky Miner) logo
开发工具stdio官方级别未说明来源级核验

Code Tree (Thinky Miner)

MCP Server

codetree是一个通过tree-sitter提供结构化代码理解的MCP服务器,帮助AI代理高效理解代码结构,减少令牌消耗。

工具数

23

提示词数

0

GitHub Stars

25

资源数

0
代码分析PythonClaude开发工具Claude DesktopClaudeCursorWindsurfVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

ThinkyMiner

提供方

ThinkyMiner

最后核验

2026/5/17 20:20

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv .venv

详细介绍

代码树

![Tests](https://github.com/ThinkyMiner/codeTree/actions/workflows/test.yml) ![PyPI](https://pypi.org/project/mcp-server-codetree/) ![Python](https://pypi.org/project/mcp-server-codetree/) ![License: MIT](LICENSE)

停止向您的AI代理提供整个文件。

快速开始

先决条件: 安装 紫外线 如果你没有(curl -LsSf https://astral.sh/uv/install.sh | sh).

然后 cd 进入任何项目并运行:

claude mcp add codetree -- uvx --from mcp-server-codetree codetree --root .

就是这样 . 意思是“这个项目”。您的代理现在对结构化代码有了理解。

不使用克劳德代码?看 编辑器设置 适用于Cursor、VS Code、Windsurf和Claude Desktop。

之前/之后

在代码树--agent读取原始文件之前:

$ cat calculator.py
import math
from typing import Optional

class Calculator:
    """A scientific calculator with memory."""

    def __init__(self):
        self.memory = 0
        self.history = []

    def add(self, a: float, b: float) -> float:
        """Add two numbers."""
        result = a + b
        self.history.append(('add', a, b, result))
        return result

    def divide(self, a: float, b: float) -> Optional[float]:
        """Divide a by b, returns None on zero division."""
        if b == 0:
            return None
        result = a / b
        self.history.append(('divide', a, b, result))
        return result

    # ... 200 more lines of methods ...

消耗的令牌:完整文件约2000+

在代码树--agent请求骨架之后:

class Calculator → line 4
  "A scientific calculator with memory."
  def __init__(self) (in Calculator) → line 7
  def add(self, a: float, b: float) (in Calculator) → line 11
    "Add two numbers."
  def divide(self, a: float, b: float) (in Calculator) → line 17
    "Divide a by b, returns None on zero division."
  def sqrt(self, x: float) (in Calculator) → line 24
    "Square root using math.sqrt."

消耗的代币:~80。减少了25倍。

代理可以看到每个类、方法和文档字符串(带行号),而无需读取单个函数体。当它需要完整的来源时 divide,它叫 get_symbol("calculator.py", "divide") 只有这6条线。

23工具

了解结构

工具目的
get_file_skeleton(file_path)带行号+文档注释的类、函数、方法
get_symbol(file_path, symbol_name)函数或类的完整源代码
get_skeletons(file_paths)多个文件的批处理骨架
get_symbols(symbols)多个符号的批处理源
get_imports(file_path)带行号的导入报表

导航关系

工具目的
find_references(symbol_name)回购中符号的所有用法
get_call_graph(file_path, function_name)函数调用什么+调用什么
get_blast_radius(file_path, symbol_name)传递性影响——如果你改变这一点,会发生什么

分析质量

工具目的
get_complexity(file_path, function_name)圈复杂度分解
find_dead_code(file_path?)已定义但从未引用的符号
detect_clones(file_path?, min_lines?)重复/接近重复的功能

检查和搜索

工具目的
search_symbols(query?, type?, parent?)使用过滤器进行灵活的符号搜索
find_tests(file_path, symbol_name)查找符号的测试函数

入职培训与图表

工具目的
index_status()图表索引新鲜度和统计数据
get_repository_map(max_items?)紧凑型仓库概述:语言、入口点、热点
resolve_symbol(query, kind?, path_hint?)在排名合格的比赛中消除短名称的歧义
search_graph(query?, kind?, file_pattern?)使用度过滤器和分页进行图形搜索

更改和数据流

工具目的
get_change_impact(symbol_query?, diff_scope?)通过符号或git diff进行影响分析,并注明风险等级
analyze_dataflow(file_path, function_name, mode?)变量数据流、污染分析或跨功能污染跟踪

可视化和历史

工具目的
find_hot_paths(top_n?)高复杂度×高呼叫数优化目标
get_dependency_graph(file_path?, format?)文件级依赖关系图为Mermaid或列表
git_history(mode?, file_path?, top_n?)Git故障、文件流失或更改耦合分析
suggest_docs(file_path?, symbol_name?)查找带有上下文的未文档化函数以生成文档
get_file_skeleton, get_skeletons,以及 search_symbols 接受 format="compact" 甚至更少的代币。

支持的语言

语言扩展
python .py
JavaScript.js, .jsx
TypeScript.ts
TSX.tsx
去吧.go
生锈.rs
Java .java
C .c, .h
C .cpp, .cc, .cxx, .hpp, .hh
红宝石.rb

编辑器设置

--root flag告诉代码树要分析哪个项目。使用 . 当前目录或完整路径。

克劳德代码

cd 进入你的项目,然后:

claude mcp add codetree -- uvx --from mcp-server-codetree codetree --root .

光标

添加 .cursor/mcp.json 在您的项目中:

{
  "mcpServers": {
    "codetree": {
      "command": "uvx",
      "args": ["--from", "mcp-server-codetree", "codetree", "--root", "${workspaceFolder}"]
    }
  }
}

VS代码(副本)

添加 .vscode/mcp.json 在您的项目中:

{
  "servers": {
    "codetree": {
      "command": "uvx",
      "args": ["--from", "mcp-server-codetree", "codetree", "--root", "${workspaceFolder}"]
    }
  }
}

帆板运动

添加 ~/.codeium/windsurf/mcp_config.json:

{
  "mcpServers": {
    "codetree": {
      "command": "uvx",
      "args": ["--from", "mcp-server-codetree", "codetree", "--root", "${workspaceFolder}"]
    }
  }
}

克劳德桌面版

添加 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)或 %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "codetree": {
      "command": "uvx",
      "args": ["--from", "mcp-server-codetree", "codetree", "--root", "/path/to/your/project"]
    }
  }
}
Claude Desktop不支持 ${workspaceFolder},所以在这里使用完整路径。

为什么是代码树?

替代限制代码树
直接读取文件Burns代币,无结构,无关系25倍代币缩减,结构化输出
grep/ripgrep纯文本,无AST感知,无调用图理解代码结构,而不仅仅是文本
LSP服务器重量级、有状态、特定语言的设置一个命令、10种语言、无状态MCP
SCIP/LSIF索引器构建速度慢,设置复杂,索引庞大~1s启动,JSON缓存,零配置
AST专用工具原始树对于代理来说冗长而困难为代理设计的预结构化输出

建筑

Agent (Claude, Copilot, Cursor, etc.)
    │ MCP (stdio)
    ▼
codetree server (FastMCP)
    │
    ├── Indexer → LanguagePlugin → tree-sitter → structured results
    │   Cache (.codetree/index.json, mtime-based)
    │
    └── Graph Layer → SQLite (.codetree/graph.db)
        Persistent symbols + edges, incremental updates
        Change impact, dataflow, taint analysis
模块责任
server.pyFastMCP服务器——定义了所有23个工具
indexer.py文件发现、插件分发、定义索引
cache.py具有mtime无效的骨架缓存
registry.py将文件扩展名映射到语言插件
languages/每种语言一个插件(Python、JS、TS、Go、Rust、Java、C、C++、Ruby)
graph/store.py符号和边的SQLite持久性
graph/builder.py增量图形生成器(sha256变化检测)
graph/queries.py存储库映射、符号解析、更改影响、热路径、依赖关系图、文档建议
graph/dataflow.py函数内和跨函数数据流和污染分析
graph/git_analysis.pyGit故障、流失、变更耦合分析

添加语言

  1. pip install tree-sitter-LANG 并添加到 pyproject.toml
  2. 复制 src/codetree/languages/_template.pylanguages/yourlang.py
  3. 实现抽象方法
  4. 在中注册扩展名 registry.py
  5. 添加测试

发展

git clone https://github.com/ThinkyMiner/codeTree.git
cd codeTree
python -m venv .venv
source .venv/bin/activate
pip install -e .
pip install pytest

# Run all tests (~1058 tests, ~35s)
pytest

# Run a single test file
pytest tests/languages/test_python.py -v

贡献

欢迎投稿!看 贡献.md 有关设置说明和指南。

目录标签

目录标签

代码分析PythonClaude开发工具本地部署AI辅助开发结构化代码

支持客户端

Claude DesktopClaudeCursorWindsurfVS Code

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

23

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP