Skip to content

feat(mcp): add deleteDocument tool for permanent deletion by ID - #1443

Open
vivekvar-dl wants to merge 1 commit into
supermemoryai:mainfrom
vivekvar-dl:feat/mcp-delete-document
Open

feat(mcp): add deleteDocument tool for permanent deletion by ID#1443
vivekvar-dl wants to merge 1 commit into
supermemoryai:mainfrom
vivekvar-dl:feat/mcp-delete-document

Conversation

@vivekvar-dl

Copy link
Copy Markdown

Closes #1442

What

Adds a deleteDocument MCP tool: permanent deletion of one document (and the memories extracted from it) by exact documentId.

Why

The MCP server covers the full document lifecycle except deletion. The only removal path today is add_memory's forget action, 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 exact documentId that listDocuments/getDocument/listMemories already 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 on get-document.ts (same input constraints, output schema pattern, error handling via deps.errorResult)
  • apps/mcp/src/server/client/index.tsdeleteDocument(id) wrapping the SDK's existing documents.delete (DELETE /v3/documents/{id}), with the client's standard operation-error handling
  • apps/mcp/src/server/tools/output-schemas.tsdeleteDocumentOutputSchema
  • apps/mcp/src/server/tools/index.ts — registration, next to the other document tools
  • apps/docs/supermemory-mcp/mcp.mdx — tool table row + a paragraph in "Save or forget" distinguishing exact-ID deletion from similarity-based forgetting
  • apps/mcp/src/server/tools/delete-document.test.ts — unit tests: happy path (client called with the right ID, structured output), error path (errorResult shape), and annotation contract (destructive, not read-only)

Testing

  • bunx vitest run src/ in apps/mcp: 20/20 passing (3 new)
  • bunx tsc --noEmit: clean
  • bunx biome check on all touched files: clean

Not covered: no e2e test against a live MCP session — happy to add one to apps/mcp/e2e/ if that's wanted for destructive tools.

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.
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.

MCP: no way to delete a document by ID — forget-by-similarity is the only removal path

1 participant