
AST
Ast Grep MCP enables AI assistants to perform structural code search and analysis using Abstract Syntax Tree pattern matching through the ast-grep tool, allowing syntax-based pattern discovery rather than simple text matching. The server provides tools for finding specific programming constructs (functions, classes, imports), writing complex YAML search rules, and debugging AST structures for pattern development. It integrates with MCP-compatible clients like Cursor and Claude Desktop to give AI assistants powerful codebase analysis capabilities beyond traditional text search.
- GitHub stars
- 403
- tools
- 4
- last updated
- Dec 15, 2025
Tools
4 toolsPublic tool metadata for what this MCP can expose to an agent.
dump_syntax_treeVisualize the Abstract Syntax Tree structure of code snippets. Essential for understanding how to write effective search patterns.
Visualize the Abstract Syntax Tree structure of code snippets. Essential for understanding how to write effective search patterns.
No parameter schema in public metadata yet.
test_match_code_ruleTest ast-grep YAML rules against code snippets before applying them to larger codebases.
Test ast-grep YAML rules against code snippets before applying them to larger codebases.
No parameter schema in public metadata yet.
find_codeSearch codebases using simple ast-grep patterns for straightforward structural matches.
Search codebases using simple ast-grep patterns for straightforward structural matches.
No parameter schema in public metadata yet.
find_code_by_ruleAdvanced codebase search using complex YAML rules that can express sophisticated matching criteria.
Advanced codebase search using complex YAML rules that can express sophisticated matching criteria.
No parameter schema in public metadata yet.
Sponsors
Readme
ast-grep MCP Server
An experimental Model Context Protocol (MCP) server that provides AI assistants with powerful structural code search capabilities using ast-grep.
Overview
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
Prerequisites
-
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
Details
- Repository
- github.com/ast-grep/ast-grep-mcp
- Category
- Search & Web Crawling