codeviewer-mcp

codeviewer-mcp

A stateful, AST-aware MCP server for structured code review workflows. It enables iterative review sessions with AST-based context localization and provides structured feedback with verdicts and patch suggestions for JavaScript/TypeScript code.

Category
访问服务器

README

codeviewer-mcp

codeviewer-mcp is a TypeScript MCP server for stateful, AST-aware code review workflows.

It is designed for clients that can run MCP servers over STDIO (local command execution) and call tools in iterative review loops.

What this repository provides

  • A local MCP server process (dist/index.js) that exposes review tools
  • Stateful review sessions stored in SQLite
  • AST-based context localization for JS/TS code
  • Deterministic preflight checks (TypeScript diagnostics + basic security pattern checks)
  • Structured review output with verdicts, categorized feedback, and optional search/replace patch suggestions

MCP tools exposed by the server

1) register_plan

Registers a review session and its ordered plan steps.

Input:

  • project_path (optional string)
  • steps (string array, required, at least 1)

Output:

  • session_id (UUID)
  • steps_registered (number)
  • status (ACTIVE)

2) review_code_chunk

Reviews one code chunk against a specific plan step.

Input:

  • session_id (UUID)
  • plan_step (positive integer)
  • target_file (string)
  • code_chunk (string)
  • modification_type (INSERT | MODIFY | DELETE | REPLACE)
  • target_node (optional string)
  • active_skills (optional string array)

Output:

  • verdict (PASS or NEEDS_WORK)
  • critical_issues (number)
  • feedback (array)
  • patches (array)
  • plan_step_status (PENDING | IN_PROGRESS | VALIDATED)

Runtime behavior

  • On startup, the server initializes a SQLite database (default: .codeviewer-mcp.sqlite in project root).
  • For each review_code_chunk request, the server:
    1. Validates the session and plan step
    2. Re-indexes project AST context
    3. Runs preflight checks on the submitted chunk
    4. Produces a structured review response
    5. Logs chunk + review data and updates plan step status

Requirements

  • Node.js 20+ (recommended)
  • npm
  • Build tools required by native Node modules (for better-sqlite3)

Installation (manual/local)

This repository is intended to run as a local MCP server process.

  1. Clone the repository
git clone https://github.com/Master0fFate/codeviewer-mcp.git
cd codeviewer-mcp
  1. Install dependencies
npm install
  1. Build
npm run build
  1. Start server
npm start

Development mode (no prebuild step):

npm run dev

Environment variables

  • MCP_PROJECT_PATH (optional): project root used for AST indexing. Defaults to current working directory.
  • MCP_REVIEWER_DB_PATH (optional): SQLite DB path. Defaults to <MCP_PROJECT_PATH>/.codeviewer-mcp.sqlite.

Example:

MCP_PROJECT_PATH=/absolute/path/to/target/repo \
MCP_REVIEWER_DB_PATH=/absolute/path/to/reviewer.sqlite \
node dist/index.js

Installing into MCP clients / LLM harnesses

The server uses STDIO transport, so integration is done by registering a local command.

Canonical command

Use this command in your MCP client configuration:

node /absolute/path/to/codeviewer-mcp/dist/index.js

Recommended args/env form:

{
  "command": "node",
  "args": ["/absolute/path/to/codeviewer-mcp/dist/index.js"],
  "env": {
    "MCP_PROJECT_PATH": "/absolute/path/to/target/project",
    "MCP_REVIEWER_DB_PATH": "/absolute/path/to/target/project/.codeviewer-mcp.sqlite"
  }
}

Claude Code

  1. Open your Claude Code MCP/server configuration file.
  2. Add a new server entry using the canonical STDIO command.
  3. Set MCP_PROJECT_PATH to the repository Claude Code should review.
  4. Save config and restart Claude Code.
  5. Confirm the server appears and exposes register_plan and review_code_chunk.

Example server block:

{
  "name": "codeviewer-mcp",
  "command": "node",
  "args": ["/absolute/path/to/codeviewer-mcp/dist/index.js"],
  "env": {
    "MCP_PROJECT_PATH": "/absolute/path/to/repo"
  }
}

OpenCode

  1. Open OpenCode MCP settings.
  2. Register a new STDIO MCP server named codeviewer-mcp.
  3. Point command/args to your built dist/index.js.
  4. Provide MCP_PROJECT_PATH in environment settings.
  5. Restart OpenCode and validate tool discovery.

Example entry:

{
  "mcpServers": {
    "codeviewer-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/codeviewer-mcp/dist/index.js"],
      "env": {
        "MCP_PROJECT_PATH": "/absolute/path/to/repo"
      }
    }
  }
}

Droid(factory)

  1. Open Droid(factory) MCP connector configuration.
  2. Add a local STDIO server entry.
  3. Use node as command and dist/index.js as the argument.
  4. Configure environment variables for project/database paths.
  5. Restart Droid(factory) runtime and verify tool availability.

Use the canonical JSON block shown above.

Kilo Code CLI

  1. Open Kilo Code CLI MCP configuration.
  2. Add a new server alias (for example codeviewer-mcp).
  3. Register the same STDIO launch command.
  4. Set MCP_PROJECT_PATH for the target repository.
  5. Restart the CLI session and list MCP tools to confirm connection.

Use the canonical JSON block shown above.

Note: client config schema and config file location can vary by version. If your MCP client expects different key names, map the same command/args/env values into its schema.

Verification checklist after integration

  • Server process starts without error
  • Client shows connected MCP server
  • Tools discovered:
    • register_plan
    • review_code_chunk
  • A sample register_plan call returns a session_id
  • A sample review_code_chunk call returns a structured verdict

Development and validation

Run tests:

npm test

Build:

npm run build

Repository layout

  • /src/index.ts - process entrypoint and STDIO transport
  • /src/server.ts - MCP server + tool registration
  • /src/schemas.ts - zod schemas for tool contracts
  • /src/state.ts - SQLite state store
  • /src/ast.ts - AST indexing and context localization
  • /src/preflight.ts - static preflight checks
  • /src/reviewer.ts - review decision + output shaping
  • /tests - vitest test suite
  • /prompts/universal-auditor-general-v2.1.md - audited prompt artifact

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选