
Code Lens
io.github.j0hanz由 GitHub 账号 j0hanz 发布v0.12.0更新于 Oct 24, 2026
Gemini-powered MCP server for code analysis.
概览
Code Lens 是一个本地 MCP 服务器,借助 Google Gemini 审查代码差异和拉取请求、分析源文件并生成文档。
- 可以做什么
- 捕获 git 差异并审查:评估 PR 影响、总结风险与合并建议、检测破坏性 API 变更、生成测试计划、分析时间空间复杂度。加载源文件后分析:给出重构建议、检测代码坏味道、生成 JSDoc/TSDoc 注释桩、就代码进行自然语言问答。通过 Gemini 代码执行沙箱验证算法逻辑。使用 Google Search 联网检索最新文档或 API 参考。
- 适用场景
- 适合在合并前让助手审查待提交的改动、对单个文件做重构与文档审计,或检查某次改动是否降低性能、破坏公开 API。
- 运行要求
- 通过 npx(需 Node.js 24 或更高版本)或 Docker 镜像以 stdio 在本地运行。需要 Gemini API 密钥,通过 GEMINI_API_KEY 提供,可用 GOOGLE_API_KEY 作为回退。需要访问 Gemini API 的网络连接。
安装
在 SourceWeft 中
- 打开 控制台中的 Code Lens,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Code Lens MCP Server
[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_filecan run via MCP tasks with polling, cancellation, and progress updates
Requirements
- Node.js >= 24
- A Gemini API key (
GEMINI_API_KEYorGOOGLE_API_KEY)
Quick Start
Docker
Or with Docker Compose:
Client Configuration
Install in VS Code
Add to .vscode/mcp.json:
Or install via CLI:
For more info, see VS Code MCP docs.
Install in VS Code Insiders
Add to .vscode/mcp.json:
Or install via CLI:
For more info, see VS Code Insiders MCP docs.
Install in Claude Desktop
Add to claude_desktop_config.json:
For more info, see Claude Desktop MCP docs.
Install in Windsurf
Add to ~/.codeium/windsurf/mcp_config.json:
For more info, see Windsurf MCP docs.
Install in Warp
For more info, see Warp MCP docs.
Install in Augment
Add to your VS Code settings.json under augment.advanced:
For more info, see Augment MCP docs.
Install in Roo Code
For more info, see Roo Code MCP docs.
Install in Kilo Code
For more info, see Kilo Code MCP docs.
Use Cases
PR Review Pipeline
- Call
generate_diffto capture unstaged or staged changes - Run
analyze_pr_impactto assess severity and breaking changes - Run
generate_review_summaryfor a risk rating and merge recommendation - Run
detect_api_breaking_changesto check for public API breakage - Run
generate_test_planto produce prioritized test cases
Single-File Analysis
- Call
load_fileto cache a source file - Run
refactor_codefor structural improvement suggestions - Run
detect_code_smellsfor Fowler-taxonomy anti-patterns - Run
generate_documentationto generate JSDoc/TSDoc stubs - Use
ask_about_codefor natural-language Q&A about the file - Use
verify_logicto verify algorithms with code execution
Performance Audit
- Call
generate_diffon a performance-sensitive change - Run
analyze_time_space_complexityto detect Big-O degradation
Research
- Use
web_searchfor up-to-date documentation or API references via Google Search with Grounding
Architecture
Request Lifecycle
Task Lifecycle
generate_diffandload_fileare sync-only. All other tools advertisetaskSupport: optional.- Requestors may supply a task TTL. The server uses that value up to
MAX_TASK_TTL_MS, or falls back toTASK_TTL_MSwhen omitted. - Cancelled tasks remain terminal as
cancelled, andtasks/resultreturns a cancellation-shaped tool result.
MCP Surface
Tools
Resources
Prompts
MCP Capabilities
Tool Annotations
All tools expose MCP tool annotations:
Structured Output
All Gemini-powered tools return validated structuredContent alongside text content, using Zod v4 output schemas.
Configuration
CLI Flags
Security
Development
Build and Release
- CI:
.github/workflows/release.yml - Docker: Multi-stage build (
Dockerfile) withnode:24-alpine - Docker Compose:
docker-compose.yml - npm: Published as
@j0hanz/code-lens-mcp
Troubleshooting
- Missing API key: Set
GEMINI_API_KEYorGOOGLE_API_KEYin your environment or client configenvblock. - "E_NO_DIFF" errors: Call
generate_diffbefore running any diff-based review tool. - "E_NO_FILE" errors: Call
load_filebefore 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
- Google Gemini — LLM backend (
@google/genai) - Model Context Protocol SDK — MCP framework (
@modelcontextprotocol/sdk) - Zod — Schema validation (
zodv4) - parse-diff — Diff parsing
Contributing and License
MIT License. See LICENSE for details.
Contributions welcome via pull requests.
来源:README.md,提交 576b329
工具
0版本历史
1- v0.12.0最新Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。