|
| 1 | +# @rethunk/mcp-multi-root-git |
| 2 | + |
| 3 | +MCP stdio server providing three read-only git tools for any workspace. No `cwd` in MCP config — workspace root comes from the client's MCP roots (provided at `initialize`). |
| 4 | + |
| 5 | +## Tools |
| 6 | + |
| 7 | +MCP clients expose these as `{serverName}_{toolName}` (e.g. `rethunk-git_git_status`). Register the server with name `rethunk-git` (or any name you choose); the tools' registered short ids are: |
| 8 | + |
| 9 | +| Registered id | Purpose | |
| 10 | +|-----------------|---------| |
| 11 | +| `git_status` | `git status --short -b` for workspace root + optional submodules | |
| 12 | +| `git_inventory` | Status + ahead/behind per listed root; ordered for push prep | |
| 13 | +| `git_parity` | Compare `git rev-parse HEAD` for left/right path pairs | |
| 14 | + |
| 15 | +## Workspace preset file |
| 16 | + |
| 17 | +For multi-root repos, commit a file at **`.rethunk/git-mcp-presets.json`** in your workspace root: |
| 18 | + |
| 19 | +```json |
| 20 | +{ |
| 21 | + "push-prep": { |
| 22 | + "nestedRoots": ["path/to/package-a", "path/to/package-b"], |
| 23 | + "parityPairs": [ |
| 24 | + { "left": "core/packages/shared", "right": "edge/packages/shared", "label": "shared" } |
| 25 | + ] |
| 26 | + } |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +Then call tools with `"preset": "push-prep"` instead of passing paths inline. |
| 31 | + |
| 32 | +**This file is not part of the npm package.** Each repo that needs named presets commits its own file. |
| 33 | + |
| 34 | +### Schema |
| 35 | + |
| 36 | +```jsonc |
| 37 | +// .rethunk/git-mcp-presets.json |
| 38 | +{ |
| 39 | + "<preset-name>": { |
| 40 | + "nestedRoots": ["<relative-path>", ...], // for git_inventory |
| 41 | + "parityPairs": [ // for git_parity |
| 42 | + { "left": "<rel>", "right": "<rel>", "label": "<display>" } |
| 43 | + ] |
| 44 | + } |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +## Installation |
| 49 | + |
| 50 | +```bash |
| 51 | +npm install -g @rethunk/mcp-multi-root-git |
| 52 | +# or use via npx (no install required): |
| 53 | +npx -y @rethunk/mcp-multi-root-git |
| 54 | +``` |
| 55 | + |
| 56 | +## Cursor user-level MCP config |
| 57 | + |
| 58 | +Add to `~/.cursor/mcp.json` (no `cwd` needed — Cursor supplies workspace roots automatically): |
| 59 | + |
| 60 | +```json |
| 61 | +{ |
| 62 | + "mcpServers": { |
| 63 | + "rethunk-git": { |
| 64 | + "command": "npx", |
| 65 | + "args": ["-y", "@rethunk/mcp-multi-root-git"] |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +## Workspace root resolution |
| 72 | + |
| 73 | +1. Explicit `workspaceRoot` arg in the tool call (overrides everything). |
| 74 | +2. First `file://` root from the MCP `initialize` / `roots/list_changed` (Cursor, Claude Desktop, etc. send these automatically). |
| 75 | +3. `process.cwd()` as a last resort (useful in CI and test harnesses that pass explicit `workspaceRoot`). |
| 76 | + |
| 77 | +When a client sends multiple roots, the first valid `file://` root wins. Document tie-breaking in your own skill if you need a different policy. |
| 78 | + |
| 79 | +## Development |
| 80 | + |
| 81 | +Requires **Node ≥ 22**. Develop on **Node 24**. |
| 82 | + |
| 83 | +```bash |
| 84 | +npm install |
| 85 | +npm run build # tsc → dist/ |
| 86 | +npm run check # Biome lint + format check |
| 87 | +npm run check:fix # Auto-fix Biome issues |
| 88 | +``` |
| 89 | + |
| 90 | +## Publishing |
| 91 | + |
| 92 | +```bash |
| 93 | +npm run prepublishOnly # build + check |
| 94 | +npm publish # publishes @rethunk/mcp-multi-root-git@1.0.0 |
| 95 | +``` |
0 commit comments