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:
list_all_classes - Call this tool only IF IT EXISTS and the user is using a (re)classification workflow where we need highest accuracy.
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
| Name | Required | Description | Default |
|---|---|---|---|
| identifier | Yes | ||
| class_identifier | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
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." ) - src/cs_mcp_server/tools/documents.py:366-392 (registration)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 } } } """ - src/cs_mcp_server/mcp_server_main.py:260-309 (registration)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}")