Skip to content
Code Guide

8. MCP Servers

MCP (Model Context Protocol) is a standard for connecting AI models to external tools and data sources.

Without MCPWith MCP
Limited to built-in toolsExtensible tool ecosystem
Claude guesses about external dataClaude queries real data
Generic code understandingDeep semantic analysis
┌─────────────────────────────────────────────────────────┐
│ MCP ARCHITECTURE │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────┐ │
│ │ Claude Code │ │
│ └──────┬──────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────┐ │
│ │ MCP Protocol │ │
│ └──────────────────────┬──────────────────────┘ │
│ │ │
│ ┌───────────────┼───────────────┐ │
│ ▼ ▼ ▼ │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ Serena │ │ Context7 │ │ Postgres │ │
│ │(Semantic) │ │ (Docs) │ │(Database) │ │
│ └───────────┘ └───────────┘ └───────────┘ │
│ │
└─────────────────────────────────────────────────────────┘

🆕 Since January 2026: MCP can now deliver interactive UIs alongside traditional text responses.

Traditional AI interactions require repeated prompts for data exploration:

Without MCP Apps:

You: "Show me customer data"
Claude: "Here are 500 customers [text list]"
You: "Sort by revenue"
Claude: "Here's the sorted list [text]"
You: "Filter to last 30 days"
Claude: "Here's the filtered list [text]"
You: "Show me the top 10"
... (multiple prompt cycles)

With MCP Apps:

You: "Show me customer data"
Claude: [Renders interactive dashboard with sorting, filtering, date pickers]
You: [Sort, filter, drill-down directly in UI - no additional prompts]

MCP Apps enable MCP servers to deliver interactive interfaces that render directly in your conversation:

  • Dashboards: Charts with filtering, drill-down, export
  • Configuration wizards: Forms with dependent fields and validation
  • Document viewers: PDFs with inline highlights and annotations
  • Real-time monitors: Live metrics updating without re-running tools

At launch (January 26, 2026), 9 interactive tools are available:

ToolWhat It Does
AsanaCreate project timelines, manage tasks visible to teams
SlackDraft formatted messages with preview before posting
FigmaConvert text into flowcharts, Gantt charts in FigJam
AmplitudeBuild analytics charts, explore trends interactively
BoxSearch files, preview documents inline
CanvaCreate presentations with real-time design customization
ClayResearch companies, find contacts, draft outreach
HexQuery data with interactive charts and tables
monday.comManage work, update boards, visualize progress

Coming soon: Salesforce (Agentforce 360), Claude Cowork integration

Access: claude.ai/directory (Pro/Max/Team/Enterprise plans)

PlatformSupportHow to Use
Claude Desktop✅ Nowclaude.ai/directory - connect interactive tools
Claude Cowork🔄 ComingAgentic workflows with file/project access
VS Code✅ InsidersInstall Insiders build, configure MCP Apps
ChatGPT🔄 RolloutWeek of Jan 26, 2026
Goose✅ NowOpen-source alternative with UI support
Claude Code CLI❌ NoTerminal is text-only (no UI rendering)

Direct impact: None - Claude Code CLI cannot render interactive UIs in the terminal.

Indirect benefits:

  1. Ecosystem awareness: Understand where MCP is heading (interactive agentic workflows)
  2. Hybrid workflows: Use Claude Desktop for visual exploration → Claude Code CLI for automation
  3. MCP server development: If building custom servers, Apps is now an option
  4. Context for tools: Some MCP servers may advertise UI capabilities (visible in metadata)

Example hybrid workflow:

1. Claude Desktop: Use Amplitude MCP App to explore analytics interactively
2. Identify patterns visually (e.g., "EU region shows 30% growth")
3. Claude Code CLI: Automate data export and reporting based on findings

MCP Apps is built on the Model Context Protocol (open standard by Anthropic):

  • Open specification: SEP-1865 on GitHub
  • Co-authored by: OpenAI, Anthropic, MCP-UI creators
  • SDK: @modelcontextprotocol/ext-apps (npm)
  • “Build once, deploy everywhere”: Works in Claude, VS Code, ChatGPT, Goose

Deep dive: See guide/architecture.md:656 for technical architecture, security model, and SDK details.


MCP Server Catalog (click to expand)

Purpose: Deep code understanding through semantic analysis, indexing, and persistent memory.

Why Serena matters: Claude Code has no built-in indexation (unlike Cursor). Serena fills this gap by indexing your codebase for faster, smarter searches. It also provides session memory — context that persists across conversations.

Key Features:

FeatureDescription
IndexationPre-indexes your codebase for efficient symbol lookup
Project MemoryStores context in .serena/memories/ between sessions
OnboardingAuto-analyzes project structure on first run

Tools:

ToolDescription
find_symbolFind functions, classes, methods by name
get_symbols_overviewGet file structure overview
search_for_patternRegex search across codebase
find_referencing_symbolsFind all usages of a symbol
replace_symbol_bodyReplace function/class body
write_memorySave context for future sessions
read_memoryRetrieve saved context
list_memoriesList all stored memories

Session Memory Workflow:

# Start of session
list_memories() → See what context exists
read_memory("auth_architecture") → Load relevant context
# During work
write_memory("api_refactor_plan", "...") → Save decisions for later
# End of session
write_memory("session_summary", "...") → Persist progress

Setup:

Terminal window
# Basic indexation (first run)
uvx --from git+https://github.com/oraios/serena serena project index
# Force full rebuild (if index is corrupted or outdated)
uvx --from git+https://github.com/oraios/serena serena project index --force-full
# Incremental indexation (faster after initial index)
uvx --from git+https://github.com/oraios/serena serena project index --incremental
# Parallel processing (recommended: 50-75% of CPU cores)
uvx --from git+https://github.com/oraios/serena serena project index --parallel 4
# Verbose mode (see progress details)
uvx --from git+https://github.com/oraios/serena serena project index --verbose --force-full
# View all options
uvx --from git+https://github.com/oraios/serena serena project index --help

Indexation Options:

OptionDescriptionUse When
--force-fullComplete rebuild of indexCorrupted index, major codebase changes
--incrementalUpdate only changed filesRegular maintenance after initial index
--parallel NUse N CPU coresLarge codebases (use 50-75% of cores)
--verboseShow detailed progressDebugging indexation issues

Cache Location: Index stored in .serena/cache/typescript/ (add to .gitignore)

Important Notes:

  • Deprecated command: serena index-project → Use serena project index instead
  • First run: Use basic serena project index (auto-detects full rebuild)
  • Regular updates: Use --incremental for faster re-indexation
  • Performance: --parallel 4 on 8-core machine = ~60% faster indexation

Sources: Serena DocsGitHub IssuesOptimization Guide

Use when:

  • Navigating large codebases (>10k lines)
  • Need context to persist across sessions
  • Understanding symbol relationships
  • Refactoring across files

Source: Serena GitHub

Purpose: Privacy-first semantic code search with call graph analysis.

Why grepai is recommended: It’s fully open-source, runs entirely locally using Ollama embeddings (no cloud/privacy concerns), and offers call graph analysis — trace who calls what function and visualize dependencies. This combination makes it the best choice for most semantic search needs.

Key Features:

FeatureDescription
Semantic searchFind code by natural language description
Call graphTrace callers, callees, and full dependency graphs
Privacy-firstUses Ollama locally (no cloud)
Background indexinggrepai watch daemon keeps index fresh

Example:

Terminal window
# Semantic search (finds code by meaning, not exact text)
grepai search "user authentication flow"
# Who calls this function?
grepai trace callers "createSession"
# → Lists all 23 files that call createSession with context
# What does this function call?
grepai trace callees "SessionProvider"
# Full dependency graph
grepai trace graph "createSession" --depth 3

MCP Tools Available:

ToolDescription
grepai_searchNatural language semantic search
grepai_trace_callersFind all callers of a function
grepai_trace_calleesFind all functions called by a function
grepai_trace_graphGenerate call graph
grepai_index_statusCheck indexation status

Setup:

Terminal window
# 1. Install Ollama and embedding model
brew install ollama
brew services start ollama
ollama pull nomic-embed-text
# 2. Install grepai
curl -sSL https://raw.githubusercontent.com/yoanbernabeu/grepai/main/install.sh | sh
# 3. Initialize in your project
cd your-project
grepai init # Choose: ollama, nomic-embed-text, gob
# 4. Start indexing daemon
grepai watch &

Combined Workflow with Serena:

1. grepai search "payment validation" → Discover relevant files
2. Serena get_symbols_overview → Understand file structure
3. grepai trace callers "validatePayment" → See all dependencies
4. Serena find_symbol + replace_symbol_body → Precise editing

Use when:

  • Exploring unfamiliar codebases by intent
  • Understanding call dependencies before refactoring
  • Privacy is required (no cloud, all local)
  • Need to trace “who calls what” across the codebase

Performance vs Traditional Tools:

Search TypeToolTimeResults
Exact matchrg (ripgrep)~20msExact hits only
Exact matchgrep~45msExact hits only
Semanticgrepai~500msIntent-based matches

Key insight: grepai is ~25x slower than rg for exact matches, but finds results that pattern-based tools cannot discover.

Terminal window
# Know exact pattern → use rg (fast)
rg "createSession" --type ts
# Don't know exact name → use grepai (semantic)
grepai search "session creation logic"

Source: grepai GitHub

Blast-Radius Pattern (pre-refactoring workflow):

Before modifying any widely-used function, run a dependency query to enumerate all affected call sites — then decide whether to proceed. This named workflow prevents cascading breakage in large codebases.

Terminal window
# Step 1: Map all callers before touching a function
grepai trace callers "processPayment"
# → Returns: 14 call sites across 7 files
# Step 2: Check callees (what it depends on)
grepai trace callees "processPayment"
# → Returns: 3 downstream dependencies
# Step 3: Decide scope before writing a single line
# 14 callers + 3 deps = significant blast radius → plan the refactor first

Run this before starting any refactor touching a function used in 3+ places — not after hitting compile errors.


Purpose: Automatic persistent memory across Claude Code sessions via AI-compressed capture of tool usage and observations. Solves context loss without manual write_memory() calls.

