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}")

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed9 schema fields changedv1.0.4
    • addedInput schema / additionalProperties
      Added value: +false
    • removedInput schema / properties / class_identifier / title
      Removed value: -"Class Identifier"
    • removedInput schema / properties / identifier / title
      Removed value: -"Identifier"
    • removedInput schema / title
      Removed value: -"update_document_classArguments"
    • removedOutput schema / $defs
      Removed value: -{
      -  "Document": {
      -    "description": "Document class for the MCP server.",
      -    "properties": {
      -      "className": {
      -        "default": "Document",
      -        "description": "Class identifier for the document",
      -        "title": "Classname",
      -        "type": "string"
      -      },
      -      "contentSize": {
      -        "anyOf": [
      -          {
      -            "type": "number"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Size of the document content",
      -        "title": "Contentsize"
      -      },
      -      "creator": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "The creator of the document",
      -        "title": "Creator"
      -      },
      -      "dateCreated": {
      -        "anyOf": [
      -          {
      -            "format": "date-time",
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Date when document was created",
      -        "title": "Datecreated"
      -      },
      -      "dateLastModified": {
      -        "anyOf": [
      -          {
      -            "format": "date-time",
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Date when document was last modified",
      -        "title": "Datelastmodified"
      -      },
      -      "id": {
      -        "description": "The id of the document",
      -        "title": "Id",
      -        "type": "string"
      -      },
      -      "isVersioningEnabled": {
      -        "anyOf": [
      -          {
      -            "type": "boolean"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Whether versioning is enabled",
      -        "title": "Isversioningenabled"
      -      },
      -      "lastModifier": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "The last modifier of the document",
      -        "title": "Lastmodifier"
      -      },
      -      "majorVersionNumber": {
      -        "anyOf": [
      -          {
      -            "type": "integer"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Major version number",
      -        "title": "Majorversionnumber"
      -      },
      -      "mimeType": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "MIME type of the document",
      -        "title": "Mimetype"
      -      },
      -      "minorVersionNumber": {
      -        "anyOf": [
      -          {
      -            "type": "integer"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Minor version number",
      -        "title": "Minorversionnumber"
      -      },
      -      "name": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "The name of the document",
      -        "title": "Name"
      -      },
      -      "owner": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "The owner of the document",
      -        "title": "Owner"
      -      },
      -      "properties": {
      -        "anyOf": [
      -          {
      -            "items": {
      -              "additionalProperties": true,
      -              "type": "object"
      -            },
      -            "type": "array"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Document properties",
      -        "title": "Properties"
      -      }
      -    },
      -    "required": [
      -      "id"
      -    ],
      -    "title": "Document",
      -    "type": "object"
      -  },
      -  "ToolError": {
      -    "description": "Represents an error response from a tool execution.\n\nThis class helps the LLM understand error messages and provides suggestions\nfor potential resolutions.",
      -    "properties": {
      -      "isError": {
      -        "const": true,
      -        "default": true,
      -        "description": "Indicates that an error occurred during tool execution if value is True",
      -        "title": "Iserror",
      -        "type": "boolean"
      -      },
      -      "message": {
      -        "description": "Detailed error message",
      -        "title": "Message",
      -        "type": "string"
      -      },
      -      "suggestions": {
      -        "description": "List of suggestions for resolving the error",
      -        "items": {
      -          "type": "string"
      -        },
      -        "title": "Suggestions",
      -        "type": "array"
      -      }
      -    },
      -    "required": [
      -      "message"
      -    ],
      -    "title": "ToolError",
      -    "type": "object"
      -  }
      -}
    • changedOutput schema / properties / result / anyOf
      Previous value: -[
      -  {
      -    "$ref": "#/$defs/Document"
      -  },
      -  {
      -    "$ref": "#/$defs/ToolError"
      -  }
      -]New value: +[
      +  {
      +    "description": "Document class for the MCP server.",
      +    "properties": {
      +      "className": {
      +        "default": "Document",
      +        "description": "Class identifier for the document",
      +        "type": "string"
      +      },
      +      "contentSize": {
      +        "anyOf": [
      +          {
      +            "type": "number"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Size of the document content"
      +      },
      +      "creator": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "The creator of the document"
      +      },
      +      "dateCreated": {
      +        "anyOf": [
      +          {
      +            "format": "date-time",
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Date when document was created"
      +      },
      +      "dateLastModified": {
      +        "anyOf": [
      +          {
      +            "format": "date-time",
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Date when document was last modified"
      +      },
      +      "id": {
      +        "description": "The id of the document",
      +        "type": "string"
      +      },
      +      "isVersioningEnabled": {
      +        "anyOf": [
      +          {
      +            "type": "boolean"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Whether versioning is enabled"
      +      },
      +      "lastModifier": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "The last modifier of the document"
      +      },
      +      "majorVersionNumber": {
      +        "anyOf": [
      +          {
      +            "type": "integer"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Major version number"
      +      },
      +      "mimeType": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "MIME type of the document"
      +      },
      +      "minorVersionNumber": {
      +        "anyOf": [
      +          {
      +            "type": "integer"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Minor version number"
      +      },
      +      "name": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "The name of the document"
      +      },
      +      "owner": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "The owner of the document"
      +      },
      +      "properties": {
      +        "anyOf": [
      +          {
      +            "items": {
      +              "additionalProperties": true,
      +              "type": "object"
      +            },
      +            "type": "array"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Document properties"
      +      }
      +    },
      +    "required": [
      +      "id"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "description": "Represents an error response from a tool execution.\n\nThis class helps the LLM understand error messages and provides suggestions\nfor potential resolutions.",
      +    "properties": {
      +      "isError": {
      +        "const": true,
      +        "default": true,
      +        "description": "Indicates that an error occurred during tool execution if value is True",
      +        "type": "boolean"
      +      },
      +      "message": {
      +        "description": "Detailed error message",
      +        "type": "string"
      +      },
      +      "suggestions": {
      +        "description": "List of suggestions for resolving the error",
      +        "items": {
      +          "type": "string"
      +        },
      +        "type": "array"
      +      }
      +    },
      +    "required": [
      +      "message"
      +    ],
      +    "type": "object"
      +  }
      +]
    • removedOutput schema / properties / result / title
      Removed value: -"Result"
    • removedOutput schema / title
      Removed value: -"update_document_classOutput"
    • addedOutput schema / x-fastmcp-wrap-result
      Added value: +true
  2. First observedv1.0.0

TDQS

A4.5/5.0
Behavior4/5

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

Discloses the destructive potential (property loss if new class lacks properties) and that the tool does not update properties. Does not mention permissions or rate limits, but with no annotations, the description carries a fair burden and provides important context.

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?

Well-structured with prerequisites, description, warning, and parameter details. Front-loaded with critical information. Slightly lengthy but each part serves a purpose. Could be more concise without losing clarity.

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

Completeness4/5

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

Covers prerequisites, operation, side effects, and return values. With no annotations, it provides sufficient context for a mutation tool. Could specify class_identifier format and if the new class must exist.

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

Parameters4/5

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

The input schema has no descriptions (0% coverage), but the description explains identifier accepts document id or path and class_identifier is the new class identifier. Provides an example for identifier. This adds meaning beyond the schema.

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 the tool changes a document's class in the content repository. It distinguishes from siblings by explicitly noting it only changes class and not properties, and points to update_document_properties for property updates.

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?

Provides prerequisites: must call list_all_classes or determine_class first. Advises when to use the tool (class change) and when not to (property updates), offering explicit alternatives.

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