get_folder_documents
Retrieve documents from a specific folder in IBM FileNet Content Manager to access and manage stored files.
Instructions
Retrieves a folder's contained documents.
:param folder_id_or_path: The folder id or path.
:returns: A list contains documents in the folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder_id_or_path | Yes |
Implementation Reference
- The handler function for the 'get_folder_documents' tool. It executes a GraphQL query to fetch documents contained in the specified folder (by ID or path), constructs Document objects from the response, and returns the list. Returns a ToolError on failure.@mcp.tool( name="get_folder_documents", ) async def get_folder_documents( folder_id_or_path: str, ) -> Union[list[Document], ToolError]: """ Retrieves a folder's contained documents. :param folder_id_or_path: The folder id or path. :returns: A list contains documents in the folder """ method_name = "get_folder_documents" logger.info("%s started", method_name) try: query = """ query getContainedDocuments($object_store_name: String!, $folder_id_or_path: String!){ folder( repositoryIdentifier: $object_store_name identifier: $folder_id_or_path ) { containedDocuments { documents { id name className properties { id value } } } } } """ variables = { "folder_id_or_path": folder_id_or_path, "object_store_name": graphql_client.object_store, } # return await graphql_client.execute_async(query=query, variables=variables) docs = await graphql_client.execute_async(query=query, variables=variables) if "errors" in docs: return ToolError( message=f"get_folder_documents failed: got err {docs}.", ) docslist = docs["data"]["folder"]["containedDocuments"]["documents"] if len(docslist) == 0: return [] else: contained_docs = [] for doc in docslist: onedoc = Document.create_an_instance( graphQL_changed_object_dict=doc, class_identifier=doc["className"], ) contained_docs.append(onedoc) return contained_docs except Exception as ex: error_traceback = traceback.format_exc(limit=TRACEBACK_LIMIT) logger.error( f"{method_name} failed: {ex.__class__.__name__} - {str(ex)}\n{error_traceback}" ) return ToolError( message=f"{method_name} failed: got err {ex}. Trace available in server logs.", )
- src/cs_mcp_server/mcp_server_main.py:221-221 (registration)Call to register_folder_tools within register_server_tools for CORE server type, which defines and registers the get_folder_documents tool among others.register_folder_tools(mcp, graphql_client)
- src/cs_mcp_server/mcp_server_main.py:237-237 (registration)Call to register_folder_tools within register_server_tools for FULL server type, which defines and registers the get_folder_documents tool among others.register_folder_tools(mcp, graphql_client)