Code Review Buddy MCP Server
133
An internal Model Context Protocol (MCP) server that grants AI agents (e.g. Claude Desktop, Cursor) the ability to inspect git repositories locally. Built using Python and the FastMCP framework.
The project follows the API-First and modular folder structure:
packages/python/code-review-buddy/
├── build/
│ ├── Dockerfile # Production container definitions
│ └── .gitkeep
├── contracts/
│ └── mcp/
│ ├── tools.json # Contract defining tool signatures
│ └── changelog.md # Changelog for contracts
├── src/
│ ├── api/
│ │ └── mcp/
│ │ ├── server.py # Launch and transport initialization
│ │ ├── router.py # Exposes Resources (project://readme)
│ │ └── tools.py # Maps and registers tools (list_files, read_file, get_git_diff, etc.)
│ ├── features/
│ │ ├── fs/
│ │ │ └── service.py # File listing and line-guarded reading logic
│ │ ├── git/
│ │ │ └── service.py # Subprocess-based git diff and logs retrieval
│ │ └── scanner/
│ │ └── service.py # TODO/FIXME scanner & large function heuristics
│ └── shared/
│ └── config.py # Shared repo-root configurations
└── tests/
└── unit/ # Unit tests for features and services
list_files: List all files in a directory relative to the repository root, optionally filtered by file extension.read_file: Read file contents with safety guards (refuses files over 500 lines).get_git_diff: Run git diff between two branches (truncated to 200 lines to keep it safe).get_recent_commits: Fetch recent commit messages.scan_todos: Recursively search directory for comment markers (TODO, FIXME, HACK, XXX).find_large_functions: Identify functions/methods containing more than 40 lines of code.project://readme: Exposes the repository's README.md.Prerequisites: Ensure you have Python 3.10+ installed on your machine.
Install dependencies:
cd packages/python/code-review-buddy
pip install -e .
Running the Server:
The server communicates over stdio transport. You can launch it using:
fastmcp run src/api/mcp/server.py
# Or using python directly if installed:
python -m src.api.mcp.server
Claude Desktop Integration:
Add the following configuration to your claude_desktop_config.json (typically located at ~/.config/Claude/claude_desktop_config.json on Linux):
{
"mcpServers": {
"code-review-buddy": {
"command": "python",
"args": ["-m", "src.api.mcp.server"],
"env": {
"REPO_ROOT": "/home/btpl-lap-22/live/codeReview"
},
"cwd": "/home/btpl-lap-22/live/codeReview/packages/python/code-review-buddy"
}
}
}
Build the Docker Image: Build the image from the root of the sub-package:
cd packages/python/code-review-buddy
docker build -t code-review-buddy -f build/Dockerfile .
Claude Desktop Integration:
Add the container execution command to your claude_desktop_config.json. Note that you must mount your target code repository to a volume in the container (e.g. /project) so the container has access to read files and run git:
{
"mcpServers": {
"code-review-buddy": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"/home/btpl-lap-22/live/codeReview:/project",
"-e",
"REPO_ROOT=/project",
"code-review-buddy:latest"
]
}
}
}
You can test the MCP server in your browser using the official MCP Inspector tool without needing to configure a desktop app.
Run the following command to spin up the inspector interface:
npx @modelcontextprotocol/inspector docker run -i --rm \
-v /home/btpl-lap-22/live/codeReview:/project \
-e REPO_ROOT=/project \
chiefj/code-review-buddy:latest
Open the link shown in your terminal (typically http://localhost:6274) to test all tools and resources interactively.
Content type
Image
Digest
sha256:45130ae03…
Size
102.2 MB
Last updated
3 months ago
docker pull chiefj/code-review-buddy