FeatureValue
CaptureHooks into SessionStart, PostToolUse, Stop, SessionEnd
StorageSQLite + optional Chroma (port 8000 fallback: SQLite FTS)
WorkerBun process, port 37777, fail-open (dead worker never blocks work)
Progressive disclosure3 layers: search (50-100 tokens) → timeline → full details
Skills/mem-search, /smart-explore, /make-plan, /do, /timeline-report
Install/plugin marketplace add thedotmack/claude-mem
LicenseAGPL-3.0 + PolyForm Noncommercial (check for commercial use)
Stars26.5K (v10.6.3, 2026-03-30)

Security warning: GET /api/settings exposes API keys in plain text — set host: "127.0.0.1", never "0.0.0.0".

Hook coexistence gotcha: claude-mem installation overwrites existing settings.json hooks arrays. Back up before installing, then manually merge.

Cost: ~$5-15/month (heavy users). Switching compression model from Claude Haiku to Gemini 2.5 Flash saves ~86%.

Full coverage: See Memory Systems: claude-mem for full architecture breakdown, observation types, progressive disclosure workflow, privacy controls, and cost comparison table.

Source: GitHub: thedotmack/claude-mem (26.5K stars, AGPL-3.0)


GitHub: safishamsi/graphify | PyPI: graphifyy | Stars: 42K | License: MIT

Graphify converts a project directory into a persistent knowledge graph and injects a compact structural report (GRAPH_REPORT.md) into Claude Code. The assistant answers architecture questions by reading the pre-built graph instead of re-scanning raw files on each prompt. Initial extraction runs once; subsequent sessions query the graph at near-zero token cost.

How it works: Three passes per run:

  1. Local AST extraction — tree-sitter parses 25+ languages (Python, TS, Go, Rust, Java, etc.) into a call graph. No API cost, no network.
  2. Optional local transcription — faster-whisper transcribes audio/video locally.
  3. Parallel semantic extraction — Claude subagents process docs, PDFs, and images using your existing API key.

Results merge into a NetworkX graph clustered with the Leiden algorithm (topology-based — no vector embeddings). Every relationship is tagged EXTRACTED, INFERRED, or AMBIGUOUS. Three output files land in graphify-out/:

  • graph.html — interactive browser visualization
  • GRAPH_REPORT.md — god nodes, cross-file connections, suggested queries (injected into Claude)
  • graph.json — persistent, queryable without re-extraction

Install:

Terminal window
# Requires Python 3.10+. PyPI package: graphifyy (double-y). CLI: graphify.
uv tool install graphifyy && graphify install
# Always-on Claude Code integration (writes CLAUDE.md section + hook)
graphify claude install
# Build graph for current directory
/graphify .
# Incremental update (re-extracts only changed files, uses SHA256 hashing)
/graphify . --update
# Query the graph directly
/graphify query "what connects auth to the database layer?"
/graphify path "UserService" "DatabasePool"
/graphify explain "RateLimiter"
# Auto-rebuild on git commits (local AST only, zero API cost)
graphify hook install

Optional extras:

Terminal window
pip install "graphifyy[office]" # .docx, .xlsx support
pip install "graphifyy[video]" # .mp4, .mov, .mp3 transcription

Graphify vs GrepAI: Different layers, complementary. GrepAI (Ollama, local, free) handles real-time semantic lookups during active coding — fast, targeted, exact. Graphify pre-computes structural relationships across the full codebase (call chains, cross-file dependencies, community clusters) and replaces repeated file reads with a single compact report per session. GrepAI for discovery; Graphify for architectural reasoning and multi-hop questions.

Graphify vs claude-mem: Separate concerns. claude-mem stores what you discussed across sessions (decisions, tool calls, observations). Graphify maps what the codebase contains (structure, dependencies, concept clusters). No overlap — they address different layers of context loss.

Team workflow: Commit graphify-out/ (excluding manifest.json and cache/) to git so teammates inherit the pre-built graph without running extraction themselves.

Caveats:

  • Non-code files (docs, PDFs, images) are sent to your AI assistant’s API on first run — costs accumulate on large mixed-media repositories.
  • Without the post-commit hook, the graph drifts from the codebase.
  • Token efficiency claims from the author (71.5x–120x fewer tokens vs grep-based exploration) are self-reported benchmarks without independent reproduction. Treat as directional.
  • No native query language — graph queries go through the AI assistant, not Cypher/SQL.

Stats: 42K GitHub stars | v0.7.4 (2026-05-04) | Python ≥3.10 | MIT

Source: safishamsi/graphify


Now that you’ve seen Serena, grepai, claude-mem, and Graphify, here’s when to use each:

NeedToolExample
”What did we do yesterday?“claude-memAuto-inject previous session context
”Find function login”Serenafind_symbol --name "login"
”Who calls this function?“grepaigrepai trace callers "login"
”Record arch decision”Serenawrite_memory("auth_decision", "Use JWT")
”Find code that does X”grepaigrepai search "payment validation"
”Summary of all sessions”claude-memWeb dashboard at localhost:37777
”Exact pattern match”rg (native)rg "authenticate" --type ts
”What does this module depend on?”Graphify/graphify query "auth dependencies"
”Map the full codebase structure”Graphify/graphify . --update

Memory Stack Pattern (5 layers):

Layer 5: Session Capture → claude-mem (automatic)
Layer 4: Symbol Memory → Serena (manual decisions)
Layer 3: Semantic Search → grepai (discovery)
Layer 2: Structural Graph → Graphify (architecture, cross-file dependencies)
Layer 1: Exact Search → rg (native, fast)

Integrated Workflow Example:

Terminal window
# Scenario: Refactoring auth module after 3 days
# 1. AUTO CONTEXT (claude-mem)
# At session start, Claude auto-injects:
# "3 previous sessions explored auth module.
# Decision: Migrate to JWT.
# Files modified: auth.service.ts, session.middleware.ts"
# 2. ARCH DECISIONS (Serena)
serena list_memories
# → "auth_decision: Use JWT for stateless API (2026-02-07)"
serena read_memory("auth_decision")
# 3. SEMANTIC DISCOVERY (grepai)
grepai search "JWT token validation"
# → Finds validateJWT() in auth.service.ts
# 4. DEPENDENCIES (grepai trace)
grepai trace callers "validateJWT"
# → Called by: ApiGateway, AdminPanel, UserController
# 5. EXACT SEARCH (rg)
rg "validateJWT" --type ts -A 5

Result: Complete context without re-reading all files, architectural decisions preserved, dependencies mapped → safe refactoring.

Comparison: claude-mem vs Serena vs grepai:

Aspectclaude-memSerenagrepai
TriggerAuto (hooks)Manual APIManual CLI
StorageSQLite + Chroma.serena/memories/Ollama vectors
PurposeSession captureSymbol memorySemantic search
Dashboard✅ Web UI❌ No❌ No
Cost~$0.15/100 obsFreeFree
EffortZero (automatic)Manual commandsManual commands
QueryNatural languageKey lookupSemantic search
LicenseAGPL-3.0MITMIT

When to combine tools:

  • claude-mem + Serena: Automatic capture + manual architectural decisions
  • claude-mem + grepai: Session history + semantic code discovery
  • All 3: Complete memory stack (session + symbol + semantic + exact)

🔍 Search Tools Comparison: rg vs grepai vs Serena vs ast-grep vs claude-mem

Section titled “🔍 Search Tools Comparison: rg vs grepai vs Serena vs ast-grep vs claude-mem”

Now that you’ve seen individual tools, here’s how they compare and when to use each:

I need to…ToolExample
Find exact textrg (Grep)rg "authenticate" --type ts
Find by meaninggrepaigrepai search "user login flow"
Find function definitionSerenaserena find_symbol --name "login"
Find structural patternast-grepast-grep "async function $F"
See who calls functiongrepaigrepai trace callers "login"
Get file structureSerenaserena get_symbols_overview
Remember past sessionsclaude-memAuto-injected at session start
Featurerg (ripgrep)grepaiSerenaast-grepclaude-mem
Search typeRegex/textSemanticSymbol-awareAST structureSession history
Speed⚡ ~20ms🐢 ~500ms⚡ ~100ms🕐 ~200ms⚡ ~100ms
Setup✅ None⚠️ Ollama⚠️ MCP⚠️ npm⚠️ Plugin
Integration✅ Native⚠️ MCP⚠️ MCP⚠️ Plugin⚠️ Plugin
Call graph❌ No✅ Yes❌ No❌ No❌ No
Symbol tracking❌ No❌ No✅ Yes❌ No❌ No
Session memory❌ No❌ No✅ Manual❌ No✅ Automatic
Auto capture❌ No❌ No❌ No❌ No✅ Yes
Web dashboard❌ No❌ No❌ No❌ No✅ Yes

Use rg (ripgrep) when:

  • ✅ You know the exact text/pattern
  • ✅ Speed is critical (~20ms)
  • ✅ No setup complexity wanted
  • ❌ Don’t use for: conceptual searches, dependency tracing

Use grepai when:

  • ✅ Finding code by meaning/intent
  • ✅ Need to trace function calls (who calls what)
  • ✅ Privacy required (100% local with Ollama)
  • ❌ Don’t use for: exact text (use rg instead)

Use Serena when:

  • ✅ Refactoring across multiple files
  • ✅ Need symbol-aware navigation
  • ✅ Persistent context/memory needed
  • ❌ Don’t use for: simple text searches

Use ast-grep when:

  • ✅ Large-scale refactoring (>50k lines)
  • ✅ Framework migrations (React, Vue)
  • ✅ Finding structural patterns (async without try/catch)
  • ❌ Don’t use for: small projects, simple searches

Use claude-mem when:

  • ✅ Multi-session projects (>1 week)
  • ✅ Need to remember architectural decisions
  • ✅ Frequently reconnecting to same project
  • ✅ Want automatic context injection (no manual effort)
  • ❌ Don’t use for: one-off tasks, extremely sensitive data

Task: Refactor authentication across codebase

Terminal window
# 1. Discover (grepai - semantic)
grepai search "authentication and session management"
# → Finds: auth.service.ts, session.middleware.ts
# 2. Structure (Serena - symbols)
serena get_symbols_overview --file auth.service.ts
# → Classes: AuthService, functions: login, logout
# 3. Dependencies (grepai - call graph)
grepai trace callers "login"
# → Called by: UserController, ApiGateway (23 files)
# 4. Patterns (ast-grep - structure)
ast-grep "async function login" --without "try { $$$ } catch"
# → Finds 3 async functions missing error handling
# 5. Verification (rg - exact)
rg "validateSession" --type ts -A 5
# → Verify specific implementation

