ast-grep-mcp

MCP.Pizza Chef: ast-grep

ast-grep-mcp is an experimental MCP server that integrates the ast-grep CLI tool to enable structured codebase searching and analysis within the MCP ecosystem. It requires installation of ast-grep and uv, and works best with MCP clients like Cursor. This server allows users to query and explore code repositories programmatically, enhancing code navigation and understanding through AST-based pattern matching.

Use This MCP server To

Search codebase using AST pattern matching Integrate code search into MCP client workflows Automate code analysis with structured queries Enable real-time code exploration in IDEs Support multi-language codebase querying Combine code search results with LLM reasoning

README

ast-grep MCP

This is an experimental MCP implementation using ast-grep CLI.

Prerequisite

  1. Installing ast-grep and uv
  2. Installing MCP client, preferably Cursor
  3. Clone this repo, install via uv
  4. Configure MCP json
{
    "mcpServers": {
      "server-name": {
        "command": "uv",
        "args": ["--directory", "/path/to/repo", "run", "main.py"],
        "env": {}
      }
    }
  }
  1. Ask cursor ai to search your codebase!

ast-grep-mcp FAQ

How do I install ast-grep-mcp?
Install ast-grep CLI and uv, clone the ast-grep-mcp repo, then configure MCP JSON to run the server.
Which MCP clients work best with ast-grep-mcp?
Cursor is recommended, but other MCP clients supporting server integration can be used.
What is the role of uv in ast-grep-mcp?
uv acts as the runtime environment to execute the MCP server commands and manage process lifecycle.
Can ast-grep-mcp handle multiple programming languages?
Yes, ast-grep supports multiple languages via AST pattern matching, enabling versatile codebase queries.
How does ast-grep-mcp improve codebase searching?
It uses AST-based pattern matching for precise, structured code queries beyond simple text search.
Is ast-grep-mcp compatible with different LLM providers?
Yes, it is provider-agnostic and can be used with OpenAI, Claude, Gemini, and others.
What are the prerequisites for running ast-grep-mcp?
You need to install ast-grep CLI, uv runtime, and have an MCP client configured to connect to the server.