Skip to content

Commit f8821d5

Browse files
AlbinoGeekclaude
andcommitted
docs: document git_diff_summary and batch_commit in v2.1.0
Add full parameter tables, JSON shapes, and error codes for both new tools to mcp-tools.md. Update README to drop the "read-only" claim now that batch_commit ships. Fix AGENTS.md implementation map: remove unexported symbols (splitPresetFileRaw, getPresetEntry, realPathOrSelf, uriToPath and friends), remove deleted MCP_JSON_FORMAT_VERSION constant, add rows for git-diff-summary-tool.ts and batch-commit-tool.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5f203be commit f8821d5

3 files changed

Lines changed: 103 additions & 7 deletions

File tree

AGENTS.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ IDEs injecting this as context: do not re-link from rules.
1414
| File | Symbols |
1515
|------|---------|
1616
| [`src/server.ts`](src/server.ts) | `FastMCP` + `roots: { enabled: true }`; `readMcpServerVersion()`; `registerRethunkGitTools` |
17-
| [`src/server/json.ts`](src/server/json.ts) | `MCP_JSON_FORMAT_VERSION="2"`, `jsonRespond()` (minified, no envelope), `spreadWhen`, `spreadDefined` |
17+
| [`src/server/json.ts`](src/server/json.ts) | `jsonRespond()` (minified, no envelope), `spreadWhen`, `spreadDefined` |
1818
| [`src/server/git.ts`](src/server/git.ts) | `gateGit`, `spawnGitAsync`, `asyncPool`, `GIT_SUBPROCESS_PARALLELISM`, `gitTopLevel`, `gitRevParseGitDir`, `gitRevParseHead`, `parseGitSubmodulePaths`, `hasGitMetadata`, `gitStatusSnapshotAsync`, `gitStatusShortBranchAsync`, `fetchAheadBehind`, `isSafeGitUpstreamToken` |
19-
| [`src/server/roots.ts`](src/server/roots.ts) | `uriToPath`, `listFileRoots`, `pathMatchesWorkspaceRootHint`, `resolveWorkspaceRoots`, `resolveRootsForPreset`, `requireGitAndRoots`session roots only |
20-
| [`src/server/presets.ts`](src/server/presets.ts) | `PRESET_FILE_PATH`, `splitPresetFileRaw`, `loadPresetsFromGitTop`, `getPresetEntry`, `presetLoadErrorPayload`, `applyPresetNestedRoots`, `applyPresetParityPairs`; Zod schemas must match [`git-mcp-presets.schema.json`](git-mcp-presets.schema.json) |
19+
| [`src/server/roots.ts`](src/server/roots.ts) | `requireGitAndRoots` — sole public export; session root resolution |
20+
| [`src/server/presets.ts`](src/server/presets.ts) | `PRESET_FILE_PATH`, `loadPresetsFromGitTop`, `presetLoadErrorPayload`, `applyPresetNestedRoots`, `applyPresetParityPairs`; Zod schemas must match [`git-mcp-presets.schema.json`](git-mcp-presets.schema.json) |
2121
| [`src/server/schemas.ts`](src/server/schemas.ts) | `WorkspacePickSchema`, `MAX_INVENTORY_ROOTS_DEFAULT` |
2222
| [`src/server/inventory.ts`](src/server/inventory.ts) | `InventoryEntryJson`, `validateRepoPath`, `makeSkipEntry`, `buildInventorySectionMarkdown`, `collectInventoryEntry` |
2323
| [`src/server/tools.ts`](src/server/tools.ts) | `registerRethunkGitTools` — dispatches to `register*` below |
@@ -26,14 +26,16 @@ IDEs injecting this as context: do not re-link from rules.
2626
| [`src/server/git-parity-tool.ts`](src/server/git-parity-tool.ts) | `git_parity` |
2727
| [`src/server/list-presets-tool.ts`](src/server/list-presets-tool.ts) | `list_presets` |
2828
| [`src/server/git-log-tool.ts`](src/server/git-log-tool.ts) | `git_log` |
29+
| [`src/server/git-diff-summary-tool.ts`](src/server/git-diff-summary-tool.ts) | `git_diff_summary` — structured token-efficient diff viewer; read-only |
30+
| [`src/server/batch-commit-tool.ts`](src/server/batch-commit-tool.ts) | `batch_commit` — sequential multi-commit; mutating |
2931
| [`src/server/presets-resource.ts`](src/server/presets-resource.ts) | `rethunk-git://presets` resource |
30-
| [`src/repo-paths.ts`](src/repo-paths.ts) | `resolvePathForRepo`, `assertRelativePathUnderTop`, `isStrictlyUnderGitTop`, `realPathOrSelf` |
32+
| [`src/repo-paths.ts`](src/repo-paths.ts) | `resolvePathForRepo`, `assertRelativePathUnderTop`, `isStrictlyUnderGitTop` |
3133

