delete_document_version
Remove a specific version of a document from the IBM Core Content Services repository using its ID or path to manage document versions and maintain repository organization.
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
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| identifier | Yes |
Implementation Reference
- The asynchronous handler function that executes the delete_document_version tool. It performs a GraphQL deleteDocument mutation to delete the specified document version and returns the deleted document ID or a ToolError.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 = await graphql_client.execute_async( query=mutation, variables=variables ) # Handle errors if "errors" in response: logger.error("GraphQL error: %s", response["errors"]) return ToolError(message=f"{method_name} failed: {response['errors']}") # 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." )
- src/cs_mcp_server/tools/documents.py:956-959 (registration)The @mcp.tool decorator that registers the delete_document_version tool with the MCP server, marking it as destructive.@mcp.tool( name="delete_document_version", annotations=ToolAnnotations(destructiveHint=True), )