Using GAC as an MCP Server

May 17, 2026 · View on GitHub

English | 简体中文 | 繁體中文 | 日本語 | 한국어 | हिन्दी | Tiếng Việt | Français | Русский | Español | Português | Norsk | Svenska | Deutsch | Nederlands | Italiano

GAC can run as a Model Context Protocol (MCP) server, allowing AI agents and editors to generate commits through structured tool calls instead of shell commands.

Table of Contents

What is MCP?

The Model Context Protocol is an open standard that lets AI applications call external tools through a structured interface. By running GAC as an MCP server, any MCP-compatible client can inspect repository state and create AI-powered commits without invoking shell commands directly.

Benefits

  • Structured interaction: Agents call typed tools with validated parameters instead of parsing shell output
  • Two-tool workflow: gac_status to inspect, gac_commit to act — a natural fit for agent reasoning
  • Full GAC capabilities: AI commit messages, grouped commits, secret scanning, and push — all available through MCP
  • Zero configuration: The server uses your existing GAC configuration (~/.gac.env, provider settings, etc.)

Setup

The MCP server is started with uvx gac serve and communicates over stdio, the standard MCP transport.

Claude Code

Add to your project's .mcp.json or global ~/.claude/claude_code_config.json:

{
  "mcpServers": {
    "gac": {
      "command": "uvx",
      "args": ["gac", "serve"]
    }
  }
}

Or if you have GAC installed globally:

{
  "mcpServers": {
    "gac": {
      "command": "gac",
      "args": ["serve"]
    }
  }
}

Cursor

Add to your Cursor MCP settings (.cursor/mcp.json):

{
  "mcpServers": {
    "gac": {
      "command": "uvx",
      "args": ["gac", "serve"]
    }
  }
}

Other MCP Clients

Any MCP-compatible client can use GAC. The server entry point is:

command: uvx
args: ["gac", "serve"]
transport: stdio

Available Tools

The server exposes two tools:

gac_status

Inspect the repository state. Use this before committing to understand what will be committed.

Parameters:

ParameterTypeDefaultDescription
format"summary" | "detailed" | "json""summary"Output format
include_diffboolfalseInclude full diff content
include_statsbooltrueInclude line change statistics
include_historyint0Number of recent commits to include
staged_onlyboolfalseOnly show staged changes
include_untrackedbooltrueInclude untracked files
max_diff_linesint500Cap diff output size (0 = unlimited)

Returns: Branch name, file status (staged/unstaged/untracked/conflicts), optional diff content, optional statistics, and optional commit history.

gac_commit

Generate an AI-powered commit message and optionally execute the commit.

Parameters:

ParameterTypeDefaultDescription
stage_allboolfalseStage all changes before committing (git add -A)
fileslist[str][]Specific files to stage
dry_runboolfalsePreview without executing
message_onlyboolfalseGenerate message without committing
pushboolfalsePush to remote after commit
groupboolfalseSplit changes into multiple logical commits
one_linerboolfalseSingle-line commit message
scopestring | nullnullConventional commit scope (auto-detected if not provided)
hintstring""Additional context for better messages
modelstring | nullnullOverride AI model (provider:model_name)
languagestring | nullnullOverride commit message language
skip_secret_scanboolfalseSkip security scan
no_verifyboolfalseSkip pre-commit hooks
auto_confirmboolfalseSkip confirmation prompts (required for agents)

Returns: Success status, generated commit message, commit hash (if committed), list of changed files, and any warnings.

Workflows

Basic Commit

1. gac_status()                              → See what's changed
2. gac_commit(stage_all=true, auto_confirm=true)  → Stage, generate message, and commit

Preview Before Committing

1. gac_status(include_diff=true, include_stats=true)  → Review changes in detail
2. gac_commit(stage_all=true, dry_run=true)            → Preview the commit message
3. gac_commit(stage_all=true, auto_confirm=true)       → Execute the commit

Grouped Commits

1. gac_status()                                           → See all changes
2. gac_commit(stage_all=true, group=true, dry_run=true)   → Preview logical groupings
3. gac_commit(stage_all=true, group=true, auto_confirm=true)  → Execute grouped commits

Commit with Context

1. gac_status(include_history=5)  → See recent commits for style reference
2. gac_commit(
     stage_all=true,
     hint="Fixes login timeout bug from issue #42",
     scope="auth",
     auto_confirm=true
   )

Configuration

The MCP server uses your existing GAC configuration. No additional setup is needed beyond:

  1. Provider and model: Run uvx gac init or uvx gac model to configure your AI provider
  2. API keys: Stored in ~/.gac.env (set up during uvx gac init)
  3. Optional settings: All GAC environment variables apply (GAC_LANGUAGE, GAC_VERBOSE, etc.)

See the main documentation for all configuration options.

Troubleshooting

"No model configured"

Run uvx gac init to set up your AI provider and model before using the MCP server.

"No staged changes found"

Either stage files manually (git add) or use stage_all=true in the gac_commit call.

Server not starting

Verify GAC is installed and accessible:

uvx gac --version

If using uvx, ensure uv is installed and on your PATH.

Agent can't find the server

Make sure the MCP configuration file is in the correct location for your client and that the command path is accessible from your shell environment.

Rich output corruption

The MCP server automatically redirects all Rich console output to stderr to prevent stdio protocol corruption. If you see garbled output, ensure you're running uvx gac serve (not uvx gac directly) when using MCP.

See Also