Skip to main content
Glama

delete_episode

Remove specific episodes from graph memory by providing their UUID to manage document content efficiently.

Instructions

Delete an episode from the graph memory.

Args:
    uuid: UUID of the episode to delete

Returns:
    Success message dictionary

Example:
    delete_episode(uuid="episode-uuid-123")

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uuidYes

Implementation Reference

  • MCP tool handler and registration for 'delete_episode'. This decorated function is the entry point for the tool, defining input schema via signature/docstring and delegating to the implementation.
    @mcp.tool()
    async def delete_episode(uuid: str) -> Dict[str, str]:
        """
        Delete an episode from the graph memory.
    
        Args:
            uuid: UUID of the episode to delete
    
        Returns:
            Success message dictionary
    
        Example:
            delete_episode(uuid="episode-uuid-123")
    
        @REQ: REQ-graphiti-chunk-mcp
        @BP: BP-graphiti-chunk-mcp
        @TASK: TASK-007-MCPTools
        """
        return await graphiti_tools.delete_episode_impl(uuid=uuid)
  • Core implementation of delete_episode logic. Creates GraphitiClient instance and calls its delete_episode method, handles errors with ToolError.
    async def delete_episode_impl(uuid: str) -> Dict[str, str]:
        """
        Delete an episode from the graph memory.
    
        @REQ: REQ-graphiti-chunk-mcp
        @BP: BP-graphiti-chunk-mcp
        @TASK: TASK-007-MCPTools
    
        Args:
            uuid: UUID of the episode to delete
    
        Returns:
            Success message dictionary
    
        Raises:
            ToolError: If deletion operation fails
        """
        try:
            client = get_graphiti_client()
            async with client:
                await client.delete_episode(uuid)
                return {"message": f"Successfully deleted episode {uuid}"}
    
        except Exception as e:
            raise ToolError(
                "DELETE_EPISODE_ERROR",
                f"Failed to delete episode: {str(e)}"
            ) from e
  • GraphitiClient helper method that performs the actual episode deletion by calling the underlying Graphiti instance's remove_episode method.
    async def delete_episode(self, episode_uuid: str) -> bool:
        """
        Delete an episode from Graphiti by its UUID.
    
        @REQ: REQ-graphiti-chunk-mcp
        @BP: BP-graphiti-chunk-mcp
        @TASK: TASK-005-GraphitiClient
    
        Args:
            episode_uuid: UUID of the episode to delete
    
        Returns:
            True if deletion was successful
    
        Raises:
            RuntimeError: If deletion fails
        """
        try:
            logger.debug(f"Deleting episode: {episode_uuid}")
    
            await self.graphiti.remove_episode(episode_uuid)
    
            logger.info(f"Episode deleted successfully: {episode_uuid}")
            return True
    
        except Exception as e:
            logger.error(f"Failed to delete episode {episode_uuid}: {e}")
            raise RuntimeError(f"Failed to delete episode: {e}") from e
  • Initialization of the FastMCP server instance where all tools including delete_episode are registered.
    mcp = FastMCP("graphiti-memory-server")
  • Input/output schema defined by function signature and docstring for the delete_episode tool.
    async def delete_episode(uuid: str) -> Dict[str, str]:
        """
        Delete an episode from the graph memory.
    
        Args:
            uuid: UUID of the episode to delete
    
        Returns:
            Success message dictionary
    
        Example:
            delete_episode(uuid="episode-uuid-123")
    
        @REQ: REQ-graphiti-chunk-mcp
        @BP: BP-graphiti-chunk-mcp
        @TASK: TASK-007-MCPTools
        """
        return await graphiti_tools.delete_episode_impl(uuid=uuid)

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