ast-grep avatar

AST

ast-grep/ast-grep-mcp

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 tools

Public 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

  1. Install ast-grep: Follow ast-grep installation guide

    # macOS
    brew install ast-grep
    nix-shell -p ast-grep
    cargo install ast-grep --locked
    
  2. Install uv: Python package manager

    curl -LsSf https://astral.sh/uv/install.sh | sh
    

View the full README on GitHub

Details

Repository
github.com/ast-grep/ast-grep-mcp
Category
Search & Web Crawling

Related Search & Web Crawling MCP servers

View all
1k-dense-ai avatarClaude Skillsk-dense-ai/claude-skills-mcpMCP server for searching and retrieving Claude Agent Skills using vector search384stars
2kagisearch avatarKagikagisearch/kagimcpThe Official Model Context Protocol (MCP) server for Kagi search & other tools.384stars
3mapbox avatarMcp Servermapbox/mcp-serverGeospatial intelligence with Mapbox APIs like geocoding, POI search, directions, isochrones, etc.0stars
4andrea9293 avatarMcp Documentation Serverandrea9293/mcp-documentation-serverLocal-first document management and semantic search for AI coding agents344stars
5jackkuo666 avatarGoogle Scholarjackkuo666/google-scholar-mcp-serverA MCP Server for Google Scholar: 🔍 Enable AI assistants to search and access Google Scholar papers through a simple MCP interface.325stars
6jordanburke avatarReddit Mcp Serverjordanburke/reddit-mcp-serverReddit MCP server with full read/write - posts, comments, search, and content creation.320stars