Repository navigation
feat(mcp): add write confirmation and redaction infrastructure - #506
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Shadow risk calibration
Calibration result: agreement. Shadow risk never blocks or enables merge. Keep it in observation mode until roughly 50 pull requests have human-reviewed labels, then calibrate before considering any policy use. |
| it('audits a write that throws and rethrows it', async () => { | ||
| const target = record(); | ||
| const ctx = context(); | ||
| target.write.mockRejectedValueOnce(new Error('upstream failed')); |
There was a problem hiding this comment.
The new tests never reuse a consumed approval or exercise refused. This test throws a plain Error, so it misses the rule that a 4xx releases an approval while a 5xx or lost response keeps it spent.
Add tests for concurrent use, replay after restoring the original record state, retry after a 4xx, and replay after a 5xx or network failure. This is non-blocking, but those tests would catch changes that allow duplicate writes or reject valid retries.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/mcp/src/tools/write-flow.test.ts
Line: 316-319
Comment:
**Approval reuse lacks tests**
The new tests never reuse a consumed approval or exercise `refused`. This test throws a plain `Error`, so it misses the rule that a 4xx releases an approval while a 5xx or lost response keeps it spent.
Add tests for concurrent use, replay after restoring the original record state, retry after a 4xx, and replay after a 5xx or network failure. This is non-blocking, but those tests would catch changes that allow duplicate writes or reject valid retries.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
* feat(mcp): add opt-in reference number tools add_reference_numbers (tier A) and remove_reference_numbers (tier C) in a new opt-in reference_numbers toolset, ported from #452 onto the write kit that landed in #506-#509. Drops the set_party_role party_id hint from the server instructions: it repeats the tool's own description, and with every toolset served the instructions otherwise exceed Claude Code's 2 KB limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(mcp): list the reference number tools in the agent trust feature map Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Extract the shared confirmation infrastructure from #451: signed five-minute approvals bound to the tool, arguments, account, credential, channel and record state; token/elicitation flows; refusal/replay handling; and redaction across logs, Sentry and PostHog. SDK 429 errors retain Retry-After for write-tool responses.
This prerequisite does not change which tools are exposed or require confirmation. The next PR activates confirmations for the two existing batch writes; lifecycle tools and publishing docs follow separately. Original author: Akshay Dodeja. Tracks DEV-14372.
Validation: full
npm run agent-verifypasses on Node 24, including 874 MCP tests, SDK/CLI tests and builds, lint/type checks, generated-contract checks, and a legacy-protocol initialize/tools-list smoke (30 tools). SDK reference regenerated withnpm run sdk:docs.Approval consumption is process-local; the original multi-instance limitation is retained. The lifecycle follow-up remains opt-in.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review order: #506 → #507 → #508 → #509. Each diff is against its predecessor; #509 is the combined QA target.
The PR appears safe to merge, with non-blocking feedback to test approval reuse and failure retries.
Fix with agent prompt
Summary
Adds shared write-confirmation helpers without activating them for exposed tools.
Acknowledged scope: alosec defers activation to the next PR and retains process-local approval consumption.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Read record] --> B{Needs approval?} B -->|No| C[Write] B -->|Yes| D{Approval supplied?} D -->|No| E[Return preview or ask user] D -->|Yes| F[Check signature, expiry, identity, and state] F -->|Invalid| G[Refuse or refresh preview] F -->|Valid| H[Reserve approval] H --> C C -->|Success| I[Keep approval spent] C -->|4xx refusal| J[Release approval] C -->|Other failure| IReviews (1) · Last reviewed commit: "fix(mcp): use a keyed credential tag for..." · Reviewed by Greptile