Skip to content

Add AST_GREP_PATH environment variable for custom ast-grep command paths#27

Open
Copilot wants to merge 2 commits intomainfrom
copilot/make-ast-grep-path-configurable
Open

Add AST_GREP_PATH environment variable for custom ast-grep command paths#27
Copilot wants to merge 2 commits intomainfrom
copilot/make-ast-grep-path-configurable

Conversation

Copy link

Copilot AI commented Jan 3, 2026

Users installing ast-grep via package managers (e.g., uv add ast-grep-cli) cannot use the MCP server since ast-grep isn't in PATH and must be invoked via wrapper commands like uv run ast-grep.

Changes

Core implementation:

  • Added AST_GREP_PATH environment variable to configure the ast-grep command
  • Enhanced run_command() to split space-separated commands into proper argument lists
  • Defaults to ast-grep when unset for backward compatibility

Documentation:

  • Added configuration examples in README for common use cases (uv, custom paths, npx)
  • Updated CLI help text to document the environment variable

Tests:

  • Added unit tests covering custom command paths with and without config files

Usage

Configure MCP clients to use ast-grep via uv:

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

Other examples:

  • AST_GREP_PATH="/custom/path/to/ast-grep" for custom installations
  • AST_GREP_PATH="npx ast-grep" for npm-based workflows

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • astral.sh
    • Triggering command: /usr/bin/curl curl -LsSf REDACTED (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Make ast-grep path configurable</issue_title>
<issue_description>Feature request

I installed ast-grep inside my python/uv project using uv add ast-grep-cli.

So ast-grep is not really in my PATH, but it could be started with uv run ast-grep.

Currently ast-grep-mcp merely assumes the ast-grep command can be found in PATH, and there is no way to tell it to execute uv run ast-grep instead.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Jan 3, 2026
Copilot AI changed the title [WIP] Make ast-grep path configurable in ast-grep-mcp Add AST_GREP_PATH environment variable for custom ast-grep command paths Jan 3, 2026
@HerringtonDarkholme HerringtonDarkholme marked this pull request as ready for review January 3, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make ast-grep path configurable

2 participants