3.4 KiB
ADDED Requirements
Requirement: Set collection on existing document via MCP
The MCP server SHALL expose a kb_set_collection tool that assigns or changes the collection of an existing document. The tool SHALL accept a document_id (required) and collection (optional string). When collection is provided, the tool SHALL ensure the document belongs to exactly that collection by removing any existing collection:* tags and adding the new one. When collection is omitted or null, the tool SHALL remove all collection:* tags from the document, leaving it unassigned.
The tool SHALL return the updated document with the collection field and cleaned tags (collection tags stripped), consistent with other MCP tool responses.
Scenario: Assign untagged document to a collection
- WHEN
kb_set_collectionis called withdocument_id=42andcollection="workspace" - THEN the document SHALL have the tag
collection:workspaceadded - AND the response SHALL include
"collection": "workspace"
Scenario: Change document from one collection to another
- WHEN
kb_set_collectionis called withdocument_id=42andcollection="memory"on a document currently in collection "documents" - THEN the tag
collection:documentsSHALL be removed andcollection:memorySHALL be added - AND the response SHALL include
"collection": "memory"
Scenario: Remove document from all collections
- WHEN
kb_set_collectionis called withdocument_id=42and nocollectionparameter - THEN all
collection:*tags SHALL be removed from the document - AND the response SHALL include
"collection": null
Scenario: Document not found
- WHEN
kb_set_collectionis called with adocument_idthat does not exist - THEN the tool SHALL return an error response indicating the document was not found
Requirement: Delete document via MCP
The MCP server SHALL expose a kb_delete tool that permanently deletes a document from the knowledge base. The tool SHALL accept a document_id (required integer). Deletion SHALL remove the document, its chunks, embeddings, tags, and any stored file on disk.
The tool SHALL return a confirmation response including the deleted document's ID and title.
Scenario: Successful deletion
- WHEN
kb_deleteis called withdocument_id=42 - THEN the document, its chunks, embeddings, tag associations, and stored file SHALL be deleted
- AND the response SHALL include
"status": "deleted", thedocument_id, and the documenttitle
Scenario: Document not found
- WHEN
kb_deleteis called with adocument_idthat does not exist - THEN the tool SHALL return an error response indicating the document was not found
Requirement: Engine client delete method
The MCP engine client (mcp/engine.py) SHALL provide a delete_document(doc_id) method that sends a DELETE request to /api/v1/documents/{doc_id} and returns the JSON response. The method SHALL raise on non-2xx status codes, consistent with other engine client methods.
Scenario: Successful engine client delete call
- WHEN
delete_document(42)is called and the engine API returns 200 - THEN the method SHALL return the parsed JSON response
Scenario: Engine client delete for missing document
- WHEN
delete_document(999)is called and the engine API returns 404 - THEN the method SHALL raise an
httpx.HTTPStatusError