An experimental Model Context Protocol (MCP) server that provides AI assistants with powerful structural code search capabilities using ast-grep.
This MCP server enables AI assistants (like Cursor, Claude Desktop, etc.) to search and analyze codebases using Abstract Syntax Tree (AST) pattern matching rather than simple text-based search. By leveraging ast-grep's structural search capabilities, AI can:
- Find code patterns based on syntax structure, not just text matching
- Search for specific programming constructs (functions, classes, imports, etc.)
- Write and test complex search rules using YAML configuration
- Debug and visualize AST structures for better pattern development
-
Install ast-grep: Follow ast-grep installation guide
# macOS brew install ast-grep nix-shell -p ast-grep cargo install ast-grep --locked -
Install uv: Python package manager
curl -LsSf https://astral.sh/uv/install.sh | sh -
MCP-compatible client: Such as Cursor, Claude Desktop, or other MCP clients
-
Clone this repository:
git clone https://github.com/ast-grep/ast-grep-mcp.git cd ast-grep-mcp -
Install dependencies:
uv sync
-
Verify ast-grep installation:
ast-grep --version
You can run the server directly from GitHub using uvx:
uvx --from git+https://github.com/ast-grep/ast-grep-mcp ast-grep-serverThis is useful for quickly trying out the server without cloning the repository.