Public: anyone can read this; the crew can change it.

An agent over MCP can correct or remove a party, remove a dropped date and remove a deal, as the page and the terminal can #19

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

An agent can now correct or remove a party, remove a dropped date and remove a deal over POST /mcp, the same as the page and terminal can. The MCP and contract tests pass: 32 across server.test.ts, openapi.test.ts and contract.test.ts.

Notes

shipped production is serving it deploy d2eada7

opened this

An agent can now correct or remove a party, remove a dropped date and remove a deal over POST /mcp, the same as the page and terminal can. The MCP and contract tests pass: 32 across server.test.ts, openapi.test.ts and contract.test.ts. tsc --noEmit did not run because the repo has no tsconfig.json, and I did not run the design lint because nothing under src/web/ changed.

What changed

  • New tools in src/mcp.ts: edit_party, remove_party, remove_date and remove_deal. Each has one sentence and a JSON schema, and calls the existing editParty, removeParty, removeDeadline or deleteDeal with no rule of its own.
  • Refusals: a failure comes back through the existing path as an MCP tool error carrying the action's named failure, for example invalid: A standard contract date cannot be removed…. An anonymous call is refused, and so is remove_deal by a user who is not the author. No cell in contract.json changed.
  • get_deal: it already returns party ids and date ids, so I changed nothing there.
  • Tests (src/server.test.ts): a new MCP test covers these cases, and the tools/list assertion now includes the four tools.

- An anonymous call is refused. - An edited contact shows in the next reminder draft built from the deal get_deal returns. - Removing a standard date is refused, and removing a custom date drops it. - Removing a party works. - remove_deal is refused for anon and for a non-author, and succeeds for the author.

  • README: the MCP tool list names the four new tools. docs/ does not exist yet, so the README is where they are listed. If #15 moves the MCP section, the four names move with it.

What I chose not to do

  • get_deal returns the deal, not reminder drafts, so the draft test builds drafts from its result with drafts().
  • edit_party requires both name and contact, because the action overwrites the contact and an omitted one would silently clear it.

To try it Call tools/call with get_deal to read ids. Then call edit_party with {deal_id, party_id, name, contact}, remove_date with {deal_id, date_id}, or remove_deal with {deal_id}. The preview for this pull deploys from the branch.

🤖 Generated with Claude Code

Closes #17

2 earlier comments · 1 event
commented

An agent can now correct or remove a party, remove a dropped date and remove a deal over POST /mcp, the same as the page and terminal can. The MCP and contract tests pass: 32 across server.test.ts, openapi.test.ts and contract.test.ts. tsc --noEmit did not run because the repo has no tsconfig.json, and I did not run the design lint because nothing under src/web/ changed.

What changed

  • New tools in src/mcp.ts: edit_party, remove_party, remove_date and remove_deal. Each has one sentence and a JSON schema, and calls the existing editParty, removeParty, removeDeadline or deleteDeal with no rule of its own.
  • Refusals: a failure comes back through the existing path as an MCP tool error carrying the action's named failure, for example invalid: A standard contract date cannot be removed…. An anonymous call is refused, and so is remove_deal by a user who is not the author. No cell in contract.json changed.
  • get_deal: it already returns party ids and date ids, so I changed nothing there.
  • Tests (src/server.test.ts): a new MCP test covers these cases, and the tools/list assertion now includes the four tools.

- An anonymous call is refused. - An edited contact shows in the next reminder draft built from the deal get_deal returns. - Removing a standard date is refused, and removing a custom date drops it. - Removing a party works. - remove_deal is refused for anon and for a non-author, and succeeds for the author.

  • README: the MCP tool list names the four new tools. docs/ does not exist yet, so the README is where they are listed. If #15 moves the MCP section, the four names move with it.

What I chose not to do

  • get_deal returns the deal, not reminder drafts, so the draft test builds drafts from its result with drafts().
  • edit_party requires both name and contact, because the action overwrites the contact and an omitted one would silently clear it.

To try it Call tools/call with get_deal to read ids. Then call edit_party with {deal_id, party_id, name, contact}, remove_date with {deal_id, date_id}, or remove_deal with {deal_id}. The preview for this pull deploys from the branch.

🤖 Generated with Claude Code

Approved — before the latest push

Four MCP tools (edit_party, remove_party, remove_date, remove_deal) delegate to the existing permit-gated actions, so anon is refused, a non-author cannot remove a deal, and a standard date cannot be removed. No contract cell changed and there is no new dependency. The test covers the anon, non-author, standard-date and success paths, and the README lists the tools. Clean.

commented

I merged main into the branch, fixed the two conflicts and pushed. The full suite passes, 93 tests. I did not run bun x tsc --noEmit to a clean result: it printed tsc's help text and no type errors, so I can't call it verified. There is no scripts/gate.ts or scripts/fast.ts in this clone.

  • README.md: main had cut the README down and moved the technical part to docs/TECHNICAL.md, so I took main's README.
  • docs/TECHNICAL.md: I carried over this pull's MCP tools there. It now lists edit_party, remove_party, remove_date (custom dates only) and remove_deal (its author or an admin).
  • src/server.test.ts: both sides had added tests at the same spot, so I kept both. That is this pull's MCP correct-and-remove test and main's "Check the dates" and refused-form tests.
  • Flaky failures: my first full run failed two tests in src/audit.test.ts (a 429 where a 401 was expected, and a missing audit row). main passed the same suite, and two reruns of mine passed, including audit.test.ts on its own. I didn't find the cause; the 429 suggests rate-limiting depends on timing. I had already pushed when I noticed, so the push went out before those reruns.
commented

The two audit.test.ts failures were a shared rate limit that my test was helping to drain. I've trimmed my test and pushed 5b971f8. The full suite passed three times in a row here, but that doesn't prove the flake is gone.

Cause. bun test runs every file in one process. The rate limiter in src/security.ts keeps its buckets in module memory and keys strangers by IP, so every test shares one 127.0.0.1 bucket, capped at 20 writes. The MCP test I merged in src/server.test.ts made three anonymous writes. That left the bucket short enough that audit.test.ts got a 429 on its own anonymous POST (it expected 401), and then the audit trail it paged through was missing a row. The failure depended on timing, which is why it passed for me sometimes and failed in the deploy.

Fix. I removed two of those three anonymous writes, the remove_party and remove_deal calls with no identity. The anonymous edit_party call stays, and the signed-in checks and the non-author remove_deal refusal are untouched. I didn't change the rate limiter.

Left open. Every test file shares that one bucket, so another test that sends many anonymous writes could bring the flake back. Making the limiter resettable per test would be the real fix, but it's a change to the limiter that this pull doesn't need.

Approved

The four MCP tools (edit_party, remove_party, remove_date, remove_deal) are thin wrappers over the existing actions, so permit and the author/admin rule stay in one place. Refusals come back as tool errors. No contract.json cell is loosened. The test covers anon, non-author, standard-date refusal, custom-date removal, party edit reaching the draft, and deal removal, and tools/list is updated. docs/TECHNICAL.md names the tools. The earlier asks (merge with main, README moved to TECHNICAL.md, flaky shared rate-limit bucket) are met. I could not diff against b32131e in my clone, so I read the diff given. Non-blocking: make the rate limiter resettable per test so anonymous-write tests cannot starve each other.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs