Skip to main content
Glama
mem0ai

Mem0 MCP Server

Official
by mem0ai

delete_all_memories

Remove all stored memories for a user, agent, app, or run while preserving the entity structure in the Mem0 MCP Server.

Instructions

Delete every memory in the given user/agent/app/run but keep the entity.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNoUser scope to delete; defaults to server user.
agent_idNoOptional agent scope to delete.
app_idNoOptional app scope to delete.
run_idNoOptional run scope to delete.

Implementation Reference

  • The handler function for the 'delete_all_memories' tool. It is registered via the @server.tool decorator on a FastMCP server instance. The function validates inputs using DeleteAllArgs schema, resolves Mem0 client and API key, constructs payload, and delegates to the Mem0 client's delete_all method.
    @server.tool(
        description="Delete every memory in the given user/agent/app/run but keep the entity."
    )
    def delete_all_memories(
        user_id: Annotated[
            Optional[str], Field(default=None, description="User scope to delete; defaults to server user.")
        ] = None,
        agent_id: Annotated[
            Optional[str], Field(default=None, description="Optional agent scope to delete.")
        ] = None,
        app_id: Annotated[
            Optional[str], Field(default=None, description="Optional app scope to delete.")
        ] = None,
        run_id: Annotated[
            Optional[str], Field(default=None, description="Optional run scope to delete.")
        ] = None,
        ctx: Context | None = None,
    ) -> str:
        """Bulk-delete every memory in the confirmed scope."""
    
        api_key, default_user, _ = _resolve_settings(ctx)
        args = DeleteAllArgs(
            user_id=user_id or default_user,
            agent_id=agent_id,
            app_id=app_id,
            run_id=run_id,
        )
        payload = args.model_dump(exclude_none=True)
        client = _mem0_client(api_key)
        return _mem0_call(client.delete_all, **payload)
  • Pydantic BaseModel defining the input schema (arguments) for the delete_all_memories tool, used for validation in the handler.
    class DeleteAllArgs(BaseModel):
        user_id: Optional[str] = Field(
            None, description="User scope to delete; defaults to server user."
        )
        agent_id: Optional[str] = Field(None, description="Optional agent scope filter.")
        app_id: Optional[str] = Field(None, description="Optional app scope filter.")
        run_id: Optional[str] = Field(None, description="Optional run scope filter.")

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/mem0ai/mem0-mcp'

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