AST MCP Server

by angrysky56

35 453 downloads Not rated yet MIT

About

By transforming source code into a queryable Semantic Graph and a structured AST, this tool bridges the gap between "reading text" and "understanding structure." For an AI assistant, it provides the "spatial" awareness needed to navigate deep dependencies without getting lost in

Details

License
MIT

Explore

- Parse code into Abstract Syntax Trees (AST)
- Generate Abstract Semantic Graphs (ASG) from code
- Analyze code structure and complexity
- Support for multiple programming languages (Python, JavaScript, TypeScript, Go, Rust, C/C++, Java)
- Compatible with Claude Desktop and other MCP clients
- Incremental parsing for faster processing of large files
- Enhanced scope handling and more complete semantic analysis
- AST diffing to identify changes between code versions
- Resource caching for improved performance

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name AST MCP Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Python 3.9 or higher
- uv package manager (recommended) or pip

uv sync

uv sync --extra dev # Development tools
uv sync --extra testing # Testing dependencies
uv sync --extra docs # Documentation tools


3. Build the tree-sitter parsers:

bash
uv run build-parsers

python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate

pip install -e .

1. Configure Claude Desktop to use the server by editing your configuration file:

Location of config file:
- macOS: ~/Library/Application Support/claude-desktop/claude_desktop_config.json
- Linux: ~/.config/claude-desktop/claude_desktop_config.json
- Windows: %APPDATA%\claude-desktop\claude_desktop_config.json

2. Add the AST MCP server configuration:

json
{
"mcpServers": {
"AstAnalyzer": {
"command": "uv",
"args": [
"--directory",
"/home/ty/Repositories/ai_workspace/ast-mcp-server/ast_mcp_server",
"run",
"server.py"
]
}
}
}

Important: Replace /absolute/path/to/ast-mcp-server with the actual absolute path on your system.

3. Restart Claude Desktop to load the new MCP server.

4. In Claude Desktop, you can now use the AST-based code analysis tools by referencing code files or pasting code snippets.

Antigravity Self-Scan Example

bash

uv sync --extra dev

uv run pre-commit install


To run the server in development mode with the MCP inspector:

bash

- pyproject.toml: Project metadata, dependencies, and tool configuration
- claude_desktop_config.json: Example Claude Desktop configuration
- dev_server.sh: Development server script
- .gitignore: Git ignore rules

The server provides the following tools for code analysis:

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "ast mcp server": {
            "ast-mcp-server": {
                "command": "uv",
                "args": [
                    "sync"
                ]
            }
        }
    }
}

McpServers

{
    "ast-mcp-server": {
        "command": "uv",
        "args": [
            "sync"
        ]
    }
}

An MCP (Model Context Protocol) server that provides code structure and semantic analysis capabilities through Abstract Syntax Trees (AST) and Abstract Semantic Graphs (ASG).

Features

- Parse code into Abstract Syntax Trees (AST)
- Generate Abstract Semantic Graphs (ASG) from code
- Analyze code structure and complexity
- Support for multiple programming languages (Python, JavaScript, TypeScript, Go, Rust, C/C++, Java)
- Compatible with Claude Desktop and other MCP clients
- Incremental parsing for faster processing of large files
- Enhanced scope handling and more complete semantic analysis
- AST diffing to identify changes between code versions
- Resource caching for improved performance

Installation

Prerequisites

- Python 3.9 or higher
- uv package manager (recommended) or pip

Using uv (Recommended)

1. Clone this repository:

git clone https://github.com/angrysky56/ast-mcp-server.git
cd ast-mcp-server

2. Install the project and dependencies:

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.

Videos about AST MCP Server

Relevant YouTube tutorials, setups, and demos