Skip to main content
Glama
arjunkmrm

Mem0 MCP Server

get_memories

Retrieve stored memories from the Mem0 MCP Server using structured filters and pagination to browse specific user or agent data without search queries.

Instructions

Page through memories using filters instead of search.

    Use filters to list specific memories. Common filter patterns:
    - Single user: {"AND": [{"user_id": "john"}]}
    - Agent memories: {"AND": [{"agent_id": "agent_name"}]}
    - Recent memories: {"AND": [{"user_id": "john"}, {"created_at": {"gte": "2024-01-01"}}]}
    - Multiple users: {"AND": [{"user_id": {"in": ["john", "jane"]}}]}

    Pagination: Use page (1-indexed) and page_size for browsing results.
    user_id is automatically added to filters if not provided.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filtersNoStructured filters; user_id injected automatically.
pageNo1-indexed page number when paginating.
page_sizeNoNumber of memories per page (default 10).
enable_graphNoSet true only if the caller explicitly wants graph-derived memories.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The @server.tool decorator and get_memories function implementation that handles listing memories with filters and pagination by calling the Mem0 client's get_all method.
    @server.tool(
        description="""Page through memories using filters instead of search.
    
        Use filters to list specific memories. Common filter patterns:
        - Single user: {"AND": [{"user_id": "john"}]}
        - Agent memories: {"AND": [{"agent_id": "agent_name"}]}
        - Recent memories: {"AND": [{"user_id": "john"}, {"created_at": {"gte": "2024-01-01"}}]}
        - Multiple users: {"AND": [{"user_id": {"in": ["john", "jane"]}}]}
    
        Pagination: Use page (1-indexed) and page_size for browsing results.
        user_id is automatically added to filters if not provided.
        """
    )
    def get_memories(
        filters: Annotated[
            Optional[Dict[str, Any]],
            Field(default=None, description="Structured filters; user_id injected automatically."),
        ] = None,
        page: Annotated[
            Optional[int], Field(default=None, description="1-indexed page number when paginating.")
        ] = None,
        page_size: Annotated[
            Optional[int], Field(default=None, description="Number of memories per page (default 10).")
        ] = None,
        enable_graph: Annotated[
            Optional[bool],
            Field(
                default=None,
                description="Set true only if the caller explicitly wants graph-derived memories.",
            ),
        ] = None,
        ctx: Context | None = None,
    ) -> str:
        """List memories via structured filters or pagination."""
    
        api_key, default_user, graph_default = _resolve_settings(ctx)
        args = GetMemoriesArgs(
            filters=filters,
            page=page,
            page_size=page_size,
            enable_graph=_default_enable_graph(enable_graph, graph_default),
        )
        payload = args.model_dump(exclude_none=True)
        payload["filters"] = _with_default_filters(default_user, payload.get("filters"))
        payload.setdefault("enable_graph", graph_default)
        client = _mem0_client(api_key)
        return _mem0_call(client.get_all, **payload)
  • Pydantic schema defining the input arguments for the get_memories tool.
    class GetMemoriesArgs(BaseModel):
        filters: Optional[Dict[str, Any]] = Field(
            None, description="Structured filters; user_id injected automatically."
        )
        page: Optional[int] = Field(None, description="1-indexed page number.")
        page_size: Optional[int] = Field(None, description="Number of memories per page.")
        enable_graph: Optional[bool] = Field(
            None, description="Set True only when the user wants graph knowledge."
        )
Behavior4/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 effectively describes key behaviors: automatic user_id injection, pagination mechanics (1-indexed), default page_size, and the distinction between filtering vs. searching. However, it doesn't mention potential rate limits, authentication requirements, or error conditions, leaving some behavioral aspects uncovered.

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 well-structured and front-loaded with the core purpose. Every sentence adds value: the initial statement of purpose, the usage guidance with examples, and the behavioral notes about pagination and automatic filtering. There's no wasted text, and the information is presented in a logical, scannable format.

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

Completeness5/5

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

Given the tool's moderate complexity (4 parameters, filtering logic) and the presence of an output schema, the description provides excellent contextual completeness. It covers the purpose, differentiation from siblings, parameter usage with examples, and key behavioral aspects. The output schema will handle return values, so the description appropriately focuses on usage context.

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

Parameters4/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds significant value beyond the schema by providing concrete filter examples with JSON syntax, explaining the automatic user_id injection behavior, and clarifying pagination usage. This gives practical context that the schema alone doesn't provide, warranting a higher score.

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

Purpose5/5

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

The description clearly states the tool's purpose: 'Page through memories using filters instead of search.' It specifies the verb ('Page through') and resource ('memories'), and explicitly distinguishes it from the sibling 'search_memories' tool by mentioning 'instead of search.' This provides excellent differentiation from alternatives.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool versus alternatives: 'Use filters to list specific memories' and 'instead of search.' It also offers practical examples of common filter patterns, helping the agent understand appropriate use cases. The mention of pagination parameters further clarifies operational context.

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

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