AstGrep
structural code search as an MCP tool — find patterns not strings
npx -y github:Isco0819/ast-grep-mcpEver run into this?
Like ast-grep (sg) which has 7k+ GitHub stars and real traction, but no MCP integration exists. AI agents doing code review rely on text grep and miss structural patterns — async without try-catch, hooks with missing deps, API routes without auth checks. Text search is blind to code semantics.
The fix
MCP server wrapping the ast-grep CLI. Agents call ast_search(lang, pattern, dir) and get structured matches with file, line, and snippet. Zero latency, no AI API needed — pure local structural analysis.
What it does
- ast_search(lang, pattern, dir) returns JSON array of {file, line, match, snippet} for any tree-sitter language
- Pre-baked preset library: async-no-catch, hooks-missing-deps, route-no-auth, sql-no-param — one call surfaces anti-patterns instantly
- Auto-installs @ast-grep/napi if sg binary not found in PATH — zero-friction npx cold start