code-lens
Enables web search with Google Search Grounding for up-to-date information retrieval.
Provides code analysis, review, documentation, and logic verification using Google Gemini models.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@code-lensreview the diff in my PR for breaking changes"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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.
Related MCP server: gpal
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-lensOr with Docker Compose:
GEMINI_API_KEY=your-api-key docker compose upClient 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@latestOr 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@latestOr 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 changesRun
analyze_pr_impactto assess severity and breaking changesRun
generate_review_summaryfor a risk rating and merge recommendationRun
detect_api_breaking_changesto check for public API breakageRun
generate_test_planto produce prioritized test cases
Single-File Analysis
Call
load_fileto cache a source fileRun
refactor_codefor structural improvement suggestionsRun
detect_code_smellsfor Fowler-taxonomy anti-patternsRun
generate_documentationto generate JSDoc/TSDoc stubsUse
ask_about_codefor natural-language Q&A about the fileUse
verify_logicto verify algorithms with code execution
Performance Audit
Call
generate_diffon a performance-sensitive changeRun
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, notificationsRequest 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 |
| Capture git diff (unstaged/staged) and cache server-side | — | Sync |
| Assess severity, categories, breaking changes, rollback complexity |
| Flash |
| PR summary, risk rating, merge recommendation |
| Flash |
| Prioritized test cases and coverage guidance |
| Flash |
| Big-O complexity analysis and degradation detection |
| Flash |
| Detect breaking API/interface changes |
| Flash |
| Cache a source file for analysis tools | — | Sync |
| Complexity, duplication, naming, grouping suggestions |
| Flash |
| Structural code smells (Fowler taxonomy) |
| Flash |
| JSDoc/TSDoc/docstring stubs for public exports |
| Flash |
| Natural-language Q&A about a cached file |
| Flash |
| Verify algorithms via Gemini code execution sandbox |
| Flash |
| Google Search with Grounding | — | Flash |
Resources
URI | Description | MIME |
| Complete server usage instructions |
|
| Tool reference: models, params, outputs, data flow |
|
| Recommended workflows and tool sequences |
|
| Runtime configuration and limits |
|
| Per-tool details (parameterized) |
|
| Most recently generated diff |
|
| Most recently loaded source file |
|
Prompts
Prompt | Description |
| Full server instructions: capabilities, tools, resources, constraints |
| Workflow guide for a specific tool and focus area |
| Recommended tool pipeline based on change type |
| Goal-based tool pipeline for single-file analysis |
| Full prerequisite chain for a given tool |
MCP Capabilities
Tool Annotations
All tools expose MCP tool annotations:
Annotation | Used |
| Yes |
| Yes |
| Yes |
| Yes |
Structured Output
All Gemini-powered tools return validated structuredContent alongside text content, using Zod v4 output schemas.
Configuration
Variable | Default | Description |
| — | Required. Gemini API key. Falls back to |
|
| Override the default Gemini model for all tools. |
|
| Maximum diff size in characters. |
|
| Maximum concurrent Gemini API calls. |
|
| Maximum concurrent batch Gemini calls. |
|
| Wait timeout for concurrency semaphore. |
|
| Default task result retention in milliseconds when the request does not specify |
|
| Upper bound for request-provided task TTL. Set to |
|
| Enable Gemini batch mode. |
|
| Safety filter threshold ( |
|
| Enable Gemini context caching for large diffs. |
|
| Cache TTL in seconds (when caching is enabled). |
CLI Flags
npx @j0hanz/code-lens-mcp@latest --model gemini-2.5-flash --max-diff-chars 200000Flag | Env Equivalent |
|
|
|
|
Security
Control | Status |
Input validation | Zod v4 schema validation on all tool inputs |
Path safety |
|
Stdout safety | Logs to stderr; stdout reserved for MCP protocol |
Non-root container | Docker runs as dedicated |
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 detectionBuild and Release
CI:
.github/workflows/release.ymlDocker: Multi-stage build (
Dockerfile) withnode:24-alpineDocker Compose:
docker-compose.ymlnpm: 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.
Maintenance
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/j0hanz/code-lens'
If you have feedback or need assistance with the MCP directory API, please join our Discord server