Repository navigation
fix(plugin-mcp): allow deleteDocuments to delete trashed documents - #19051
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Accept and forward the trash option packages/payload/src/collections/operations/inputSchemas.ts, packages/payload/src/cli/commands/collections/deleteDocuments.ts, packages/plugin-mcp/src/mcp/builtin/collections/deleteTool.ts, test/plugin-mcp/int.spec.ts |
The deletion input schema accepts trash. The CLI command and MCP tool pass the option to both deletion paths. The MCP integration test checks the success text and forwarded arguments. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
- The MCP deletion changes address the reported inability to delete trashed documents: the input accepts
trash, and the tool forwards it topayload.delete.
Suggested reviewers: alessiogr
Merge Risk: 
Minimal · up to fd91c
-
The change appears ready to merge after normal checks; no actionable deletion risk remains identified.
Architecture risk: 
Low · up to fd91c
-
The change affects 3 systems.
Changed systems:
packages/payload,packages/plugin-mcp,testArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — packages/payload (library) was modified; 2 changed files map to changed impact.
- observed — packages/plugin-mcp (library) was modified; 1 changed file maps to changed impact.
- observed — test (service) was modified; 1 changed file maps to changed impact.
Before / after behavior
- observed — Modified behavior in packages/payload/src/cli/commands/collections/deleteDocuments.ts: The ID-based deletion call now passes
args.trashtopayload.delete. - observed — Modified behavior in packages/payload/src/cli/commands/collections/deleteDocuments.ts: The
where-based deletion call now passesargs.trashtopayload.delete. - observed — Modified behavior in packages/payload/src/collections/operations/inputSchemas.ts:
deleteDocumentsInputShapeadds thetrashfield, validated withtrashSchema; deletion inputs can now specify trash behavior. - observed — Modified behavior in packages/plugin-mcp/src/mcp/builtin/collections/deleteTool.ts: The input destructuring now includes
trash.
-
Pre-merge checks: 
5
-
Check name Status Explanation Title check The title names the MCP plugin, the deleteDocuments tool, and the trashed-document fix. The raw summary shows the change adds a trash option to the shared delete schema and passes it to payload.delete… Description check The description states the problem (MCP deleteDocuments cannot delete trashed documents), the cause (no trash option in deleteDocumentsInputShape and no trash passed to payload.delete), and the fix (t… Linked Issues check Issue #19050requires the MCP deleteDocuments tool to accept trash: true and pass it to payload.delete, so trashed documents can be deleted. At head fd91cc6:
- Schema: packages/payload/src/collection…Out of Scope Changes check All changes map to the #19050objective:
- inputSchemas.ts (+1): adds the trash option to the shared delete input shape. This is the change the issue requests.
- deleteTool.ts (+3/-1): passes trash t…Docstring Coverage No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4… Full details: Title check
-
Explanation
The title names the MCP plugin, the deleteDocuments tool, and the trashed-document fix. The raw summary shows the change adds a trash option to the shared delete schema and passes it to payload.delete in the MCP tool and CLI command, so the title matches the main change.
Full details: Description check
-
Explanation
The description states the problem (MCP deleteDocuments cannot delete trashed documents), the cause (no trash option in deleteDocumentsInputShape and no trash passed to payload.delete), and the fix (trash added to the shared schema and passed to both delete calls, plus an int test). This directly matches the changeset.
Full details: Linked Issues check
-
Explanation
Issue
#19050requires the MCP deleteDocuments tool to accept trash: true and pass it to payload.delete, so trashed documents can be deleted. At head fd91cc6:- Schema: packages/payload/src/collections/operations/inputSchemas.ts adds
trash: trashSchemato deleteDocumentsInputShape. deleteDocumentsInputSchema is strict, so trash: true is now accepted instead of rejected as an unrecognized key. - Handler: packages/plugin-mcp/src/mcp/builtin/collections/deleteTool.ts destructures
trashfrom input and passes it to both payload.delete calls (the id branch and the where branch), matching the pattern the issue cites from updateTool.ts. - Automated test: the PR adds an int test in test/plugin-mcp/int.spec.ts that calls deleteDocuments with trash: true and checks that payload.delete receives the post ID, collection slug, and trash: true. This test verifies pass-through through a spy, not end-to-end deletion of a trashed document from the database. It supports the stated requirement.
The issue's suggested fix matches these changes. The required behavior is implemented. The
#19050requirements are met. - Schema: packages/payload/src/collections/operations/inputSchemas.ts adds
Full details: Out of Scope Changes check
-
Explanation
All changes map to the
#19050objective:- inputSchemas.ts (+1): adds the trash option to the shared delete input shape. This is the change the issue requests.
- deleteTool.ts (+3/-1): passes trash to both payload.delete calls. This is the change the issue requests.
- test/plugin-mcp/int.spec.ts (+35): adds a test for the new behavior. Tests support the objective.
- packages/payload/src/cli/commands/collections/deleteDocuments.ts (+2): passes args.trash to both payload.delete calls. The CLI command uses deleteDocumentsLocalInputSchema, which is built from the same deleteDocumentsInputShape. The CLI therefore accepts trash as a direct result of the shared schema change. The issue names this schema as the fix location, so this side effect is expected and not unrelated work.
No change lacks a connection to the objective. No unrelated refactoring or unrelated behavior change is present in the reviewed summary.
Full details: Docstring Coverage
-
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4 files.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
🚀 This is included in version v4.0.0-beta.8 |
What?
The MCP
deleteDocumentstool can't delete a document that is already in the trash. Calling it with justidreturns NotFound, and passingtrash: trueis rejected by the input schema.Why?
deleteDocumentsInputShapehas notrashoption and the tool callspayload.deletewithout one, so the delete operation always filters out trashed documents. The find, count and update tools already accepttrash.How?
Added
trashto the shared delete input schema and passed it through to bothpayload.deletecalls in the MCP tool, likeupdateTool.tsdoes. The CLIdeleteDocumentscommand uses the same schema, so it now passestrashtoo. Added an int test that callsdeleteDocumentswithtrash: true.Fixes #19050