code-to-tree

code-to-tree

Universal Code-to-AST MCP Server for LLM Integration

66
Stars
8
Forks
66
Watchers
1
Issues
code-to-tree is an MCP (Model Context Protocol) server that enables large language models to accurately convert source code into abstract syntax trees (AST) across multiple programming languages. It provides a standalone executable that integrates with MCP clients, ensuring seamless parsing using the tree-sitter framework. The server supports languages including C, C++, Rust, Ruby, Go, Java, and Python, with minimal dependencies required. Its design focuses on ease of setup and integration in AI workflows requiring code analysis capabilities.

Key Features

Converts source code to abstract syntax trees (AST)
Implements Model Context Protocol (MCP) server
Stand-alone binary with minimal dependencies
Supports multiple programming languages (C, C++, Rust, Ruby, Go, Java, Python)
Integrates with MCP clients like Claude
Leverages tree-sitter for robust parsing
Cross-platform support (Windows, macOS)
Easy configuration for popular AI model clients
Includes sample configurations and screenshots
Designed for high accuracy and versatility

Use Cases

Automated code analysis for large language models
Facilitating context-aware code understanding in AI systems
Providing AST conversion services to AI applications
Streamlining code-to-AST transformations during language model inference
Assisting in code summarization and refactoring tasks
Supporting educational tools in parsing and understanding code structure
Aiding static analysis tools requiring ASTs as input
Enhancing code review workflows powered by AI
Improving explainability of code for AI-driven platforms
Enabling research on language-agnostic code representation

README

Table of Contents

MCP Server: code-to-tree

The code-to-tree server's goals are:

  1. Give LLMs the capability of accurately converting source code into AST(Abstract Syntax Tree), regardless of language.
  2. One standalone binary should be everything the MCP client needs.

These goals imply:

  1. The underlying syntax parser should be versatile enough. Here we choose tree-sitter, and languages are: C, C++, Rust, Ruby, Go, Java, Python.
  2. The server should be able to carry all capabilities within itself, imposing minimum software dependencies on the end user's machine. Here we choose mcpc.

Screenshots:

The above screenshots are obtained by asking the question specified in q.md.

(IMPORTANT NOTE: LLMs have no responsibility of generating the identical result for the same question, you will likely get a completely different style or content. The screenshots or questions provided here are just for the reference)

Using code-to-tree

Before everthing, you need to have the code-to-tree executable on your machine (code-to-tree.exe for Windows, code-to-tree for macOS), you can download at GitHub release page or build it yourself. Once downloaded, you configure your MCP clients to install it, check the section "Configure MCP Clients" for more details.

Configure MCP Clients

Here we use Claude as the example.

Windows

In your Claude configuration (C:\Users\YOUR_NAME\AppData\Roaming\Claude\claude_desktop_config.json), specify the location of code-to-tree.exe:

{
    "mcpServers": {
	    "code-to-tree": { "command": "C:\\path\\to\\code-to-tree.exe" }
    }
}

macOS

In your Claude configuration, (~/Library/Application Support/Claude/claude_desktop_config.json) specify the location of code-to-tree

{
    "mcpServers": {
	    "code-to-tree": { "command": "/path/to/code-to-tree" }
    }
}

Building (Windows)

1. Prepare environment

  1. download & install MSYS2.
  2. open application "MSYS2 MINGW64"
  3. run pacman -S make gcc git

2. Prepare tree-sitter libraries

Here we need to compile and install tree-sitter and all related grammars.

Clone them:

git clone https://github.com/tree-sitter/tree-sitter

git clone https://github.com/tree-sitter/tree-sitter-c

git clone https://github.com/tree-sitter/tree-sitter-cpp

git clone https://github.com/tree-sitter/tree-sitter-rust

git clone https://github.com/tree-sitter/tree-sitter-ruby

git clone https://github.com/tree-sitter/tree-sitter-go

git clone https://github.com/tree-sitter/tree-sitter-java

Compile and install them:

cd tree-sitter && OS=1 make install

cd tree-sitter-c && OS=1 make install

cd tree-sitter-cpp && OS=1 make install

cd tree-sitter-rust && OS=1 make install

cd tree-sitter-ruby && OS=1 make install

cd tree-sitter-go && OS=1 make install

cd tree-sitter-java && OS=1 make install

3. Build code-to-tree

Install mcpc:

git clone https://github.com/micl2e2/mcpc
cd mcpc && make install

Compile code-to-tree:

cd mcpc/example/code-to-tree

CFLAGS="-I/usr/local/include -L/usr/local/lib" make

# Check the binary
file code-to-tree.exe

# Remember the binary's location
pwd
# Assume the output is: /c/path/to/code-to-tree.exe

Building (macOS)

1. Prepare environment

  1. Xcode Command Line Tools

2. Prepare tree-sitter libraries

Here we need to compile and install tree-sitter and all related grammars.

Clone them:

git clone https://github.com/tree-sitter/tree-sitter

