Skip to main content
Glama
stevereiner
by stevereiner

delete_node

Remove documents or folders from Alfresco content management system by specifying the node ID, with options for permanent deletion or temporary removal.

Instructions

Delete a document or folder from Alfresco.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
node_idYes
permanentNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core handler function implementing the delete_node tool logic: validates input, ensures Alfresco connection, retrieves node info, performs deletion (to trash or permanent), handles errors, and returns formatted confirmation with progress reporting via MCP context.
    async def delete_node_impl(
        node_id: str, 
        permanent: bool = False,
        ctx: Optional[Context] = None
    ) -> str:
        """Delete a document or folder from Alfresco.
        
        Args:
            node_id: Node ID to delete
            permanent: Whether to permanently delete (bypass trash)
            ctx: MCP context for progress reporting
        
        Returns:
            Deletion confirmation
        """
        if ctx:
            delete_type = "permanently delete" if permanent else "move to trash"
            await ctx.info(f"Preparing to {delete_type}: {node_id}")
            await ctx.info("Validating deletion request...")
            await ctx.report_progress(0.1)
        
        if not node_id.strip():
            return safe_format_output("āŒ Error: node_id is required")
        
        try:
            await ensure_connection()
            from ...utils.connection import get_client_factory
            
            # Get client factory and create core client (working pattern from test)
            client_factory = await get_client_factory()
            core_client = client_factory.create_core_client()
            
            # Clean the node ID (remove any URL encoding or extra characters)
            clean_node_id = node_id.strip()
            if clean_node_id.startswith('alfresco://'):
                # Extract node ID from URI format
                clean_node_id = clean_node_id.split('/')[-1]
            
            logger.info(f"Attempting to delete node: {clean_node_id}")
            
            if ctx:
                await ctx.report_progress(0.7)
            
            # Get node information first to validate it exists (working pattern from test)
            node_response = core_client.nodes.get(clean_node_id)
            
            if not hasattr(node_response, 'entry'):
                return safe_format_output(f"āŒ Failed to get node information for: {clean_node_id}")
            
            node_info = node_response.entry
            filename = getattr(node_info, 'name', f"document_{clean_node_id}")
            
            # Use the working high-level API pattern from test script
            core_client.nodes.delete(clean_node_id)
            
            status = "permanently deleted" if permanent else "moved to trash"
            logger.info(f"āœ… Node {status}: {filename}")
            
            if ctx:
                await ctx.report_progress(1.0)
            return safe_format_output(f"""āœ… **Deletion Complete**
    
    šŸ“„ **Node**: {node_info.name}
    šŸ—‘ļø **Status**: {status.title()}
    {"āš ļø **WARNING**: This action cannot be undone" if permanent else "ā„¹ļø **INFO**: Can be restored from trash"}
    
    šŸ†” **Node ID**: {clean_node_id}""")
            
        except Exception as e:
            error_msg = f"ERROR: Deletion failed: {str(e)}"
            if ctx:
                await ctx.error(error_msg)
            logger.error(f"Deletion failed: {e}")
            return error_msg 
  • Registration of the 'delete_node' MCP tool using FastMCP @mcp.tool decorator. Defines tool name, input parameters (serving as schema: node_id (str), permanent (bool, default False), ctx (Context)), docstring, and delegates to the core implementation delete_node_impl.
    @mcp.tool
    async def delete_node(
        node_id: str, 
        permanent: bool = False,
        ctx: Context = None
    ) -> str:
        """Delete a document or folder from Alfresco."""
        return await delete_node_impl(node_id, permanent, ctx)
  • Input schema inferred from function signature in the registered tool: required node_id (string), optional permanent (boolean, defaults to False indicating move to trash), optional ctx for MCP context.
    async def delete_node(
        node_id: str, 
        permanent: bool = False,
        ctx: Context = None
    ) -> str:
        """Delete a document or folder from Alfresco."""
        return await delete_node_impl(node_id, permanent, ctx)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. While 'Delete' implies a destructive operation, it doesn't specify whether this requires special permissions, what happens to linked content, if deletion can be undone, or what the output contains. The 'permanent' parameter hints at behavioral nuance, but the description doesn't explain it.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it efficient for quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive tool with 2 parameters (one with behavioral implications like 'permanent'), 0% schema coverage, no annotations, and multiple sibling tools, the description is inadequate. It doesn't address permissions, consequences, alternatives, or parameter meanings, leaving significant gaps despite the existence of an output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage for both parameters, the description adds no parameter information beyond what's inferred from the tool name. It doesn't explain what 'node_id' represents, how to obtain it, or what 'permanent' means in context (e.g., vs. moving to trash).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Delete') and the resource ('a document or folder from Alfresco'), making the purpose immediately understandable. However, it doesn't differentiate this tool from potential alternatives like 'cancel_checkout' or 'checkin_document' that might also remove content in different ways.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'cancel_checkout' and 'checkin_document' that might handle document lifecycle states, there's no indication of whether this tool is for permanent deletion, version management, or specific document states.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/stevereiner/python-alfresco-mcp-server'

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