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

已驗證STDIO僅桌面開發者工具AI 與機器學習

概覽

AI 產生的概覽

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 金鑰。
安裝前請注意
API 金鑰是會產生費用的憑證:審查會把程式碼差異與擷取的脈絡傳送給所選模型供應商,大規模審查可能消耗大量 token 並產生費用。審查結果(含程式碼片段)會寫入本機檔案。伺服器會讀取你的 Git 儲存庫,對敏感程式碼執行前應確認審查範圍。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Selvage,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

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]

▶ Watch Demo Video

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 /review skill and selvage-reviewer agent 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)

bash
# Install uv (run once)curl -LsSf https://astral.sh/uv/install.sh | sh
# Install Selvageuv tool install selvage

Alternative Method (using pipx)

bash
# Install pipx (macOS)brew install pipx
# Install Selvagepipx install selvage

Traditional Method (pip)

bash
# ⚠️ May cause externally-managed-environment error on some systemspip install selvage

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:

bash
export OPENROUTER_API_KEY="your_openrouter_api_key_here"

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

json
// Method 1: Using environment variables (if already set){  "mcpServers": {    "selvage": {      "command": "uvx",      "args": ["selvage", "mcp"]    }  }}
// Method 2: Direct specification{  "mcpServers": {    "selvage": {      "command": "uvx",      "args": ["selvage", "mcp"],      "env": {        "OPENROUTER_API_KEY": "your_openrouter_api_key_here"      }    }  }}
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:

bash
# Step 1: Add Selvage marketplace/plugin marketplace add selvage-lab/selvage
# Step 2: Install the plugin/plugin install selvage@selvage-lab-selvage

After installation, use the /review skill directly:

/review                      # Review unstaged changes/review staged               # Review staged changes/review branch main          # Review against main branch/review commit abc1234       # Review from specific commit

💡 No API key required! The plugin uses get_review_context to leverage Claude Code's own LLM for code review, so no external API key is needed.

Method B: MCP Server Registration
bash
# Method 1: Using environment variables (if already set)claude mcp add selvage -- uvx selvage mcp
# Method 2: Direct specificationclaude mcp add selvage -e OPENROUTER_API_KEY=your_openrouter_api_key_here -- uvx selvage mcp
Usage

After restarting your IDE, request reviews from your Coding Assistant:

Please review current changes using selvage mcpReview changes between current branch and main branch using claude-sonnet-4-thinking with selvage mcp

🎉 Done! Selvage will analyze the code, review it, and deliver results through your Coding Assistant.

CLI Mode Usage

For direct terminal usage:

bash
selvage review --model claude-sonnet-4-thinking

💡 More Options: CLI Usage | Practical Usage Guide


🎯 Practical Usage Guide

MCP Mode Usage

Basic Usage
# Basic review requestPlease review current changes using selvage mcp
# Review staged changesReview staged work using gpt-5-high with selvage mcp
# Review against specific branchReview current branch against main branch using selvage mcp
# Review with automatic model selectionReview current branch against main branch using selvage mcp, automatically selecting appropriate model
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.

# Request agent-delegated review contextGet review context for current changes using selvage mcp, then review the code
# Agent-delegated review for staged changesGet review context for staged changes using selvage mcp
# Agent-delegated review against branchGet review context comparing current branch to main using selvage mcp

💡 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

Review staged work using both gpt-5-high and claude-sonnet-4-thinking with selvage mcp, then compare the results

Stepwise Code Improvement Workflow

1. Review current changes using claude-sonnet-4-thinking with selvage mcp2. Critically evaluate review feedback for validity against current codebase and set priorities3. Apply improvements sequentially based on established priorities

CI/CD Integration Scenarios

# Code quality verification before PR creationReview changes against main branch using selvage mcp for code quality verification before PR creation
# Final check before deploymentPerform comprehensive review of staged changes using selvage mcp for final check before deployment

⌨️ CLI Usage

Direct terminal usage method. While MCP mode is recommended, CLI is useful for scripts and CI/CD.

