Skip to main content
Glama

delete_entities

Remove user, agent, app, or run records and their associated memories from the Mem0 MCP Server to manage data storage.

Instructions

Remove a user/agent/app/run record entirely (and cascade-delete its memories).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
user_idNoDelete this user and its memories.
agent_idNoDelete this agent and its memories.
app_idNoDelete this app and its memories.
run_idNoDelete this run and its memories.

Implementation Reference

  • The handler function for the 'delete_entities' tool, registered via the @server.tool decorator. Validates input arguments using DeleteEntitiesArgs, checks for required scope, prepares payload, and invokes Mem0 client's delete_users method via _mem0_call.
    @server.tool( description="Remove a user/agent/app/run record entirely (and cascade-delete its memories)." ) def delete_entities( user_id: Annotated[ Optional[str], Field(default=None, description="Delete this user and its memories.") ] = None, agent_id: Annotated[ Optional[str], Field(default=None, description="Delete this agent and its memories.") ] = None, app_id: Annotated[ Optional[str], Field(default=None, description="Delete this app and its memories.") ] = None, run_id: Annotated[ Optional[str], Field(default=None, description="Delete this run and its memories.") ] = None, ctx: Context | None = None, ) -> str: """Delete a user/agent/app/run (and its memories) once the user confirms the scope.""" api_key, _, _ = _resolve_settings(ctx) args = DeleteEntitiesArgs( user_id=user_id, agent_id=agent_id, app_id=app_id, run_id=run_id, ) if not any([args.user_id, args.agent_id, args.app_id, args.run_id]): return json.dumps( { "error": "scope_missing", "detail": "Provide user_id, agent_id, app_id, or run_id before calling delete_entities.", }, ensure_ascii=False, ) payload = args.model_dump(exclude_none=True) client = _mem0_client(api_key) return _mem0_call(client.delete_users, **payload)
  • Pydantic model defining the input schema (user_id, agent_id, app_id, run_id) for the delete_entities tool, used for validation in the handler.
    class DeleteEntitiesArgs(BaseModel): user_id: Optional[str] = Field(None, description="Delete this user and all related memories.") agent_id: Optional[str] = Field(None, description="Delete this agent and its memories.") app_id: Optional[str] = Field(None, description="Delete this app and its memories.") run_id: Optional[str] = Field(None, description="Delete this run and its memories.")
  • The @server.tool decorator registers the delete_entities function as an MCP tool with the specified description.
    @server.tool( description="Remove a user/agent/app/run record entirely (and cascade-delete its memories)." )

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