3234
## Changing contracts
3335

3436
- **No banner paragraphs** in shipped docs. Use normal titles + cross-links.
35-
- **`MCP_JSON_FORMAT_VERSION`** (currently `"2"`): bump on incompatible JSON changes (renamed/nested/omitted fields). Document migration here + [docs/mcp-tools.md](docs/mcp-tools.md). v2 removed the `rethunkGitMcp` envelope; payloads are minified; optional fields omitted when empty/null/false.
36-
- **Preset file:** keep `splitPresetFileRaw` + Zod aligned with [`git-mcp-presets.schema.json`](git-mcp-presets.schema.json).
37+
- **JSON format version** (currently `"2"`, discoverable via MCP `initialize`): bump on incompatible JSON changes (renamed/nested/omitted fields). Document migration here + [docs/mcp-tools.md](docs/mcp-tools.md). v2 removed the `rethunkGitMcp` envelope; payloads are minified; optional fields omitted when empty/null/false.
38+
- **Preset file:** keep `presets.ts` Zod schemas aligned with [`git-mcp-presets.schema.json`](git-mcp-presets.schema.json).
3739
- **Public tool surface:** rename/add → update [docs/mcp-tools.md](docs/mcp-tools.md) + [README.md](README.md) (if mentioned). Install/client wiring → [docs/install.md](docs/install.md) only. `.cursor/rules/rethunk-git-mcp.mdc` → only when *MCP-vs-shell* guidance changes.
3840

