MCP.so
ログイン

Ast Grep MCP Server

@ast-grep

基本情報

カテゴリ

その他

ライセンス

MIT

トランスポート

stdio

作者

ast-grep

投稿者

Herrington Darkholme (えっちチャン)

Ast Grep MCP Server について

概要はまだありません

Ast Grep MCP Server の設定

以下の設定を使って、このサーバーを MCP 対応クライアントに追加してください。

{
  "mcpServers": {
    "ast-grep": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/repo",
        "run",
        "main.py"
      ],
      "env": {}
    }
  }
}

Ast Grep MCP Server のツール

ツール一覧はまだありません

この掲載には表示できるツール一覧がまだありません。サーバーにツールがないという意味ではありません。対応機能はプロジェクトのドキュメントをご確認ください。

ツールは README から自動的に抽出されます。メンテナーは ## Tools という見出しの下に記載することで、このタブに反映できます。

概要

What is Ast Grep?

Ast Grep is an experimental Model Context Protocol (MCP) server that gives AI assistants structural code search capabilities using ast-grep, an Abstract Syntax Tree (AST) pattern matching tool. It is designed for developers using MCP‑compatible clients like Cursor or Claude Desktop to analyze codebases by syntax structure rather than plain text.

How to use Ast Grep?

Install ast‑grep and uv, clone the repository, run uv sync, then configure your MCP client (Cursor or Claude Desktop) to run main.py with uv. Alternatively, run directly via uvx without cloning: uvx --from git+https://github.com/ast-grep/ast-grep-mcp ast-grep-server. Optionally set a custom ast‑grep config file using --config flag or AST_GREP_CONFIG environment variable.

Key features of Ast Grep

  • Visualize AST structure with dump_syntax_tree
  • Test YAML rules against code snippets with test_match_code_rule
  • Simple pattern search with find_code
  • Advanced rule‑based search with find_code_by_rule
  • Supports dozens of languages including JavaScript, Python, Rust, Go, Java, C/C++, C#
  • Configurable via custom sgconfig.yaml for rule behavior and custom languages

Use cases of Ast Grep

  • Debug why an ast‑grep pattern isn't matching by inspecting the AST
  • Validate and iterate on search rules before applying them to a full codebase
  • Find all instances of a specific function call or variable declaration
  • Search for complex nested code structures using relational constraints like inside, has, precedes, follows
  • Develop and test multi‑condition YAML rules interactively with an AI assistant

よくある質問

1

What are the prerequisites to use Ast Grep?

You need ast‑grep installed (via brew, nix, or cargo), uv (Python package manager), and an MCP‑compatible client like Cursor or Claude Desktop.

2

How can I run Ast Grep without cloning the repository?

Use `uvx` directly: `uvx --from git+https://github.com/ast-grep/ast-grep-mcp ast-grep-server`.

3

What languages does Ast Grep support?

Ast Grep supports many programming languages including JavaScript/TypeScript, Python, Rust, Go, Java, C/C++, C#, and more. Custom languages can be added via `sgconfig.yaml`.

4

How do I configure custom ast‑grep settings?

Provide a `sgconfig.yaml` file either via the `--config` command‑line argument or the `AST_GREP_CONFIG` environment variable.

5

What should I do if no matches are found?

Make sure ast‑grep is installed and in your PATH. For relational rules, try adding `stopBy: end`. Use `dump_syntax_tree` to understand the AST structure of your target code.

コメント

「その他」の他のコンテンツ