Skip to main content
Glama

clear_graph

Clear all data from the graph memory and rebuild indices in the RBT Document Editor. This irreversible operation deletes all graph data and should be used with caution.

Instructions

Clear all data from the graph memory and rebuild indices.

WARNING: This operation is irreversible and will delete all data from the graph!
Use with extreme caution.

Returns:
    Success message dictionary

Example:
    clear_graph()

@REQ: REQ-graphiti-chunk-mcp
@BP: BP-graphiti-chunk-mcp
@TASK: TASK-007-MCPTools

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Primary MCP tool handler for 'clear_graph'. Registered via @mcp.tool() decorator. Delegates execution to graphiti_tools.clear_graph_impl() which performs the actual graph clearing.
    @mcp.tool()
    async def clear_graph() -> Dict[str, str]:
        """
        Clear all data from the graph memory and rebuild indices.
    
        WARNING: This operation is irreversible and will delete all data from the graph!
        Use with extreme caution.
    
        Returns:
            Success message dictionary
    
        Example:
            clear_graph()
    
        @REQ: REQ-graphiti-chunk-mcp
        @BP: BP-graphiti-chunk-mcp
        @TASK: TASK-007-MCPTools
        """
        return await graphiti_tools.clear_graph_impl()
  • Helper implementation that initializes GraphitiClient, calls client.clear_graph(), returns success message or raises ToolError.
    async def clear_graph_impl() -> Dict[str, str]:
        """
        Clear all data from the graph memory and rebuild indices.
    
        @REQ: REQ-graphiti-chunk-mcp
        @BP: BP-graphiti-chunk-mcp
        @TASK: TASK-007-MCPTools
    
        WARNING: This operation is irreversible and will delete all data!
    
        Returns:
            Success message dictionary
    
        Raises:
            ToolError: If operation fails
        """
        try:
            client = get_graphiti_client()
            async with client:
                await client.clear_graph()
                return {"message": "Successfully cleared graph and rebuilt indices"}
    
        except Exception as e:
            raise ToolError(
                "CLEAR_GRAPH_ERROR",
                f"Failed to clear graph: {str(e)}"
            ) from e
  • Core GraphitiClient.clear_graph() method that executes the actual graph clearing using external clear_data utility and rebuilds Neo4j indices/constraints.
    async def clear_graph(self) -> bool:
        """
        Clear all data from the graph memory and rebuild indices.
    
        @REQ: REQ-graphiti-chunk-mcp
        @BP: BP-graphiti-chunk-mcp
        @TASK: TASK-007-MCPTools
    
        WARNING: This operation is irreversible and will delete all data!
    
        Returns:
            True if operation was successful
    
        Raises:
            RuntimeError: If operation fails
        """
        try:
            logger.warning("Clearing all graph data - this operation is irreversible!")
    
            # Import clear_data function
            from graphiti_core.utils.maintenance.graph_data_operations import clear_data
    
            # Clear all data first
            await clear_data(self.graphiti.driver)
            logger.info("Graph data cleared")
    
            # Rebuild indices and constraints for future data
            await self.graphiti.build_indices_and_constraints()
            logger.info("Indices and constraints rebuilt")
    
            logger.info("Graph cleared and indices rebuilt successfully")
            return True
    
        except Exception as e:
            logger.error(f"Failed to clear graph: {e}")
            raise RuntimeError(f"Failed to clear graph: {e}") from e
Behavior5/5

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

Since no annotations are provided, the description carries the full burden of behavioral disclosure. It effectively communicates critical behavioral traits: the irreversible destructive nature ('will delete all data'), the rebuild indices behavior, and the return format ('Success message dictionary'). This provides essential context beyond what the empty input schema offers.

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

Conciseness4/5

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

The description is well-structured with clear sections: purpose statement, warning, return information, and example. While the example and metadata tags (@REQ, @BP, @TASK) could be considered extraneous, the core description is appropriately sized and front-loaded with the most critical information.

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

Completeness5/5

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

Given this is a destructive operation with no annotations, the description provides complete context: purpose, irreversible nature, warning, return format, and example. The existence of an output schema means the description doesn't need to detail return values, and it appropriately focuses on behavioral implications.

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

Parameters4/5

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

With 0 parameters and 100% schema description coverage, the baseline would be 4. The description appropriately doesn't discuss parameters since none exist, and instead focuses on the tool's behavior and consequences, which is the correct emphasis for a parameterless destructive operation.

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

Purpose5/5

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

The description clearly states the specific action ('clear all data from the graph memory and rebuild indices'), identifies the resource ('graph memory'), and distinguishes this destructive operation from sibling tools that perform more targeted operations like add_document, delete_entity_edge, or search functions.

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

Usage Guidelines5/5

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

The description provides explicit guidance with a WARNING section stating 'Use with extreme caution' and noting the operation is irreversible. It clearly distinguishes this from other tools by emphasizing it deletes ALL data, unlike sibling tools that perform selective operations.

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/leo7nel23/KnowkedgeSmith-MCP'

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