3941
## Validate + CI

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![npm version](https://img.shields.io/npm/v/%40rethunk%2Fmcp-multi-root-git.svg)](https://www.npmjs.com/package/@rethunk/mcp-multi-root-git)
55
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
66

7-
Read-only **git** tools over MCP (status, multi-root inventory, `HEAD` parity, presets). **Install and MCP client wiring:** **[docs/install.md](docs/install.md)** only — do not duplicate those steps elsewhere.
7+
**git** tools over MCP: read-only status, multi-root inventory, `HEAD` parity, presets, structured diff viewer, and batch commit. **Install and MCP client wiring:** **[docs/install.md](docs/install.md)** only — do not duplicate those steps elsewhere.
88

99
**Repository:** [github.com/Rethunk-AI/mcp-multi-root-git](https://github.com/Rethunk-AI/mcp-multi-root-git) · **npmjs (manual releases):** [`@rethunk/mcp-multi-root-git`](https://www.npmjs.com/package/@rethunk/mcp-multi-root-git) · **GitHub Packages (CI on each tag):** [`@rethunk-ai/mcp-multi-root-git`](https://github.com/Rethunk-AI/mcp-multi-root-git/packages) — see [docs/install.md](docs/install.md) and [HUMANS.md](HUMANS.md) Publishing.
1010

docs/mcp-tools.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ MCP clients expose tools as `{serverName}_{toolName}`. With the server registere
1616
| `git_parity` | `rethunk-git_git_parity` | Compare `git rev-parse HEAD` for path pairs. `pairs`, `preset`, `presetMerge`, `format`, plus workspace pick args. |
1717
| `list_presets` | `rethunk-git_list_presets` | List preset names/counts from `.rethunk/git-mcp-presets.json`; invalid JSON/schema surface as errors. Workspace pick + `format` only. |
1818
| `git_log` | `rethunk-git_git_log` | Path-filtered, time-windowed `git log` across one or more workspace roots. Returns commit history with author, date, subject, and shortstat. Args: `since`, `paths`, `grep`, `author`, `maxCommits`, `branch`, plus workspace pick args + `format`. |
19+
| `git_diff_summary` | `rethunk-git_git_diff_summary` | Structured, token-efficient diff viewer. Returns per-file diffs with additions/deletions counts, truncated to configurable line limits, with lock files/dist/vendor excluded by default. Args: `range`, `fileFilter`, `maxLinesPerFile`, `maxFiles`, `excludePatterns`, plus workspace pick args + `format`. **Read-only.** |
20+
| `batch_commit` | `rethunk-git_batch_commit` | Create multiple sequential git commits in a single call. Each entry stages the listed files then commits with the given message. Stops on first failure. Args: `commits` (array of `{message, files}`), plus workspace pick args + `format`. **Mutating — not idempotent.** |
1921

2022
Pass **`format: "json"`** on any tool for structured JSON instead of markdown (default).
2123

@@ -98,6 +100,98 @@ v2 field-omission rules: `filesChanged`, `insertions`, `deletions` are omitted w
98100
| `git_log_failed` | `git log` exited non-zero (e.g. unknown branch ref). |
99101
| `root_index_out_of_range` | `rootIndex` exceeds the number of MCP file roots. |
100102

103+
### `git_diff_summary` — parameters
104+
105+
| Parameter | Type | Default | Notes |
106+
|-----------|------|---------|-------|
107+
| `range` | string | unstaged | Diff range. `"staged"` / `"cached"` for index; `"HEAD"` for last commit; `"A..B"` or `"A...B"` for revision ranges; single ref. Default: unstaged working-tree changes. |
108+
| `fileFilter` | string || Glob pattern to restrict output to matching files (e.g. `"*.ts"`, `"src/**"`). |
109+
| `maxLinesPerFile` | int | `50` | Max diff lines to include per file (1–2000). |
110+
| `maxFiles` | int | `30` | Max files to include in output (1–500). |
111+
| `excludePatterns` | string[] | lock files, dist, vendor | Glob patterns to exclude. Defaults to `*.lock`, `*.lockb`, `bun.lock`, `package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `*.min.js`, `*.min.css`, `vendor/**`, `node_modules/**`, `dist/**`. Pass an empty array to disable. |
112+
| `workspaceRoot` | string || Explicit root; highest priority. |
113+
| `rootIndex` | int || Pick one of several MCP roots (0-based). |
114+
| `format` | `"markdown"` \| `"json"` | `"markdown"` | Output format. |
115+
116+
### `git_diff_summary` — JSON shape (`format: "json"`)
117+
118+
```json
119+
{
120+
"range": "unstaged changes",
121+
"totalFiles": 2,
122+
"totalAdditions": 10,
123+
"totalDeletions": 5,
124+
"files": [{
125+
"path": "src/foo.ts",
126+
"status": "modified",
127+
"additions": 8,
128+
"deletions": 3,
129+
"truncated": false,
130+
"diff": "@@ -1,3 +1,8 @@\n-const x = 1;\n+const x = 2;"
131+
}],
132+
"truncatedFiles": 1,
133+
"excludedFiles": ["yarn.lock"]
134+
}
135+
```
136+
137+
`status` is one of `"modified"`, `"added"`, `"deleted"`, `"renamed"`. `oldPath` is present only for renamed files. `truncatedFiles` and `excludedFiles` are omitted when zero/empty (v2 field-omission contract).
138+
139+
### `git_diff_summary` — error codes
140+
141+
| Code | Meaning |
142+
|------|---------|
143+
| `git_not_found` | `git` binary not on `PATH`. |
144+
| `not_a_git_repository` | The resolved workspace root is not inside a git repository. |
145+
| `unsafe_range_token` | The `range` string contains characters outside the safe token set. |
146+
| `git_diff_failed` | `git diff` exited non-zero. |
147+
148+
---
149+
150+
### `batch_commit` — parameters
151+
152+
| Parameter | Type | Notes |
153+
|-----------|------|-------|
154+
| `commits` | `{message: string, files: string[]}[]` | Commits to create in order. 1–50 entries. Each `files` entry is a path relative to the git root; all must stay within the git toplevel. |
155+
| `workspaceRoot` | string | Explicit root; highest priority. |
156+
| `rootIndex` | int | Pick one of several MCP roots (0-based). |
157+
| `format` | `"markdown"` \| `"json"` | Output format. Default: `"markdown"`. |
158+
159+
### `batch_commit` — JSON shape (`format: "json"`)
160+
161+
```json
162+
{
163+
"ok": true,
164+
"committed": 2,
165+
"total": 2,
166+
"results": [{
167+
"index": 0,
168+
"ok": true,
169+
"sha": "a1b2c3d",
170+
"message": "feat: add foo",
171+
"files": ["src/foo.ts"]
172+
}, {
173+
"index": 1,
174+
"ok": true,
175+
"sha": "b2c3d4e",
176+
"message": "chore: update config",
177+
"files": ["config.json"]
178+
}]
179+
}
180+
```
181+
182+
On first failure `ok` is `false`, `committed` reflects only the entries that succeeded before the error, and the failing entry includes `error` and `detail` fields. Remaining entries are skipped and not included in `results`.
183+
184+
### `batch_commit` — error codes (per-result `error` field)
185+
186+
| Code | Meaning |
187+
|------|---------|
188+
| `path_escapes_repository` | One of the listed file paths resolves outside the git toplevel. |
189+
| `stage_failed` | `git add` failed (e.g. untracked path or permission error). |
190+
| `commit_failed` | `git commit` failed (e.g. nothing staged, hooks rejected). |
191+
| `not_a_git_repository` | The resolved workspace root is not inside a git repository. |
192+
193+
---
194+
101195
## Resource
102196

103197
| URI | Purpose |

0 commit comments

Comments
 (0)