A modular MCP server providing structural code search, Schema.org tools, and code quality analysis through 47 tools organized across 9 feature categories.

Overview

ast-grep-mcp is a Model Context Protocol (MCP) server that leverages ast-grep for structural code search and provides comprehensive tools for:

  • Code Search - AST-based pattern matching across 9 search tools
  • Refactoring - Automated code rewrite and transformation
  • Schema.org - Knowledge graph generation and validation
  • Code Quality - Complexity analysis and quality metrics
  • Documentation - Automatic doc generation from code

Installation

# Clone and install
cd ast-grep-mcp
uv sync

# Run tests
uv run pytest

# Start MCP server
uv run main.py

Tool Categories

CategoryToolsDescription
Search9Structural code search with AST patterns
Rewrite3Code transformation and refactoring
Refactoring2Automated refactoring operations
Deduplication4Code duplication detection
Schema.org9Knowledge graph and entity tools
Complexity3Cyclomatic and cognitive complexity
Quality7Code quality metrics and analysis
Documentation5Documentation generation
Cross-Language5Multi-language support tools

Architecture

src/ast_grep_mcp/
├── core/           # Config, cache, executor, logging
├── models/         # Data models
├── utils/          # Templates, formatters, validation
├── features/       # Feature modules (search, rewrite, etc.)
└── server/         # MCP server registry