git clone https://github.com/tree-sitter/tree-sitter-c

git clone https://github.com/tree-sitter/tree-sitter-cpp

git clone https://github.com/tree-sitter/tree-sitter-rust

git clone https://github.com/tree-sitter/tree-sitter-ruby

git clone https://github.com/tree-sitter/tree-sitter-go

git clone https://github.com/tree-sitter/tree-sitter-java

Compile and install them:

cd tree-sitter && make install

cd tree-sitter-c && make install

cd tree-sitter-cpp && make install

cd tree-sitter-rust && make install

cd tree-sitter-ruby && make install

cd tree-sitter-go && make install

cd tree-sitter-java && make install

3. Build code-to-tree

Install mcpc:

git clone https://github.com/micl2e2/mcpc
cd mcpc && make install

Compile code-to-tree:

cd mcpc/example/code-to-tree

make

# Check the binary
file ./code-to-tree

# Remember the binary's location
pwd
# Assume the output is: /path/to/code-to-tree

Star History

Star History Chart

Repository Owner

micl2e2
micl2e2

User

Repository Details

Language C
Default Branch master
Size 580 KB
Contributors 1
License MIT License
MCP Verified Nov 11, 2025

Programming Languages

C
90.4%
Makefile
9.6%

Tags

Topics

abstract-syntax-tree agentic ast claude dependency-free llm mcp mcp-server mcp-tools no-runtime-dependencies runtime-free syntax-analysis syntax-tree tree-sitter

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • MCP Language Server

    MCP Language Server

    Bridge codebase navigation tools to AI models using MCP-enabled language servers.

    MCP Language Server implements the Model Context Protocol, allowing MCP-enabled clients, such as LLMs, to interact with language servers for codebase navigation. It exposes standard language server features—like go to definition, references, rename, and diagnostics—over MCP for seamless integration with AI tooling. The server supports multiple languages by serving as a proxy to underlying language servers, including gopls, rust-analyzer, and pyright.

    • 1,256
    • MCP
    • isaacphi/mcp-language-server
  • Code Assistant

    Code Assistant

    AI coding assistant with multi-modal tool execution and MCP integration

    Code Assistant is an AI-powered coding assistant written in Rust that provides both command-line and graphical user interfaces for autonomous code analysis and modification. It supports multi-modal tool invocation, real-time streaming, and session-based project management. The tool features full Model Context Protocol (MCP) compatibility, enabling seamless integration with MCP clients, and offers advanced project-level configuration and formatting capabilities.

    • 110
    • MCP
    • stippi/code-assistant
  • codelogic-mcp-server

    codelogic-mcp-server

    Leverage CodeLogic’s dependency data for AI-powered impact analysis.

    Codelogic-mcp-server implements an MCP (Model Context Protocol) server, enabling integration of CodeLogic's software dependency data into AI programming assistants. It provides tools for code and database impact assessments by interacting with a CodeLogic server, enhancing context-aware code and database analysis. The server supports integration with popular IDEs, including VS Code and Claude Desktop, using Astral UV/UVX for communication. This solution is designed to bring actionable dependency insights to AI coding workflows.

    • 31
    • MCP
    • CodeLogicIncEngineering/codelogic-mcp-server
  • MCP Claude Code

    MCP Claude Code

    Claude Code-like functionality via the Model Context Protocol.

    Implements a server utilizing the Model Context Protocol to enable Claude Code functionality, allowing AI agents to perform advanced codebase analysis, modification, and command execution. Supports code understanding, file management, and integration with various LLM providers. Offers specialized tools for searching, editing, and delegating tasks, with robust support for Jupyter notebooks. Designed for seamless collaboration with MCP clients including Claude Desktop.

    • 281
    • MCP
    • SDGLBL/mcp-claude-code
  • Lucidity MCP

    Lucidity MCP

    Intelligent prompt-based code quality analysis for AI coding assistants.

    Lucidity MCP is a Model Context Protocol (MCP) server that empowers AI coding assistants to deliver high-quality code through intelligent, prompt-driven analysis. It offers comprehensive detection of code issues across multiple quality dimensions, providing structured and actionable feedback. With language-agnostic capabilities, extensible framework, and flexible transport options, Lucidity MCP seamlessly integrates into developer workflows and AI systems.

    • 72
    • MCP
    • hyperb1iss/lucidity-mcp
  • MCP Server for Cortex

    MCP Server for Cortex

    Bridge Cortex threat analysis capabilities to MCP-compatible clients like Claude.

    MCP Server for Cortex exposes the analysis capabilities of a Cortex instance as tools consumable by Model Context Protocol (MCP) clients, such as large language models. It enables these clients to request threat intelligence analyses via Cortex and receive structured results. The server supports easy configuration, secure authentication, and flexible analyzer selection for integrating threat intelligence tasks into automated AI workflows.

    • 12
    • MCP
    • gbrigandi/mcp-server-cortex
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results