Enables code review operations including fetching pull request details, retrieving code diffs, adding review comments, and analyzing code quality for GitHub repositories.
Provides code review and merge request management capabilities including fetching merge request details, retrieving code diffs, adding review comments, creating merge requests, and analyzing code quality for GitLab projects.
Node Code Review MCP
A Node.js implementation of the Model Context Protocol (MCP) server for code review operations, supporting both GitHub and GitLab platforms.
π δΈζζζ‘£: README-zh.md | εΏ«ιεΌε§ | εθ½ε―Ήζ―
Features
π Fetch pull request/merge request details
π Get code diffs for PRs or commits
π¬ Add review comments
π Basic code quality analysis
π§ Configurable via command line arguments
π Support for both GitHub and GitLab APIs
Installation
Via NPM (when published)
Local Development
Configuration
Environment Variables
Copy env.example to .env and configure:
Command Line Arguments
MCP Configuration
Add to your MCP client configuration (e.g., Claude Desktop):
Using NPX (Recommended)
Using Local Installation
For GitLab
Available Tools
fetch_pull_request
Fetch pull request/merge request details.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project" (aliases:projectId,project_path)pullRequestNumber(number): Pull request numberprovider(string, optional): "github" or "gitlab" (default: "gitlab")
fetch_code_diff
Fetch code diff for a pull request or commit.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project"pullRequestNumber(number, optional): Pull request numbercommitSha(string, optional): Commit SHAfilePath(string, optional): Specific file path to get diff forprovider(string, optional): "github" or "gitlab" (default: "gitlab")
add_review_comment
Add a review comment to a pull request.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project"pullRequestNumber(number): Pull request numberbody(string): Comment bodyfilePath(string, optional): File path for line commentline(number, optional): Line number for line commentprovider(string, optional): "github" or "gitlab" (default: "gitlab")
analyze_code_quality
Analyze code quality and provide suggestions with detailed metrics.
Parameters:
code(string): Code content to analyzelanguage(string): Programming language (javascript, typescript, python, java, go, etc.)rules(array, optional): Specific rules to check
get_repository_info
Get repository information.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project"provider(string, optional): "github" or "gitlab" (default: "gitlab")
analyze_files_batch
Analyze multiple files for code quality issues.
Parameters:
files(array): Array of file objects withpath,content, andlanguagepropertiesrules(array, optional): Specific rules to apply to all files
get_pull_request_files
Get list of files changed in a pull request.
Parameters:
repository(string): Repository in format "owner/repo" or GitLab project path like "group/project"pullRequestNumber(number): Pull request numberprovider(string, optional): "github" or "gitlab" (default: "gitlab")
get_supported_languages
Get list of supported programming languages for code analysis.
get_language_rules
Get available analysis rules for a specific language.
Parameters:
language(string): Programming language
get_server_config
Get current server configuration and health status.
create_merge_request π
Create a new GitLab merge request from a source branch with enhanced error handling.
Parameters:
projectId(string): GitLab project ID or pathNumeric ID (recommended):
"12345"Project path:
"group/project"or"group/subgroup/project"
sourceBranch(string): Source branch name (e.g., "feature/new-feature")targetBranch(string, optional): Target branch name (defaults to "main")title(string, optional): Merge request title (auto-generated from branch name if not provided)description(string, optional): Merge request descriptionassigneeId(number, optional): User ID to assign the merge request toreviewerIds(array, optional): Array of user IDs to request reviews fromdeleteSourceBranch(boolean, optional): Whether to delete source branch when MR is mergedsquash(boolean, optional): Whether to squash commits when merging
Enhanced Error Handling:
Project ID validation with detailed error messages
Automatic project verification before MR creation
Comprehensive troubleshooting guidance for common errors (404, 401, 403, etc.)
Support for both numeric IDs and project paths
Example:
Auto-generated Titles: The tool automatically generates conventional commit-style titles based on branch prefixes:
feature/βfeat:bugfix/βfix:hotfix/βfix:docs/βdocs:refactor/βrefactor:
get_current_branch π
Get current Git branch and repository information.
Parameters:
workingDirectory(string, optional): Working directory path (defaults to current directory)
Example:
Returns:
get_project_info π
Get current GitLab project information from Git remotes.
Parameters:
workingDirectory(string, optional): Working directory path (defaults to current directory)remoteName(string, optional): Git remote name (defaults to "origin")
Example:
Returns:
API Token Setup
GitHub
Go to GitHub Settings > Developer settings > Personal access tokens
Generate a new token with appropriate permissions:
reposcope for private repositoriespublic_reposcope for public repositories only
GitLab
Go to GitLab User Settings > Access Tokens
Create a personal access token with:
apiscope for full API accessread_apiscope for read-only access
Development
License
MIT License - see LICENSE file for details.