Skip to main content
Glama
mem0ai

Mem0 MCP Server

Official
by mem0ai

delete_entities

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

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.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @server.tool decorator registers the delete_entities function, and the function itself implements the tool logic by validating inputs and calling the Mem0 client's delete_users method.
        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 for delete_entities tool arguments.
    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.")
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states that removal is 'entire' and includes cascade-deletion of memories, which adds important context about destructive behavior. However, it doesn't cover other critical aspects like permissions needed, rate limits, error handling, or confirmation steps, leaving gaps in transparency for a high-impact deletion tool.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads key information ('Remove a user/agent/app/run record entirely') and adds critical behavioral detail ('and cascade-delete its memories') without any wasted words. It's appropriately sized for the tool's complexity and gets straight to the point.

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

Completeness3/5

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

Given that this is a destructive tool with no annotations and an output schema exists (which handles return values), the description is moderately complete. It covers the core action and cascade effect but lacks important context like safety warnings, permission requirements, or error scenarios. For a high-stakes deletion tool, more completeness would be beneficial to guide safe usage.

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

Parameters3/5

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

Schema description coverage is 100%, with each parameter documented in the schema (e.g., 'Delete this user and its memories.'). The description adds no additional parameter semantics beyond what's in the schema, such as explaining parameter interactions or constraints. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, though the description could have enhanced understanding of how multiple parameters work together.

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

Purpose4/5

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

The description clearly states the action ('Remove') and the resources affected ('user/agent/app/run record entirely'), making the purpose specific and understandable. However, it doesn't explicitly distinguish this tool from sibling deletion tools like 'delete_memory' or 'delete_all_memories', which handle memory-specific deletions rather than entity-level deletions with cascading effects.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'delete_memory' or 'delete_all_memories'. It mentions cascade-deletion of memories, which hints at broader scope, but lacks explicit when-to-use rules, prerequisites, or warnings about irreversible deletion, leaving usage context unclear.

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

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