Code Review Analyst

io.github.j0hanz由 GitHub 帳號 j0hanz 發布v1.7.6更新於 Oct 24, 2026

Gemini-powered MCP server for code review analysis.

發布方自己的服務:Review Expert

概覽

AI 產生的概覽

一個本機 MCP 伺服器,透過 Google Gemini 審查程式碼差異、分析原始碼檔案並產生文件。

可以做什麼
擷取 git 差異,並對其進行 PR 影響、風險、測試計畫、複雜度與破壞性變更審查。載入原始碼檔案後提供重構建議、程式碼異味偵測、文件產生與問答分析。透過 Gemini 程式碼執行沙箱驗證演算法邏輯。使用 Google Search 連網檢索最新資料。以 MCP 資源與提示詞形式讀取快取的差異、檔案及伺服器指南。
適用情境
適合希望讓助理審查拉取請求或差異、對單一檔案做異味與重構稽核,或在聊天用戶端內起草文件的開發者。最適合已使用 Gemini 且用戶端支援 stdio 的使用者。
執行需求
透過 npx 或 Docker 以 stdio 在本機執行。需要 Node.js 24 或更新版本,以及透過 GEMINI_API_KEY(或 GOOGLE_API_KEY)提供的 Gemini API 金鑰。需要連線至 Google Gemini 與 Google Search 的網路存取。
安裝前請注意
原始碼、差異與提問會傳送給 Google Gemini,連網搜尋查詢會傳送給 Google Search。API 金鑰是可計費憑證,使用可能產生 Gemini 費用。load_file 限制在工作區根目錄內,但審查結果僅供參考,合併前應自行核實。

安裝

在 SourceWeft 中

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

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Code Lens MCP Server

[npm version] [License: MIT]

[Install in VS Code] [Install in VS Code Insiders] [Install in Visual Studio]

[Add to LM Studio] [Install in Cursor] [Install in Goose]

Gemini-powered MCP server for automated code review, analysis, and documentation.

Overview

Code Lens is a Model Context Protocol server that uses Google Gemini to analyze diffs, review pull requests, detect code smells, generate documentation, and verify logic. It exposes 13 tools, 7 resources, and 5 prompts over stdio transport.

Key Features

  • PR review pipeline — generate diffs, assess impact, detect breaking API changes, and produce review summaries with merge recommendations
  • File analysis — load any source file for refactoring suggestions, code smell detection, documentation generation, and natural-language Q&A
  • Logic verification — verify algorithms using Gemini's code execution sandbox
  • Structured outputs — all tools return validated JSON via Zod v4 output schemas
  • Web search — Google Search with Grounding for up-to-date information retrieval
  • Task lifecycle support — every tool except load_file can run via MCP tasks with polling, cancellation, and progress updates

Requirements

Quick Start

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

Docker

bash
docker run -i --rm -e GEMINI_API_KEY="your-api-key" ghcr.io/j0hanz/code-lens

Or with Docker Compose:

bash
GEMINI_API_KEY=your-api-key docker compose up

Client Configuration

Install in VS Code

[Install in VS Code]

Add to .vscode/mcp.json:

