Skip to content

feat(mcp): add MCP server with status, commit, and group workflow support#70

Merged
thomwebb merged 5 commits intothomwebb:mainfrom
rinadelph:main
Mar 10, 2026
Merged

feat(mcp): add MCP server with status, commit, and group workflow support#70
thomwebb merged 5 commits intothomwebb:mainfrom
rinadelph:main

Conversation

@rinadelph
Copy link
Copy Markdown
Contributor

@rinadelph rinadelph commented Mar 10, 2026

Exposes GAC's commit generation capabilities via the Model Context Protocol using FastMCP.

Tools

gac_status — repository inspection

  • format: summary / detailed / json
  • include_diff, include_stats, include_history, max_diff_lines
  • Returns a summary string with structured sections ready for agent consumption

gac_commit — AI commit generation

  • Single-commit mode (default)
  • Group mode (group=True) — splits staged changes into logical commits via GroupedCommitWorkflow; returns grouped_commits list with scope, files, suggested_message per group
  • message_only / dry_run for previewing without committing
  • stage_all, push, no_verify, hint, one_liner, language, scope all supported

Invocation

Adds a serve subcommand to the main CLI — no separate binary needed:

gac serve
uvx gac serve

MCP client config:

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

Rich console output is redirected to stderr during commit execution to prevent stdout corruption of the JSON-RPC stdio channel.

Summary by CodeRabbit

  • New Features

    • Added MCP support with new tools to view repository status and generate/execute commits (gac-mcp).
    • Exposed a CLI command to run the MCP server.
    • Added a convenient executable wrapper to launch the gac-mcp command.
  • Chores

    • Added MCP runtime dependency to the project.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 10, 2026

Warning

Rate limit exceeded

@rinadelph has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 39 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3b8eb8b6-e55c-4352-8305-9d997f616f01

📥 Commits

Reviewing files that changed from the base of the PR and between 3b24595 and b517236.

⛔ Files ignored due to path filters (2)
  • .swarm/project_memory.db is excluded by !**/*.db
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • gac-mcp.sh
  • pyproject.toml
  • src/gac/cli.py
  • src/gac/mcp/__init__.py
  • src/gac/mcp/models.py
  • src/gac/mcp/server.py
📝 Walkthrough

Walkthrough

This change adds an MCP integration for GAC: Pydantic models, a FastMCP server exposing gac_status and gac_commit, a CLI serve command and entry point, a pyproject dependency for MCP, and a small shell wrapper script to run the MCP server.

Changes

Cohort / File(s) Summary
Shell wrapper
\gac-mcp.sh``
New executable script at repo root that cd's to /home/swarm/Clover/gac and delegates to uv run gac-mcp "$@".
Project configuration
\pyproject.toml``
Added runtime dependency mcp[cli]>=1.0.0 and registered CLI entry point gac-mcp -> gac.mcp.server:main. Review packaging and entry-point syntax.
Package init
\src/gac/mcp/init.py``
New package initializer re-exporting models and server symbols (CommitRequest, CommitResult, StatusRequest, StatusResult, mcp, main).
Data models
\src/gac/mcp/models.py``
New comprehensive Pydantic models for commit and status workflows (CommitRequest/CommitResult/GroupedCommit and StatusRequest/StatusResult plus DiffStats/FileStat/CommitInfo). Validate types and optional fields.
Server implementation
\src/gac/mcp/server.py``
New FastMCP server with gac_status and gac_commit tools, AI-driven commit message generation, grouped-commit flow, git state/diff handling, and helpers for diff stats/history. High-surface-area logic; review IO/console redirection, error handling, and git/AI interactions.
CLI integration
\src/gac/cli.py``
Added serve Click command that invokes gac.mcp.server.main, and registered it on the CLI. Verify command registration and invocation behavior.

Sequence Diagram

sequenceDiagram
    participant Client
    participant MCPServer as MCP Server
    participant Git as Git Operations
    participant AI as AI Model

    rect rgba(100,150,255,0.5)
    Note over Client,MCPServer: gac_status flow
    Client->>MCPServer: StatusRequest
    MCPServer->>Git: Inspect repo (branch, staged/unstaged/untracked, diffs)
    Git-->>MCPServer: Repo state, diffs
    MCPServer->>Git: Recent commits (optional)
    Git-->>MCPServer: Commit history
    MCPServer-->>Client: StatusResult
    end

    rect rgba(150,200,100,0.5)
    Note over Client,MCPServer: gac_commit flow
    Client->>MCPServer: CommitRequest
    MCPServer->>Git: Verify repo, collect staged/unstaged diffs
    Git-->>MCPServer: Diffs/state
    MCPServer->>AI: Generate commit messages / group suggestions
    AI-->>MCPServer: Messages / groupings
    alt Grouped commits
        MCPServer-->>Client: GroupedCommit suggestions
        MCPServer->>Git: Perform grouped commits (if not dry-run)
        Git-->>MCPServer: Commit hashes
    else Single commit
        MCPServer->>Git: Create commit (if not dry-run)
        Git-->>MCPServer: Commit hash
    end
    MCPServer-->>Client: CommitResult
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 A small hop, a clever trick,
MCP tools wrapped up so slick,
Status, commits, AI in play,
Models, server, ready to sway,
I nibble code and bound away. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and specifically describes the main addition: an MCP server with status and commit functionality, including group workflow support. It directly aligns with the substantial changes across multiple files introducing MCP server infrastructure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Add FastMCP server integration to expose GAC's git commit capabilities to AI agents through the Model Context Protocol. This enables AI agents to inspect repository state and generate/execute commits programmatically.

- Implement gac_status tool providing comprehensive repository inspection including branch info, staged/unstaged/untracked files, merge conflicts, optional diffs with statistics, and recent commit history
- Implement gac_commit tool for AI-powered commit message generation with support for staging changes, dry runs, message-only mode, automatic pushing, and various commit style options (one-liner, scope, language, hints)
- Define Pydantic models for all tool requests and responses enabling automatic schema generation for MCP protocol
- Add gac-mcp script entry point and bash wrapper for server execution
- Include detailed inline documentation with usage examples, workflow guidance, and parameter descriptions for agent developers
- Configure stdio transport for agent communication with proper error handling and logging</think> feat(mcp): initial implementation of GAC MCP server

Add FastMCP server integration to expose GAC's git commit capabilities to AI agents through the Model Context Protocol. This enables AI agents to inspect repository state and generate/execute commits programmatically.

- Implement gac_status tool providing comprehensive repository inspection including branch info, staged/unstaged/untracked files, merge conflicts, optional diffs with statistics, and recent commit history
- Implement gac_commit tool for AI-powered commit message generation with support for staging changes, dry runs, message-only mode, automatic pushing, and various commit style options (one-liner, scope, language, hints)
- Define Pydantic models for all tool requests and responses enabling automatic schema generation for MCP protocol
- Add gac-mcp script entry point and bash wrapper for server execution
- Include detailed inline documentation with usage examples, workflow guidance, and parameter descriptions for agent developers
- Configure stdio transport for agent communication with proper error handling and logging
…ncation

- Add format parameter to StatusRequest supporting 'summary', 'detailed', and 'json' output modes
- Add max_diff_lines parameter to limit diff output size and prevent overwhelming responses
- Add summary field to StatusResult providing clean, human-readable formatted output for agents
- Implement _format_status_summary() helper to generate organized status with emoji indicators and smart file grouping
- Implement _truncate_diff() helper to manage large diff outputs with truncation tracking
- Add diff_truncated field to indicate when diff output has been limited
- Clean up unused imports (typing.Any, GroupedCommit) from server.py
- Improve gac_commit() documentation with clearer warnings for dry_run and message_only modes
- Move CommitExecutor import to avoid premature loading in preview modes
- Integrate GroupedCommitWorkflow to enable AI-driven grouping of staged changes into multiple logical commits
- Add branch logic for group=True mode that analyzes changes and organizes them by scope/topic
- Include grouped_commits field in CommitResult to return scope, files, and suggested_message for each group
- Add _extract_scope helper function to parse conventional commit scopes from generated messages
- Support dry_run and message_only modes for previewing groupings before execution
- Scale token allocation proportionally to number of files being grouped to handle larger change sets
- Provide comprehensive documentation with usage examples for group mode workflow
- Add _stderr_console_redirect context manager to redirect Rich console
  output to stderr during commit execution
- Integrate context manager around workflow.execute_grouped_commits(),
  executor.create_commit(), and executor.push_to_remote() calls
- Prevents stdout writes from corrupting JSON-RPC framing in MCP stdio
  communication
- Ensures all Rich console output from commit operations is properly
  routed to stderr where it won't interfere with protocol messages
- Remove standalone gac-mcp script entry point from pyproject.toml
- Add serve subcommand to main CLI that invokes the MCP server
- Update server usage documentation to reflect new invocation pattern
- Enable MCP server invocation via 'uvx gac serve' for consistent tooling
- Maintain all existing MCP server functionality (gac_status, gac_commit tools)
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 0.79787% with 373 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/gac/mcp/server.py 0.00% 302 Missing ⚠️
src/gac/mcp/models.py 0.00% 66 Missing ⚠️
src/gac/mcp/__init__.py 0.00% 3 Missing ⚠️
src/gac/cli.py 60.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@thomwebb thomwebb merged commit d821e32 into thomwebb:main Mar 10, 2026
5 of 6 checks passed
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.

2 participants