get_document_properties
Retrieve a document's properties from the repository by providing its ID or file path. Get metadata directly without searching by other criteria.
Instructions
Retrieves a document's properties from the content repository by ID or path.
Note: Use this tool ONLY when you need to retrieve a document using its ID or file path. For searching documents by other properties, use the repository_search tool instead.
: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 Document object with its properties. If unsuccessful, returns a ToolError with details about the failure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| identifier | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The 'get_document_properties' tool handler function. It is an async function registered with @mcp.tool(name='get_document_properties') that takes an identifier (GUID or path), executes a GraphQL query to fetch document properties (id, name, properties), and returns a Document object or ToolError.
@mcp.tool( name="get_document_properties", ) async def get_document_properties( identifier: str, ) -> Union[Document, ToolError]: """ Retrieves a document's properties from the content repository by ID or path. Note: Use this tool ONLY when you need to retrieve a document using its ID or file path. For searching documents by other properties, use the repository_search tool instead. :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 Document object with its properties. If unsuccessful, returns a ToolError with details about the failure. """ method_name = "get_document" try: # Prepare the query query = """ query ($object_store_name: String!, $identifier: String!) { document(repositoryIdentifier: $object_store_name, identifier: $identifier) { id name properties { id value } } } """ # Prepare variables for the GraphQL query variables = { "object_store_name": graphql_client.object_store, "identifier": identifier, } # Execute the GraphQL query logger.info("Executing document retrieval") response: Union[ToolError, Dict[str, Any]] = ( await graphql_client_execute_async_wrapper( logger, method_name, graphql_client, query=query, variables=variables, ) ) if isinstance(response, ToolError): return response # Check if document was found if not response.get("data") or not response["data"].get("document"): return ToolError( message=f"Document not found with identifier: {identifier}", suggestions=[ "Check if the document ID or path is correct", "Verify that the document exists in the repository", "Try using repository_search tool to find the document by other properties", ], ) # Create and return a Document instance from the response return Document.create_an_instance( graphQL_changed_object_dict=response["data"]["document"], class_identifier=response["data"]["document"].get( "className", DEFAULT_DOCUMENT_CLASS ), ) 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:896-898 (registration)The tool is registered via the @mcp.tool decorator with name='get_document_properties' inside the register_document_tools() function.
@mcp.tool( name="get_document_properties", ) - src/cs_mcp_server/mcp_server_main.py:269-270 (registration)The register_document_tools function is called from mcp_server_main.py during server setup for both CORE and FULL server types.
if server_type == ServerType.CORE: register_document_tools(mcp, graphql_client, metadata_cache) - The DocumentPropertiesInput class used as an input schema for document properties in several tools (create, update, etc.). It defines fields like properties, name, owner, content, mimeType, etc.
class DocumentPropertiesInput(CustomInputBase): """Input for document properties.""" properties: Optional[List[PropertyIdentifierAndScalarValue]] = Field( default=None, description="Properties for Document" ) name: Optional[str] = Field( default=None, description="Name sets DocumentTitle or whatever property is configured as the Name property", ) owner: Optional[str] = Field(default=None, description="Owner") content: Optional[str] = Field( default=None, description="Content can be specified if this represents a Reservation document or document creation", ) mimeType: Optional[str] = Field(default=None, description="Mime type") compoundDocumentState: Optional[str] = Field( default=None, description="Compound document state" ) cmRetentionDate: Optional[datetime] = Field( default=None, description="Retention date" ) # contentElements field removed from the model to prevent agents from interpreting and creating this field # Instead, we use the methods from CustomInputBase to add content elements programmatically # Commented out references to ObjectReferenceInput, PermissionListInput, ObjectPropertyInput """ objectProperties: Optional[List[ObjectPropertyInput]] = Field( default=None, description="Object properties" ) replicationGroup: Optional[ObjectReferenceInput] = Field( default=None, description="Replication group" ) permissions: Optional[PermissionListInput] = Field( default=None, description="Permissions" ) securityPolicy: Optional[ObjectReferenceInput] = Field( default=None, description="Security policy" ) securityFolder: Optional[ObjectReferenceInput] = Field( default=None, description="Security folder" ) storagePolicy: Optional[ObjectReferenceInput] = Field( default=None, description="Storage policy" ) documentLifecyclePolicy: Optional[ObjectReferenceInput] = Field( default=None, description="Document lifecycle policy" ) storageArea: Optional[ObjectReferenceInput] = Field( default=None, description="Storage area" ) """ - The get_document_text_extract_content helper function used by property_extraction tool to retrieve document text extract content. Related utility for the document tools.
async def get_document_text_extract_content( graphql_client: GraphQLClient, identifier: str ) -> str: """ Retrieves a document's text extract content. This utility function queries the document's annotations, filters for text extract annotations, and downloads the text content from each annotation's content elements. :param graphql_client: GraphQL client instance :param identifier: The document id or path (GUID or repository path) :returns: The concatenated text content from all text extract annotations. Returns empty string if no text extract is found. """ query = """ query getDocumentTextExtract($object_store_name: String!, $identifier: String!) { document(repositoryIdentifier: $object_store_name, identifier: $identifier) { annotations{ annotations{ id name className annotatedContentElement descriptiveText contentElements{ ... on ContentTransfer{ downloadUrl retrievalName contentSize } } } } } } """ variables = { "identifier": identifier,