Favicon of ast-grep MCP

ast-grep MCP

A local MCP server that gives Cursor, Claude Desktop and other AI clients structural code search through ast-grep. Open source under MIT.

ast-grep MCP is a locally run server that lets AI coding assistants search code by its syntax structure. It connects ast-grep to Cursor, Claude Desktop and other clients that support the Model Context Protocol (MCP). It's for developers who need an assistant to find specific code constructs when matching words alone is too broad.

An assistant can look for function calls, declarations, classes or imports, then narrow a search to relationships within the code. For example, it can find async functions containing an await expression, or code nested inside a particular construct. Simple patterns cover straightforward searches; YAML rules express more detailed conditions, including what a match contains and what comes before or after it.

The server also lets assistants test rules against code snippets before searching a whole codebase. Its syntax-tree inspection tool exposes how the parser sees a snippet, which helps diagnose patterns that miss their intended matches. Search results can include readable code with file locations or JSON with fuller metadata.

The Python server uses a local ast-grep installation for code analysis and requires an MCP-compatible client. It provides search tools rather than an AI model of its own. The project is open source under the MIT license. Language support comes from ast-grep and includes JavaScript, TypeScript, Python, Rust, Go, Java, C/C++ and C#. Custom ast-grep configuration can add language support.

The maintainers describe this MCP server as experimental.

Similar to ast-grep MCP