MCP server for code analysis using Tree-sitter
Project description
Tree-sitter MCP Server
A Model Context Protocol (MCP) server for code analysis using Tree-sitter. This tool provides capabilities to parse code, extract symbols, generate call graphs, find usages, and run custom queries against C, C++, JavaScript, PHP, Rust, TypeScript, Go, Java, and Python code.
Features
- AST Retrieval: Get the full Abstract Syntax Tree (AST) of a file.
- Symbol Extraction: Find function and variable definitions.
- Call Graph: Generate a call graph for C/C++ functions.
- Tree-sitter Queries: Run custom S-expression queries against your code.
- Usage Finder: Find usages of functions and variables.
- Dependency Extraction: List file dependencies (includes/imports).
- Multi-Language Support: Currently supports C, C++, JavaScript, PHP, Rust, TypeScript, Go, Java, and Python.
Installation
Quick install (PyPI)
pip install treesitter-mcp
# or with uvx (no global install)
uvx treesitter-mcp --help
# or install the binary with uv tool
uv tool install treesitter-mcp
This provides two commands:
treesitter: CLI for analyzing filestreesitter-mcp: MCP server
Check available options:
treesitter --help
treesitter-mcp --help
Usage
CLI
The CLI is available as the treesitter command after installation.
treesitter <file_path> [options]
Examples
Get AST:
treesitter test.c --ast
Find Function Definition:
treesitter test.c --find-function my_func
Find Usages:
treesitter test.c --find-usage my_func
Get Dependencies:
treesitter test.c --dependencies
Run Custom Query:
treesitter test.c --query "(function_definition) @func"
MCP Server
To run the MCP server:
treesitter-mcp
Configure your MCP client (e.g., Claude Desktop) to use this server. See docs/MCP_USAGE.md for detailed configuration instructions.
Supported Languages
- C: Full support (Symbols, Call Graph, Queries, Usage).
- C++: Full support.
- JavaScript: Full support.
- PHP: Full support.
- Rust: Full support.
- TypeScript: Full support.
- Go: Full support.
- Java: Full support.
- Python: Full support.
Documentation
See the docs/ directory for more details:
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file treesitter_mcp-0.1.2.tar.gz.
File metadata
- Download URL: treesitter_mcp-0.1.2.tar.gz
- Upload date:
- Size: 23.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bba9823e14ecc79f58dbd6f4af2e4c0d3650b5e07f17cd602fe27b93571912fe
|
|
| MD5 |
5e4472b89a375939605ce5e45f065a6e
|
|
| BLAKE2b-256 |
ccd19c7fb488a5ef9660ba7589e53fd12c617bf0835c51b31d41ec42ce58a80b
|
File details
Details for the file treesitter_mcp-0.1.2-py3-none-any.whl.
File metadata
- Download URL: treesitter_mcp-0.1.2-py3-none-any.whl
- Upload date:
- Size: 25.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c61408a065d3ac9b0965ce89d1d0d1d00e1f44c3f21d972545ceffbb171e8329
|
|
| MD5 |
cda829b17d4fa7eb68c5ec109090c1ae
|
|
| BLAKE2b-256 |
986bd701ed4a3806d89ad4ac02bd3cb574990639fdc5eba42072961ec39fbc91
|