A Model Context Protocol (MCP) server that provides AI-powered code review using Google Gemini 3.8 Flash. LGTMCP reviews your code changes and either commits them automatically (if approved) or provides detailed feedback for improvements.
In my usage with Gemini 3.8 Flash, the median review takes 3.2 minutes and costs $0.35, with an acceptance rate around 85%. You should decide whether that is slow and expensive or fast and cheap.
- AI Code Review: Leverages Google Gemini 3.8 Flash for intelligent code analysis
- Automatic Commit: Commits changes when code passes review (optional)
- Security Scanning: Built-in secret detection using Gitleaks, honoring a repository's
.gitleaks.toml - Gitignore Protection: Prevents access to gitignored files during review
- Project Guidelines: Discovers
AGENTS.mdandREVIEW.mdfor project-specific review rules - MCP Integration: Works seamlessly with Claude Desktop and other MCP clients
- Review-Only Mode: Option to get feedback without automatic commits
git clone https://msrl.dev/lgtmcp.git
cd lgtmcp
make buildmake installThis installs the binary to ~/bin by default. You can customize the installation directory:
make install INSTALL_PATH=/usr/local/binNote: Ensure ~/bin is in your shell's PATH. Add this to your shell configuration file if needed:
# For bash/zsh
export PATH="$HOME/bin:$PATH"-
Get a Google API key from Google AI Studio.
-
Create configuration directory:
mkdir -p ~/.config/lgtmcp -
Create configuration file from example:
cp config.example.yaml ~/.config/lgtmcp/config.yaml -
Edit the configuration file with your settings:
google: api_key: "your-gemini-api-key-here" gemini: model: "gemini-3.8-flash" thinking_level: "high" # fallback_model: "gemini-3.1-pro-preview" # Optional; disabled by default logging: level: "info"
thinking_level sets how much reasoning Gemini does before answering:
minimal, low, medium, or high (the default, for the most thorough
review), or none to leave the model's own default in place. Gemini 3.8 Flash
accepts only low, medium, and high. Thinking tokens are billed as output.
The optional fallback_model is used when we run into quota exhaustion on the
primary model. It is disabled by default (none); Gemini 3.8 Flash is generally
available with generous daily rate limits, so a fallback is rarely needed. Set
fallback_model to a model name (e.g. gemini-3.1-pro-preview) if you want a
safety net. The fallback receives the same thinking_level.
-
Set up configuration file as described above
-
Configure LGTMCP with Claude Code:
claude mcp add lgtmcp -- lgtmcpTo expose only some of the tools (see Enabling tools), add
the -tools flag to that command instead:
claude mcp add lgtmcp -- lgtmcp -tools review_onlyBy default the MCP server exposes two tools:
Reviews code changes and returns feedback without committing.
Parameters:
directory: Path to the git repository
Reviews code changes and commits if approved. This is a separate tool so that
you can set tool permissions on it differently from review.
Parameters:
directory: Path to the git repositorycommit_message: Message for the commit if approved
The -tools command-line flag takes a comma-separated list of the tools to
expose. It defaults to both: -tools review_only,review_and_commit. To make the
server unable to commit at all, rather than relying on tool permissions, enable
only the reviewer:
lgtmcp -tools review_onlyTools that are not listed are not advertised to the client and cannot be called. An unknown tool name, or an empty list, is an error at startup.
Review only (no commit):
review_only("/path/to/repo")
Review and commit if approved:
review_and_commit("/path/to/repo", "Add new feature")
- Security check: Scans the changed files for secrets using Gitleaks
- Uses the repository's
.gitleaks.tomlwhen it has one, with the CLI's semantics: a config without[extend] useDefault = truereplaces the default rules, allowlists apply, andgitleaks:allowcomments are honored - A
gitleaks.configfile in LGTMCP's own configuration applies to every repository instead, likegitleaks --config extend.path,extend.urland.gitleaksignoreare not supported
- Uses the repository's
- Diff generation: Creates diff of all staged and unstaged changes
- AI review: Sends diff to Gemini 3.8 Flash for analysis
- Gemini can request file contents for context
- Gitignored files are automatically blocked from access
- Decision:
- If approved (LGTM): Returns approval message (
review_only) or commits changes (review_and_commit) - If not approved: Returns detailed feedback
- If approved (LGTM): Returns approval message (
Repositories can include AGENTS.md and/or REVIEW.md files with project-specific
review guidelines. LGTMCP automatically discovers these files by walking from each
changed file's directory up to the repo root, and injects their contents into the
review prompt. Files are deduplicated and sorted root-first (shallowest depth first).
All configuration except the set of enabled tools (the -tools flag; see
Enabling tools) is managed through the YAML configuration
file located at:
$XDG_CONFIG_HOME/lgtmcp/config.yaml(if XDG_CONFIG_HOME is set)~/.config/lgtmcp/config.yaml(default)
See config.example.yaml for all available configuration options.
LGTMCP logs are written to platform-specific default locations:
- macOS:
~/Library/Logs/lgtmcp/lgtmcp.log - Linux:
~/.local/share/lgtmcp/logs/lgtmcp.log(or$XDG_DATA_HOME/lgtmcp/logs/lgtmcp.log) - Windows:
%LOCALAPPDATA%\lgtmcp\logs\lgtmcp.log
You can configure logging in your config.yaml:
logging:
output: "directory" # Options: none, stderr, directory
level: "info" # Options: debug, info, warn, error
# directory: "/custom/log/path" # Optional custom directoryTo view logs on macOS:
# View the log file
tail -f ~/Library/Logs/lgtmcp/lgtmcp.log
# Or open in Console.app
open ~/Library/Logs/lgtmcp/lgtmcp.logmake buildmake testmake lintmake coverage"Not a git repository" error
- Ensure you're in a git repository with a
.gitdirectory
"Secrets detected" error
- Review and remove any exposed secrets from your changes
"Gemini API error"
- Verify your API key is valid and has quota remaining
- Check network connectivity
"No changes to review"
- Make sure you have staged or unstaged changes in your repository
"Review Result: NOT REVIEWED"
- The diff is larger than
review.max_diff_bytes(400 KiB by default), so nothing was sent to Gemini andreview_and_commitcommitted nothing - Diffs this large are usually generated, vendored, or mass-edited code, where a line-by-line LLM review costs a lot and catches little; raise the limit if you do want them reviewed
"Review Result: INCOMPLETE"
- The reviewer found no issues, but file retrieval reached its limit (20 tool
turns or 1.5M prompt tokens per review) while it was still asking for
files, so the result lists the files its refused request asked for and
review_and_commitcommitted nothing