feat(mcp): add deleteDocument tool for permanent deletion by ID - #1443
Open
vivekvar-dl wants to merge 1 commit into
Open
feat(mcp): add deleteDocument tool for permanent deletion by ID#1443vivekvar-dl wants to merge 1 commit into
vivekvar-dl wants to merge 1 commit into
Conversation
The MCP server exposes every document operation except deletion: a connector user who spots a stale document via listDocuments has to open the web app to remove it. The only removal path, add_memory's forget action, matches by content similarity above 0.85 and can therefore delete the wrong memory when several are close. Add a deleteDocument tool that removes one document (and its extracted memories) by exact documentId via the existing documents.delete SDK call. It carries destructive-tool annotations so MCP hosts that surface them prompt before running it. Docs table and forget section updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1442
What
Adds a
deleteDocumentMCP tool: permanent deletion of one document (and the memories extracted from it) by exactdocumentId.Why
The MCP server covers the full document lifecycle except deletion. The only removal path today is
add_memory'sforgetaction, which resolves its target by content similarity (0.85 threshold) — it can delete the wrong memory when several are similar, and it can't act on the exactdocumentIdthatlistDocuments/getDocument/listMemoriesalready hand the assistant. A connector user who spots a stale document mid-conversation currently has to open the web app to remove it.Exact-ID deletion is strictly safer than the existing similarity-based path, and the tool carries
MEMORY_TOOL_ANNOTATIONS(destructiveHint: true) so hosts that surface MCP annotations prompt before running it.Changes
apps/mcp/src/server/tools/delete-document.ts— new tool, modeled line-for-line onget-document.ts(same input constraints, output schema pattern, error handling viadeps.errorResult)apps/mcp/src/server/client/index.ts—deleteDocument(id)wrapping the SDK's existingdocuments.delete(DELETE /v3/documents/{id}), with the client's standard operation-error handlingapps/mcp/src/server/tools/output-schemas.ts—deleteDocumentOutputSchemaapps/mcp/src/server/tools/index.ts— registration, next to the other document toolsapps/docs/supermemory-mcp/mcp.mdx— tool table row + a paragraph in "Save or forget" distinguishing exact-ID deletion from similarity-based forgettingapps/mcp/src/server/tools/delete-document.test.ts— unit tests: happy path (client called with the right ID, structured output), error path (errorResultshape), and annotation contract (destructive, not read-only)Testing
bunx vitest run src/inapps/mcp: 20/20 passing (3 new)bunx tsc --noEmit: cleanbunx biome checkon all touched files: cleanNot covered: no e2e test against a live MCP session — happy to add one to
apps/mcp/e2e/if that's wanted for destructive tools.