MCP Hub
Back to servers

Code Assistant

Gemini-powered MCP server for code analysis.

Registrynpm136/wk
Updated
Mar 3, 2026

Quick Install

npx -y @j0hanz/code-assistant

Code Assistant MCP

npm License: MIT TypeScript Node.js Docker

Gemini-powered MCP server for code analysis with structured outputs for findings, risk assessment, and focused patch suggestions.

Install in VS Code Install in VS Code Insiders

Add to LM Studio Install in Cursor Install in Goose

Overview

Code Assistant is a Model Context Protocol server that connects AI assistants to the Google Gemini API for automated code review, refactoring suggestions, complexity analysis, breaking-change detection, and test plan generation. It operates over stdio transport and exposes 13 tools, 7 resources, and 2 prompts.

Key Features

  • Diff-based code review — generate diffs from git, then analyze PR impact, produce review summaries, detect API breaking changes, and assess time/space complexity
  • File-based analysis — load individual files for refactoring suggestions, question answering, and logic verification via Gemini's code execution sandbox
  • Repository indexing — walk a local repository into a Gemini File Search Store for natural-language RAG queries
  • Web search — Google Search with Grounding for up-to-date information
  • Structured outputs — all Gemini-backed tools return validated JSON via Zod v4 schemas
  • Task lifecycle — supports MCP Tasks API for async operation tracking with cancellation
  • Configurable thinking — per-tool thinking levels (minimal/medium/high) balance speed vs depth
  • Multi-platform Docker — published to GHCR for linux/amd64 and linux/arm64

Requirements

Quick Start

{
  "mcpServers": {
    "code-assistant": {
      "command": "npx",
      "args": ["-y", "@j0hanz/code-assistant@latest"],
      "env": {
        "GEMINI_API_KEY": "<your-api-key>"
      }
    }
  }
}

[!TIP] Use the one-click install badges above for automatic setup in VS Code, Cursor, Goose, or LM Studio.

Client Configuration

Install in VS Code

Install in VS Code

Or add manually to .vscode/mcp.json:

{
  "servers": {
    "code-assistant": {
      "command": "npx",
      "args": ["-y", "@j0hanz/code-assistant@latest"],
      "env": {
        "GEMINI_API_KEY": "<your-api-key>"
      }
    }
  }
}

Or via CLI:

code --add-mcp '{"name":"code-assistant","command":"npx","args":["-y","@j0hanz/code-assistant@latest"]}'

For more info, see VS Code MCP docs.

Install in VS Code Insiders

Install in VS Code Insiders

Or via CLI:

code-insiders --add-mcp '{"name":"code-assistant","command":"npx","args":["-y","@j0hanz/code-assistant@latest"]}'
Install in Cursor

Install in Cursor

Or add to ~/.cursor/mcp.json:

{
  "mcpServers": {
    "code-assistant": {
      "command": "npx",
      "args": ["-y", "@j0hanz/code-assistant@latest"],
      "env": {
        "GEMINI_API_KEY": "<your-api-key>"
      }
    }
  }
}

For more info, see Cursor MCP docs.

Install in Claude Desktop

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "code-assistant": {
      "command": "npx",
      "args": ["-y", "@j0hanz/code-assistant@latest"],
      "env": {
        "GEMINI_API_KEY": "<your-api-key>"
      }
    }
  }
}

For more info, see Claude Desktop MCP docs.

Install in Claude Code
claude mcp add code-assistant -- npx -y @j0hanz/code-assistant@latest

For more info, see Claude Code MCP docs.

Install in Windsurf

Add to your Windsurf MCP config:

{
  "mcpServers": {
    "code-assistant": {
      "command": "npx",
      "args": ["-y", "@j0hanz/code-assistant@latest"],
      "env": {
        "GEMINI_API_KEY": "<your-api-key>"
      }
    }
  }
}

For more info, see Windsurf MCP docs.

Install in Amp
amp mcp add code-assistant -- npx -y @j0hanz/code-assistant@latest

For more info, see Amp MCP docs.

Install in Cline

Add to cline_mcp_settings.json:

{
  "mcpServers": {
    "code-assistant": {
      "command": "npx",
      "args": ["-y", "@j0hanz/code-assistant@latest"],
      "env": {
        "GEMINI_API_KEY": "<your-api-key>"
      }
    }
  }
}
Install via Docker
{
  "mcpServers": {
    "code-assistant": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "GEMINI_API_KEY",
        "ghcr.io/j0hanz/code-assistant:latest"
      ],
      "env": {
        "GEMINI_API_KEY": "<your-api-key>"
      }
    }
  }
}

Or run directly:

docker run -i -e GEMINI_API_KEY="<your-api-key>" ghcr.io/j0hanz/code-assistant:latest

MCP Surface

Tools

generate_diff

Generate a diff of current changes and cache it server-side. Must be called before diff-based analysis tools.

NameTypeRequiredDescription
modestringyes'unstaged' or 'staged' diff capture.

analyze_pr_impact

Assess severity, categories, breaking changes, and rollback complexity.

NameTypeRequiredDescription
repositorystringyesRepository identifier (owner/repo).
languagestringnoPrimary language hint.

generate_review_summary

Produce PR summary, risk rating, and merge recommendation.

NameTypeRequiredDescription
repositorystringyesRepository identifier (owner/repo).
languagestringnoPrimary language hint.

generate_test_plan

Generate prioritized test cases and coverage guidance.

NameTypeRequiredDescription
repositorystringyesRepository identifier (owner/repo).
languagestringnoPrimary language hint.
testFrameworkstringnoFramework hint (jest, pytest, etc).
maxTestCasesnumbernoMax test cases (1-30).

analyze_time_space_complexity

Analyze Big-O complexity and detect degradations in changed code.

NameTypeRequiredDescription
languagestringnoPrimary language hint.

detect_api_breaking_changes

Detect breaking API/interface changes in a diff.

NameTypeRequiredDescription
languagestringnoPrimary language hint.

load_file

Read a single file from disk and cache it server-side. Must be called before file analysis tools.

NameTypeRequiredDescription
filePathstringyesAbsolute path to the file to load.

refactor_code

Analyze cached file for naming, complexity, duplication, and grouping improvements.

NameTypeRequiredDescription
languagestringnoPrimary language hint.

ask_about_code

Answer natural-language questions about a cached file.

NameTypeRequiredDescription
questionstringyesQuestion about the loaded file.
languagestringnoPrimary language hint.

verify_logic

Verify algorithms and logic in cached file using Gemini code execution sandbox.

NameTypeRequiredDescription
questionstringyesQuestion about the loaded file.
languagestringnoPrimary language hint.

web_search

Perform a Google Search with Grounding to get up-to-date information.

NameTypeRequiredDescription
querystringyesSearch query.

index_repository

Walk a local repository, upload source files to a Gemini File Search Store for RAG queries.

NameTypeRequiredDescription
rootPathstringyesAbsolute path to the repository root.
displayNamestringnoDisplay name for the store. Default: dir name.

query_repository

Query the indexed repository search store using natural language.

NameTypeRequiredDescription
querystringyesNatural-language question about the repo.
languagestringnoPrimary language hint.

Resources

URI PatternMIME TypeDescription
internal://instructionstext/markdownComplete server usage instructions.
internal://tool-catalogtext/markdownTool reference: models, params, data flow.
internal://workflowstext/markdownRecommended workflows and tool sequences.
internal://server-configtext/markdownRuntime configuration and limits.
internal://tool-info/{toolName}text/markdownPer-tool reference (supports completions).
internal://diff/currenttext/x-patchMost recently generated diff (cached).
internal://file/currenttext/plainMost recently loaded file (cached).

Prompts

PromptArgumentsDescription
get-helpnoneServer instructions.
review-guidetool, focusAreaWorkflow guide for tool/focus area.

Configuration

Environment Variables

VariableDefaultRequiredDescription
GEMINI_API_KEYN/AyesGoogle Gemini API key.
GOOGLE_API_KEYN/Ayes*Alternative API key variable (*either one required).
GEMINI_MODELgemini-3-flash-previewnoModel override for all tools.
MAX_DIFF_CHARS120000noMax diff size in characters.
GEMINI_HARM_BLOCK_THRESHOLDBLOCK_NONEnoSafety threshold (BLOCK_NONE, BLOCK_ONLY_HIGH, BLOCK_MEDIUM_AND_ABOVE, BLOCK_LOW_AND_ABOVE).
GEMINI_INCLUDE_THOUGHTSfalsenoInclude model thinking in responses.
GEMINI_BATCH_MODEoffnoBatch mode: off or inline.
GEMINI_BATCH_POLL_INTERVAL_MSN/AnoPoll cadence for batch status checks.
GEMINI_BATCH_TIMEOUT_MSN/AnoMax wait for batch completion.
MAX_CONCURRENT_CALLS10noMax concurrent Gemini calls.
MAX_CONCURRENT_BATCH_CALLS2noMax concurrent batch calls.
MAX_CONCURRENT_CALLS_WAIT_MS2000noWait timeout for concurrency queue (ms).
GEMINI_DIFF_CACHE_ENABLEDfalsenoEnable Gemini-side diff caching.
GEMINI_DIFF_CACHE_TTL_SN/AnoCache TTL in seconds.

CLI Arguments

FlagShortMaps to env varDescription
--model-mGEMINI_MODELOverride default model.
--max-diff-charsMAX_DIFF_CHARSOverride diff budget.

Security

ControlStatusEvidence
Non-root Docker userconfirmedDockerfileadduser -D mcp, USER mcp
Read-only volume mountconfirmeddocker-compose.yml:ro flag
Diff budget enforcementconfirmedsrc/lib/diff.tsMAX_DIFF_CHARS
Noisy file exclusionconfirmedsrc/lib/diff.tsNOISY_EXCLUDE_PATHSPECS
Configurable safety filtersconfirmedsrc/lib/gemini/config.tsGEMINI_HARM_BLOCK_THRESHOLD
npm publish provenanceconfirmed.github/workflows/release.yml--provenance flag

Development

ScriptCommandPurpose
buildnpm run buildCompile TypeScript to dist/.
devnpm run devWatch mode (tsc --watch).
startnpm run startRun built server.
type-checknpm run type-checkType-check src and tests.
lintnpm run lintESLint.
formatnpm run formatPrettier.
testnpm run testRun tests (node:test).
knipnpm run knipDead-code detection.
inspectornpm run inspectorMCP Inspector.

Debugging with MCP Inspector

npx @modelcontextprotocol/inspector npx -y @j0hanz/code-assistant@latest

Build and Release

  • Release workflow: manual dispatch via GitHub Actions (workflow_dispatch) with version bump type (patch/minor/major) or custom version.
  • npm: published to @j0hanz/code-assistant with OIDC trusted publishing and provenance attestation.
  • Docker: multi-platform image (linux/amd64, linux/arm64) pushed to ghcr.io/j0hanz/code-assistant.
  • MCP Registry: published to registry.modelcontextprotocol.io as io.github.j0hanz/code-assistant.

Docker Build

docker build -t code-assistant .

Troubleshooting

  • Missing API key: set GEMINI_API_KEY or GOOGLE_API_KEY in your environment or client config.
  • Diff too large: increase MAX_DIFF_CHARS or use --max-diff-chars flag. Lock files and build artifacts are excluded automatically.
  • Inspector not connecting: ensure the server builds cleanly with npm run build before running the inspector.
  • E_NO_DIFF error: call generate_diff before any diff-based analysis tool.
  • E_NO_FILE error: call load_file before refactor_code, ask_about_code, or verify_logic.

Contributing and License

Reviews

No reviews yet

Sign in to write a review