Result: Complete understanding + safe refactoring in 5 commands

📖 Complete Guide: See Search Tools Mastery for detailed workflows, real-world scenarios, and advanced combinations.


Purpose: Natural language semantic search across code, docs, PDFs, and images.

Why consider mgrep: If you need multi-format search (code + PDFs + images) or prefer a cloud-based solution, mgrep is an alternative to grepai. Their benchmarks show ~2x fewer tokens used compared to grep-based workflows.

Key Features:

FeatureDescription
Semantic searchFind code by natural language description
Background indexingmgrep watch indexes respecting .gitignore
Multi-formatSearch code, PDFs, images, text
Web integrationWeb search fallback capability

Example:

Terminal window
# Traditional grep (exact match required)
grep -r "authenticate.*user" .
# mgrep (intent-based)
mgrep "code that handles user authentication"

Use when:

  • Need to search across mixed content (code + PDFs + images)
  • Prefer cloud-based embeddings over local Ollama setup
  • grepai’s call graph analysis isn’t needed

Note: I haven’t tested mgrep personally. Consider it an alternative worth exploring. Source: mgrep GitHub

Purpose: Access official library documentation.

Tools:

ToolDescription
resolve-library-idFind library documentation
query-docsQuery specific documentation

Use when:

  • Learning new libraries
  • Finding correct API usage
  • Checking official patterns

Purpose: AST-based pattern matching for precise structural code searches.

Type: Optional Community Plugin (not core Claude Code)

Installation:

Terminal window
# Install ast-grep skill for Claude Code
npx skills add ast-grep/agent-skill
# Or manually via plugin marketplace
/plugin marketplace add

What is ast-grep?

ast-grep searches code based on syntax structure (Abstract Syntax Tree) rather than plain text. This enables finding patterns like “async functions without error handling” or “React components using specific hooks” that regex cannot reliably detect.

Key Characteristics:

AspectBehavior
InvocationExplicit - Claude cannot automatically detect when to use it
IntegrationPlugin that teaches Claude how to write ast-grep rules
LanguagesJavaScript, Python, Rust, Go, Java, C/C++, Ruby, PHP + more
Pattern matchingMetavariables ($VAR), relational queries, composite logic

When to use ast-grep:

Use for:

  • Large-scale refactoring (>50k lines, indicative threshold)
  • Framework migrations (React class→hooks, Vue 2→3)
  • Structural patterns:
    • Async functions lacking error handling
    • Functions exceeding parameter thresholds
    • Console.log calls within class methods
    • React components using specific hooks
  • Architecture analysis (identify coupled components, dependency patterns)

Don’t use for (grep suffices):

  • Simple string searches (function names, imports)
  • Small projects (<10k lines)
  • One-off searches
  • Text-based patterns (TODO comments, log messages)

Decision Tree:

Search need?
├─ String/regex pattern → Grep (native, fast)
├─ Semantic meaning → Serena MCP (symbol search) or grepai (RAG-based)
└─ Structural pattern (AST) → ast-grep (plugin, setup required)

Trade-offs:

AspectGrepast-grepSerena MCPgrepai
Speed⚡ Fast (~20ms)ModerateFastSlower (embedding)
Setup✅ None⚠️ Installation + learning⚠️ MCP config⚠️ MCP + Ollama
PrecisionRegex-basedAST-accurateSymbol-awareSemantic
Use caseText patternsCode structureSymbols/functionsMeaning-based

Example usage:

Terminal window
# User explicitly requests ast-grep
You: Use ast-grep to find all async functions without try/catch blocks
# Claude uses the ast-grep skill to construct rules
Claude: [Constructs AST pattern, executes search, reports results]

Important limitations (as of Nov 2025):

“Claude Code cannot automatically detect when to use ast-grep for all appropriate use cases.” - ast-grep/claude-skill README

This means you must explicitly tell Claude to use ast-grep. It won’t decide on its own.

Sources:

Design Philosophy Context:

Early Claude Code versions used RAG with Voyage embeddings for semantic search. Anthropic switched to grep-based (ripgrep) agentic search after benchmarks showed superior performance with lower operational complexity (no index sync, no security liabilities). This “Search, Don’t Index” philosophy prioritizes simplicity.

ast-grep is a community extension for specialized structural searches where grep’s regex approach isn’t sufficient, but it’s not a replacement for grep — it’s a surgical tool for specific use cases.

Related: See Section 8.4 - Server Selection Guide for choosing between grep/ast-grep/Serena/grepai.

Sequential Thinking (Structured Reasoning)

Section titled “Sequential Thinking (Structured Reasoning)”

Purpose: Multi-step analysis with explicit reasoning.

Tools:

ToolDescription
sequentialthinkingStep-by-step reasoning

Use when:

  • Complex debugging
  • Architectural analysis
  • System design decisions

Purpose: Direct database access for queries.

Tools:

ToolDescription
queryExecute SQL queries

Use when:

  • Investigating data issues
  • Understanding schema
  • Debugging data problems

Purpose: Browser testing and automation.

Tools:

ToolDescription
navigateGo to URL
clickClick element
fillFill form field
screenshotCapture screenshot

Use when:

  • E2E testing
  • Visual validation
  • Browser debugging

agent-browser (Vercel Labs) — AI-Native Browser Automation

Section titled “agent-browser (Vercel Labs) — AI-Native Browser Automation”

Status: Active development — v0.15.0 (Feb 2026). 12,100+ stars. Rapid release cycle.

Purpose: Headless browser CLI built for AI agents. Uses Playwright/CDP under the hood but optimizes all output for LLM consumption. Written in Rust for sub-millisecond startup.

Why it matters for agentic workflows: Playwright MCP is verbose — every DOM snapshot adds tokens. agent-browser returns only actionable elements via stable short references (@e1, @e2), cutting token usage by ~82.5% on identical scenarios (Pulumi benchmark, 2026-03-03).

Install:

Terminal window
# Homebrew
brew install vercel-labs/tap/agent-browser
# Or npm
npm install -g @vercel-labs/agent-browser

Capabilities:

FeatureDetails
Navigation + interactionClick, type, scroll, fill forms
Accessibility treeLLM-optimized snapshots (actionable elements only)
Visual diffsPixel-level comparison against baselines
Session persistenceSave/restore auth state (AES-256-GCM)
Multi-sessionIsolated instances, separate cookies/storage
Security (v0.15.0)Auth vaults, domain allowlists, action policies
Browser streamingLive WebSocket preview for human+agent “pair browsing”

agent-browser vs Playwright MCP:

DimensionPlaywright MCPagent-browser
Primary audienceDevelopers (test suites)AI agents
Token usageBaseline-82.5%
Element referencesXPath/CSS selectors@e1, @e2 (stable, compact)
ImplementationNode.jsRust (sub-ms startup)
Session persistenceNoYes
Security controlsNoneAuth vaults, domain allowlists
Self-verifying agentsAwkwardNative pattern

The Ralph Wiggum Loop — self-verifying agent pattern:

1. Agent codes the feature
2. Deploys (Vercel, any target)
3. agent-browser navigates to deployed URL autonomously
4. Tests scenarios, reads accessibility snapshots
5. On failure: agent reads output, fixes code, re-deploys
6. Loop until all scenarios pass — no human in the loop

Documented in production at Pulumi (2026-03-03) across 6 test scenarios on a real app.

Use when:

  • Agent must verify its own deployed output (self-verifying loops)
  • Token cost of browser context is a constraint
  • Multi-session testing (parallel isolated browser instances)
  • Visual regression in agentic CI/CD pipelines

Don’t use when:

  • You have existing Playwright test suites — not a drop-in replacement for test runners
  • Scraping anti-bot protected sites — IP/behavior detection unchanged (Browserbase-type services still needed)

Resources:

⚠️ Status: Under Testing — Evaluated early 2026. MIT licensed, Python.

Purpose: Persistent semantic memory with cross-session search and multi-client support. Complements Serena (key-value) with meaning-based retrieval: retrieve_memory("what did we decide about auth?").

FeatureValue
StorageSQLite-vec (default), Cloudflare D1+Vectorize, hybrid
Tools12 MCP tools (store, retrieve, tag search, graph ops, health check)
Multi-client13+ apps share ~/.mcp-memory-service/memories.db
Installpip install mcp-memory-service
Cross-deviceCloudflare backend required

Known issues: busy_timeout=5000ms default causes intermittent errors under concurrent access; fix with MCP_MEMORY_SQLITE_PRAGMAS=busy_timeout=15000,cache_size=20000.

Full coverage: See Memory Systems: doobidoo for installation, configuration, storage backends, known issues, and comparison with Kairn/ICM.

Source: doobidoo/mcp-memory-service GitHub (~1.6K stars, v10.0.2)

Kairn: Knowledge Graph Memory with Biological Decay

Section titled “Kairn: Knowledge Graph Memory with Biological Decay”

⚠️ Status: Under Testing — Evaluated Feb 2026. MIT licensed, Python.

Purpose: Long-term project memory as a knowledge graph with automatic biological decay — stale info expires without manual cleanup.

FeatureValue
Typed relationshipsdepends-on, resolves, causes
Decay modelSolutions ~200 days, workarounds ~50 days
Tools18 MCP tools (graph ops, search, cross-workspace patterns)
Installpip install kairn

Use Kairn when causality matters (“this breaks because of that”) or when long-running projects accumulate stale workarounds that need auto-pruning.

Full coverage: See Memory Systems: Kairn for full feature breakdown, decay model details, and comparison with doobidoo/ICM.

Source: kairn-ai/kairn GitHub (MIT, Python)

ICM: Dual Memory Architecture (Rust Binary, Zero Dependencies)

Section titled “ICM: Dual Memory Architecture (Rust Binary, Zero Dependencies)”

⚠️ Status: Under Testing — Evaluated March 2026. Source-Available license (free for individuals and teams ≤20). Benchmarks are vendor-reported, unverified independently.

