Skip to main content
Glama
ibm-ecm

Core Content Services MCP Server

Official
by ibm-ecm

update_document_class

Change a document's class in a content repository without altering its properties. Use after determining the correct class to avoid unintended property loss.

Instructions

PREREQUISITES: Before using this tool, you MUST call ONE of these tools first:

  1. list_all_classes - Call this tool only IF IT EXISTS and the user is using a (re)classification workflow where we need highest accuracy.

  2. determine_class - For general class update.

Description: Changes a document's class in the content repository. WARNING: Changing a document's class can result in loss of properties if the new class does not have the same properties as the old class. Properties that don't exist in the new class will be removed from the document.

This tool ONLY changes the document's class and does NOT update any properties. To update properties after changing the class, use the update_document_properties tool.

: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"). :param class_identifier: The new class identifier for the document (required).

:returns: If successful, returns a Document object with the new class. If unsuccessful, returns a ToolError with details about the failure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
identifierYes
class_identifierYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The async function `update_document_class` that implements the tool logic. It takes an `identifier` and `class_identifier`, executes a GraphQL mutation (`updateDocument`) to change the document's class, and returns a Document object or ToolError.
    @mcp.tool(
        name="update_document_class",
    )
    async def update_document_class(
        identifier: str,
        class_identifier: str,
    ) -> Union[Document, ToolError]:
        """
        **PREREQUISITES**: Before using this tool, you MUST call ONE of these tools first:
        1. list_all_classes - Call this tool only IF IT EXISTS and the user is using a (re)classification workflow where we need highest accuracy.
        2. determine_class - For general class update.
    
        Description:
        Changes a document's class in the content repository.
        WARNING: Changing a document's class can result in loss of properties if the new class
        does not have the same properties as the old class. Properties that don't exist in the
        new class will be removed from the document.
    
        This tool ONLY changes the document's class and does NOT update any properties.
        To update properties after changing the class, use the update_document_properties tool.
    
        :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").
        :param class_identifier: The new class identifier for the document (required).
    
        :returns: If successful, returns a Document object with the new class.
                 If unsuccessful, returns a ToolError with details about the failure.
        """
        method_name = "update_document_class"
        try:
            # Prepare the mutation
            mutation = """
            mutation ($object_store_name: String!, $identifier: String!, $class_identifier: String!) {
              updateDocument(
                repositoryIdentifier: $object_store_name
                identifier: $identifier
                classIdentifier: $class_identifier
              ) {
                id
                className
                properties {
                  id
                  value
                }
              }
            }
            """
    
            # Prepare variables for the GraphQL query
            variables = {
                "object_store_name": graphql_client.object_store,
                "identifier": identifier,
                "class_identifier": class_identifier,
            }
    
            # Execute the GraphQL mutation
            logger.info("Executing document class update")
            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 Document.create_an_instance(
                graphQL_changed_object_dict=response["data"]["updateDocument"],
                class_identifier=class_identifier,
            )
    
        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 tool is registered using the @mcp.tool decorator with name='update_document_class' within the register_document_tools function (line 60).
    @mcp.tool(
        name="update_document_class",
    )
    async def update_document_class(
        identifier: str,
        class_identifier: str,
    ) -> Union[Document, ToolError]:
        """
        **PREREQUISITES**: Before using this tool, you MUST call ONE of these tools first:
        1. list_all_classes - Call this tool only IF IT EXISTS and the user is using a (re)classification workflow where we need highest accuracy.
        2. determine_class - For general class update.
    
        Description:
        Changes a document's class in the content repository.
        WARNING: Changing a document's class can result in loss of properties if the new class
        does not have the same properties as the old class. Properties that don't exist in the
        new class will be removed from the document.
    
        This tool ONLY changes the document's class and does NOT update any properties.
        To update properties after changing the class, use the update_document_properties tool.
    
        :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").
        :param class_identifier: The new class identifier for the document (required).
    
        :returns: If successful, returns a Document object with the new class.
                 If unsuccessful, returns a ToolError with details about the failure.
        """
  • The function's type signature defines the input schema: `identifier: str` and `class_identifier: str`. The return type is `Union[Document, ToolError]`. These are the input/output validation definitions.
    ) -> Union[Document, ToolError]:
        """
        **PREREQUISITES**: Before using this tool, you MUST call ONE of these tools first:
        1. list_all_classes - Call this tool only IF IT EXISTS and the user is using a (re)classification workflow where we need highest accuracy.
        2. determine_class - For general class update.
    
        Description:
        Changes a document's class in the content repository.
        WARNING: Changing a document's class can result in loss of properties if the new class
        does not have the same properties as the old class. Properties that don't exist in the
        new class will be removed from the document.
    
        This tool ONLY changes the document's class and does NOT update any properties.
        To update properties after changing the class, use the update_document_properties tool.
    
        :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").
        :param class_identifier: The new class identifier for the document (required).
    
        :returns: If successful, returns a Document object with the new class.
                 If unsuccessful, returns a ToolError with details about the failure.
  • GraphQL mutation string used by the handler to call the updateDocument mutation with classIdentifier to change the document's class.
    mutation = """
    mutation ($object_store_name: String!, $identifier: String!, $class_identifier: String!) {
      updateDocument(
        repositoryIdentifier: $object_store_name
        identifier: $identifier
        classIdentifier: $class_identifier
      ) {
        id
        className
        properties {
          id
          value
        }
      }
    }
    """
  • The mcp_server_main.py registers document tools (including update_document_class) via `register_document_tools(mcp, graphql_client, metadata_cache)` for CORE and FULL server types (lines 270, 293).
        metadata_cache: The metadata cache instance
        server_type: The type of server (ServerType enum)
    """
    # Ensure mcp is initialized (type narrowing for type checker)
    assert mcp is not None
    
    logger.info("Registering tools for %s server", server_type.value)
    
    # Register tools based on 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")
    
    else:
        raise ValueError(f"Unknown server type: {server_type}")
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully discloses behavioral traits: warns about potential property loss if the new class lacks certain properties, states it only changes class (not properties), and describes return values (Document object or ToolError).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with bolded PREREQUISITES, a warning, and clear sections for parameters and returns. It is informative but slightly lengthy; could be more concise while retaining all essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has two required parameters and no annotations, the description covers prerequisites, side effects, parameter details, and return values. It differentiates from siblings and includes error details (ToolError). Highly complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, but the description provides clear explanations for both parameters—'identifier' can be a GUID or path, and 'class_identifier' is the new class—thus fully compensating for the lack of schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Changes a document's class in the content repository,' uses a specific verb+resource, and distinguishes from sibling tools like update_document_properties by emphasizing it only changes class and not properties.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly lists prerequisites (must call list_all_classes or determine_class first) and provides guidance on when to use each. Also clarifies this tool does not update properties and directs to update_document_properties for that purpose.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/cs-mcp-server'

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