
Code Assistant
io.github.j0hanz由 GitHub 帳號 j0hanz 發布v2.0.0更新於 Oct 24, 2026
Gemini-powered MCP server for code analysis.
概覽
由 Gemini 驅動的本機 MCP 伺服器,用於審查差異與拉取請求、分析原始碼檔案並產生文件。
- 可以做什麼
- Code Assistant(Code Lens)透過 stdio 在本機執行,使用 Google Gemini 分析程式碼。它能擷取 git 差異,並產生 PR 影響評估、審查摘要、測試計畫、破壞性變更偵測以及 Big-O 複雜度分析。它也能快取原始碼檔案,用於重構建議、程式碼異味偵測、文件存根、自然語言問答,以及透過 Gemini 程式碼執行沙箱進行邏輯驗證。獨立的網路搜尋工具使用帶 Grounding 的 Google 搜尋。
- 適用情境
- 適合希望助理協助進行拉取請求審查、重構、文件撰寫或本機儲存庫複雜度檢查的情境。適用於在合併決策前分析差異與檔案,以及需要透過網頁搜尋取得最新文件或 API 參考的工作流程。
- 執行需求
- 需要 Node.js 24 或更新版本,或 Docker。需要以 GEMINI_API_KEY 提供的 Gemini API 金鑰(可回退到 GOOGLE_API_KEY)。需要存取 Gemini API 的網路連線。選用設定包括 GEMINI_MODEL、MAX_DIFF_CHARS 與任務 TTL 變數。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Code Assistant,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
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- v2.0.0最新Sep 16, 2026
評分
已滿足適用檢查項的 40%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
請在儲存庫或註冊中心條目中宣告授權條款。