Skip to main content

MCP server for code analysis using Tree-sitter

Project description

Tree-sitter MCP Server

An MCP server 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

Install

Requires Python 3.10+.

# Install directly
uv pip install treesitter-mcp

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

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.

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_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.

Language support

Language analyze_file get_ast get_call_graph find_function find_variable find_usage get_dependencies
C
C++
Python
JavaScript
TypeScript
Go
Java
PHP
Rust
Ruby

File extensions

Language Extensions
C .c
C++ .cpp, .cc, .cxx, .h, .hpp
Python .py
JavaScript .js, .jsx, .mjs, .cjs
TypeScript .ts, .tsx, .cts, .mts
Go .go
Java .java
PHP .php, .phtml
Rust .rs
Ruby .rb

Docs

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

treesitter_mcp-2.0.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

treesitter_mcp-2.0-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file treesitter_mcp-2.0.tar.gz.

File metadata

  • Download URL: treesitter_mcp-2.0.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for treesitter_mcp-2.0.tar.gz
Algorithm Hash digest
SHA256 0530124de95357a59ce8b9bd06aae9353e414151ab46b8e07760009795eed561
MD5 7689f732ed6770842ad4888dedb03772
BLAKE2b-256 d6b7bea0321a6813cc83aa8ae57b2a41eb0cea5ecd423daa6a72afd55b1bd01d

See more details on using hashes here.

File details

Details for the file treesitter_mcp-2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for treesitter_mcp-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2623d78721a798820d0ca5449e940f83b9cad8e1f436b315f96a38457800db7f
MD5 d9dbaefa1701e9d8c454009e86ec671e
BLAKE2b-256 aceb3c39edd5967dd2ed9e1459d4082f1cba7d792f0e2ad864488d71da94a297

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page