delete_document_version
Remove a specific document version from the content repository using its ID or path. The tool returns the deleted document identifier upon successful removal.
Instructions
Deletes a specific document version in the content repository.
:param identifier: The document id or path (required). This can be either the document's ID (GUID) or its path in the repository (e.g., "/Folder1/document.pdf").
:returns: If successful, returns the deleted Document id. If unsuccessful, returns a ToolError with details about the failure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| identifier | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/cs_mcp_server/tools/documents.py:835-894 (registration)The 'delete_document_version' tool is registered as an MCP tool via the @mcp.tool decorator inside register_document_tools(), with a destructive hint annotation.
@mcp.tool( name="delete_document_version", annotations=ToolAnnotations(destructiveHint=True), ) async def delete_document_version( identifier: str, ) -> Union[str, ToolError]: """ Deletes a specific document version in the content repository. :param identifier: The document id or path (required). This can be either the document's ID (GUID) or its path in the repository (e.g., "/Folder1/document.pdf"). :returns: If successful, returns the deleted Document id. If unsuccessful, returns a ToolError with details about the failure. """ method_name = "delete_document_version" try: # Delete only the specified version mutation = """ mutation ($object_store_name: String!, $identifier: String!) { deleteDocument( repositoryIdentifier: $object_store_name identifier: $identifier ) { id className } } """ # Prepare variables for the GraphQL query variables = { "object_store_name": graphql_client.object_store, "identifier": identifier, } # Execute the GraphQL mutation logger.info("Executing single document version deletion") response: Union[ToolError, Dict[str, Any]] = ( await graphql_client_execute_async_wrapper( logger, method_name, graphql_client, query=mutation, variables=variables, ) ) if isinstance(response, ToolError): return response # Create and return a Document instance from the response return response["data"]["deleteDocument"]["id"] except Exception as e: logger.error("%s failed: %s", method_name, str(e)) logger.error(traceback.format_exc()) return ToolError( message=f"{method_name} failed: {str(e)}. Trace available in server logs." ) - The handler function 'delete_document_version' (async) takes an 'identifier' parameter (document ID or path) and executes a GraphQL 'deleteDocument' mutation to delete a specific document version. It returns the ID of the deleted document on success or a ToolError on failure.
async def delete_document_version( identifier: str, ) -> Union[str, ToolError]: """ Deletes a specific document version in the content repository. :param identifier: The document id or path (required). This can be either the document's ID (GUID) or its path in the repository (e.g., "/Folder1/document.pdf"). :returns: If successful, returns the deleted Document id. If unsuccessful, returns a ToolError with details about the failure. """ method_name = "delete_document_version" try: # Delete only the specified version mutation = """ mutation ($object_store_name: String!, $identifier: String!) { deleteDocument( repositoryIdentifier: $object_store_name identifier: $identifier ) { id className } } """ # Prepare variables for the GraphQL query variables = { "object_store_name": graphql_client.object_store, "identifier": identifier, } # Execute the GraphQL mutation logger.info("Executing single document version deletion") response: Union[ToolError, Dict[str, Any]] = ( await graphql_client_execute_async_wrapper( logger, method_name, graphql_client, query=mutation, variables=variables, ) ) if isinstance(response, ToolError): return response # Create and return a Document instance from the response return response["data"]["deleteDocument"]["id"] except Exception as e: logger.error("%s failed: %s", method_name, str(e)) logger.error(traceback.format_exc()) return ToolError( message=f"{method_name} failed: {str(e)}. Trace available in server logs." ) - The GraphQL mutation schema used by delete_document_version: sends a 'deleteDocument' mutation with repositoryIdentifier and identifier, requesting id and className back.
mutation = """ mutation ($object_store_name: String!, $identifier: String!) { deleteDocument( repositoryIdentifier: $object_store_name identifier: $identifier ) { id className } } """ - src/cs_mcp_server/mcp_server_main.py:269-306 (registration)The 'register_document_tools' function (which registers delete_document_version) is called for the CORE server type and the FULL server type.
if server_type == ServerType.CORE: register_document_tools(mcp, graphql_client, metadata_cache) register_folder_tools(mcp, graphql_client) register_class_tools(mcp, graphql_client, metadata_cache) register_search_tools(mcp, graphql_client, metadata_cache) # register_annotation_tools(mcp, graphql_client) # register_custom_object_tools(mcp, graphql_client) logger.info("Core tools registered") elif server_type == ServerType.AI__DOCUMENT_INSIGHT: register_advanced_search_tools(mcp, graphql_client, metadata_cache) register_vector_search_tool(mcp, graphql_client) logger.info("AI Document Insight tools registered") elif server_type == ServerType.LEGAL_HOLD: register_hold_tools(mcp, graphql_client) logger.info("Legal hold tools registered") elif server_type == ServerType.PROPERTY_EXTRACTION_AND_CLASSIFICATION: register_property_extraction_tools(mcp, graphql_client, metadata_cache) register_classification_tools(mcp, graphql_client, metadata_cache) logger.info("Property extraction and classification tools registered") elif server_type == ServerType.FULL: register_document_tools(mcp, graphql_client, metadata_cache) register_folder_tools(mcp, graphql_client) register_class_tools(mcp, graphql_client, metadata_cache) register_search_tools(mcp, graphql_client, metadata_cache) # register_annotation_tools(mcp, graphql_client) # register_custom_object_tools(mcp, graphql_client) register_vector_search_tool(mcp, graphql_client) register_advanced_search_tools(mcp, graphql_client, metadata_cache) register_annotation_tools(mcp, graphql_client) register_hold_tools(mcp, graphql_client) register_property_extraction_tools(mcp, graphql_client, metadata_cache) register_classification_tools(mcp, graphql_client, metadata_cache) logger.info("All tools registered")