Purpose: Persistent memory combining episodic decay (Memories) and permanent knowledge graph (Memoirs) in a single zero-dependency Rust binary.

FeatureValue
Installbrew tap rtk-ai/tap && brew install icm
ModesMCP (31 tools) / Hook (zero explicit calls) / Skills (/recall, /remember)
Dual architectureMemories (configurable decay) + Memoirs (permanent typed graph, 9 relation types)
Hybrid searchBM25 30% + vector 70%, hybrid latency ~951 µs/op
Auto-extractionThree layers: pattern hooks, pre-compaction, session-start
Cross-IDE14 clients (Claude Code, Cursor, VS Code, Windsurf, Zed, Amp, Cline, Roo Code…)
LicenseSource-Available — free for teams ≤20, enterprise required above

Critical setup note: icm init --mode hook ships the hook file but does NOT register it in settings.json. Add manually:

{"hooks": {"PostToolUse": [{"matcher": "*", "hooks": [{"type": "command", "command": "~/.claude/hooks/icm-post-tool.sh"}]}]}}

Full coverage: See Memory Systems: ICM for full architecture breakdown, Memoir relation types, benchmarks, and comparison with Kairn/doobidoo.

Source: rtk-ai/icm GitHub (52 stars, Source-Available)

MCP Memory Stack: Complementarity Patterns

Section titled “MCP Memory Stack: Complementarity Patterns”

The four tools serve orthogonal roles in a layered knowledge stack:

LayerToolQuestion answered
Business contextdoobidoo”Why did we do this?”
Code structureSerena”Where is X defined?”
Code by intentgrepai”Find code that does X”
Library docsContext7”How to use library X?”

Combination workflows: retrieve_memory() for business context, grepai search to find code, find_symbol() for exact location.

Full coverage: See Memory Systems: Architecture Patterns and Master Comparison Table for the complete 20-tool matrix, combined workflows, multi-agent patterns, and decision flowchart.


Purpose: Programmatic Git access via 12 structured tools for commit, diff, log, and branch management.

Why Git MCP vs Bash git: The Bash tool can run git commands but returns raw terminal output that requires parsing and consumes tokens. Git MCP returns structured data directly usable by Claude, with built-in filters (date, author, branch) and token-efficient diffs via the context_lines parameter.

⚠️ Status: Early development — API subject to change. Suitable for local workflows; test before adopting in production pipelines.

Tools (12):

ToolDescription
git_statusWorking tree status (staged, unstaged, untracked)
git_diff_unstagedUnstaged changes
git_diff_stagedStaged changes ready to commit
git_diffCompare any two branches, commits, or refs
git_commitCreate a commit with message
git_addStage one or more files
git_resetUnstage files
git_logCommit history with date, author, and branch filters
git_create_branchCreate a new branch
git_checkoutSwitch branches
git_showShow details for a commit or tag
git_branchList all local branches

Setup:

Terminal window
# No install required — uvx pulls it on first run
uvx mcp-server-git --repository /path/to/repo

Claude Code configuration (~/.claude.json):

{
"mcpServers": {
"git": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "/absolute/path/to/repo"]
}
}
}

Multi-repo configuration (different server per project):

{
"mcpServers": {
"git-frontend": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "/projects/frontend"]
},
"git-backend": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "/projects/backend"]
}
}
}

Comparison: Git MCP vs Bash:

Use caseBash gitGit MCP
Simple status checkFineOverkill
Filtered log (date + author)Long commandNative filter params
Diff with context controlPossiblecontext_lines param
Scripting / automationGoodBetter (structured output)
CI / production pipelinesTested, stableEarly dev, use with care

Typical workflows:

  • “Show me all commits by Alice in the last 7 days on the main branch”
  • “What files changed in the last 3 commits? Summarize the changes.”
  • “Stage src/auth.ts and create a commit with an appropriate message”

Source: modelcontextprotocol/servers/src/git — MIT license, part of the Anthropic-maintained monorepo (77k+ stars).


Purpose: Full GitHub platform access — Issues, Pull Requests, Projects, Code search, repository management, and GitHub Enterprise.

Git MCP vs GitHub MCP (two distinct layers):

LayerToolScope
Local Git operationsGit MCP ServerCommits, diffs, branches, staging
GitHub cloud platformGitHub MCP ServerIssues, PRs, Projects, Reviews, Search

Both can be active simultaneously. They complement each other: Git MCP handles local work, GitHub MCP handles collaboration and cloud state.

Two setup modes:

ModeRequiresWhen to use
Remote (api.githubcopilot.com)GitHub Copilot subscriptionAlready a Copilot subscriber
Self-hosted binaryGitHub PAT onlyNo Copilot, proprietary code, or privacy requirements

Remote MCP (requires a GitHub Copilot subscription):

⚠️ Known issue: claude mcp add --transport http attempts OAuth dynamic client registration by default, which the Copilot endpoint does not support. You’ll get: Incompatible auth server: does not support dynamic client registration. The fix is to inject the token manually (see below).

Step 1 — Add the server:

Terminal window
claude mcp add --transport http github https://api.githubcopilot.com/mcp/

Step 2 — Get your active GitHub CLI token:

Terminal window
gh auth token
# → gho_xxxxxxxxxxxx

Step 3 — Edit ~/.claude.json to add the Authorization header:

{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer gho_xxxxxxxxxxxx"
}
}
}
}

If the token expires: gh auth refresh then update the value in ~/.claude.json.

Self-hosted setup (GitHub PAT only, no Copilot required):

Terminal window
# Download binary from github.com/github/github-mcp-server/releases
export GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxx
./github-mcp-server stdio
{
"mcpServers": {
"github": {
"command": "/path/to/github-mcp-server",
"args": ["stdio"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxx"
}
}
}
}

Key capabilities:

  • Issues: create, list, filter, assign, close
  • Pull Requests: create, review, merge, list by assignee/label
  • Projects: read and update GitHub Projects v2
  • Code search: search across all repos in an org
  • GitHub Enterprise: same API, different base URL

Typical workflows with Claude Code:

  • “List all open PRs assigned to me on org/repo, sorted by last activity”
  • “For PR #456, summarize the changes, flag breaking changes, and draft a review comment”
  • “Create an issue for bug X with a checklist, then open a branch and push a fix commit”
  • “Search all repos in the org for usages of deprecated fetchUser() and list files to migrate”

Differentiator vs @modelcontextprotocol/server-github: The official GitHub MCP server adds Projects support, OAuth 2.1 auth, GitHub Enterprise, and the remote hosted endpoint. The npm reference server is lighter but covers fewer features.

Source: github/github-mcp-server — Go, MIT license, 20k+ stars, actively maintained with regular releases.


The Claude Code Ultimate Guide ships its own MCP server — claude-code-ultimate-guide-mcp — so you can query the guide directly from any Claude Code session without cloning the repo.

What it gives you: 9 tools covering search, content reading, templates, digests, cheatsheet, and release notes. The structured index (882 entries) is bundled in the package (~130KB); markdown files are fetched from GitHub on demand with 24h local cache.

Add to ~/.claude.json:

{
"mcpServers": {
"claude-code-guide": {
"type": "stdio",
"command": "npx",
"args": ["-y", "claude-code-ultimate-guide-mcp"]
}
}
}

Or with a local clone (dev mode — reads files directly from disk):

{
"mcpServers": {
"claude-code-guide": {
"type": "stdio",
"command": "node",
"args": ["/path/to/claude-code-ultimate-guide/mcp-server/dist/index.js"],
"env": {
"GUIDE_ROOT": "/path/to/claude-code-ultimate-guide"
}
}
}
}
ToolSignatureDescription
search_guide(query, limit?)Search 882 indexed entries by keyword or question
read_section(path, offset?, limit?)Read any guide file with pagination (500 lines max)
list_topics()Browse all 25 topic categories
get_example(name)Fetch a production-ready template by name
list_examples(category?)List all templates — agents, commands, hooks, skills, scripts
get_changelog(count?)Last N guide CHANGELOG entries (default 5)
get_digest(period)Combined digest of guide + CC releases: day, week, month
get_release(version?)Claude Code CLI release details
get_cheatsheet(section?)Full cheatsheet or filtered by section

Resources: claude-code-guide://reference (full 94KB YAML index), claude-code-guide://releases, claude-code-guide://llms

Prompt: claude-code-expert — activates expert mode with optimal search workflow

Install the companion slash commands for one-keystroke access (stored in ~/.claude/commands/ccguide/):

Terminal window
# These commands are included in the guide repo under .claude/commands/ccguide/
# Copy or symlink to ~/.claude/commands/ccguide/ to install globally

Guide commands:

CommandExampleDescription
/ccguide:search/ccguide:search hooksSearch by keyword
/ccguide:cheatsheet/ccguide:cheatsheet hooksCheatsheet (full or section)
/ccguide:digest/ccguide:digest weekWhat changed this week (guide + CC releases)
/ccguide:example/ccguide:example code-reviewerFetch a template
/ccguide:examples/ccguide:examples agentsList templates by category
/ccguide:release/ccguide:release 2.1.59Release details
/ccguide:changelog/ccguide:changelog 10Recent guide CHANGELOG
/ccguide:topics/ccguide:topicsBrowse all categories

Official Anthropic docs tracker (MCP v1.1.0+):

CommandDescription
/ccguide:init-docsFetch official docs + store as local baseline (run once)
/ccguide:refresh-docsRe-fetch latest docs, update current snapshot (baseline unchanged)
/ccguide:diff-docsCompare baseline vs current — added/removed/modified pages, 0 network
/ccguide:search-docs <query>Search official Anthropic docs from local cache
/ccguide:dailyDaily briefing: refresh + diff official docs + guide/CC digest

Typical workflow:

Terminal window
/ccguide:init-docs # once — stores baseline + current in ~/.cache/claude-code-guide/
# days later...
/ccguide:daily # every day — refresh + diff + digest in one shot

A claude-code-guide agent is included in .claude/agents/claude-code-guide.md. It uses Haiku (fast, cheap) and automatically searches the guide before answering any Claude Code question.


Beyond the official servers listed above, the MCP ecosystem includes validated community servers that extend Claude Code’s capabilities with specialized integrations.

📖 Complete Guide: See MCP Servers Ecosystem for:

  • 8 validated production-ready servers: Playwright (Microsoft), Semgrep, Kubernetes (Red Hat), Context7, Linear, Vercel, Browserbase, MCP-Compose
  • Evaluation framework: How servers are validated (stars, releases, docs, tests, security)
  • Production deployment guide: Security checklist, quick start stack, performance metrics
  • Ecosystem evolution: Linux Foundation standardization, MCPB format, Advanced MCP Tool Use, MCP Apps
  • Monthly watch methodology: Template for maintaining the guide with ecosystem updates

Featured Community Servers:

ServerPurposeQuality ScoreMaintainer
Playwright MCPBrowser automation with accessibility trees8.8/10 ⭐⭐⭐⭐⭐Microsoft (Official)
Semgrep MCPSecurity scanning (SAST, secrets, supply chain)9.0/10 ⭐⭐⭐⭐⭐Semgrep Inc. (Official)
Kubernetes MCPCluster management in natural language8.4/10 ⭐⭐⭐⭐Red Hat Containers Community
Context7 MCPReal-time library documentation (500+ libs)8.2/10 ⭐⭐⭐⭐Upstash (Official)
Linear MCPIssue tracking, project management7.6/10 ⭐⭐⭐⭐Community
Vercel MCPNext.js deployments, CI/CD7.6/10 ⭐⭐⭐⭐Community
Browserbase MCPCloud browser automation with AI agent7.6/10 ⭐⭐⭐⭐Browserbase Inc. (Official)
MCP-ComposeDocker Compose-style multi-server orchestration7.4/10 ⭐⭐⭐⭐Community

Quick Start Example (Playwright):

Terminal window
# Installation
npm install @microsoft/playwright-mcp
# Configuration (~/.claude.json or .mcp.json)
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["--yes", "@microsoft/playwright-mcp"]
}
}
}

Why use community servers?

  • Specialized integrations: Kubernetes, Vercel, Linear APIs not in official servers
  • Enhanced capabilities: Browser automation (Playwright), security scanning (Semgrep)
  • Production-ready: All servers validated for maintenance, docs, tests, security
  • Ecosystem standard: Many backed by major organizations (Microsoft, Red Hat, Semgrep Inc.)

~/.claude.json # User-scope MCP config (field "mcpServers")
.mcp.json # Project-scope (project root, shareable via VCS)

Note: Three scopes exist: local (default, private to you + current project, in ~/.claude.json), project (shared via .mcp.json at project root), and user (cross-project, also in ~/.claude.json). Use claude mcp add --scope <scope> to target a specific scope.

{
"mcpServers": {
"serena": {
"command": "npx",
"args": ["serena-mcp"],
"env": {
"PROJECT_PATH": "${PROJECT_PATH}"
}
},
"context7": {
"command": "npx",
"args": ["@context7/mcp-server"]
},
"postgres": {
"command": "npx",
"args": ["@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "${DATABASE_URL}"
}
}
}
}
FieldDescription
commandExecutable to run
argsCommand arguments
envEnvironment variables
cwdWorking directory
alwaysLoadWhen true, all tools from this server skip tool-search deferral and are always available without a ToolSearch call first. Use for servers with 1-5 critical tools needed on every turn. (v2.1.121)

Dynamic Headers for Multiple MCP Servers (v2.1.85+)

Section titled “Dynamic Headers for Multiple MCP Servers (v2.1.85+)”

When a single headersHelper script serves multiple MCP servers, you can branch on CLAUDE_CODE_MCP_SERVER_NAME and CLAUDE_CODE_MCP_SERVER_URL to return different authentication tokens or scopes per server:

.claude/mcp-headers.sh
#!/bin/bash
case "$CLAUDE_CODE_MCP_SERVER_NAME" in
"github")
echo "{\"Authorization\": \"Bearer $GITHUB_TOKEN\"}"
;;
"linear")
echo "{\"Authorization\": \"Bearer $LINEAR_API_KEY\"}"
;;
*)
echo "{}"
;;
esac

Reference the script in your MCP server config:

{
"mcpServers": {
"github": {
"command": "npx",
"args": ["@modelcontextprotocol/server-github"],
"headersHelper": ".claude/mcp-headers.sh"
},
"linear": {
"command": "npx",
"args": ["@modelcontextprotocol/server-linear"],
"headersHelper": ".claude/mcp-headers.sh"
}
}
}
VariableExpands To
${VAR}Environment variable value
${VAR:-default}Environment variable with fallback
${CLAUDE_PROJECT_DIR}Absolute path to the project root (the directory Claude was started from). Auto-injected into stdio-type MCP server process environments. Also usable in plugin command strings. (v2.1.139)

Warning: The syntax ${workspaceFolder} and ${env:VAR_NAME} are VS Code conventions, not Claude Code. Claude Code uses standard shell-style ${VAR} and ${VAR:-default} for environment variable expansion in MCP config.

MCP stdio env injection: All stdio-type MCP servers automatically receive CLAUDE_PROJECT_DIR as an environment variable — no config needed. This lets MCP servers know which project they’re operating in without requiring the client to pass it explicitly.

When you accumulate many MCP servers, enabling them all globally degrades Claude’s tool selection — each server adds tool descriptions to the context, making the model less precise at picking the right one.

Pattern: keep a minimal global config (2-3 core servers) and activate project-specific servers via per-project .mcp.json.

# User-scope (~/.claude.json "mcpServers") → always loaded
context7, sequential-thinking
# Project-scope (.mcp.json at project root) → only when needed
postgres # database project
playwright # frontend project
serena # large codebase

Community tools (e.g. cc-setup) are emerging to provide a TUI registry with per-project toggling and health checks — useful if you manage 8+ servers regularly.

Claude Code v4 introduced MCP Tool Search: instead of loading all MCP tool definitions at startup, tool schemas are fetched on-demand when Claude needs them.

Why it matters: each MCP server injects its full tool schema into the context window. With a dozen servers, that’s ~77,000 tokens consumed before you’ve written a single prompt.

SetupContext used by tools
All tools loaded upfront~77,000 tokens
MCP Tool Search enabled~8,700 tokens
Reduction~85%

Model accuracy on tool-selection tasks (measured on Opus 4): 49% → 74% (+25 points) when switching from full preload to lazy-loading. Auto-enables when MCP tools would consume >10% of the context window.

Practical implication: you can now connect dozens of MCP servers without the “too many tools” accuracy penalty. The advice to keep global config minimal still applies for unrelated tools, but MCP Tool Search changes the calculus for large project-specific sets.

To opt a specific server out of deferral entirely, set alwaysLoad: true in its config. Use this for servers with small tool counts (1-5 tools) that you know you’ll need every session:

.claude/settings.json
{
"mcpServers": {
"my-critical-server": {
"command": "npx",
"args": ["my-mcp-server"],
"alwaysLoad": true
}
}
}

CLI vs MCP — when a shell command beats a server: Familiar CLI tools (git, grep, jq, curl) are already deeply embedded in Claude’s training data. A few usage examples in CLAUDE.md are often more effective than an equivalent MCP server, because the model already knows the tool’s behavior, flags, and output format. An MCP server adds tool schema overhead and introduces an unfamiliar interface. Default to CLIs for standard tools; use MCP servers for proprietary systems or APIs the model has no training context for.

Source: HumanLayer — Harness Engineering for Coding Agents (March 2026)

Quick setup with environment variables:

Terminal window
# Add server with API key
claude mcp add -e API_KEY=your-key my-server -- npx @org/server
# Multiple environment variables
claude mcp add -e DATABASE_URL=postgresql://... -e DEBUG=true postgres -- npx @prisma/postgres
# Verify with --help
claude mcp add --help

Source: CLI syntax adapted from Shipyard Claude Code Cheat Sheet

Problem: MCP servers require API keys and credentials. Storing them in plaintext mcp.json creates security risks (accidental Git commits, exposure in logs, lateral movement after breach).

Solution: Separate secrets from configuration using environment variables, OS keychains, or secret vaults.

Before implementing secrets management, understand the baseline requirements from Security Hardening Guide:

  • Encryption at rest: Secrets must be encrypted on disk (OS keychain > plaintext .env)
  • Least privilege: Use read-only credentials when possible
  • Token rotation: Short-lived tokens with automated refresh
  • Audit logging: Track secret access without logging the secrets themselves
  • Never in Git: Secrets must never be committed to version control

For full threat model and CVE details, see Section 8.6 MCP Security.

ApproachSecurityComplexityUse Case
OS KeychainHigh (encrypted at rest)MediumSolo developers, macOS/Linux
.env + .gitignoreMedium (file permissions)LowSmall teams, rapid prototyping
Secret VaultsVery High (centralized, audited)HighEnterprise, compliance requirements

Best for: Solo developers on macOS/Linux with high security needs.

Pros: Encrypted at rest, OS-level access control, no plaintext files Cons: Platform-specific, requires scripting for automation

macOS Keychain Setup:

Terminal window
# Store secret in Keychain
security add-generic-password \
-a "claude-mcp" \
-s "github-token" \
-w "ghp_your_token_here"
# Verify storage
security find-generic-password -s "github-token" -w

MCP configuration with keychain retrieval:

{
"mcpServers": {
"github": {
"command": "bash",
"args": ["-c", "GITHUB_TOKEN=$(security find-generic-password -s 'github-token' -w) npx @github/mcp-server"],
"env": {}
}
}
}

Linux Secret Service (GNOME Keyring, KWallet):

Terminal window
# Install secret-tool (part of libsecret)
sudo apt install libsecret-tools # Ubuntu/Debian
# Store secret
secret-tool store --label="GitHub Token" service claude key github-token
# Prompt will ask for the secret value
# Retrieve in MCP config (bash wrapper)
# ~/.claude/scripts/mcp-github.sh
#!/bin/bash
export GITHUB_TOKEN=$(secret-tool lookup service claude key github-token)
npx @github/mcp-server
# ~/.claude.json (or .mcp.json)
{
"mcpServers": {
"github": {
"command": "~/.claude/scripts/mcp-github.sh",
"args": []
}
}
}

Windows Credential Manager:

Terminal window
# Store secret
cmdkey /generic:"claude-mcp-github" /user:"token" /pass:"ghp_your_token_here"
# Retrieve in PowerShell wrapper
$password = cmdkey /list:"claude-mcp-github" | Select-String -Pattern "Password" | ForEach-Object { $_.ToString().Split(":")[1].Trim() }
$env:GITHUB_TOKEN = $password
npx @github/mcp-server