Configuring Selvage
bash
# View all settingsselvage config list
# Set default modelselvage config model <model_name>
# Set default languageselvage config language <language_name>
Code Review
bash
selvage review [OPTIONS]
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
bash
# Review current working directory changesselvage review
# Final check before commitselvage review --staged
# Review specific files onlygit add specific_files.py && selvage review --staged
# Code review before sending PRselvage review --target-branch develop
# Quick and economical review for simple changesselvage review --model gemini-2.5-flash
# Review and then view detailed results in web UIselvage review --target-branch main --open-ui
Git Workflow Integration
Team Collaboration Scenarios
bash
# Code quality verification before Pull Request creationselvage review --target-branch main --model claude-sonnet-4-thinking
# Pre-analysis of changes for code reviewersselvage review --target-branch develop --model claude-sonnet-4-thinking
# Comprehensive review of all changes after specific commitselvage review --target-commit a1b2c3d --model claude-sonnet-4-thinking
Development Stage Quality Management
bash
# Quick feedback during development (before WIP commit)selvage review --model gemini-2.5-flash
# Final verification of staged changes (before commit)selvage review --staged --model claude-sonnet-4-thinking
# Emergency review before hotfix deploymentselvage review --target-branch main --model claude-sonnet-4-thinking
Large-scale Code Review
bash
# Large codebases are automatically handledselvage review --model claude-sonnet-4  # Usage is the same, multi-turn processing automatically applied after detection

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
bash
# Use economical models for small changesselvage review --model gemini-2.5-flash
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:

bash
# Manage all saved review results in web UIselvage view
# Run UI on different portselvage view --port 8502

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:

🎯 Small Changes           → Fast and accurate analysis with Smart Context📄 Small Files            → Complete context understanding with full file analysis📋 Partial Edits in Large Files → Focused analysis of related code with Smart Context📚 Large Changes in Big Files   → Comprehensive review with full file analysis

💡 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

[Selvage UI Demo]

💡 Advanced Settings (For Developers/Contributors)

Development and Advanced Settings Options

Development Version Installation

Using uv (recommended)
bash
git clone https://github.com/selvage-lab/selvage.gitcd selvage
# Install all development dependencies automaticallyuv sync --dev --extra e2e
# Runuv run selvage --help
Using pip
bash
git clone https://github.com/selvage-lab/selvage.gitcd selvagepip install -e .

Development Environment Installation

Using uv (recommended)
bash
# Development dependencies onlyuv sync --dev
# E2E test environment includeduv sync --dev --extra e2e
# Run testsuv run pytest tests/
Using pip
bash
# Install with development dependencies (pytest, build, etc.)pip install -e .[dev]
# Install with development + E2E test environment (testcontainers, docker, etc.)pip install -e .[dev,e2e]

Individual Provider API Key Usage

You can also set individual provider API keys instead of OpenRouter:

bash
export OPENAI_API_KEY="your_openai_api_key_here"export ANTHROPIC_API_KEY="your_anthropic_api_key_here"export GEMINI_API_KEY="your_gemini_api_key_here"

Development and Debugging Settings

bash
# Set default model to use (for advanced users)selvage config model claude-sonnet-4-thinking
# Check configurationselvage config list
# Enable debug mode (for troubleshooting and development)selvage config debug-mode on

🔧 Troubleshooting

Installation Errors

externally-managed-environment Error (macOS/Linux)

bash
# Solution 1: Use uv (recommended)curl -LsSf https://astral.sh/uv/install.sh | shuv tool install selvage
# Solution 2: Use pipxbrew install pipx  # macOSpipx install selvage
# Solution 3: Use virtual environmentpython3 -m venv ~/.selvage-envsource ~/.selvage-env/bin/activatepip install selvage

API Key Errors

bash
# Check environment variableecho $OPENROUTER_API_KEY
# Permanent setup (Linux/macOS)echo 'export OPENROUTER_API_KEY="your_key_here"' >> ~/.bashrcsource ~/.bashrc

Model not found Error

bash
# Check available model listselvage models
# Use correct model nameselvage review --model claude-sonnet-4-thinking

Network Connection Error

bash
# Retry ignoring cacheselvage review --skip-cache
# Check detailed info with debug modeselvage config debug-mode onselvage review

🤝 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.

📋 View Complete Change Log →

You can find detailed changes for each version, including new features, bug fixes, and performance improvements.

📞 Contact and Community


Write better code with Selvage! 🚀
⭐ If this project helped you, please give us a Star on GitHub!

來源:README.md,提交 e82f34a

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.4.1最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。