@gbrandtio/rw-git-mcp 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,130 @@
1
+ # @gbrandtio/rw-git-mcp
2
+
3
+ **Model Context Protocol (MCP) server for rw-git**
4
+
5
+ This package provides an embedded Model Context Protocol (MCP) server that allows AI agents and IDEs (like Claude Desktop, Cursor, and Antigravity) to interact directly with your git repositories. It communicates over standard I/O using JSON-RPC 2.0.
6
+
7
+ `rw-git-mcp` provides a comprehensive suite of tools for AI agents to analyze and manipulate your repository, including core git commands (init, clone, checkout), code quality metrics, dependency drift analysis, compliance auditing, and LLM-assisted code review evaluations.
8
+
9
+ The MCP can also be used to provide Git harness to your agent, while keeping AI tokens to a minimum. It can be installed with bundled AI agent skills that offer structured workflows and best practices for repository analysis.
10
+
11
+ ## Available MCP Tools
12
+
13
+ `rw-git-mcp` provides a comprehensive suite of tools for AI agents to analyze and manipulate your repository:
14
+
15
+ **Repository Operations:**
16
+ - `init_repository`: Initializes a new Git repository.
17
+ - `clone_repository`: Clones a remote repository.
18
+ - `clone_specific_branch`: Clones a specific branch of a remote repository.
19
+ - `checkout_branch`: Switches branches.
20
+ - `is_git_repository`: Checks if a directory is a valid Git repository.
21
+ - `fetch_tags`: Retrieves all tags from the repository.
22
+
23
+ **Analysis & Metrics:**
24
+ - `analyze_code_quality`: Analyzes recent commits to identify code smells and technical debt.
25
+ - `analyze_code_quality_with_authors`: Analyzes code quality metrics along with author contributions.
26
+ - `analyze_bus_factor`: Calculates the "bus factor" by analyzing file ownership and contribution concentration.
27
+ - `analyze_commit_velocity`: Computes time-series commit velocity to track team productivity trends.
28
+ - `analyze_dependency_drift`: Parses dependency manifests for supply chain risk analysis.
29
+ - `analyze_file_ownership`: Cross-references CODEOWNERS with git blame history for ownership drift.
30
+ - `analyze_pr_diff`: Analyzes PR diffs for risk signals like high churn and exposed secrets.
31
+ - `analyze_release_delta`: Analyzes the changes and impact between two release tags.
32
+ - `predict_merge_conflicts`: Identifies files modified on both branches to predict merge conflicts.
33
+ - `analyze_dart_ast_quality`: Performs deep AST-level analysis of Dart files.
34
+ - `analyze_architecture_drift`: Analyzes git history to detect architectural drift by identifying commits that modify multiple layers.
35
+ - `analyze_clean_code`: Language-agnostic tool to analyze basic clean code heuristics.
36
+ - `calculate_universal_lexical_metrics`: Calculates language-agnostic code quality metrics (Cyclomatic, Halstead, Cognitive, Maintainability Index) for any source file.
37
+ - `get_stats`: Retrieves Git statistics like insertions and deletions.
38
+ - `get_commits_between`: Lists commits between two tags or branches.
39
+ - `get_contributions_by_author`: Retrieves commit counts grouped by author.
40
+
41
+
42
+ **Security & Compliance:**
43
+ - `audit_compliance`: Scans commit history for unsigned commits, empty messages, and unrecognized author emails.
44
+ - `detect_secrets_in_commits`: Scans commit history for exposed secrets or credentials.
45
+
46
+ **Code Review AI Agents:**
47
+ - `evaluate_comment_llm_generation`: Detects if code comments were likely generated by an LLM.
48
+ - `evaluate_comment_necessity`: Evaluates if comments are redundant or if the code could be self-documenting.
49
+ - `evaluate_comment_quality`: Analyzes the quality and usefulness of newly added comments.
50
+
51
+ ## Available Prompts
52
+
53
+ The server natively exposes MCP Prompts that provide AI agents with detailed instructions and workflows on how to effectively use the repository tools:
54
+
55
+ - `rw-git-mcp-reporting`: A comprehensive, step-by-step workflow instructing the AI on how to orchestrate the analysis tools to generate thorough repository reports, code quality assessments, and risk analysis.
56
+
57
+ ## Installation
58
+
59
+ This package acts as an installer that automatically downloads a pre-compiled, highly-optimized native executable of the rw-git MCP for your operating system and architecture.
60
+
61
+ ### Option 1: Run dynamically via `npx` (Recommended for MCP Clients)
62
+ This is the easiest way to integrate the server into tools like Claude Desktop or Cursor:
63
+ ```bash
64
+ npx -y @gbrandtio/rw-git-mcp
65
+ ```
66
+
67
+ ### Option 2: Install Globally
68
+ To install the server globally on your machine:
69
+ ```bash
70
+ npm install -g @gbrandtio/rw-git-mcp
71
+ ```
72
+ After installation, you can run the server simply by typing `rw-git-mcp` in your terminal.
73
+
74
+ ## Installing Agent Skills
75
+
76
+ To install the bundled AI agent skills directly into your local workspace, you can use `npx`:
77
+ ```bash
78
+ npx @gbrandtio/rw-git-mcp install-skills
79
+ ```
80
+
81
+ Alternatively, if you have installed the package globally via `npm install -g`, you can simply run:
82
+ ```bash
83
+ rw-git-mcp install-skills
84
+ ```
85
+
86
+ This will extract the skills to `./.agents/skills/rw-git-mcp/` in your current directory.
87
+
88
+ ## MCP Client Configuration
89
+
90
+
91
+ ### Claude Desktop
92
+ Add the following to your `claude_desktop_config.json`:
93
+ ```json
94
+ {
95
+ "mcpServers": {
96
+ "rw_git": {
97
+ "command": "npx",
98
+ "args": ["-y", "@gbrandtio/rw-git-mcp"]
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ ### Cursor
105
+ Add the following to your Cursor's `mcp.json` or `.cursor/mcp.json`:
106
+ ```json
107
+ {
108
+ "mcpServers": {
109
+ "rw_git": {
110
+ "command": "npx",
111
+ "args": ["-y", "@gbrandtio/rw-git-mcp"]
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ ### Antigravity (AGY CLI / Web IDE)
118
+ Add this to your MCP configuration block:
119
+ ```json
120
+ {
121
+ "mcpServers": {
122
+ "rw_git": {
123
+ "command": "npx",
124
+ "args": ["-y", "@gbrandtio/rw-git-mcp"]
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ For more details, visit the [main repository on GitHub](https://github.com/gbrandtio/rw-git).
package/bin/cli.js ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path');
4
+ const fs = require('fs');
5
+ const { spawn } = require('child_process');
6
+ const os = require('os');
7
+
8
+ const command = process.argv[2];
9
+
10
+ if (command === 'install-skills') {
11
+ const skillsSourceDir = path.join(__dirname, '../skills');
12
+ const targetDir = path.join(process.cwd(), '.agents', 'skills', 'rw-git-mcp');
13
+
14
+ if (!fs.existsSync(skillsSourceDir)) {
15
+ console.error(`Error: Skills directory not found in the package at ${skillsSourceDir}`);
16
+ console.error('This may be a packaging issue.');
17
+ process.exit(1);
18
+ }
19
+
20
+ try {
21
+ fs.mkdirSync(targetDir, { recursive: true });
22
+ fs.cpSync(skillsSourceDir, targetDir, { recursive: true });
23
+ console.log(`Successfully installed rw-git-mcp skills to ${targetDir}`);
24
+ process.exit(0);
25
+ } catch (error) {
26
+ console.error(`Failed to copy skills: ${error.message}`);
27
+ process.exit(1);
28
+ }
29
+ }
30
+
31
+ // Proxy to the actual Dart binary
32
+ const isWindows = os.platform() === 'win32';
33
+ const binName = isWindows ? 'rw-git-mcp-bin.exe' : 'rw-git-mcp-bin';
34
+ const binPath = path.join(__dirname, binName);
35
+
36
+ if (!fs.existsSync(binPath)) {
37
+ console.error(`Error: The executable ${binName} was not found.`);
38
+ console.error('Make sure the postinstall script completed successfully.');
39
+ process.exit(1);
40
+ }
41
+
42
+ // Pass all arguments down, minus the 'node' and 'cli.js' parts
43
+ const args = process.argv.slice(2);
44
+
45
+ const child = spawn(binPath, args, {
46
+ stdio: 'inherit'
47
+ });
48
+
49
+ child.on('error', (err) => {
50
+ console.error(`Failed to start child process: ${err}`);
51
+ process.exit(1);
52
+ });
53
+
54
+ child.on('exit', (code, signal) => {
55
+ if (code !== null) {
56
+ process.exit(code);
57
+ } else if (signal) {
58
+ process.kill(process.pid, signal);
59
+ } else {
60
+ process.exit(0);
61
+ }
62
+ });
package/install.js ADDED
@@ -0,0 +1,57 @@
1
+ const fs = require('fs');
2
+ const https = require('https');
3
+ const os = require('os');
4
+ const path = require('path');
5
+
6
+ const version = require('./package.json').version;
7
+ const binDir = path.join(__dirname, 'bin');
8
+ if (!fs.existsSync(binDir)) {
9
+ fs.mkdirSync(binDir);
10
+ }
11
+
12
+ const platform = os.platform();
13
+ const arch = os.arch();
14
+
15
+ let artifactName = '';
16
+ if (platform === 'linux' && arch === 'x64') {
17
+ artifactName = 'rw_git_mcp_linux_x64';
18
+ } else if (platform === 'darwin' && arch === 'arm64') {
19
+ artifactName = 'rw_git_mcp_macos_arm64';
20
+ } else if (platform === 'darwin' && arch === 'x64') {
21
+ artifactName = 'rw_git_mcp_macos_x64';
22
+ } else if (platform === 'win32' && arch === 'x64') {
23
+ artifactName = 'rw_git_mcp_windows_x64.exe';
24
+ } else {
25
+ console.error(`Unsupported platform/architecture: ${platform}/${arch}`);
26
+ process.exit(1);
27
+ }
28
+
29
+ const url = `https://github.com/gbrandtio/rw-git/releases/download/v${version}/${artifactName}`;
30
+ const destPath = path.join(binDir, platform === 'win32' ? 'rw-git-mcp-bin.exe' : 'rw-git-mcp-bin');
31
+
32
+ console.log(`Downloading ${url} ...`);
33
+
34
+ https.get(url, (res) => {
35
+ if (res.statusCode === 302 || res.statusCode === 301) {
36
+ https.get(res.headers.location, (redirectRes) => {
37
+ saveFile(redirectRes);
38
+ });
39
+ } else {
40
+ saveFile(res);
41
+ }
42
+ }).on('error', (err) => {
43
+ console.error('Download failed:', err);
44
+ process.exit(1);
45
+ });
46
+
47
+ function saveFile(res) {
48
+ const fileStream = fs.createWriteStream(destPath);
49
+ res.pipe(fileStream);
50
+ fileStream.on('finish', () => {
51
+ fileStream.close();
52
+ if (platform !== 'win32') {
53
+ fs.chmodSync(destPath, 0o755); // Make executable
54
+ }
55
+ console.log('Download complete.');
56
+ });
57
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@gbrandtio/rw-git-mcp",
3
+ "version": "2.0.2",
4
+ "description": "Model Context Protocol (MCP) server for rw-git",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "prepack": "node -e \"const fs = require('fs'); fs.cpSync('../../.agents/skills', './skills', {recursive: true});\"",
8
+ "postinstall": "node install.js"
9
+ },
10
+ "bin": {
11
+ "rw-git-mcp": "bin/cli.js"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/gbrandtio/rw-git.git"
16
+ },
17
+ "keywords": [
18
+ "mcp",
19
+ "git",
20
+ "ai",
21
+ "claude",
22
+ "cursor",
23
+ "gemini",
24
+ "harness"
25
+ ],
26
+ "author": "Ioannis Brant-Ioannidis",
27
+ "license": "MIT"
28
+ }
@@ -0,0 +1,71 @@
1
+ ---
2
+ name: rw-git-mcp-installation
3
+ description: "Guides the agent through installing and configuring the rw_git MCP server on the user's system."
4
+ ---
5
+
6
+ # `rw-git` MCP Server Installation Guide
7
+
8
+ This skill instructs you on how to set up the `rw_git` Model Context Protocol (MCP) server for a user so that their AI agents can access robust repository analysis tools.
9
+
10
+ Trigger this skill whenever a user asks to "install rw_git MCP", "connect the git MCP server", or "set up the repo analysis AI tools".
11
+
12
+ ## 1. Determine the Target Environment
13
+
14
+ First, identify which AI client the user wants to connect the MCP server to. If they haven't specified, ask them. Common clients include:
15
+ - **Claude Desktop**
16
+ - **Cursor IDE**
17
+ - **Antigravity (AGY)**
18
+
19
+ Also, ensure the user has Node.js installed, as `npx` is the recommended and easiest way to run the server. If they don't have Node.js, ask if they have Homebrew or the Dart SDK.
20
+
21
+ ## 2. Locate the Configuration File
22
+
23
+ Based on their client and OS, locate the correct MCP configuration file:
24
+
25
+ ### Claude Desktop
26
+ - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
27
+ - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
28
+
29
+ ### Cursor IDE
30
+ - Check if `.cursor/mcp.json` exists in the current workspace. If so, update it.
31
+ - Otherwise, guide the user to add it via the Cursor UI (Settings -> Features -> MCP), as Cursor's global config files are heavily nested.
32
+
33
+ ### Antigravity (AGY)
34
+ - Configuration is usually located at `~/.gemini/config/mcp.json` or within a plugin configuration.
35
+
36
+ ## 3. Inject the Configuration
37
+
38
+ Once the target file is located, use your file editing tools to safely merge the following `rw_git` configuration block into the `mcpServers` object.
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "rw_git": {
44
+ "command": "npx",
45
+ "args": [
46
+ "-y",
47
+ "@gbrandtio/rw-git-mcp"
48
+ ]
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ > [!WARNING]
55
+ > Do NOT overwrite existing MCP servers in the configuration file. Parse the JSON carefully and only insert or update the `rw_git` key inside `mcpServers`.
56
+
57
+ ### Alternative Commands
58
+ If the user prefers not to use `npx`, adjust the `command` and `args` accordingly:
59
+ - **Homebrew:** `command: "rw-git-mcp", args: []`
60
+ - **Dart global activate:** `command: "rw_git_mcp", args: []`
61
+
62
+ ## 4. Verification
63
+
64
+ After updating the configuration file, instruct the user to restart their AI client (e.g., fully quit and reopen Claude Desktop or reload Cursor).
65
+
66
+ To proactively verify that the server works on their machine, you can run a quick test via standard input:
67
+
68
+ ```bash
69
+ echo '{"jsonrpc": "2.0", "id": 1, "method": "prompts/list"}' | npx -y @gbrandtio/rw-git-mcp
70
+ ```
71
+ If the command outputs a valid JSON-RPC response containing a prompt named `rw-git-mcp-reporting`, the installation is successful!
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: rw-git-mcp-reporting
3
+ description: "Comprehensive workflow for orchestrating rw_git MCP tools to generate thorough repository reports, code quality assessments, and risk analysis."
4
+ ---
5
+
6
+ # `rw-git` MCP Reporting Workflow
7
+
8
+ This skill instructs you on how to orchestrate the complete suite of MCP tools provided by the `rw_git` server to generate a comprehensive, structured report of a repository.
9
+ When a user asks you to analyze the repository, assess code quality, evaluate an entire project, or generate a report, strictly follow this step-by-step workflow to ensure no stone is left unturned.
10
+
11
+ ## 1. Environment & Scope Preparation
12
+ Before diving into analysis, you **MUST** understand the context and establish the baseline environment.
13
+ - **Is it a remote or local repo?** Use `clone_repository` or `clone_specific_branch` to fetch it remotely. If you need to initialize a fresh local repository for analysis from scratch, use `init_repository`.
14
+ - **Local Verification:** If working locally, use `is_git_repository` to ensure you are in a valid Git directory.
15
+ - **Branch Context:** Use `checkout_branch` to switch to the appropriate target branch before running analysis, if needed.
16
+ - **Reference Gathering:** Use `fetch_tags` to get a list of available tags if you need to perform release comparisons.
17
+ - **Internal Docs:** If you ever need to understand how the underlying `rw_git` commands execute or handle errors, run `get_rw_git_documentation`.
18
+ - **Scope Resolution:** Resolve the exact arguments you will need for downstream tools (e.g., `limit`, `since`, `until`, `oldVersion`, `newVersion`, `branchA`, `branchB`).
19
+
20
+ ## 2. General Statistics & Contributor Activity
21
+ Start by building a foundational understanding of the codebase's size, scope, and primary drivers.
22
+ - **Overall Stats:** Run `get_stats` to get a high-level view of insertions, deletions, and total files changed.
23
+ - **Commit History:** Run `get_commits_between` to retrieve the raw sequence of commits in the target range to understand the context of the work.
24
+ - **Contributor Breakdown:** Run `get_contributions_by_author` to identify the most active contributors in the repository.
25
+
26
+ ## 3. Targeted Assessment & Velocity
27
+ Dive into the specific changes, analyzing their impact and how fast the team is moving.
28
+ - **For Branch/PR Comparisons:** Run `analyze_pr_diff` to get a breakdown of the specific risks introduced in a Pull Request.
29
+ - **For Tag/Release Comparisons:** Run `analyze_release_delta` to understand the structural changes between versions.
30
+ - **Code Quality:** Run `analyze_code_quality` (or `analyze_code_quality_with_authors` if the breakdown of contributors is important) to spot code smells, complex files, and technical debt.
31
+ - **Bug Hotspots:** Run `analyze_bug_hotspots` to identify files that are frequently modified in bug-fix commits, highlighting areas that may need refactoring.
32
+ - **Trend Analysis:** Run `analyze_commit_velocity` to gather time-series trend data, exposing anomalies in commit frequency and tracking team productivity over time.
33
+ - **Deep Inspection:** If you are analyzing Dart code, use `analyze_dart_ast_quality` for AST-level insights into dead code, public signature diffs, and dependency graphs. Use `analyze_clean_code` on individual files to check basic SOLID principles and readability heuristics.
34
+
35
+ ## 4. Security & Compliance Check
36
+ Ensure the code being analyzed meets security policies and project compliance standards. This step is critical for CI/CD environments.
37
+ - **Secret Scanning:** Run `detect_secrets_in_commits` to aggressively flag any exposed credentials, API keys, or tokens.
38
+ - **Compliance Auditing:** Run `audit_compliance` to ensure commit signatures exist, email addresses match recognized domains, and project commit message policies (like conventional commits or no empty messages) are being followed.
39
+
40
+ ## 5. Risk Analysis
41
+ Detect architectural bottlenecks, ownership risks, and potential integration disasters.
42
+ - **Knowledge Silos:** Run `analyze_bus_factor` and `analyze_file_ownership` to identify "mega-files" that have drifted in ownership or rely too heavily on a single author (low bus factor).
43
+ - **Integration Risk:** If you are analyzing a branch intended for integration (PR), run `predict_merge_conflicts` to proactively surface files that will conflict with the base branch.
44
+ - **Architecture Integrity:** Run `analyze_architecture_drift` to ensure that commits are not simultaneously modifying disparate architectural layers (which could signal leaky abstractions or tight coupling).
45
+
46
+ ## 6. Code Review & Ecosystem Health
47
+ Deep dive into the contents of the changes, focusing on dependencies and documentation.
48
+ - **Supply Chain Risks:** Use `analyze_dependency_drift` to flag vulnerable, unpinned, or floating dependencies across ecosystem manifests (e.g., `pubspec.yaml`, `package.json`).
49
+ - **AI-Assisted Code Review:** Evaluate the quality and origin of code comments using `evaluate_comment_quality` and `evaluate_comment_necessity`. Use `evaluate_comment_llm_generation` to detect if documentation was hastily generated by an LLM without human oversight, helping maintain a clean, self-documenting codebase.
50
+
51
+ ## 7. Release Notes & Changelogs
52
+ If the user's request involves summarizing changes between releases or wrapping up a large feature branch, prepare the user-facing documentation.
53
+ - **Changelog Generation:** Run `generate_changelog` to retrieve a structured, human-readable list of features, fixes, and breaking changes. Note that this tool also structurally links fixes to bug-introducing commits via SZZ.
54
+
55
+ ## 8. Synthesis & Formatting
56
+ Aggregate the outputs from all the invoked tools into a highly structured, unified Markdown artifact.
57
+ - Present the information with a clear executive summary followed by detailed sections.
58
+ - Use Github-flavored markdown alerts (`> [!WARNING]`, `> [!IMPORTANT]`, `> [!CAUTION]`) to highlight critical risks, exposed secrets, severe compliance violations, or likely merge conflicts.
59
+ - **Do not dump raw JSON.** Synthesize the metrics into readable tables, lists, and actionable insights. Use mermaid diagrams if it helps visualize complex relationships like contributor ownership.
60
+ - Point the user directly to the most critical files requiring attention based on the analysis.