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

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

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