{"_id":"@ahmedshaikh/apply-patch-mcp","name":"@ahmedshaikh/apply-patch-mcp","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@ahmedshaikh/apply-patch-mcp","version":"0.1.0","type":"module","description":"Apply a unified diff / patch to files as an MCP server — tolerant of line-offset drift (matches by context), supports modify/create/delete across files, with a dry-run. So agents can apply PR diffs and generated patches without shell gymnastics.","bin":{"agent-patch":"dist/cli.js"},"engines":{"node":">=18"},"scripts":{"serve":"tsx src/server.ts","patch":"tsx src/cli.ts","build":"tsc","test":"node --import tsx --test --test-force-exit test/*.test.ts","prepublishOnly":"npm run build"},"dependencies":{"@modelcontextprotocol/sdk":"^1.0.0","zod":"^3.23.8"},"devDependencies":{"@types/node":"^20.11.0","tsx":"^4.7.0","typescript":"^5.4.0"},"license":"MIT","author":{"name":"ahmedshaikh"},"keywords":["mcp","model-context-protocol","claude","agent","ai","diff","patch","unified-diff"],"repository":{"type":"git","url":"git+https://github.com/RaziStuff/apply-patch-mcp.git"},"homepage":"https://github.com/RaziStuff/apply-patch-mcp#readme","bugs":{"url":"https://github.com/RaziStuff/apply-patch-mcp/issues"},"publishConfig":{"access":"public"},"gitHead":"f0b639ab3e56cd1c8b6a6257444788db00318d26","_id":"@ahmedshaikh/apply-patch-mcp@0.1.0","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-X4kgdeLmZvN6Gmx6fJjCvzBN8Cd5LJkfv4PObW9ms+1jobRamFPaCNdOTB5wfVk4NW0Kdh0I0S/c2RMR2IPhnw==","shasum":"898e77e93857abb83e267dedb3f1106533af98d6","tarball":"https://registry.npmjs.org/@ahmedshaikh/apply-patch-mcp/-/apply-patch-mcp-0.1.0.tgz","fileCount":6,"unpackedSize":10841,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICSYRhGrclnEmRBsLB8f9kb2T/htyuLQJg1muF0QYrH7AiB/s1oeYn0tsct7COdHCKTIqECSWT+bvgEXjP++qb91+g=="}]},"_npmUser":{"name":"ahmedshaikh","email":"ahmed@shaikh1.com"},"directories":{},"maintainers":[{"name":"ahmedshaikh","email":"ahmed@shaikh1.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/apply-patch-mcp_0.1.0_1782701042741_0.596171313217795"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-29T02:44:02.604Z","0.1.0":"2026-06-29T02:44:02.901Z","modified":"2026-06-29T02:44:03.140Z"},"maintainers":[{"name":"ahmedshaikh","email":"ahmed@shaikh1.com"}],"description":"Apply a unified diff / patch to files as an MCP server — tolerant of line-offset drift (matches by context), supports modify/create/delete across files, with a dry-run. So agents can apply PR diffs and generated patches without shell gymnastics.","homepage":"https://github.com/RaziStuff/apply-patch-mcp#readme","keywords":["mcp","model-context-protocol","claude","agent","ai","diff","patch","unified-diff"],"repository":{"type":"git","url":"git+https://github.com/RaziStuff/apply-patch-mcp.git"},"author":{"name":"ahmedshaikh"},"bugs":{"url":"https://github.com/RaziStuff/apply-patch-mcp/issues"},"license":"MIT","readme":"# apply-patch\n\nApply a **unified diff / patch** to files — for an agent that has diff text (from a\nPR, `git format-patch`, or generated by an LLM) and needs to *land* it, without\nshell gymnastics. Tolerant of line-offset drift: it matches each hunk by its\nsurrounding context, not just the stated line number.\n\n```\napply_patch({ diff: \"<unified diff>\", dry_run: true })   // validate first\n→ { ok: true, files: [ { path: \"src/api.ts\", action: \"modified\", hunks: 2 } ] }\n```\n\n## Why\n\n`Edit` is for hand-written edits; there was no clean way to apply an *external*\ndiff. This closes that — and completes the edit-safety story: **checkpoint →\napply_patch → verify** (and restore if verify fails).\n\n## The tool\n\n**`apply_patch(diff, root?, dry_run?)`** — applies a unified diff. Handles\n**modify / create (`--- /dev/null`) / delete (`+++ /dev/null`)** across multiple\nfiles. Returns per-file `{ path, ok, action, hunks, error? }`.\n\n- **Context matching** — if the file has drifted from the diff's line numbers, it\n  searches outward from the expected position for the matching context block.\n- **Per-file safety** — a file whose hunk doesn't match is reported as failed and\n  left **unchanged** (no half-applied file).\n- **`dry_run: true`** — validate every hunk without writing.\n\n## Setup\n\n```bash\nnpm install\nnpm test\n```\n\n```bash\nclaude mcp add apply-patch -e APPLY_PATCH_ROOT=/path/to/project -- node /abs/path/apply-patch/dist/server.js\n# CLI: agent-patch change.diff   |   git diff | agent-patch --dry-run\n```\n\n## Honest limits\n\n- Standard unified-diff format (`---`/`+++`/`@@`); git-extended metadata lines are\n  ignored. Renames-as-metadata aren't specially handled (delete+create works).\n- Created files don't get a guaranteed trailing newline (the `\\ No newline` marker\n  is ignored).\n- Context matching is exact-line within the search window — it won't apply against\n  already-modified content (use `verify` after, `checkpoint` before).\n","readmeFilename":"README.md","_rev":"1-0004aa8e8c5183070f382ecb08b1088c"}