json
{  "servers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

Or install via CLI:

sh
code --add-mcp '{"name":"code-lens","command":"npx","args":["-y","@j0hanz/code-lens-mcp@latest"]}'

For more info, see VS Code MCP docs.

Install in VS Code Insiders

[Install in VS Code Insiders]

Add to .vscode/mcp.json:

json
{  "servers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

Or install via CLI:

sh
code-insiders --add-mcp '{"name":"code-lens","command":"npx","args":["-y","@j0hanz/code-lens-mcp@latest"]}'

For more info, see VS Code Insiders MCP docs.

Install in Cursor

[Install in Cursor]

Add to ~/.cursor/mcp.json:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Cursor MCP docs.

Install in Visual Studio

[Install in Visual Studio]

Add to mcp.json:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Visual Studio MCP docs.

Install in Goose

[Install in Goose]

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Goose MCP docs.

Install in LM Studio

[Add to LM Studio]

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see LM Studio MCP docs.

Install in Claude Desktop

Add to claude_desktop_config.json:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Claude Desktop MCP docs.

Install in Claude Code
sh
claude mcp add code-lens -- npx -y @j0hanz/code-lens-mcp@latest

Or add to config:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Claude Code MCP docs.

Install in Windsurf

Add to ~/.codeium/windsurf/mcp_config.json:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Windsurf MCP docs.

Install in Amp
sh
amp mcp add code-lens -- npx -y @j0hanz/code-lens-mcp@latest

Or add to config:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Amp MCP docs.

Install in Cline

Add to cline_mcp_settings.json:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Cline MCP docs.

Install in Codex CLI

Add to ~/.codex/config.yaml:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Codex CLI MCP docs.

Install in GitHub Copilot

Add to .vscode/mcp.json:

json
{  "servers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see GitHub Copilot MCP docs.

Install in Warp
json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Warp MCP docs.

Install in Kiro

Add to .kiro/settings/mcp.json:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Kiro MCP docs.

Install in Gemini CLI

Add to ~/.gemini/settings.json:

json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Gemini CLI MCP docs.

Install in Zed

Add to ~/.config/zed/settings.json:

json
{  "context_servers": {    "code-lens": {      "settings": {        "command": "npx",        "args": ["-y", "@j0hanz/code-lens-mcp@latest"]      }    }  }}

For more info, see Zed MCP docs.

Install in Augment

Add to your VS Code settings.json under augment.advanced:

json
{  "augment.advanced": {    "mcpServers": [      {        "id": "code-lens",        "command": "npx",        "args": ["-y", "@j0hanz/code-lens-mcp@latest"],        "env": {          "GEMINI_API_KEY": "your-api-key"        }      }    ]  }}

For more info, see Augment MCP docs.

Install in Roo Code
json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Roo Code MCP docs.

Install in Kilo Code
json
{  "mcpServers": {    "code-lens": {      "command": "npx",      "args": ["-y", "@j0hanz/code-lens-mcp@latest"],      "env": {        "GEMINI_API_KEY": "your-api-key"      }    }  }}

For more info, see Kilo Code MCP docs.

Use Cases

PR Review Pipeline

  1. Call generate_diff to capture unstaged or staged changes
  2. Run analyze_pr_impact to assess severity and breaking changes
  3. Run generate_review_summary for a risk rating and merge recommendation
  4. Run detect_api_breaking_changes to check for public API breakage
  5. Run generate_test_plan to produce prioritized test cases

Single-File Analysis

  1. Call load_file to cache a source file
  2. Run refactor_code for structural improvement suggestions
  3. Run detect_code_smells for Fowler-taxonomy anti-patterns
  4. Run generate_documentation to generate JSDoc/TSDoc stubs
  5. Use ask_about_code for natural-language Q&A about the file
  6. Use verify_logic to verify algorithms with code execution

Performance Audit

  1. Call generate_diff on a performance-sensitive change
  2. Run analyze_time_space_complexity to detect Big-O degradation

Research

  • Use web_search for up-to-date documentation or API references via Google Search with Grounding

Architecture

text
[MCP Client]    │    │ Transport: stdio    ▼[MCP Server: code-lens]    │ Entry: src/index.ts → src/server.ts    │    ├── initialize / initialized (lifecycle handshake)    │    ├── tools/call ──────────────────────────────────────────────    │   │    │   │ Diff-based tools (require generate_diff first):    │   ├── [generate_diff]              Sync — capture git diff    │   ├── [analyze_pr_impact]          Flash — severity & impact    │   ├── [generate_review_summary]    Flash — risk & merge rec    │   ├── [generate_test_plan]         Flash — test cases    │   ├── [analyze_time_space_complexity] Flash — Big-O analysis    │   ├── [detect_api_breaking_changes]  Flash — API breakage    │   │    │   │ File-based tools (require load_file first):    │   ├── [load_file]                  Sync — cache source file    │   ├── [refactor_code]              Flash — refactoring    │   ├── [detect_code_smells]         Flash — smell detection    │   ├── [generate_documentation]     Flash — doc stubs    │   ├── [ask_about_code]             Flash — Q&A    │   ├── [verify_logic]               Flash — code execution    │   │    │   │ Standalone:    │   └── [web_search]                 Flash — Google Search    │    ├── resources/read ──────────────────────────────────────────    │   ├── [internal://instructions]        Server usage guide    │   ├── [internal://tool-catalog]        Tool reference    │   ├── [internal://workflows]           Workflow sequences    │   ├── [internal://server-config]       Runtime config    │   ├── [internal://tool-info/{name}]    Per-tool details    │   ├── [internal://diff/current]        Cached diff (text/x-patch)    │   └── [internal://file/current]        Cached source file    │    ├── prompts/get ─────────────────────────────────────────────    │   ├── [get-help]           Full server instructions    │   ├── [review-guide]       Tool + focus area workflow    │   ├── [select-workflow]    Pipeline by change type    │   ├── [analyze-file]       File analysis pipeline    │   └── [tool-chain]         Tool prerequisite chain    │    └── Capabilities: structured output, tool annotations, notifications

Request Lifecycle

text
[Client] -- initialize {protocolVersion, capabilities} --> [Server][Server] -- {protocolVersion, capabilities, serverInfo} --> [Client][Client] -- notifications/initialized --> [Server][Client] -- tools/call {name, arguments} --> [Server][Server] -- notifications/progress {token, progress, total} --> [Client][Server] -- {content, structuredContent, isError?} --> [Client]

Task Lifecycle

  • generate_diff and load_file are sync-only. All other tools advertise taskSupport: optional.
  • Requestors may supply a task TTL. The server uses that value up to MAX_TASK_TTL_MS, or falls back to TASK_TTL_MS when omitted.
  • Cancelled tasks remain terminal as cancelled, and tasks/result returns a cancellation-shaped tool result.

MCP Surface

Tools

ToolDescriptionPrerequisiteModel
generate_diffCapture git diff (unstaged/staged) and cache server-side—Sync
analyze_pr_impactAssess severity, categories, breaking changes, rollback complexitygenerate_diffFlash
generate_review_summaryPR summary, risk rating, merge recommendationgenerate_diffFlash
generate_test_planPrioritized test cases and coverage guidancegenerate_diffFlash
analyze_time_space_complexityBig-O complexity analysis and degradation detectiongenerate_diffFlash
detect_api_breaking_changesDetect breaking API/interface changesgenerate_diffFlash
load_fileCache a source file for analysis tools—Sync
refactor_codeComplexity, duplication, naming, grouping suggestionsload_fileFlash
detect_code_smellsStructural code smells (Fowler taxonomy)load_fileFlash
generate_documentationJSDoc/TSDoc/docstring stubs for public exportsload_fileFlash
ask_about_codeNatural-language Q&A about a cached fileload_fileFlash
verify_logicVerify algorithms via Gemini code execution sandboxload_fileFlash
web_searchGoogle Search with Grounding—Flash

Resources

URIDescriptionMIME
internal://instructionsComplete server usage instructionstext/markdown
internal://tool-catalogTool reference: models, params, outputs, data flowtext/markdown
internal://workflowsRecommended workflows and tool sequencestext/markdown
internal://server-configRuntime configuration and limitstext/markdown
internal://tool-info/{toolName}Per-tool details (parameterized)text/markdown
internal://diff/currentMost recently generated difftext/x-patch
internal://file/currentMost recently loaded source filetext/plain

Prompts

PromptDescription
get-helpFull server instructions: capabilities, tools, resources, constraints
review-guideWorkflow guide for a specific tool and focus area
select-workflowRecommended tool pipeline based on change type
analyze-fileGoal-based tool pipeline for single-file analysis
tool-chainFull prerequisite chain for a given tool

MCP Capabilities

Tool Annotations

All tools expose MCP tool annotations:

AnnotationUsed
readOnlyHintYes
destructiveHintYes
idempotentHintYes
openWorldHintYes

Structured Output

All Gemini-powered tools return validated structuredContent alongside text content, using Zod v4 output schemas.

Configuration

VariableDefaultDescription
GEMINI_API_KEY—Required. Gemini API key. Falls back to GOOGLE_API_KEY.
GEMINI_MODELgemini-3-flash-previewOverride the default Gemini model for all tools.
MAX_DIFF_CHARS120000Maximum diff size in characters.
MAX_CONCURRENT_CALLS10Maximum concurrent Gemini API calls.
MAX_CONCURRENT_BATCH_CALLS2Maximum concurrent batch Gemini calls.
MAX_CONCURRENT_CALLS_WAIT_MS2000Wait timeout for concurrency semaphore.
TASK_TTL_MS300000Default task result retention in milliseconds when the request does not specify task.ttl.
MAX_TASK_TTL_MS3600000Upper bound for request-provided task TTL. Set to 0 to remove the cap.
GEMINI_BATCH_MODEoffEnable Gemini batch mode.
GEMINI_HARM_BLOCK_THRESHOLDBLOCK_NONESafety filter threshold (BLOCK_NONE, BLOCK_ONLY_HIGH, BLOCK_MEDIUM_AND_ABOVE, BLOCK_LOW_AND_ABOVE).
GEMINI_DIFF_CACHE_ENABLEDfalseEnable Gemini context caching for large diffs.
GEMINI_DIFF_CACHE_TTL_S3600Cache TTL in seconds (when caching is enabled).

CLI Flags

bash
npx @j0hanz/code-lens-mcp@latest --model gemini-2.5-flash --max-diff-chars 200000
FlagEnv Equivalent
--model, -mGEMINI_MODEL
--max-diff-charsMAX_DIFF_CHARS

Security

ControlStatus
Input validationZod v4 schema validation on all tool inputs
Path safetyload_file restricts paths to workspace root
Stdout safetyLogs to stderr; stdout reserved for MCP protocol
Non-root containerDocker runs as dedicated mcp user

Development

bash
npm install          # Install dependenciesnpm run build        # Compile TypeScriptnpm run dev          # Watch modenpm run dev:run      # Run with --watch and .envnpm run start        # Run compiled servernpm run type-check   # Type-check src + testsnpm run lint         # ESLintnpm run test         # Run test suitenpm run format       # Prettiernpm run inspector    # MCP Inspectornpm run knip         # Dead code detection

Build and Release

  • CI: .github/workflows/release.yml
  • Docker: Multi-stage build (Dockerfile) with node:24-alpine
  • Docker Compose: docker-compose.yml
  • npm: Published as @j0hanz/code-lens-mcp

Troubleshooting

  • Missing API key: Set GEMINI_API_KEY or GOOGLE_API_KEY in your environment or client config env block.
  • "E_NO_DIFF" errors: Call generate_diff before running any diff-based review tool.
  • "E_NO_FILE" errors: Call load_file before running any file analysis tool.
  • Large diffs truncated: Increase MAX_DIFF_CHARS (default: 120,000 characters).
  • Stdout noise: Ensure no other processes write to stdout; the server uses stdio transport.

Credits

Contributing and License

MIT License. See LICENSE for details.

Contributions welcome via pull requests.

來源:README.md,提交 576b329

工具

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

版本歷史

1
  1. v1.7.6最新Sep 16, 2026

評分

已滿足適用檢查項的 40%

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

  • 近 30 天內可連通25 分

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

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

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

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

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

其他 Review 整合