CodeLens — Análise de Código Alimentada por IA
amzaandrei/codelens
Análise inteligente de código com MCP multi-servidor e revisão em tempo real
Ver no GitHubMCP server que oferece análise estruturada de código em tempo real usando Claude Sonnet, combinando dois servidores independentes para avaliar qualidade, segurança e métricas. Interface Next.js 15 / React 19 com streaming de resultados via Server-Sent Events.
Instalação
npx convez-ai amzaandrei/codelens1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
Casos de uso
- Revisar qualidade e segurança de snippets de código
- Identificar code smells e vulnerabilidades automaticamente
- Aprender padrões de arquitetura MCP multi-servidor
Veredito

Projeto exemplar de implementação MCP production-ready em TypeScript. Demonstra padrão crítico de agregação multi-servidor e agentic tool-use, sendo referência técnica para arquitetos que precisam escalar assistentes IA com múltiplas capacidades especializadas.
README
A tradução para o português deste README ainda está na fila.
CodeLens
AI-powered code analysis built on the Model Context Protocol (MCP).
Paste any code snippet and get an instant, structured review — quality metrics, code smells, and a full security audit — powered by two custom MCP servers whose tools are aggregated and driven by Claude Sonnet 4.6 (claude-sonnet-4-6).

Highlights
- Two custom MCP servers, built from scratch — independent TypeScript processes on
@modelcontextprotocol/sdkexposing six analysis tools over JSON-RPC (stdio). - Multi-server tool aggregation — a single host connects to both servers and merges their tools into one set for the model; the same pattern Claude Desktop and IDEs use to combine many servers.
- Agentic tool-use loop — Claude autonomously decides which tools to call and iterates until its review is complete.
- Real-time streaming UI — every
tool_callandtool_resultstreams to the browser over Server-Sent Events as it happens. - Production-grade frontend — Next.js 15 / React 19 App Router, Tailwind CSS v4, shadcn/ui, with light & dark themes.
What makes it interesting
The headline feature is multi-server tool aggregation — the thing MCP is actually built for.
CodeLens runs two completely independent MCP servers (one for code quality, one for security). The Next.js route connects to both, merges their tool schemas into a single tool set, and hands that set to Claude. Claude doesn't know or care that the tools come from different processes — it just sees six tools and calls whichever it needs. Each call is then dispatched back to the server that owns it.
This is the pattern real MCP hosts (Claude Desktop, IDEs) use to combine many servers into one assistant. Adding a third server is purely additive: register it, and its tools show up in the same aggregated set with zero changes to the agent loop.
Architecture
┌──────────────────────────────────────────────────────────────┐
│ Browser UI — React 19 │
│ paste code ──► ◄── live SSE: tool calls + review │
└───────────────────────────┬──────────────────────────────────┘
│ POST /api/analyze (SSE stream)
┌───────────────────────────▼──────────────────────────────────┐
│ Next.js route = MCP host + Anthropic client │
│ │
│ 1. spawn + connect to every MCP server over stdio │
│ 2. merge their tool schemas into ONE aggregated tool set │
│ 3. give the merged set to Claude │
│ 4. dispatch each tool call back to the server that owns it │
└───────┬─────────────────────────────────────┬────────────────┘
│ stdio / JSON-RPC │ Messages API
▼ ▼
┌────────────────────────────┐ ┌──────────────────────┐
│ MCP servers (aggregated) │ │ Claude Sonnet 4.6 │
│ │ │ agentic tool-use │
│ analysis server │ │ loop │
│ • analyze_complexity │ └──────────────────────┘
│ • detect_code_smells │
│ • extract_structure │
│ │
│ security server │
│ • scan_secrets │
│ • detect_vulnerabilities │
│ • check_crypto │
└────────────────────────────┘
Request lifecycle
- The user submits code from the browser; the API route opens an SSE stream back to it.
- The route spawns each MCP server as a subprocess and connects over stdio.
- It calls
listTools()on every server and merges the results into one tool list, recording which server owns each tool (toolToClientmap). - The merged tool set is handed to Claude through the Anthropic Messages API.
- Claude runs an agentic loop: it calls tools, the route dispatches each call to the owning server, returns the JSON result, and Claude continues until it has everything it needs.
- Every step —
tools_loaded, eachtool_call, eachtool_result, and the final streamed review — is pushed to the browser as it happens.
MCP servers & tools
analysis server — code quality and structure
| Tool | Description |
|---|---|
analyze_complexity | LOC, function/class count, cyclomatic complexity estimate, max nesting depth |
detect_code_smells | TODOs, debug statements, magic numbers, long functions, deep nesting — with a 0–100 quality score |
extract_structure | Imports, exports, function signatures, class and interface names |
security server — static application security testing
| Tool | Description |
|---|---|
scan_secrets | Hardcoded secrets: API keys, private keys, AWS keys, Slack tokens, JWTs, credentials in string literals |
detect_vulnerabilities | Injection-class flaws: eval/new Function, command injection, SQL injection, XSS sinks (innerHTML, dangerouslySetInnerHTML, document.write) |
check_crypto | Weak cryptography: MD5/SHA-1, insecure Math.random(), broken ciphers (DES/RC4), ECB mode, hardcoded IVs/salts |
Each server is a standalone process speaking MCP over stdio — runnable on its own, testable in isolation, and reusable by any MCP host (not just this app).
Stack
- MCP servers — TypeScript,
@modelcontextprotocol/sdk, two independent processes over stdio - Web app — Next.js 15, React 19, App Router, Tailwind CSS v4, shadcn/ui
- AI — Anthropic SDK, Claude Sonnet 4.6 (
claude-sonnet-4-6), agentic tool-use loop - Streaming — Server-Sent Events (SSE) for live tool-call and review updates
Getting started
# 1. Clone
git clone https://github.com/amzaandrei/codelens
cd codelens
# 2. Install & build both MCP servers and the web app
npm run setup
# 3. Add your Anthropic API key
cp web/.env.local.example web/.env.local
# edit web/.env.local and set ANTHROPIC_API_KEY=sk-ant-...
# 4. Start the dev server
npm run dev
# → http://localhost:3000
Click Analyze on the bundled example (it ships with deliberate quality and security issues) to watch all six tools run across both servers.
Each server runs standalone
The MCP servers don't depend on the web app — they're reusable by any MCP host (Claude Desktop, an IDE, or the MCP Inspector):
cd mcp-server-security && npm install && npm run build
node dist/index.js # now speaking MCP over stdio
Project structure
codelens/
├── mcp-server/ # "analysis" MCP server — code quality
│ └── src/
│ ├── index.ts # Server entry, tool registry
│ └── tools/
│ ├── analyzeComplexity.ts
│ ├── detectCodeSmells.ts
│ └── extractStructure.ts
├── mcp-server-security/ # "security" MCP server — SAST
│ └── src/
│ ├── index.ts # Server entry, tool registry
│ └── tools/
│ ├── scanSecrets.ts
│ ├── detectVulnerabilities.ts
│ ├── checkCrypto.ts
│ └── types.ts # Shared finding/risk types + summarizer
└── web/ # Next.js frontend
└── src/
├── app/
│ ├── page.tsx # Main UI
│ └── api/analyze/route.ts # MCP host: aggregates both servers + drives Claude
└── components/
├── CodeEditor.tsx
├── ToolCallPanel.tsx # Live multi-server tool-call visualiser
└── AnalysisResult.tsx
License
MIT — see LICENSE.