delete_folder
Delete a folder from the content repository by providing its unique identifier or path.
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
| Name | Required | Description | Default |
|---|---|---|---|
| id_or_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/cs_mcp_server/tools/folders.py:153-155 (registration)The delete_folder tool is registered with FastMCP via the @mcp.tool decorator with name 'delete_folder'. This registration happens inside the register_folder_tools() function.
@mcp.tool( name="delete_folder", ) - The handler function for delete_folder. It accepts a single parameter id_or_path (string), validates it, executes a GraphQL mutation 'deleteFolder' via the graphql_client, and returns the deleted folder's ID or a ToolError on failure.
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: # check 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 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.", ) - src/cs_mcp_server/mcp_server_main.py:294-294 (registration)The register_folder_tools function (which registers delete_folder) is called in mcp_server_main.py for the FULL server type.
register_folder_tools(mcp, graphql_client) - src/cs_mcp_server/mcp_server_main.py:271-271 (registration)The register_folder_tools function (which registers delete_folder) is called in mcp_server_main.py for the CORE server type.
register_folder_tools(mcp, graphql_client)