PI

pwno-io/treesitter-mcp

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

20 stars 4 forks 품질 49 트렌드 0

쓰레기를 위한 MCP 서버

개요

MCP 서버 및 CLI를 사용하여 트리 시터를 파싱 및 분석 코드를 사용합니다. - Parse 파일 및 AST - 추출 기능 및 변수 - 빌드 호출 그래프 - 기능 / 변수가 사용되는 곳 찾기 - 사용자 정의 실행 Tree-sitter 쿼리 - 목록 가져 오기 / 포함 - 특정 라인 / 열 범위에 대한 소스 코드를 추출 - 독립 CLI 또는 Claude 데스크톱을위한 MCP 서버로 사용 나무가 돋보이는 mcp와 ts-cli 항목 포인트를 모두 설치합니다. Claude 데스크탑 또는 다른 MCP 클라이언트와 함께 사용: 구성하는 방법을 위해 docs/MCP USAGE.md를 참조하십시오. 터미널에서 직접 분석 실행: stdout 대신 JSON 파일에 결과를 쓰기 위해 --output-file을 사용합니다. 또는 URL 쿼리 param을 통해: http://127.0.0.1:8000?tools=treesitter_analyze_file,treesitter_get_ast

개요(AI 번역)

MCP 서버 및 CLI를 사용하여 트리 시터를 파싱 및 분석 코드를 사용합니다.

무엇 그것

  • Parse 파일과 그들의 AST를 얻을
  • 추출 기능 및 변수
  • 호출 그래프 구축
  • 기능/variables가 사용되는 곳 찾기
  • 맞춤 트리 시터 쿼리 실행
  • 목록 가져오기/includes
  • 특정한 선/column 범위를 위한 근원 부호를 추출하십시오
  • 독립 CLI 또는 Claude Desktop용 MCP 서버로 사용

설치

Python 3.10+를 요구합니다.

treesitter-mcp]와 ts-cli 항목 포인트를 모두 설치합니다.

또는 설치하지 않고 실행:

실행

MCP 서버로 (과태)

Claude 데스크탑 또는 다른 MCP 클라이언트와 함께 사용:

docs/MCP_USAGE.md] 를 참조하십시오.

독립 CLI (ts-cli)

터미널에서 직접 분석 실행:

--output-file]를 사용하여 stdout 대신 JSON 파일에 결과를 작성합니다.

HTTP 모드

시험 또는 수동 사용을 위해:

제한 도구

--tools로 특정 도구를 노출:

또는 URL 쿼리 param을 통해: http://127.0.0.1:8000?tools=treesitter_analyze_file,treesitter_get_ast

유효한 공구:

  • treesitter_analyze_file - 기본 분석
  • [T7] - 전체 AST
  • treesitter_get_call_graph - 기능 호출

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

원문 README의 일부입니다. 원문 보기.

Tree-sitter MCP Server & CLI

An MCP server and CLI that uses Tree-sitter to parse and analyze code.

What it does

  • Parse files and get their AST
  • Extract functions and variables
  • Build call graphs
  • Find where functions/variables are used
  • Run custom Tree-sitter queries
  • List imports/includes
  • Extract source code for specific line/column ranges
  • Use as a standalone CLI or as an MCP server for Claude Desktop

Install

Requires Python 3.10+.

# Install directly
uv pip install treesitter-mcp

# Or install a specific version
uv pip install treesitter-mcp==2.1

# Or clone and install
git clone https://github.com/pwno-io/treesitter-mcp.git
cd treesitter-mcp
uv pip install -e .

This installs both treesitter-mcp and ts-cli entry points.

Or run without installing:

uvx treesitter-mcp

Running

As an MCP server (default)

For use with Claude Desktop or other MCP clients:

treesitter-mcp

See docs/MCP_USAGE.md for how to configure.

Standalone CLI (ts-cli)

Run analysis directly from the terminal:

ts-cli path/to/file.py
ts-cli path/to/file.py --ast --max-depth 2
ts-cli path/to/file.py --find-function main --include-source
ts-cli --supported-languages

Use --output-file to write results to JSON files instead of stdout.

HTTP mode

For testing or manual use:

treesitter-mcp --http --port 8000 --host 127.0.0.1

Limiting tools

Only expose certain tools with --tools:

treesitter-mcp --http --port 8000 --tools treesitter_analyze_file,treesitter_get_ast

Or via URL query param: http://127.0.0.1:8000?tools=treesitter_analyze_file,treesitter_get_ast

Tools available:

  • treesitter_analyze_file - Basic analysis
  • treesitter_get_ast - Full AST
  • treesitter_get_call_graph - Function calls
  • treesitter_find_function - Find function definitions
  • treesitter_find_variable - Find variables
  • treesitter_get_source_for_range - Extract source code for a range
  • treesitter_get_supported_languages - What’s supported
  • treesitter_get_node_at_point - AST node at a line/column
  • treesitter_get_node_for_range - AST node for a range
  • treesitter_cursor_walk - Walk tree with context
  • treesitter_run_query - Custom Tree-sitter queries
  • treesitter_find_usage - Find symbol usages
  • treesitter_get_dependencies - Extract imports/includes

If you don’t specify --tools, everything is exposed.

Writing output to file

All tools support an optional output_file parameter. When provided, the tool writes its result directly to the specified file (as pretty-printed JSON) instead of returning it. This is useful for large outputs like ASTs that could cause context overload in agents.

Example:

# Returns result to file, minimal response to agent
treesitter_get_ast(file_path="large_file.py", output_file="~/output/ast.json")
# Returns: {"status": "written", "output_file": "/home/user/output/ast.json", "bytes_written": 123456}
GitHub에서 전체 README 보기

설치

uvx treesitter-mcp
MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →