feat(mcp): add MCP server with status, commit, and group workflow support#70
feat(mcp): add MCP server with status, commit, and group workflow support#70thomwebb merged 5 commits intothomwebb:mainfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis change adds an MCP integration for GAC: Pydantic models, a FastMCP server exposing Changes
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Exposes GAC's commit generation capabilities via the Model Context Protocol using FastMCP.
Tools
gac_status— repository inspectionformat:summary/detailed/jsoninclude_diff,include_stats,include_history,max_diff_linessummarystring with structured sections ready for agent consumptiongac_commit— AI commit generationgroup=True) — splits staged changes into logical commits viaGroupedCommitWorkflow; returnsgrouped_commitslist withscope,files,suggested_messageper groupmessage_only/dry_runfor previewing without committingstage_all,push,no_verify,hint,one_liner,language,scopeall supportedInvocation
Adds a
servesubcommand to the main CLI — no separate binary needed: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
Chores