Skip to content

feat(mcp): diff and sync, as the CLI calls them - #157

Merged
jasdeepkhalsa merged 1 commit into
mainfrom
feat/mcp-diff-sync
Oct 22, 2026
Merged

jasdeepkhalsa merged 1 commit into
mainfrom
feat/mcp-diff-sync

Conversation

@jasdeepkhalsa

Copy link
Copy Markdown
Member

The MCP tools now use the CLI's vocabulary, and each tool's annotations tell the truth about it.

Was Now Annotation
scan_drift diff: every difference, plus the plan sync would run Read-only
apply_fixes sync: runs that plan; prove: true rehearses it first Destructive
(none) list_environments: environment names, never credentials Read-only
create_migration Now writes exactly what migrate create writes Writes files

Why two tools rather than one with a flag: clients decide what to run unattended from readOnlyHint and destructiveHint, which apply to a whole tool. A tool that both plans and writes has to be marked destructive, so a client asks before every plan. Otherwise it's marked read-only while able to write.

  • diff: writes nothing. Returns the findings, the drift score and plan: the statements sync would run, in order, and what it holds back and why. apply_fixes previewed by default but listed its preview under applied.
  • sync: takes the same arguments as diff, so the plan an agent shows is the plan that runs. Fixes that drop tables or columns are still held back unless allowDestructive is set. prove rehearses on a throwaway copy of the target and refuses to write if the copy wouldn't match the source.
  • Shared proof: the proof step moves out of the diff command into prove-gate, so diff --apply --prove and sync decide the same way. The CLI's output is unchanged.
  • list_environments: for clients that show tools but not resources, which had no way to learn environment names short of reading the config file.
  • create_migration: used to diff two snapshots of one environment. It now writes the source-to-target migration migrate create writes, with the grants on what it creates and a DOWN. Building the file moves into migration-file, shared by both.
  • Finding descriptions: schema and data findings now say in words what differs and what the fix does, instead of "difference detected by @dbdiff/cli".

Breaking: the tool names change. This is pre-1.0, so there are no aliases; two names for each action would only confuse agents.

Tested:

  • Unit tests, build and lint all pass, with new tests showing that diff and sync share arguments and that sync defaults hold back drops and don't prove.
  • Run live over stdio against two real databases:
    • list_environments returns no connection strings.
    • diff returns a 4-statement plan.
    • sync with prove: true converges and applies all 4; a second diff comes back clean.
    • create_migration reports nothing left to write.
    • With a client pg_dump too old for the server, sync with prove refuses and writes nothing.

🤖 Generated with Claude Code

scan_drift and apply_fixes become diff and sync. A single tool with a "really
write" argument has to be marked destructive, so a client asked before every
plan, or read-only while it could write. Two tools let each annotation be true.

- diff writes nothing and returns the plan: the statements sync would run, in
  order, and what it holds back. apply_fixes previewed by default but called
  its preview "applied".
- sync takes the same arguments, so the plan shown is the plan run, and adds
  prove: a rehearsal on a throwaway copy that refuses to write if the copy
  would not match the source. The proof is shared with diff --apply --prove,
  moved out of the command into prove-gate.
- list_environments names the environments without their credentials, for
  clients that show tools but not resources.
- create_migration writes what migrate create writes, grants included; it
  diffed two snapshots of one environment. The file's construction is shared,
  in migration-file.
- Schema and data findings say what differs and what the fix does, in words,
  where they said "difference detected by @dbdiff/cli".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jasdeepkhalsa
jasdeepkhalsa merged commit a0b44c4 into main Oct 22, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant