
A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

An experimental MCP server that gives AI assistants structural code search and rule testing capabilities powered by ast-grep's AST pattern matching.
ast-grep MCP Server is cataloged as an MCP server attributed to ast-grep. An experimental MCP server that gives AI assistants structural code search and rule testing capabilities powered by ast-grep's AST pattern matching. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.
Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.
Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.
Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
Email delivery is not connected. This page does not collect email addresses or create subscriptions.
Browse the registry for current listings instead.
Reviews for ast-grep MCP Server are not available yet
Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.
It supports many languages through ast-grep, including JavaScript/TypeScript, Python, Rust, Go, Java, C/C++ and C#, with custom languages addable via sgconfig.yaml.
Yes, a custom sgconfig.yaml can be supplied via a --config command-line argument or the AST_GREP_CONFIG environment variable.
README.md · 51d5a23f025c · Fetched 2026-11-13 09:37:26 UTC
Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.
Showing the last retrieved documentation snapshot; check the source for current changes.
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:
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
uvxYou can run the server directly from GitHub using uvx:
uvx --from git+https://github.com/ast-grep/ast-grep-mcp ast-grep-server
This is useful for quickly trying out the server without cloning the repository.
Add to your MCP settings (usually in .cursor-mcp/settings.json):
{
"mcpServers": {
"ast-grep": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/ast-grep-mcp", "run", "main.py"],
"env": {}
}
}
}
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"ast-grep": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/ast-grep-mcp", "run", "main.py"],
"env": {}
}
}
}
The MCP server supports using a custom sgconfig.yaml file to configure ast-grep behavior.
See the ast-grep configuration documentation for details on the config file format.
You can provide the config file in two ways (in order of precedence):
--config /path/to/sgconfig.yamlAST_GREP_CONFIG=/path/to/sgconfig.yamlIf ast-grep is not in PATH, or must be launched through another command, set
AST_GREP_PATH. The value can be an executable path or a command prefix:
{
"mcpServers": {
"ast-grep": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/ast-grep-mcp", "run", "main.py"],
"env": {
"AST_GREP_PATH": "uv run ast-grep"
}
}
}
}
Other examples:
AST_GREP_PATH="/custom/path/to/ast-grep"AST_GREP_PATH="npx ast-grep"AST_GREP_PATH='"/path containing spaces/ast-grep"'If unset, the command defaults to ast-grep.
This repository includes comprehensive ast-grep rule documentation in ast-grep.mdc. The documentation covers all aspects of writing effective ast-grep rules, from simple patterns to complex multi-condition searches.
You can add it to your cursor rule or Claude.md, and attach it when you need AI agent to create ast-grep rule for you.
The prompt will ask LLM to use MCP to create, verify and improve the rule it creates.
The server provides four main tools for code analysis:
dump_syntax_treeVisualize the Abstract Syntax Tree structure of code snippets. Essential for understanding how to write effective search patterns.
Use cases:
test_match_code_ruleTest ast-grep YAML rules against code snippets before applying them to larger codebases.
Use cases:
find_codeSearch codebases using simple ast-grep patterns for straightforward structural matches.
Parameters:
max_results: Limit number of complete matches returned (default: unlimited)output_format: Choose between "text" (default, ~75% fewer tokens) or "json" (full metadata)Text Output Format:
Found 2 matches:
path/to/file.py:10-15
def example_function():
# function body
return result
path/to/file.py:20-22
def another_function():
pass
Use cases:
find_code_by_ruleAdvanced codebase search using complex YAML rules that can express sophisticated matching criteria.
Parameters:
max_results: Limit number of complete matches returned (default: unlimited)output_format: Choose between "text" (default, ~75% fewer tokens) or "json" (full metadata)Use cases:
Use Query:
Find all console.log statements
AI will generate rules like:
id: find-console-logs
language: javascript
rule:
pattern: console.log($$$)
User Query:
Find async functions that use await
AI will generate rules like:
id: async-with-await
language: javascript
rule:
all:
- kind: function_declaration
- has:
pattern: async
- has:
pattern: await $EXPR
stopBy: end
ast-grep supports many programming languages including:
For a complete list of built-in supported languages, see the ast-grep language support documentation.
You can also add support for custom languages through the sgconfig.yaml configuration file. See the custom language guide for details.
stopBy: end to relational rulesdump_syntax_tree to understand the AST structureThis is an experimental project. Issues and pull requests are welcome!
Claim this server with your GitHub account to request manual ownership verification.
Link to the catalog listing for ast-grep MCP Server from your README. This badge does not certify ownership, compatibility or security.
[](https://awesome-mcp.com/servers/ast-grep-mcp)Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.
Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.
No reviewed package or image identity; download statistics are not listed yet.
Alternative and complementary servers in the same category

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.