
Selvage
io.github.selvage-lab由 GitHub 账号 selvage-lab 发布v0.4.1更新于 Oct 24, 2026
An LLM-based code review MCP server with AST-powered smart context extraction
概览
Selvage 是一个本地 MCP 服务器,让 AI 助手审查 Git 变更,并通过基于 AST 的上下文提取只把相关代码发送给大模型。
- 可以做什么
- 审查 Git 变更:分析未暂存、已暂存、与指定提交或分支之间的差异,给出质量、缺陷和安全问题,并可同时用多个模型对比结果。提取审查上下文:返回 diff、基于 AST 的智能上下文和系统提示词,让宿主代理用自己的模型完成审查,无需 API 密钥。管理结果:审查结果输出到终端并同时保存为 Markdown 和 JSON 文件,另有网页界面用于浏览和复查已保存的审查。配置默认项:通过命令行设置默认模型和审查语言。
- 适用场景
- 适合在提交、发起合并请求或部署前,让助手审查工作区、暂存区或某个分支的改动,也适合需要自动多轮处理的大规模差异。代理委托模式适合 Claude Code、Cursor 等希望用自身模型完成审查的宿主。
- 运行要求
- 以 Python 包形式在本地运行,可用 uv、pipx 或 pip 安装。被审查的改动需要位于 Git 仓库中。使用 Selvage 自带模型审查需要 OPENROUTER_API_KEY(或 OpenAI、Anthropic、Google 等提供商的密钥)和网络访问;代理委托的 get_review_context 方式不需要 API 密钥。
安装
在 SourceWeft 中
- 打开 控制台中的 Selvage,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Selvage: AI-Powered Code Review Automation Tool
🌐 한국어
A modern CLI tool that helps AI analyze Git diffs to improve code quality, find bugs, and identify security vulnerabilities.
🤖 AI Agents: Read our documentation at https://selvage.ai/llms.txt
[PyPI] [License] [Python] [AI Models]
Selvage: Code reviews with an edge!
No more waiting for reviews! AI instantly analyzes your code changes to provide quality improvements and bug prevention. With smart context analysis (AST-based) that's accurate and cost-effective, plus multi-turn processing for large codebases - seamlessly integrated with all Git workflows.
Table of Contents
✨ Key Features
- 🤖 Multiple AI Model Support: Leverage the latest LLM models including OpenAI GPT-5, Anthropic Claude Sonnet-4, Google Gemini, and more
- 🔍 Git Workflow Integration: Support for analyzing staged, unstaged, and changes between specific commits/branches
- 🎯 Optimized Context Analysis: Tree-sitter based AST analysis automatically extracts the smallest code blocks containing changed lines along with their dependency statements, providing contextually optimized information for each situation
- 🔄 Automatic Multi-turn Processing: Automatic prompt splitting when context limits are exceeded, supporting stable large-scale code reviews (Large Context Mode now auto-triggers once total tokens exceed 200k, even without provider errors)
- 🤖 MCP Mode Support: Register as MCP mode in Cursor, Claude Code, etc., and request code reviews through natural language like "Review current changes"
- 🔌 Claude Code Plugin: Install via marketplace with a single command — includes dedicated
/reviewskill andselvage-revieweragent for seamless integration - 🧠 Agent-Delegated Review (
get_review_context): Returns structured review context (diff + Smart Context + system prompt) so host agents (Claude Code, Cursor, Antigravity, etc.) can perform code reviews with their own LLM — no API key required - 📖 Open Source: Freely use and modify under Apache-2.0 License
🚀 Quick Start
Common Setup
1. Installation
Recommended Method (using uv)
Alternative Method (using pipx)
Traditional Method (pip)
macOS/Linux users: If you encounter errors with pip install, please use the uv or pipx methods above.
2. API Key Setup
Get an API key from OpenRouter and set it up:
MCP Mode Usage (Recommended)
Register as MCP mode in Cursor, Claude Code, etc., to request code reviews through natural language.
Cursor Integration
Register in Cursor's MCP configuration file (path may vary depending on user environment):
Common path: ~/.cursor/mcp.json
Claude Code Integration
Method A: Plugin via Marketplace (Recommended)
Install the Selvage plugin from the marketplace to get the dedicated /review skill and selvage-reviewer agent:
After installation, use the /review skill directly:
💡 No API key required! The plugin uses
get_review_contextto leverage Claude Code's own LLM for code review, so no external API key is needed.
Method B: MCP Server Registration
Usage
After restarting your IDE, request reviews from your Coding Assistant:
🎉 Done! Selvage will analyze the code, review it, and deliver results through your Coding Assistant.
CLI Mode Usage
For direct terminal usage:
💡 More Options: CLI Usage | Practical Usage Guide
🎯 Practical Usage Guide
MCP Mode Usage
Basic Usage
Agent-Delegated Review (No API Key Required)
The get_review_context tool returns structured review context so host agents can perform code reviews with their own LLM — no Selvage API key needed.
💡 How it works: Selvage extracts diff + AST-based Smart Context + system prompt and returns it as structured context. The host agent (Claude Code, Cursor, Antigravity, etc.) then performs the review directly with its own LLM, without needing an external API key.
Advanced Workflows
Multi-model Comparison Review
Stepwise Code Improvement Workflow
CI/CD Integration Scenarios
⌨️ CLI Usage
Direct terminal usage method. While MCP mode is recommended, CLI is useful for scripts and CI/CD.
Configuring Selvage
Code Review
Key Options
--repo-path <path>: Git repository path (default: current directory)--staged: Review only staged changes--target-commit <commit_id>: Review changes from specific commit to HEAD (e.g., abc1234)--target-branch <branch_name>: Review changes between current branch and specified branch (e.g., main)--model <model_name>: AI model to use (e.g., claude-sonnet-4-thinking)--open-ui: Automatically launch UI after review completion--no-print: Don't output review results to terminal (terminal output enabled by default)--skip-cache: Perform new review without using cache
Usage Examples
Git Workflow Integration
Team Collaboration Scenarios
Development Stage Quality Management
Large-scale Code Review
Selvage automatically handles large code changes that exceed LLM model context limits. Once usage reaches roughly 200k tokens (tiktoken basis), Large Context Mode starts automatically, so just wait for it to complete.
Cost Optimization
Viewing Results
Review results are output directly to the terminal and automatically saved to files simultaneously.
For additional review management and re-examination, you can use the web UI:
Key UI Features:
- 📋 Display list of all review results
- 🎨 Markdown format display
- 🗂️ JSON structured result view
🌐 Smart Context Analysis and Supported AI Models
🎯 Smart Context Analysis
Selvage uses Tree-sitter based AST analysis to precisely extract only the code blocks related to changed lines, ensuring both cost efficiency and review quality simultaneously.
How Smart Context Works
- Precise Extraction: Extracts only the minimal function/class blocks containing changed lines + related dependencies (imports, etc.)
- Cost Optimization: Dramatically reduces token usage by sending only necessary context instead of entire files
- Quality Assurance: Maintains high review accuracy through AST-based precise code structure understanding
Smart Context Automatic Application
Selvage analyzes file size and change scope to automatically select the most efficient review method:
💡 Automatic Optimization: The optimal analysis method for each situation is automatically applied without requiring any manual configuration.
Smart Context Supported Languages
- Python, JavaScript, TypeScript, Java, Kotlin
Universal Context Extraction Support
- Major Programming Languages: Go, Ruby, PHP, C#, C/C++, Rust, Swift, Dart, etc.
🚀 Universal context extraction method provides excellent code review quality for major programming languages. Smart Context supported languages are continuously expanding.
Supported AI Models
🚀 Manage all models below with just one OpenRouter API key!
OpenAI Models (OpenRouter or OpenAI API Key)
- gpt-5.2-codex: ⭐ Recommended - Most capable agentic coding model with stronger reasoning (400K context)
Anthropic Models (OpenRouter or Anthropic API Key)
- claude-opus-4.6: ⭐ Recommended - Frontier reasoning model with extended thinking (1M context)
- claude-sonnet-4.5: Hybrid reasoning model with extended thinking for advanced coding (1M context)
Google Models (OpenRouter or Google API Key)
- gemini-3-pro: ⭐ Recommended - Most advanced reasoning model (1M+ tokens)
- gemini-3-flash: High speed, high value model for agentic workflows (1M+ tokens)
🌟 OpenRouter Provided Models (OpenRouter API Key Only)
- minimax-m2.5 (MiniMax): ⭐ Recommended - State-of-the-art open-source model for coding (SWE-bench 80.2%, 200K context)
- glm-5 (Zhipu AI): Flagship 745B MoE model for complex systems (200K context)
- qwen3-coder (Qwen): Coding-specialized model (262K context)
- kimi-k2.5 (Moonshot AI): Large context processing model (262K context)
- deepseek-r1-0528 (DeepSeek): Reasoning-specialized model (163K context)
- deepseek-v3-0324 (DeepSeek): Advanced conversation model (163K context)
Free tier models available: qwen3-coder-free, kimi-k2.5-free, deepseek-v3-0324-free, deepseek-r1-0528-free
📄 Review Result Storage Format
Review results are saved as structured files simultaneously with terminal output:
- 📋 Markdown Format: Clean structure that's easy for humans to read, including summary, issue list, and improvement suggestions
- 🔧 JSON Format: For programmatic processing and integration with other tools
💡 Advanced Settings (For Developers/Contributors)
Development and Advanced Settings Options
Development Version Installation
Using uv (recommended)
Using pip
Development Environment Installation
Using uv (recommended)
Using pip
Individual Provider API Key Usage
You can also set individual provider API keys instead of OpenRouter:
Development and Debugging Settings
🔧 Troubleshooting
Installation Errors
externally-managed-environment Error (macOS/Linux)
API Key Errors
Model not found Error
Network Connection Error
🤝 Contributing
Selvage is an open-source project and we always welcome your contributions! Bug reports, feature suggestions, documentation improvements, code contributions - any form of contribution is appreciated.
How to Contribute:
- 🐛 Bug reports or feature suggestions on GitHub Issues
- 🔧 Code contributions through Pull Requests
- 📚 Documentation improvements and translations
Detailed contribution guidelines can be found in CONTRIBUTING.md.
📜 License
Selvage is distributed under the Apache License 2.0. This license permits commercial use, modification, and distribution, with comprehensive patent protection and trademark restrictions included.
📋 Change Log
Check out all version changes and new features of Selvage.
You can find detailed changes for each version, including new features, bug fixes, and performance improvements.
📞 Contact and Community
- 🐛 Bug Reports and Feature Requests: GitHub Issues
- 📧 Direct Contact: [email protected]
Write better code with Selvage! 🚀
⭐ If this project helped you, please give us a Star on GitHub!
来源:README.md,提交 e82f34a
工具
0版本历史
1- v0.4.1最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。