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++, 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++, and Python.
Installation
Prerequisites
- Python 3.10+
pip
Setup
- Clone the repository.
- Install the package:
# Using uv (recommended) uv pip install -e . # Or using pip pip install -e .
This will install the treesitter-mcp command-line tool.
You can also run it directly without installation using uvx:
uvx treesitter-mcp
Usage
MCP Server (Default)
By default, treesitter-mcp runs as an MCP server in stdio mode:
treesitter-mcp
This is perfect for integrating with MCP clients like Claude Desktop. See docs/MCP_USAGE.md for configuration instructions.
HTTP Mode
To run the server in HTTP mode for testing or development:
treesitter-mcp --http --port 8000 --host 127.0.0.1
Example with uvx
# Run in stdio mode (default)
uvx treesitter-mcp
# Run in HTTP mode
uvx treesitter-mcp --http --port 8000
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.
- **Python**: Full support.
## Documentation
See the `docs/` directory for more details:
- [API Reference](docs/API.md)
- [MCP Server Usage](docs/MCP_USAGE.md)
- [Architecture](docs/ARCHITECTURE.md)
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.3.tar.gz.
File metadata
- Download URL: treesitter_mcp-0.1.3.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa98a4ba6c508aa5126d7363554094ab778b0aea87b1f7b2efee2bdf7f72cfc2
|
|
| MD5 |
11999ce7188188ebe938d267f128d805
|
|
| BLAKE2b-256 |
b4ef8c96855d59a8a1253609dec6b96ab1f37e9ce167d78e769371f556953f9e
|
File details
Details for the file treesitter_mcp-0.1.3-py3-none-any.whl.
File metadata
- Download URL: treesitter_mcp-0.1.3-py3-none-any.whl
- Upload date:
- Size: 24.0 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 |
9a632c2c7ec29d2d288f1da7b3566de7621ecea7db6dd8bd523c8a4d66eae501
|
|
| MD5 |
e86e5ff3fcc728518ab4766d7d69c618
|
|
| BLAKE2b-256 |
f830c272f7bf6b4551fcb4175eb521a33e3e2cb113c560cf5da5357c3c2279bf
|