Code Review Analyst

编码与调试

by j0hanz

基于 Gemini 的代码审查分析 MCP 服务器,可帮助发现问题、评估风险并提出改进建议。

什么是 Code Review Analyst

基于 Gemini 的代码审查分析 MCP 服务器,可帮助发现问题、评估风险并提出改进建议。

README

<!-- mcp-name: io.github.j0hanz/code-lens -->

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

<details> <summary><b>Install in VS Code</b></summary>

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.

</details> <details> <summary><b>Install in VS Code Insiders</b></summary>

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.

</details> <details> <summary><b>Install in Cursor</b></summary>

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.

</details> <details> <summary><b>Install in Visual Studio</b></summary>

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.

</details> <details> <summary><b>Install in Goose</b></summary>

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.

</details> <details> <summary><b>Install in LM Studio</b></summary>

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.

</details> <details> <summary><b>Install in Claude Desktop</b></summary>

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.

</details> <details> <summary><b>Install in Claude Code</b></summary>
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.

</details> <details> <summary><b>Install in Windsurf</b></summary>

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.

</details> <details> <summary><b>Install in Amp</b></summary>
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.

</details> <details> <summary><b>Install in Cline</b></summary>

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.

</details> <details> <summary><b>Install in Codex CLI</b></summary>

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.

</details> <details> <summary><b>Install in GitHub Copilot</b></summary>

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.

</details> <details> <summary><b>Install in Warp</b></summary>
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.

</details> <details> <summary><b>Install in Kiro</b></summary>

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.

</details> <details> <summary><b>Install in Gemini CLI</b></summary>

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.

</details> <details> <summary><b>Install in Zed</b></summary>

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.

</details> <details> <summary><b>Install in Augment</b></summary>

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.

</details> <details> <summary><b>Install in Roo Code</b></summary>
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.

</details> <details> <summary><b>Install in Kilo Code</b></summary>
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.

</details>

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-sideSync
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 toolsSync
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 GroundingFlash

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_KEYRequired. 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 dependencies
npm run build        # Compile TypeScript
npm run dev          # Watch mode
npm run dev:run      # Run with --watch and .env
npm run start        # Run compiled server
npm run type-check   # Type-check src + tests
npm run lint         # ESLint
npm run test         # Run test suite
npm run format       # Prettier
npm run inspector    # MCP Inspector
npm 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.

常见问题

Code Review Analyst 是什么?

基于 Gemini 的代码审查分析 MCP 服务器,可帮助发现问题、评估风险并提出改进建议。

相关 Skills

网页构建器

by anthropics

Universal
热门

面向复杂 claude.ai HTML artifact 开发,快速初始化 React + Tailwind CSS + shadcn/ui 项目并打包为单文件 HTML,适合需要状态管理、路由或多组件交互的页面。

在 claude.ai 里做复杂网页 Artifact 很省心,多组件、状态和路由都能顺手搭起来,React、Tailwind 与 shadcn/ui 组合效率高、成品也更精致。

编码与调试
未扫描172.7k

网页应用测试

by anthropics

Universal
热门

用 Playwright 为本地 Web 应用编写自动化测试,支持启动开发服务器、校验前端交互、排查 UI 异常、抓取截图与浏览器日志,适合调试动态页面和回归验证。

借助 Playwright 一站式验证本地 Web 应用前端功能,调 UI 时还能同步查看日志和截图,定位问题更快。

编码与调试
未扫描172.7k

前端设计

by anthropics

Universal
热门

面向组件、页面、海报和 Web 应用开发,按鲜明视觉方向生成可直接落地的前端代码与高质感 UI,适合做 landing page、Dashboard 或美化现有界面,避开千篇一律的 AI 审美。

想把页面做得既能上线又有设计感,就用前端设计:组件到整站都能产出,难得的是能避开千篇一律的 AI 味。

编码与调试
未扫描172.7k

相关 MCP Server

GitHub

编辑精选

by GitHub

热门

GitHub 是 MCP 官方参考服务器,让 Claude 直接读写你的代码仓库和 Issues。

这个参考服务器解决了开发者想让 AI 安全访问 GitHub 数据的问题,适合需要自动化代码审查或 Issue 管理的团队。但注意它只是参考实现,生产环境得自己加固安全。

编码与调试
89.7k

by Context7

热门

Context7 是实时拉取最新文档和代码示例的智能助手,让你告别过时资料。

它能解决开发者查找文档时信息滞后的问题,特别适合快速上手新库或跟进更新。不过,依赖外部源可能导致偶尔的数据延迟,建议结合官方文档使用。

编码与调试
60.2k

by tldraw

热门

tldraw 是让 AI 助手直接在无限画布上绘图和协作的 MCP 服务器。

这解决了 AI 只能输出文本、无法视觉化协作的痛点——想象让 Claude 帮你画流程图或白板讨论。最适合需要快速原型设计或头脑风暴的开发者。不过,目前它只是个基础连接器,你得自己搭建画布应用才能发挥全部潜力。

编码与调试
49.9k

评论