Skip to main content

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

  1. Clone the repository.
  2. 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

treesitter_mcp-0.1.3.tar.gz (22.3 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-0.1.3-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

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

Hashes for treesitter_mcp-0.1.3.tar.gz
Algorithm Hash digest
SHA256 aa98a4ba6c508aa5126d7363554094ab778b0aea87b1f7b2efee2bdf7f72cfc2
MD5 11999ce7188188ebe938d267f128d805
BLAKE2b-256 b4ef8c96855d59a8a1253609dec6b96ab1f37e9ce167d78e769371f556953f9e

See more details on using hashes here.

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

Hashes for treesitter_mcp-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9a632c2c7ec29d2d288f1da7b3566de7621ecea7db6dd8bd523c8a4d66eae501
MD5 e86e5ff3fcc728518ab4766d7d69c618
BLAKE2b-256 f830c272f7bf6b4551fcb4175eb521a33e3e2cb113c560cf5da5357c3c2279bf

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