Skip to content

feat(mcp): add deleteDocument tool for exact-ID removal (#1442) - #1633

Open
devaniketh wants to merge 1 commit into
supermemoryai:mainfrom
devaniketh:feat-mcp-delete-document
Open

feat(mcp): add deleteDocument tool for exact-ID removal (#1442)#1633
devaniketh wants to merge 1 commit into
supermemoryai:mainfrom
devaniketh:feat-mcp-delete-document

Conversation

@devaniketh

Copy link
Copy Markdown

Summary

Adds a deleteDocument tool to the Supermemory MCP server to allow AI clients (Claude Desktop, Cursor, Claude Code) to delete documents by their exact ID, completing the document CRUD lifecycle.

Fixes #1442

Problem

Previously, the MCP server exposed full reading (listDocuments, getDocument, listMemories, search_memory) and writing (add_memory, save-memory, upload-file, guided-save), but had no direct way to delete a document by ID.

The only removal option was add_memory with action: "forget", which uses vector cosine similarity (threshold 0.85). This posed two problems:

  1. When memories have high semantic similarity, similarity-based forgetting can accidentally remove the wrong document.
  2. AI agents that browse documents via listDocuments or inspect them via getDocument receive exact documentIds, but had no tool to delete that specific document.

Solution

  • New deleteDocument MCP Tool: Added apps/mcp/src/server/tools/delete-document.ts taking { documentId: string }.
  • Destructive Annotations: Configured with MEMORY_TOOL_ANNOTATIONS (destructiveHint: true) so MCP hosts prompt the user for confirmation.
  • Space Isolation: Enforces space boundary checks against the effective container tag (matches getDocument behavior).
  • Client Integration: Added SupermemoryClient.deleteDocument(id) calling this.client.documents.delete(id).
  • Telemetry & Tool Discovery: Registered deleteDocument under TOOL_SURFACES ("model_tool") and added to EXPECTED_TOOLS.
  • Documentation: Updated tools tables in apps/docs/supermemory-mcp/mcp.mdx and apps/mcp/README.md.

Testing

  • Added unit tests in apps/mcp/src/server/tools/delete-document.test.ts covering tool registration, space validation, successful deletion, and error propagation.
  • Verified MCP tool discovery table updates.

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