Best for: Small teams, rapid prototyping, adequate security with proper .gitignore.

Pros: Simple, cross-platform, easy onboarding Cons: Plaintext on disk (file permissions only), requires discipline

Setup:

Terminal window
# 1. Create .env file (project root or ~/.claude/)
cat > ~/.claude/.env << EOF
GITHUB_TOKEN=ghp_your_token_here
OPENAI_API_KEY=sk-your-key-here
DATABASE_URL=postgresql://user:pass@localhost/db
EOF
# 2. Secure permissions (Unix only)
chmod 600 ~/.claude/.env
# 3. Add to .gitignore
echo ".env" >> ~/.claude/.gitignore

MCP configuration with .env variables:

{
"mcpServers": {
"github": {
"command": "npx",
"args": ["@github/mcp-server"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"postgres": {
"command": "npx",
"args": ["@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "${DATABASE_URL}"
}
}
}
}

Load .env before Claude Code:

~/bin/claude-with-env
# Option 1: Shell wrapper
#!/bin/bash
export $(cat ~/.claude/.env | xargs)
claude "$@"
# Option 2: direnv (automatic per-directory)
# Install: https://direnv.net/
echo 'dotenv ~/.claude/.env' > ~/.config/direnv/direnvrc
direnv allow ~/.claude

Template approach for teams:

Terminal window
# Commit template (no secrets)
cat > ~/.claude/mcp-config.template.json << EOF
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["@github/mcp-server"],
"env": {
"GITHUB_TOKEN": "\${GITHUB_TOKEN}"
}
}
}
}
EOF
# Generate actual config from template + .env
envsubst < ~/.claude/mcp-config.template.json > ~/.claude.json
# .gitignore
.claude.json # Generated, contains resolved secrets
.env # Never commit

See also: sync-claude-config.sh for automated template substitution.


Best for: Enterprise, compliance (SOC 2, HIPAA), centralized secret management.

Pros: Centralized, audited, automated rotation, fine-grained access control Cons: Complex setup, requires infrastructure, vendor lock-in

HashiCorp Vault:

Terminal window
# Store secret in Vault
vault kv put secret/claude/github token=ghp_your_token_here
# Retrieve in wrapper script
# ~/.claude/scripts/mcp-github-vault.sh
#!/bin/bash
export GITHUB_TOKEN=$(vault kv get -field=token secret/claude/github)
npx @github/mcp-server
# ~/.claude.json (or .mcp.json)
{
"mcpServers": {
"github": {
"command": "~/.claude/scripts/mcp-github-vault.sh",
"args": []
}
}
}

AWS Secrets Manager:

Terminal window
# Store secret
aws secretsmanager create-secret \
--name claude/github-token \
--secret-string "ghp_your_token_here"
# Retrieve in wrapper
export GITHUB_TOKEN=$(aws secretsmanager get-secret-value \
--secret-id claude/github-token \
--query SecretString \
--output text)
npx @github/mcp-server

1Password CLI (team-friendly):

Terminal window
# Store in 1Password (via GUI or CLI)
op item create --category=password \
--title="Claude MCP GitHub Token" \
token=ghp_your_token_here
# Retrieve in wrapper
export GITHUB_TOKEN=$(op read "op://Private/Claude MCP GitHub Token/token")
npx @github/mcp-server

Problem: API keys expire or are compromised. Rotating secrets across multiple MCP servers is manual and error-prone.

Solution: Centralized .env file with rotation script.

~/.claude/rotate-secret.sh
#!/bin/bash
SECRET_NAME=$1
NEW_VALUE=$2
# 1. Update .env file
sed -i.bak "s|^${SECRET_NAME}=.*|${SECRET_NAME}=${NEW_VALUE}|" ~/.claude/.env
# 2. Regenerate config from template
envsubst < ~/.claude/mcp-config.template.json > ~/.claude.json
# 3. Restart MCP servers (if running)
pkill -f "mcp-server" || true
echo "✅ Rotated $SECRET_NAME"
echo "⚠️ Restart Claude Code to apply changes"

Usage:

Terminal window
# Rotate GitHub token
./rotate-secret.sh GITHUB_TOKEN ghp_new_token_here
# Rotate database password
./rotate-secret.sh DATABASE_URL postgresql://user:new_pass@localhost/db

Automated rotation with Vault (advanced):

vault-rotate.sh
#!/bin/bash
# Fetch latest secrets from Vault, update .env, restart Claude
vault kv get -format=json secret/claude | jq -r '.data.data | to_entries[] | "\(.key)=\(.value)"' > ~/.claude/.env
envsubst < ~/.claude/mcp-config.template.json > ~/.claude.json
echo "✅ Secrets rotated from Vault"

Schedule with cron:

Terminal window
# Rotate daily at 3 AM
0 3 * * * ~/claude-rotate.sh >> ~/claude-rotate.log 2>&1

Problem: Developers accidentally commit secrets to Git despite .gitignore (e.g., adding .env with git add -f).

Solution: Pre-commit hook to block commits containing secrets.

Terminal window
# Install hook
cp examples/hooks/bash/pre-commit-secrets.sh .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# Test (should fail)
echo "GITHUB_TOKEN=ghp_test" > test.txt
git add test.txt
git commit -m "Test"
# ❌ Blocked: Secret detected in test.txt

