Skip to main content
Glama
ibm-ecm

IBM Core Content Services MCP Server

Official
by ibm-ecm

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
NameRequiredDescriptionDefault
identifierYes

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."
            )
  • 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),
    )

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ibm-ecm/ibm-content-services-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server