npm @j0hanz/code-lens-mcpstdioupdated 6mo ago
Gemini-powered MCP server for automated code review, analysis, and documentation.
Was kannst du mit Code Lens machen?
Code Lens MCP Server
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
{
"mcpServers": {
"code-lens": {
"command": "npx",
"args": ["-y", "@j0hanz/code-lens-mcp@latest"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}
Docker
docker run -i --rm -e GEMINI_API_KEY="your-api-key" ghcr.io/j0hanz/code-lens
Or with Docker Compose:
GEMINI_API_KEY=your-api-key docker compose up
Client Configuration
Add to .vscode/mcp.json:
{
"servers": {
"code-lens": {
"command": "npx",
"args": ["-y", "@j0hanz/code-lens-mcp@latest"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}
Or install via CLI:
code --add-mcp '{"name":"code-lens","command":"npx","args":["-y","@j0hanz/code-lens-mcp@latest"]}'
For more info, see VS Code MCP docs.
Add to .vscode/mcp.json:
{
"servers": {
"code-lens": {
"command": "npx",
"args": ["-y", "@j0hanz/code-lens-mcp@latest"],
"env": {
"GEMINI_API_KEY": "your-api-key"
}
}
}
}
Or install via CLI:
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.
Add to ~/.cursor/mcp.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.
Add to mcp.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.
{
"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.
{
"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.
Add to claude_desktop_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 Desktop MCP docs.
claude mcp add code-lens -- npx -y @j0hanz/code-lens-mcp@latest
Or add to config:
{
"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.
Add to ~/.codeium/windsurf/mcp_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 Windsurf MCP docs.
amp mcp add code-lens -- npx -y @j0hanz/code-lens-mcp@latest
Or add to config:
{
"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.
Add to cline_mcp_settings.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.
Add to ~/.codex/config.yaml:
{
"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.
Add to .vscode/mcp.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.
{
"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.
Add to .kiro/settings/mcp.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.
Add to ~/.gemini/settings.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.
Add to ~/.config/zed/settings.json:
{
"context_servers": {
"code-lens": {
"settings": {
"command": "npx",
"args": ["-y", "@j0hanz/code-lens-mcp@latest"]
}
}
}
}
For more info, see Zed MCP docs.
Add to your VS Code settings.json under augment.advanced:
{
"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.
{
"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.
{
"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
- 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
[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
[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_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
| Tool | Description | Prerequisite | Model |
|---|---|---|---|
generate_diff |
Capture git diff (unstaged/staged) and cache server-side | β | Sync |
analyze_pr_impact |
Assess severity, categories, breaking changes, rollback complexity | generate_diff |
Flash |
generate_review_summary |
PR summary, risk rating, merge recommendation | generate_diff |
Flash |
generate_test_plan |
Prioritized test cases and coverage guidance | generate_diff |
Flash |
analyze_time_space_complexity |
Big-O complexity analysis and degradation detection | generate_diff |
Flash |
detect_api_breaking_changes |
Detect breaking API/interface changes | generate_diff |
Flash |
load_file |
Cache a source file for analysis tools | β | Sync |
refactor_code |
Complexity, duplication, naming, grouping suggestions | load_file |
Flash |
detect_code_smells |
Structural code smells (Fowler taxonomy) | load_file |
Flash |
generate_documentation |
JSDoc/TSDoc/docstring stubs for public exports | load_file |
Flash |
ask_about_code |
Natural-language Q&A about a cached file | load_file |
Flash |
verify_logic |
Verify algorithms via Gemini code execution sandbox | load_file |
Flash |
web_search |
Google Search with Grounding | β | Flash |
Resources
| URI | Description | MIME |
|---|---|---|
internal://instructions |
Complete server usage instructions | text/markdown |
internal://tool-catalog |
Tool reference: models, params, outputs, data flow | text/markdown |
internal://workflows |
Recommended workflows and tool sequences | text/markdown |
internal://server-config |
Runtime configuration and limits | text/markdown |
internal://tool-info/{toolName} |
Per-tool details (parameterized) | text/markdown |
internal://diff/current |
Most recently generated diff | text/x-patch |
internal://file/current |
Most recently loaded source file | text/plain |
Prompts
| Prompt | Description |
|---|---|
get-help |
Full server instructions: capabilities, tools, resources, constraints |
review-guide |
Workflow guide for a specific tool and focus area |
select-workflow |
Recommended tool pipeline based on change type |
analyze-file |
Goal-based tool pipeline for single-file analysis |
tool-chain |
Full prerequisite chain for a given tool |
MCP Capabilities
Tool Annotations
All tools expose MCP tool annotations:
| Annotation | Used |
|---|---|
readOnlyHint |
Yes |
destructiveHint |
Yes |
idempotentHint |
Yes |
openWorldHint |
Yes |
Structured Output
All Gemini-powered tools return validated structuredContent alongside text content, using Zod v4 output schemas.
Configuration
| Variable | Default | Description |
|---|---|---|
GEMINI_API_KEY |
β | Required. Gemini API key. Falls back to GOOGLE_API_KEY. |
GEMINI_MODEL |
gemini-3-flash-preview |
Override the default Gemini model for all tools. |
MAX_DIFF_CHARS |
120000 |
Maximum diff size in characters. |
MAX_CONCURRENT_CALLS |
10 |
Maximum concurrent Gemini API calls. |
MAX_CONCURRENT_BATCH_CALLS |
2 |
Maximum concurrent batch Gemini calls. |
MAX_CONCURRENT_CALLS_WAIT_MS |
2000 |
Wait timeout for concurrency semaphore. |
TASK_TTL_MS |
300000 |
Default task result retention in milliseconds when the request does not specify task.ttl. |
MAX_TASK_TTL_MS |
3600000 |
Upper bound for request-provided task TTL. Set to 0 to remove the cap. |
GEMINI_BATCH_MODE |
off |
Enable Gemini batch mode. |
GEMINI_HARM_BLOCK_THRESHOLD |
BLOCK_NONE |
Safety filter threshold (BLOCK_NONE, BLOCK_ONLY_HIGH, BLOCK_MEDIUM_AND_ABOVE, BLOCK_LOW_AND_ABOVE). |
GEMINI_DIFF_CACHE_ENABLED |
false |
Enable Gemini context caching for large diffs. |
GEMINI_DIFF_CACHE_TTL_S |
3600 |
Cache TTL in seconds (when caching is enabled). |
CLI Flags
npx @j0hanz/code-lens-mcp@latest --model gemini-2.5-flash --max-diff-chars 200000
| Flag | Env Equivalent |
|---|---|
--model, -m |
GEMINI_MODEL |
--max-diff-chars |
MAX_DIFF_CHARS |
Security
| Control | Status |
|---|---|
| Input validation | Zod v4 schema validation on all tool inputs |
| Path safety | load_file restricts paths to workspace root |
| Stdout safety | Logs to stderr; stdout reserved for MCP protocol |
| Non-root container | Docker runs as dedicated mcp user |
Development
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) 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.
Installation
Code Lens zu deinem Client hinzufΓΌgen. WΓ€hl den, den du nutzt.
claude mcp add code-lens-mcp -- npx -y @j0hanz/code-lens-mcpcodex mcp add code-lens-mcp -- npx -y @j0hanz/code-lens-mcpamp mcp add code-lens-mcp -- npx -y @j0hanz/code-lens-mcp{
"mcpServers": {
"code-lens-mcp": {
"command": "npx",
"args": [
"-y",
"@j0hanz/code-lens-mcp"
]
}
}
}Add to `claude_desktop_config.json`, then restart Claude Desktop.
{
"mcpServers": {
"code-lens-mcp": {
"command": "npx",
"args": [
"-y",
"@j0hanz/code-lens-mcp"
]
}
}
}Add to `~/.cursor/mcp.json`, or `.cursor/mcp.json` for a single project.
code --add-mcp '{"name":"code-lens-mcp","command":"npx","args":["-y","@j0hanz/code-lens-mcp"]}'Or add the block manually to `.vscode/mcp.json` under `servers`.
{
"mcpServers": {
"code-lens-mcp": {
"command": "npx",
"args": [
"-y",
"@j0hanz/code-lens-mcp"
]
}
}
}Add to `~/.codeium/windsurf/mcp_config.json`.
{
"mcpServers": {
"code-lens-mcp": {
"command": "npx",
"args": [
"-y",
"@j0hanz/code-lens-mcp"
]
}
}
}Add to `cline_mcp_settings.json` via the MCP Servers panel.
{
"mcpServers": {
"code-lens-mcp": {
"command": "npx",
"args": [
"-y",
"@j0hanz/code-lens-mcp"
]
}
}
}Add to `~/.gemini/settings.json`.
{
"mcpServers": {
"code-lens-mcp": {
"type": "local",
"command": "npx",
"args": [
"-y",
"@j0hanz/code-lens-mcp"
],
"tools": [
"*"
]
}
}
}Add to `~/.copilot/mcp-config.json`, or run `/mcp add` inside the CLI.
{
"context_servers": {
"code-lens-mcp": {
"command": {
"path": "npx",
"args": [
"-y",
"@j0hanz/code-lens-mcp"
]
}
}
}
}Add to your Zed `settings.json`.
npx -y @j0hanz/code-lens-mcpRun `goose configure`, choose **Add Extension β Command-line Extension**, and paste this command.
13 Tools
Code Lens stellt einem verbundenen Agent 13 Tools bereit.
- generate_diff
- Capture git diff (unstaged/staged) and cache server-side
- analyze_pr_impact
- Assess severity, categories, breaking changes, rollback complexity
- generate_review_summary
- PR summary, risk rating, merge recommendation
- generate_test_plan
- Prioritized test cases and coverage guidance
- analyze_time_space_complexity
- Big-O complexity analysis and degradation detection
- detect_api_breaking_changes
- Detect breaking API/interface changes
- load_file
- Cache a source file for analysis tools
- refactor_code
- Complexity, duplication, naming, grouping suggestions
- detect_code_smells
- Structural code smells (Fowler taxonomy)
- generate_documentation
- JSDoc/TSDoc/docstring stubs for public exports
- ask_about_code
- Natural-language Q&A about a cached file
- verify_logic
- Verify algorithms via Gemini code execution sandbox
- web_search
- Google Search with Grounding
Score
77 / 100
Gut
- Dokumentation25/25
- Pflege19/25
- Vertrauen6/20
- Funktionsumfang15/15
- Installation12/15
- Documents what it does and how to connect
- Has a resolvable package or endpoint
- Exposes at least one tool, prompt or resource
- README has substantive content
- Includes a code example
- Documents its configuration
- Mentions credentials or security posture
- Last commit 176 days ago
- Has a release history
- Repository is not archived
- No licence detected
- Namespace verified in the official MCP registry
- Claimed by its owner
- Published under an organisation
- 13 tool(s) documented
- Provides prompt templates
- Provides resources
- 12 documented install method(s)
- Published to a package registry
- Offers a hosted endpoint β no local install
Versionsverlauf
| Versionen | VerΓΆffentlicht |
|---|---|
| 0.12.0Aktuell | 9. MΓ€rz 2026 |
| 0.11.0 | 9. MΓ€rz 2026 |
| 0.10.0 | 8. MΓ€rz 2026 |
| 0.9.5 | 6. MΓ€rz 2026 |
| 0.9.4 | 6. MΓ€rz 2026 |
| 0.9.3 | 5. MΓ€rz 2026 |
| 0.9.2 | 5. MΓ€rz 2026 |
| 0.9.1 | 5. MΓ€rz 2026 |