Skip to main content
Glama
ibm-ecm

IBM Core Content Services MCP Server

Official
by ibm-ecm

delete_folder

Remove folders from IBM Content Manager repositories using GraphQL API by specifying folder ID or path to manage document storage efficiently.

Instructions

Deletes a folder in the content repository. This tool interfaces with the GraphQL API to delete a folder object with the provided id.

:param id_or_path string Yes The unique identifier or path for the folder. If not provided, an error will be returned.

:returns: If successful, return the folder id. Else, return a ToolError instance that describes the error.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
id_or_pathYes

Implementation Reference

  • The main handler function for the 'delete_folder' tool, which performs input validation, executes a GraphQL mutation to delete the folder, and returns the deleted folder ID or a ToolError.
    def delete_folder(id_or_path: str) -> Union[str, ToolError]:
        """
        Deletes a folder in the content repository. This tool interfaces with the GraphQL API
        to delete a folder object with the provided id.
    
    
        :param id_or_path	string	Yes	The unique identifier or path for the folder. If not provided, an error will be returned.
    
        :returns: If successful, return the folder id.
         Else, return a ToolError instance that describes the error.
        """
        method_name = "delete_folder"
        try:
            # dcheck id or path
            if not id_or_path:
                return ToolError(
                    message=f"delete_folder failed: id is a required input.",
                )
    
            mutation = """
                    mutation deleteFolder( $id_or_path:String!
                    $repo: String!)
                    {
                    deleteFolder(repositoryIdentifier: $repo, 
                        identifier: $id_or_path
                    )
                    {
                        id
                        className
                    }
                    }
            """
            var = {
                "repo": graphql_client.object_store,
                "id_or_path": id_or_path,
            }
            response = graphql_client.execute(query=mutation, variables=var)
            # handling exception, for example duplicate folder name
            if "errors" in response:
                return ToolError(
                    message=f"delete_folder failed: got err {response}.",
                )
            return_id = response["data"]["deleteFolder"]["id"]
    
            return response["data"]["deleteFolder"]["id"]
    
        except Exception as e:
            error_traceback = traceback.format_exc(limit=TRACEBACK_LIMIT)
            logger.error(
                f"{method_name} failed: {e.__class__.__name__} - {str(e)}\n{error_traceback}"
            )
    
            return ToolError(
                message=f"{method_name} failed: got err {e}. Trace available in server logs.",
            )
  • Registration of the 'delete_folder' tool using the FastMCP @mcp.tool decorator inside the register_folder_tools function.
    @mcp.tool(
        name="delete_folder",
    )
  • Function signature and docstring defining the input schema (id_or_path: str) and output (Union[str, ToolError]) for the delete_folder tool.
    def delete_folder(id_or_path: str) -> Union[str, ToolError]:
        """
        Deletes a folder in the content repository. This tool interfaces with the GraphQL API
        to delete a folder object with the provided id.
    
    
        :param id_or_path	string	Yes	The unique identifier or path for the folder. If not provided, an error will be returned.
    
        :returns: If successful, return the folder id.
         Else, return a ToolError instance that describes the error.
        """
  • GraphQL mutation schema/query used by the delete_folder tool to delete the folder by identifier.
    mutation = """
            mutation deleteFolder( $id_or_path:String!
            $repo: String!)
            {
            deleteFolder(repositoryIdentifier: $repo, 
                identifier: $id_or_path
            )
            {
                id
                className
            }
            }
    """

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/ibm-content-services-mcp-server'

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