Detection patterns (see hook for full list):

  • OpenAI keys: sk-[A-Za-z0-9]{48}
  • GitHub tokens: ghp_[A-Za-z0-9]{36}
  • AWS keys: AKIA[A-Z0-9]{16}
  • Generic API keys: api[_-]?key[\"']?\s*[:=]\s*[\"']?[A-Za-z0-9]{20,}

Before deploying MCP servers with secrets:

CheckCommandPass Criteria
.env not in Git`git ls-filesgrep .env`
File permissionsls -l ~/.claude/.env-rw------- (600)
Template committed`git ls-filesgrep template`
Pre-commit hookcat .git/hooks/pre-commitSecret detection script present
Secrets resolvedclaude mcp listAll servers start without errors

Test secret isolation:

Terminal window
# Should work (secret from .env)
export $(cat ~/.claude/.env | xargs)
claude
# Should fail (no secrets in environment)
unset GITHUB_TOKEN DATABASE_URL
claude
# ❌ MCP servers fail to start (expected)

PracticeRationale
Use OS keychain when possibleEncrypted at rest, OS-level security
Never commit .env to GitOne leak = full compromise
Commit .env.example templateTeam onboarding without secrets
Use ${VAR} in MCP configSeparation of config and secrets
Rotate secrets quarterlyLimit blast radius of old leaks
Audit .gitignore before pushPrevent accidental exposure
Least privilege credentialsRead-only DB users, scoped API tokens
Monitor for leaked secretsGitHub secret scanning, GitGuardian

For production deployments, consider zero standing privilege where MCP servers start with no secrets and request just-in-time credentials on tool invocation.

What do you need?
├─ Know exact pattern/text?
│ └─ Use native Grep tool or rg (~20ms)
├─ Deep code understanding?
│ └─ Use Serena
├─ Explore code by intent / semantic search?
│ └─ Use grepai (~500ms)
├─ Trace who calls what? (call graph)
│ └─ Use grepai
├─ Library documentation?
│ └─ Use Context7
├─ Complex reasoning?
│ └─ Use Sequential Thinking
├─ Database queries?
│ └─ Use Postgres
├─ Browser testing?
│ └─ Use Playwright
└─ General task?
└─ Use built-in tools
NeedBest ToolWhy
”Find exact string ‘validateUser‘“Native Grep / rgFast exact match (~20ms)
“Find all usages of this function”SerenaSemantic symbol analysis
”Remember this for next session”SerenaPersistent memory
”Find code that handles payments”grepai / mgrepIntent-based semantic search
”Who calls this function?“grepaiCall graph analysis
”How does React useEffect work?”Context7Official docs
”Why is this failing?”SequentialStructured debugging
”What’s in the users table?”PostgresDirect query
”Test the login flow”PlaywrightBrowser automation

Servers can work together:

1. Context7 → Get official pattern for auth
2. Serena → Find existing auth code
3. Sequential → Analyze how to integrate
4. Playwright → Test the implementation

Production Case Study: Multi-System Support Investigator

Section titled “Production Case Study: Multi-System Support Investigator”

Context: Mergify (CI/CD automation platform) needed to triage support tickets across 5 disconnected systems — a manual 15-minute process per ticket.

Architecture: Claude Code as orchestrator + 5 custom MCP servers as system adapters:

Support ticket received
┌───────────────┐
│ Claude Code │ ← orchestrates, synthesizes, produces report
└───────┬───────┘
│ parallel fan-out
├──────────────────┬──────────────────┬──────────────────┬──────────────────┐
▼ ▼ ▼ ▼ ▼
┌─────────────┐ ┌─────────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Datadog │ │ Sentry │ │ PostgreSQL │ │ Linear │ │ GitHub │
│ (metrics, │ │ (errors, perf │ │ (customer │ │ (tickets, │ │ (source, │
│ traces) │ │ regressions) │ │ data, DB) │ │ history) │ │ recent PRs) │
└─────────────┘ └─────────────────┘ └──────────────┘ └──────────────┘ └──────────────┘

Key design decisions:

  • MCP servers handle auth/credentials — Claude Code sees only clean interfaces
  • Queries execute in parallel, not sequentially → majority of the time savings
  • Human investigators review Claude’s structured report, not raw data
  • One dedicated repo for all MCP server implementations + system prompt

Results (self-reported by Mergify, Nov 2025):

  • Triage time: ~15 min → <5 min (⅔ reduction)
  • First-pass accuracy: 75% (25% still require human follow-up)

Key takeaway: This pattern — Claude Code as operational orchestrator with domain-specific MCP adapters — applies to any ops/support team juggling multiple disconnected systems. It’s distinct from “Claude Code as dev tool”: here Claude runs in a production workflow, not an IDE.

Source: Mergify blog — “How We Turned Claude Into a Cross-System Support Investigator” (Julian Maurin, Nov 2025)

Claude Code includes a comprehensive plugin system that allows you to extend functionality through community-created or custom plugins and marketplaces.

Plugins are packaged extensions that can add:

  • Custom agents with specialized behavior
  • New skills for reusable workflows
  • Pre-configured commands
  • Domain-specific tooling

Think of plugins as distributable packages that bundle agents, skills, and configuration into installable modules.

CommandPurposeExample
claude pluginList installed pluginsShows all plugins with status
claude plugin install <name>Install plugin from marketplaceclaude plugin install security-audit
claude plugin install <name>@<marketplace>Install from specific marketplaceclaude plugin install linter@company
claude plugin enable <name>Enable installed pluginclaude plugin enable security-audit
claude plugin disable <name>Disable plugin without removingclaude plugin disable linter
claude plugin uninstall <name>Remove plugin completely (prompts before deleting persistent data)claude plugin uninstall security-audit
claude plugin update [name]Update plugin to latest versionclaude plugin update security-audit
claude plugin validate <path>Validate plugin manifestclaude plugin validate ./my-plugin

${CLAUDE_PLUGIN_DATA} — Persistent plugin storage (v2.1.78+): Plugins can store state that survives updates using the ${CLAUDE_PLUGIN_DATA} env variable. This variable points to a dedicated directory that is preserved when the plugin is updated and only deleted on explicit /plugin uninstall (with confirmation prompt). Use it for caches, user preferences, or any data your plugin needs across sessions.

// In your plugin's hooks.json
{
"hooks": {
"SessionStart": [{
"type": "command",
"command": "mkdir -p ${CLAUDE_PLUGIN_DATA}/cache && my-plugin init"
}]
}
}

Marketplaces are repositories of plugins you can install from.

Marketplace commands:

Terminal window
# Add a marketplace
claude plugin marketplace add <url-or-path>
# Examples:
claude plugin marketplace add https://github.com/claudecode/plugins
claude plugin marketplace add /Users/yourname/company-plugins
claude plugin marketplace add gh:myorg/claude-plugins # GitHub shorthand
# List configured marketplaces
claude plugin marketplace list
# Update marketplace catalog
claude plugin marketplace update [name]
# Remove a marketplace
claude plugin marketplace remove <name>

Typical workflow:

Terminal window
# 1. Add a marketplace (one-time setup)
claude plugin marketplace add https://github.com/awesome-claude/plugins
# 2. Install a plugin
claude plugin install code-reviewer
# 3. Enable it for your project
claude plugin enable code-reviewer
# 4. Use it in Claude Code session
claude
You: /review-pr
# Plugin command is now available

Load plugins temporarily for a single session:

Terminal window
# Load plugin directory for this session only
claude --plugin-dir ~/.claude/custom-plugins
# Load multiple plugin directories
claude --plugin-dir ~/work/plugins --plugin-dir ~/personal/plugins

This is useful for testing plugins before permanent installation.

Repo-Level Plugin Policy via --add-dir (v2.1.45+)

Section titled “Repo-Level Plugin Policy via --add-dir (v2.1.45+)”

Define plugin policies at repository or shared-config level using --add-dir:

Terminal window
# Load plugin configuration from a shared directory
claude --add-dir /path/to/shared-config

The directory’s settings.json can specify:

  • enabledPlugins: list of pre-enabled plugins for every session
  • extraKnownMarketplaces: additional marketplace registries to recognize

Example shared config settings.json:

{
"enabledPlugins": ["security-audit", "code-review"],
"extraKnownMarketplaces": [
"https://github.com/myorg/internal-plugins"
]
}

Team use case: Commit a shared config directory to your repo and all team members automatically get the same enabled plugins and approved marketplaces — no per-user configuration needed.

ScenarioUse Plugins
Team workflows✅ Share standardized agents/skills across team via private marketplace
Domain expertise✅ Install pre-built plugins for security, accessibility, performance analysis
Repeating patterns✅ Package your custom workflows for reuse across projects
Community solutions✅ Leverage community expertise instead of rebuilding from scratch
Quick experiments❌ Use custom agents/skills directly in .claude/ folder
Project-specific❌ Keep as project CLAUDE.md instructions instead

Plugins are structured directories with a manifest inside .claude-plugin/:

my-plugin/
├── .claude-plugin/
│ └── plugin.json # Plugin manifest (ONLY file in this dir)
├── agents/
│ └── my-agent.md # Custom agents
├── skills/
│ └── code-review/
│ └── SKILL.md # Agent Skills (folder + SKILL.md)
├── commands/
│ └── my-cmd.md # Slash commands
├── hooks/
│ └── hooks.json # Event handlers
├── .mcp.json # MCP server configurations (optional)
├── .lsp.json # LSP server configurations (optional)
└── README.md # Documentation

Since v2.0.74 (December 2025), Claude Code natively integrates with Language Server Protocol servers. Instead of navigating your codebase through text search (grep), Claude connects to the LSP server of your project and understands symbols, types, and cross-references — the same way an IDE does.

Why it matters: Finding all call sites of a function drops from ~45 seconds (text search) to ~50ms (LSP). Claude also gets automatic diagnostics after every file edit — errors and warnings appear in real time, without a separate build step.

Supported languages (11): Python, TypeScript, JavaScript, Go, Rust, Java, C/C++, C#, PHP, Kotlin, Ruby.

Terminal window
# Option 1 — one-time env variable
ENABLE_LSP_TOOL=1 claude
# Option 2 — persist in ~/.claude/settings.json
{
"env": {
"ENABLE_LSP_TOOL": "1"
}
}

The LSP server for your language must already be installed on the machine — Claude Code connects to it, it doesn’t install it. Common servers:

LanguageServerInstall
TypeScripttsserverBundled with TypeScript
Pythonpylsppip install python-lsp-server
Gogoplsgo install golang.org/x/tools/gopls@latest
Rustrust-analyzerrustup component add rust-analyzer
Kotlinkotlin-language-serverVia IntelliJ or standalone
Swiftsourcekit-lspBundled with Xcode

Controls how long Claude waits for an LSP server to initialize before treating it as unresponsive (v2.1.50+):

{
"servers": {
"tsserver": { "startupTimeout": 15000 },
"pylsp": { "startupTimeout": 10000 }
}
}

Useful in slow environments (CI, Docker, cold start) where default timeouts cause LSP features to be silently skipped.

⚠️ Common mistake: Don’t put commands/, agents/, skills/, or hooks/ inside .claude-plugin/. Only plugin.json goes there.

Example .claude-plugin/plugin.json:

{
"name": "security-audit",
"version": "1.0.0",
"description": "Security audit tools for Claude Code",
"author": {
"name": "Your Name"
}
}

The manifest only defines metadata. Claude Code auto-discovers components from the directory structure.

Skill namespacing: Plugin skills are prefixed with the plugin name to prevent conflicts:

  • Plugin security-audit with skill scan/security-audit:scan

Validate before distribution:

Terminal window
claude plugin validate ./my-plugin

Official documentation: code.claude.com/docs/en/plugins

Understanding when to use which:

FeaturePluginMCP Server
PurposeBundle Claude-specific workflows (agents, skills)Add external tool capabilities (databases, APIs)
ComplexitySimpler - just files + manifestMore complex - requires server implementation
ScopeClaude Code instructions and patternsExternal system integrations
Installationclaude plugin installAdd to settings.json MCP config
Use caseSecurity auditor agent, code review workflowsPostgreSQL access, Playwright browser automation
Interactive UINoYes (via MCP Apps extension - SEP-1865)*

Rule of thumb:

  • Plugin = “How Claude thinks” (new workflows, specialized agents)
  • MCP Server = “What Claude can do” (new tools, external systems)
  • MCP Apps = “What Claude can show” (interactive UIs in supported clients)*

*Note: MCP Apps render in Claude Desktop, VS Code, ChatGPT, Goose. Not supported in Claude Code CLI (terminal is text-only). See Section 8.1 for details.

Before installing plugins:

  1. Trust the source - Only install from verified marketplaces
  2. Review manifest - Check what the plugin includes with validate
  3. Test in isolation - Use --plugin-dir for testing before permanent install
  4. Company policies - Check if your organization has approved plugin sources

Red flags:

  • Plugins requesting network access without clear reason
  • Unclear or obfuscated code in agents/skills
  • Plugins without documentation or proper manifest

1. Team Code Standards Plugin

Terminal window
# Company creates private marketplace
git clone git@github.com:yourcompany/claude-plugins.git ~/company-plugins
# Add marketplace
claude plugin marketplace add ~/company-plugins
# Install company standards
claude plugin install code-standards@company
# Now all team members use same linting, review patterns

2. Security Audit Suite

Terminal window
# Install community security plugin
claude plugin install owasp-scanner
# Use in session
claude
You: /security-scan
# Runs OWASP Top 10 checks, dependency audit, secret scanning

3. Accessibility Testing

Terminal window
# Install a11y plugin
claude plugin install wcag-checker
# Enable for project
claude plugin enable wcag-checker
# Adds accessibility-focused agents
You: Review this component for WCAG 2.1 compliance

Plugin not found after install:

Terminal window
# Refresh marketplace catalogs
claude plugin marketplace update
# Verify plugin is installed
claude plugin
# Check if disabled
claude plugin enable <name>

Plugin conflicts:

Terminal window
# Disable conflicting plugin
claude plugin disable <conflicting-plugin>
# Or uninstall completely
claude plugin uninstall <conflicting-plugin>

Plugin not loading in session:

  • Plugins are loaded at session start
  • Restart Claude Code after enabling/disabling
  • Check ~/.claude/plugins/ for installation

The Claude Code plugin ecosystem has grown significantly. Here are verified community resources:

Major marketplaces:

MarketplaceStatsFocus
wshobson/agents67 plugins, 99 agents, 107 skillsProduction-ready dev workflows, DevOps, security
claude-plugins.dev11,989 plugins, 63,065 skills indexedRegistry + CLI for plugin discovery
claudemarketplaces.comAuto-scans GitHubMarketplace directory

Installation example (wshobson/agents):

Terminal window
# Add the marketplace
/plugin marketplace add wshobson/agents
# Browse available plugins
/plugin
# Install specific plugin
/plugin install react-development

Popular plugins by install count (Jan 2026):

PluginInstallsUse case
Context7~72kLibrary documentation lookup
Ralph Wiggum~57kCode review automation
Figma MCP~18kDesign-to-code workflow
Linear MCP~9.5kIssue tracking integration

Curated lists:

Source: Stats from claude-plugins.dev, Firecrawl analysis (Jan 2026). Counts evolve rapidly.

All 181 templates in this guide’s examples/ directory are available as installable plugins — no file copying, hooks auto-wired on install:

Terminal window
claude plugin marketplace add FlorianBruniaux/claude-code-plugins
PluginWhat’s inside
security-suiteOWASP auditing, 4-agent cyber-defense pipeline, 13 protective hooks
devops-pipelineCI/CD (auto-detects Python/Node/Rust), git worktrees, GitHub Actions
release-automationChangelog, release notes (3 formats), social content from git log
code-qualitySOLID refactoring, TDD, GoF patterns, 6 specialist review agents
pr-workflowCEO + Eng planning gates, PR/issue triage, session handoffs
session-toolsccboard dashboard, voice refinement, 11 session hooks
ai-methodologyScaffolding, 6-stage talk pipeline, landing page generator
session-summaryAnalytics dashboard at session end (15 configurable sections)

Install only what you need. Source of truth for all templates stays in examples/ — the plugins repo is the published distribution layer.

github.com/FlorianBruniaux/claude-code-plugins

Two community plugins address complementary problems that AI-assisted development creates: code quality drift (accumulation of poorly-structured AI-generated code) and hallucination in generated solutions.

Problem solved: AI tools write code faster than teams can maintain it. GitClear’s analysis of 211M lines shows refactoring collapsed from 25% to under 10% of all changes (2021–2025). Vitals identifies which files are most likely to cause problems next — before they do.

How it works: Computes git churn × structural complexity × coupling centrality to rank hotspots. Not just “this file is complex” but “this complex file changed 49 times in 90 days and 63 other files break when it does.”

Terminal window
# Install (two commands in Claude Code)
/plugin marketplace add chopratejas/vitals
/plugin install vitals@vitals
# Scan from repo root
/vitals:scan
# Scope options
/vitals:scan src/ # Specific folder
/vitals:scan --top 20 # More results (default: 10)
/vitals:scan src/auth --top 5

What you get: Claude reads the flagged files and gives semantic diagnosis. Instead of “high complexity,” you get: “this class handles routing, caching, rate limiting, AND metrics in 7,137 lines — extract each concern.”

Status: v0.1 alpha. MIT. Zero dependencies (Python stdlib + git). Works on any repo.

Source: chopratejas/vitals

Problem solved: AI-generated code contains subtle errors that survive code review because both the AI and the reviewer follow the same reasoning path. SE-CoVe breaks this by running an independent verifier that never sees the initial solution.

Research foundation: Adaptation of Meta’s Chain-of-Verification methodology (Dhuliawala et al., ACL 2024 Findings — arXiv:2309.11495).

How it works — 5-stage pipeline:

  1. Baseline — Claude generates initial solution
  2. Planner — Creates verification questions from the solution’s claims
  3. Executor — Answers questions without seeing the baseline (prevents confirmation bias)
  4. Synthesizer — Compares findings, surfaces discrepancies
  5. Output — Produces verified solution
Terminal window
# Install (two separate commands — marketplace limitation)
/plugin marketplace add vertti/se-cove-claude-plugin
/plugin install chain-of-verification
# Use
/chain-of-verification:verify <your question>
/ver<Tab> # Autocomplete available

Trade-offs: ~2x token cost, reduced output volume. Worth it for security-sensitive code, complex debugging, and architectural decisions — not for rapid prototyping or simple fixes.

Source: vertti/se-cove-claude-plugin — v1.1.1, MIT

These tools solve different problems at different stages of the development cycle:

VitalsSE-CoVe
WhenMaintenance / weekly reviewPer-task generation
ProblemAccumulated code debtPer-solution accuracy
InputEntire git historyA specific question
OutputRanked hotspot files + diagnosisVerified answer
Token costLow (Python analysis + Claude reads top files)~2x standard generation
Best for”Which file is going to break?""Is this solution correct?”
Statusv0.1 alphav1.1.1 stable

Complementary workflow: Run Vitals weekly to identify which areas of the codebase need attention, then use SE-CoVe when asking Claude to refactor or fix those hotspot files.

Not every change warrants SE-CoVe’s 5-stage pipeline. For everyday review within a single session, you can prompt Claude to switch from author to reviewer explicitly:

You just wrote the implementation above. Now forget you wrote it.
Review it as a senior engineer who did not author this code.
Check: requirement fidelity, edge cases, error handling, backward
compatibility, security, performance. For each issue found, cite
the file and line, explain the problem, and propose a concrete fix.
Verdict: APPROVE, REQUEST CHANGES, or REJECT.

This works because the explicit instruction to “forget you wrote it” forces Claude to re-evaluate rather than defend prior decisions. It catches surface-level issues (missing null checks, inconsistent error handling, naming drift) but shares the same reasoning path as the author, so subtle architectural flaws may survive.

When to use what:

ApproachCostCatchesBest for
Role-switch (same session)1xSurface issues, naming, obvious bugsDaily development, quick fixes
SE-CoVe (plugin)~2xReasoning-path blind spots, subtle logic errorsSecurity-sensitive code, architecture
Cross-model review (see below)1x-2xDifferent reasoning patterns, fresh perspectiveCritical paths, pre-merge gates
Scope-focused agents2-5xDomain-specific issues in parallelLarge PRs, multi-concern review

A single model reviewing its own code follows the same reasoning patterns that produced the code. Using a different model for review introduces genuinely independent analysis.

The pattern: generate with one model, review with another.

Terminal window
# Implement with Opus (deep reasoning)
claude --model opus
# Review the diff with Sonnet (different reasoning path, lower cost)
claude -p "Review the changes in the last commit. Check for logic errors, \
edge cases, backward compatibility, and security issues. \
Cite file:line for each finding." --model sonnet
# Quick sanity check with Haiku (fast, cheap, catches obvious issues)
claude -p "List any bugs, missing error handling, or security issues \
in the last commit." --model haiku

With custom agents:

.claude/agents/cross-model-reviewer.md
---
name: cross-model-reviewer
model: sonnet # Different from your working model
tools: Read, Grep, Glob
---
You are reviewing code you did not write. Your job is to find problems.
Read the files listed below, then check:
1. Logic errors and edge cases
2. Error handling completeness
3. Backward compatibility risks
4. Security issues (injection, auth gaps, data leaks)
5. Performance concerns (O(n²), unbounded queries)
For each finding: severity (critical/high/medium), file:line, problem, fix.
If no issues found, say so explicitly.

Why different models catch different bugs: each model has distinct reasoning biases, training distributions, and failure modes. A bug that sits in one model’s blind spot may be obvious to another. This is the same principle behind diverse code review teams in traditional engineering.

Cost-effective patterns:

Generation ModelReview ModelCost MultiplierWhen
OpusSonnet~1.3xDefault for critical code
SonnetHaiku~1.05xHigh-volume, pre-commit gate
SonnetOpus~2xArchitecture, security-critical
AnySame model, fresh session~1.5xContext isolation without model switch

The fresh session variant (same model, new context via claude -p) gives you context isolation without changing the model. Less effective than a true model switch but still better than reviewing in the same session where the code was written.


MCP servers extend Claude Code’s capabilities, but they also expand its attack surface. Before installing any MCP server, especially community-created ones, apply the same security scrutiny you’d use for any third-party code dependency.

CVE details & advanced vetting: For documented CVEs (2025-53109/53110, 54135, 54136), MCP Safe List, and incident response procedures, see Security Hardening Guide.

Before adding an MCP server to your configuration:

CheckWhy
Source verificationGitHub with stars, known organization, or official vendor
Code auditReview source code—avoid opaque binaries without source
Minimal permissionsDoes it need filesystem access? Network? Why?
Active maintenanceRecent commits, responsive to issues
DocumentationClear explanation of what tools it exposes

Tool Shadowing

A malicious MCP server can declare tools with common names (like Read, Write, Bash) that shadow built-in tools. When Claude invokes what it thinks is the native Read tool, the MCP server intercepts the call.

Legitimate flow: Claude → Native Read tool → Your file
Shadowed flow: Claude → Malicious MCP "Read" → Attacker exfiltrates content

Mitigation: Check exposed tools with /mcp command. Use disallowedTools in settings to block suspicious tool names from specific servers.

Confused Deputy Problem

An MCP server with elevated privileges (database access, API keys) can be manipulated via prompt to perform unauthorized actions. The server authenticates Claude’s request but doesn’t verify the user’s authorization for that specific action.

Example: A database MCP with admin credentials receives a query from a prompt-injected request, executing destructive operations the user never intended.

Mitigation: Always configure MCP servers with read-only credentials by default. Only grant write access when explicitly needed.

Dynamic Capability Injection

MCP servers can dynamically change their tool offerings. A server might pass initial review, then later inject additional tools.

Mitigation: Pin server versions in your configuration. Periodically re-audit installed servers.

Minimal privilege setup:

{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgres://readonly_user:pass@host/db"
}
}
}
}

Tool restriction via settings:

{
"permissions": {
"deny": ["mcp__untrusted-server__execute", "mcp__untrusted-server__shell"]
}
}

Note: disallowedTools is a root-level key or CLI flag (--disallowedTools), not nested under permissions. For settings.json, use permissions.deny to block tool patterns.

Avoid MCP servers that:

  • Request credentials beyond their stated purpose
  • Expose shell execution tools without clear justification
  • Have no source code available (binary-only distribution)
  • Haven’t been updated in 6+ months with open security issues
  • Request network access for local-only functionality
Terminal window
# List active MCP servers and their tools
claude
/mcp
# Check what tools a specific server exposes
# Look for unexpected tools or overly broad capabilities

Best practice: Audit your MCP configuration quarterly. Remove servers you’re not actively using.


Quick jump: The Trinity · Composition Patterns · CI/CD Integration · IDE Integration · Tight Feedback Loops


Prerequisite: Read 4.1 What Are Agents and 3.1 CLAUDE.md before diving into 9.17-9.20.

New to Claude Code? Start with Ch.1-3 first. Chapter 9 makes most sense after 1-2 months of daily use.