LGTMCP

LGTMCP

Gemini-powered code review. Offers review-only and review-and-commit modes with integrated Gitleaks security scanning.

Category
访问服务器

README

<!-- Copyright © 2025 Michael Shields

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->

LGTMCP

A Model Context Protocol (MCP) server that provides AI-powered code review using Google Gemini 3.1 Pro. LGTMCP reviews your code changes and either commits them automatically (if approved) or provides detailed feedback for improvements.

In my usage, the median review takes 1.9 minutes and costs $0.20, with an acceptance rate around 45%. You should decide whether that is slow and expensive or fast and cheap.

Features

  • AI Code Review: Leverages Google Gemini 3.1 Pro for intelligent code analysis
  • Automatic Commit: Commits changes when code passes review (optional)
  • Security Scanning: Built-in secret detection using Gitleaks
  • Gitignore Protection: Prevents access to gitignored files during review
  • MCP Integration: Works seamlessly with Claude Desktop and other MCP clients
  • Review-Only Mode: Option to get feedback without automatic commits

Installation

Build from source

git clone https://msrl.dev/lgtmcp.git
cd lgtmcp
make build

Install to ~/bin

make install

This installs the binary to ~/bin by default. You can customize the installation directory:

make install INSTALL_PATH=/usr/local/bin

Note: 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"

Configuration

  1. Get a Google API key from Google AI Studio.

  2. Create configuration directory:

    mkdir -p ~/.config/lgtmcp
    
  3. Create configuration file from example:

    cp config.example.yaml ~/.config/lgtmcp/config.yaml
    
  4. Edit the configuration file with your settings:

    google:
      api_key: "your-gemini-api-key-here"
    gemini:
      model: "gemini-3.1-pro-preview"
      fallback_model: "gemini-2.5-pro" # Default; set to "none" to disable
    logging:
      level: "info"
    

The fallback_model is use when we run into quota exhaustion on the primary model. While Gemini 3.1 Pro is in preview, it has very low daily rate limits.

Claude Code configuration

  1. Set up configuration file as described above

  2. Configure LGTMCP with Claude Code:

claude mcp add lgtmcp -- lgtmcp

Usage

Basic Usage

The MCP server exposes two tools:

review_only

Reviews code changes and returns feedback without committing.

Parameters:

  • directory: Path to the git repository

review_and_commit

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 repository
  • commit_message: Message for the commit if approved

Example Workflows

Review only (no commit):

review_only("/path/to/repo")

Review and commit if approved:

review_and_commit("/path/to/repo", "Add new feature")

What Happens

  1. Security check: Scans files for secrets using Gitleaks
  2. Diff generation: Creates diff of all staged and unstaged changes
  3. AI review: Sends diff to Gemini 3.1 Pro for analysis
    • Gemini can request file contents for context
    • Gitignored files are automatically blocked from access
  4. Decision:
    • If approved (LGTM): Returns approval message (review_only) or commits changes (review_and_commit)
    • If not approved: Returns detailed feedback

Configuration

All configuration 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.

Logging

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, stdout, stderr, directory, mcp
  level: "info" # Options: debug, info, warn, error
  # directory: "/custom/log/path"  # Optional custom directory

To 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.log

Development

Building

make build

Testing

make test

Linting

make lint

Coverage

make coverage

Troubleshooting

"Not a git repository" error

  • Ensure you're in a git repository with a .git directory

"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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选