Favicon of ast-grep MCP

ast-grep MCP

A local MCP server gives AI coding assistants structural code search through ast-grep and connects to Cursor, Claude Desktop and other MCP clients.

ast-grep MCP lets AI coding assistants find code by syntax structure. It's for developers who need searches for specific constructs or relationships that text matching alone can't express.

  • Structural search: Assistants can locate function calls, declarations, classes and imports using ast-grep patterns.
  • Detailed search rules: YAML rules can match nested code and relationships, such as functions containing an await expression or code inside another construct.
  • Rule testing: Assistants can check a rule against a code snippet before applying it across a codebase.
  • Syntax inspection: A syntax-tree view helps explain why a search pattern misses its intended match.

The server runs locally and requires ast-grep plus an MCP-compatible client, such as Cursor or Claude Desktop. It supplies code analysis tools to the client rather than a model of its own. Results can include readable matches or JSON with fuller metadata.

Language support comes from ast-grep and includes JavaScript, TypeScript, Python, Rust, Go, Java, C/C++ and C#. Custom ast-grep configuration can add languages. The Python project is open source under the MIT license.

Similar to ast-grep MCP