### Clone and Install Mem0 MCP from Source Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Clone the mem0-mcp repository and install it in development mode. This is for local development setup. ```bash git clone https://github.com/mem0ai/mem0-mcp.git cd mem0-mcp-server pip install -e ".[dev]" ``` -------------------------------- ### Python Package Installation Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Install the mem0-mcp-server package locally using uv or pip. ```bash # Install with uv uv pip install mem0-mcp-server # Or with pip pip install mem0-mcp-server ``` -------------------------------- ### Local testing setup for Pydantic AI REPL agent Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Installs the mem0-mcp-server package and sets required environment variables for local testing with a Pydantic AI REPL agent. ```bash pip install mem0-mcp-server export MEM0_API_KEY="m0-..." export OPENAI_API_KEY="sk-..." ``` -------------------------------- ### Install mem0-mcp-server with pip Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Install the mem0-mcp-server package using pip. ```bash pip install mem0-mcp-server ``` -------------------------------- ### Install mem0-mcp-server with uv pip Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Install the mem0-mcp-server package locally using uv pip for development or testing. ```bash uv pip install mem0-mcp-server ``` -------------------------------- ### Install Mem0 MCP Server with npx Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Quickly install the Mem0 MCP server and configure it for various clients using npx. This command sets up the server and specifies the clients it should be compatible with. ```bash npx mcp-add \ --name mem0-mcp \ --type http \ --url "https://mcp.mem0.ai/mcp" \ --clients "claude,claude code,cursor,windsurf,vscode,opencode" ``` -------------------------------- ### Install mem0-mcp-server Package Source: https://github.com/mem0ai/mem0-mcp/blob/main/example/README.md Install the mem0-mcp-server package using pip or uv. Ensure your API keys are set as environment variables before running the agent. ```bash pip install mem0-mcp-server # Or with uv uv pip install mem0-mcp-server # Set your API keys export MEM0_API_KEY="m0-..." export OPENAI_API_KEY="sk-openai_..." # Run the REPL python example/pydantic_ai_repl.py ``` -------------------------------- ### Run Mem0 MCP Server Locally Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Commands to run the mem0-mcp-server locally after installation from source. Supports direct execution or using uv. ```bash # Run locally mem0-mcp-server ``` ```bash # Or with uv uv sync uv run mem0-mcp-server ``` -------------------------------- ### Build Custom Pydantic AI Agent Programmatically Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Programmatically build a custom Pydantic AI agent using the MCPServerStdio for standard input/output communication. This example demonstrates setting up the server with specific arguments and environment variables, and configuring the agent with a model, toolsets, and a system prompt. ```python import asyncio from pydantic_ai import Agent from pydantic_ai.mcp import MCPServerStdio async def main(): server = MCPServerStdio( "uvx", args=["mem0-mcp-server"], env={"MEM0_API_KEY": "m0-...", "MEM0_DEFAULT_USER_ID": "alice"}, timeout=30, ) agent = Agent( model="openai:gpt-4o", toolsets=[server], system_prompt="You are a memory-aware assistant. Use Mem0 tools to persist and recall information.", ) async with server, agent: result = await agent.run("Remember that I prefer dark mode in all my apps.") print(result.output) asyncio.run(main()) ``` -------------------------------- ### Run Pydantic AI Agent with Docker Source: https://github.com/mem0ai/mem0-mcp/blob/main/example/README.md Start a Mem0 MCP server in a Docker container and configure the agent to connect to it. This involves setting environment variables for the configuration path and server name. ```bash # Start Docker container docker run --rm -d \ --name mem0-mcp \ -e MEM0_API_KEY="m0-..." \ -p 8080:8081 \ mem0-mcp-server # Run agent pointing to Docker export MEM0_MCP_CONFIG_PATH=example/docker-config.json export MEM0_MCP_CONFIG_SERVER=mem0-docker python example/pydantic_ai_repl.py ``` -------------------------------- ### Run Pydantic AI Agent with Local Server Source: https://github.com/mem0ai/mem0-mcp/blob/main/example/README.md Execute the Pydantic AI agent, which will connect to a local Mem0 MCP server by default. Ensure the server is running or configured to start. ```bash python example/pydantic_ai_repl.py ``` -------------------------------- ### Build Mem0 MCP Docker Image Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Build the Docker image for the mem0-mcp-server. Ensure you are in the directory containing the Dockerfile. ```bash docker build -t mem0-mcp-server . ``` -------------------------------- ### Run Interactive REPL with Docker Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Execute the interactive REPL using a Docker-backed Mem0 MCP server. Ensure the MEM0_MCP_CONFIG_PATH and MEM0_MCP_CONFIG_SERVER environment variables are set correctly. ```bash export MEM0_MCP_CONFIG_PATH=example/docker-config.json export MEM0_MCP_CONFIG_SERVER=mem0-docker python example/pydantic_ai_repl.py ``` -------------------------------- ### Test Mem0 MCP Server with Pydantic AI REPL Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Clone the repository and run the Pydantic AI REPL script to test the Mem0 MCP server locally. Ensure your API keys are exported as environment variables. ```bash # Install the package pip install mem0-mcp-server # Or with uv uv pip install mem0-mcp-server # Set your API keys export MEM0_API_KEY="m0-..." export OPENAI_API_KEY="sk-openai..." # Clone and test with the agent git clone https://github.com/mem0ai/mem0-mcp.git cd mem0-mcp-server python example/pydantic_ai_repl.py ``` -------------------------------- ### Smithery configuration for cloud-hosted Mem0 MCP Source: https://context7.com/mem0ai/mem0-mcp/llms.txt JSON configuration for launching the Mem0 MCP server using Smithery, a cloud-hosted execution environment. Includes command, arguments, and environment variables. ```json { "mcpServers": { "mem0-memory-mcp": { "command": "npx", "args": [ "-y", "@smithery/cli@latest", "run", "@mem0ai/mem0-memory-mcp", "--key", "your-smithery-key", "--profile", "your-profile-name" ], "env": { "MEM0_API_KEY": "m0-..." } } } } ``` -------------------------------- ### Configure stdio (local MCP client) Source: https://context7.com/mem0ai/mem0-mcp/llms.txt JSON configuration for the stdio transport, typically used with local clients like Claude Desktop or Cursor. Specifies the command, arguments, and environment variables for the mem0-mcp-server. ```json { "mcpServers": { "mem0": { "command": "uvx", "args": ["mem0-mcp-server"], "env": { "MEM0_API_KEY": "m0-...", "MEM0_DEFAULT_USER_ID": "alice" } } } } ``` -------------------------------- ### Test with the Python Agent Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Clone the repository and test the server immediately using the included Pydantic AI agent. Ensure your API keys are set as environment variables. ```bash # Install the package pip install mem0-mcp-server # Or with uv uv pip install mem0-mcp-server # Set your API keys export MEM0_API_KEY="m0-..." export OPENAI_API_KEY="sk-openai-..." # Clone and test with the agent git clone https://github.com/mem0ai/mem0-mcp.git cd mem0-mcp-server python example/pydantic_ai_repl.py ``` -------------------------------- ### Run Mem0 MCP Docker Container Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Run the mem0-mcp-server as a Docker container. Mount necessary environment variables and port mappings. ```bash docker run --rm -d \ --name mem0-mcp \ -e MEM0_API_KEY=m0-... \ -p 8080:8081 \ mem0-mcp-server ``` -------------------------------- ### Docker configuration for Mem0 MCP server Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Builds and runs the Mem0 MCP server as a Docker container. Exposes the MCP service via HTTP on the host port. ```bash # Build docker build -t mem0-mcp-server . # Run — exposes /mcp on host port 8080 docker run --rm -d \ --name mem0-mcp \ -e MEM0_API_KEY=m0-... \ -p 8080:8081 \ mem0-mcp-server ``` -------------------------------- ### Using different server configurations with Python Agent Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Test the Python agent with different server configurations, such as Docker or Smithery remote server, by setting the MEM0_MCP_CONFIG_PATH and MEM0_MCP_CONFIG_SERVER environment variables. ```bash # Use with Docker container export MEM0_MCP_CONFIG_PATH=example/docker-config.json export MEM0_MCP_CONFIG_SERVER=mem0-docker python example/pydantic_ai_repl.py # Use with Smithery remote server export MEM0_MCP_CONFIG_PATH=example/config-smithery.json export MEM0_MCP_CONFIG_SERVER=mem0-memory-mcp python example/pydantic_ai_repl.py ``` -------------------------------- ### Test Mem0 MCP Server with Docker Container Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Configure and run the Pydantic AI REPL script to test the Mem0 MCP server using a Docker container. This requires setting the MEM0_MCP_CONFIG_PATH and MEM0_MCP_CONFIG_SERVER environment variables. ```bash # Use with Docker container export MEM0_MCP_CONFIG_PATH=example/docker-config.json export MEM0_MCP_CONFIG_SERVER=mem0-docker python example/pydantic_ai_repl.py ``` -------------------------------- ### Test Mem0 MCP Server with Smithery Remote Server Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Configure and run the Pydantic AI REPL script to test the Mem0 MCP server with a remote Smithery service. This requires setting the MEM0_MCP_CONFIG_PATH and MEM0_MCP_CONFIG_SERVER environment variables. ```bash # Use with Smithery remote server export MEM0_MCP_CONFIG_PATH=example/config-smithery.json export MEM0_MCP_CONFIG_SERVER=mem0-memory-mcp python example/pydantic_ai_repl.py ``` -------------------------------- ### Set environment variables for Mem0 MCP Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Configures the Mem0 MCP client using environment variables. MEM0_API_KEY is required, while others are optional with default values. ```bash # Required export MEM0_API_KEY="m0-..." # Optional export MEM0_DEFAULT_USER_ID="alice" # default: "mem0-mcp" export MEM0_ENABLE_GRAPH_DEFAULT="false" # default: false export MEM0_MCP_AGENT_MODEL="openai:gpt-4o" # default: "openai:gpt-5" export HOST="0.0.0.0" # HTTP mode only export PORT="8081" # HTTP mode only ``` -------------------------------- ### Enumerate all entities with stored memories Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Returns a list of all users, agents, apps, and runs that currently have memories stored. ```python result = await session.call_tool("list_entities", {}) # result → '[{"id": "alice", "type": "user", "memory_count": 42, ...}, {"id": "onboarding-agent", "type": "agent", ...}]' ``` -------------------------------- ### Configure Smithery Remote Server for MCP Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md JSON configuration for connecting the MCP client to a Smithery-hosted server. This includes command, arguments, and environment variables. ```json { "mcpServers": { "mem0-memory-mcp": { "command": "npx", "args": [ "-y", "@smithery/cli@latest", "run", "@mem0ai/mem0-memory-mcp", "--key", "your-smithery-key", "--profile", "your-profile-name" ], "env": { "MEM0_API_KEY": "m0-..." } } } } ``` -------------------------------- ### Configure Mem0 MCP Server for MCP Client Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Add this JSON configuration to your MCP client to connect to the Mem0 MCP server. Ensure MEM0_API_KEY and MEM0_DEFAULT_USER_ID environment variables are set. ```json { "mcpServers": { "mem0": { "command": "uvx", "args": ["mem0-mcp-server"], "env": { "MEM0_API_KEY": "m0-...", "MEM0_DEFAULT_USER_ID": "your-handle" } } } } ``` -------------------------------- ### Run Pydantic AI Agent with Smithery Remote Server Source: https://github.com/mem0ai/mem0-mcp/blob/main/example/README.md Configure the agent to connect to a Smithery remote Mem0 MCP server. This requires setting specific environment variables for the configuration path and server. ```bash export MEM0_MCP_CONFIG_PATH=example/config-smithery.json export MEM0_MCP_CONFIG_SERVER=mem0-memory-mcp python example/pydantic_ai_repl.py ``` -------------------------------- ### list_entities Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Enumerates all entities (users, agents, apps, runs) that have stored memories. ```APIDOC ## list_entities ### Description Returns the list of all users, agents, apps, and runs that currently have at least one memory stored in the Mem0 account. ### Method `session.call_tool("list_entities", {{}}) ### Parameters This endpoint does not accept any parameters. ### Request Example ```python result = await session.call_tool("list_entities", {{}}) ``` ### Response #### Success Response (200) - **id** (string) - The entity ID. - **type** (string) - The type of entity (user, agent, app, run). - **memory_count** (integer) - The number of memories associated with the entity. #### Response Example ```json [ { "id": "alice", "type": "user", "memory_count": 42, ... }, { "id": "onboarding-agent", "type": "agent", ... } ] ``` ``` -------------------------------- ### Mem0 MCP Server Tools Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md The Mem0 MCP server exposes the following tools for interacting with the Mem0 Memory API. All responses are JSON strings returned directly from the Mem0 API. ```APIDOC ## Tools The server exposes the following tools to your LLM: | Tool | Description | | --------------------- | --------------------------------------------------------------------------------- | | `add_memory` | Save text or conversation history (or explicit message objects) for a user/agent. | | `search_memories` | Semantic search across existing memories (filters + limit supported). | | `get_memories` | List memories with structured filters and pagination. | | `get_memory` | Retrieve one memory by its `memory_id`. | | `update_memory` | Overwrite a memory's text once the user confirms the `memory_id`. | | `delete_memory` | Delete a single memory by `memory_id`. | | `delete_all_memories` | Bulk delete all memories in the confirmed scope (user/agent/app/run). | | `delete_entities` | Delete a user/agent/app/run entity (and its memories). | | `list_entities` | Enumerate users/agents/apps/runs stored in Mem0. | All responses are JSON strings returned directly from the Mem0 API. ``` -------------------------------- ### Monitor Mem0 MCP Docker Container Source: https://github.com/mem0ai/mem0-mcp/blob/main/README.md Commands to monitor the running mem0-mcp Docker container, including viewing logs and checking its status. ```bash # View logs docker logs -f mem0-mcp ``` ```bash # Check status docker ps ``` -------------------------------- ### List memories with get_memories Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Use `get_memories` for paginated listing and filtering without semantic search. Supports `page` and `page_size` for pagination. Filters can target specific `user_id`, `agent_id`, and `created_at` ranges. Multiple users can be queried simultaneously using the `in` operator. ```python # List all memories for the default user (page 1, default page size) result = await session.call_tool("get_memories", {}) # result → '[{"id": "mem_abc123", "memory": "...", "created_at": "2024-03-01T12:00:00Z", ...}, ...]' ``` ```python # Paginated listing result = await session.call_tool("get_memories", { "filters": {"AND": [{"user_id": "alice"}]}, "page": 2, "page_size": 20 }) ``` ```python # Filter memories for a specific agent within a date window result = await session.call_tool("get_memories", { "filters": { "AND": [ {"agent_id": "onboarding-agent"}, {"created_at": {"gte": "2024-03-01"}} ] }, "page": 1, "page_size": 50 }) ``` ```python # Multiple users in one query result = await session.call_tool("get_memories", { "filters": {"AND": [{"user_id": {"in": ["alice", "bob", "carol"]}}]}}) ``` -------------------------------- ### Search memories using search_memories Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Perform semantic searches with `search_memories`. The `user_id` is automatically injected if not provided in filters. Results can be limited using the `limit` parameter. Filters can narrow results by `user_id`, `agent_id`, and `created_at` date ranges. ```python # Simple query (user_id injected automatically from env) result = await session.call_tool("search_memories", { "query": "dietary restrictions and food allergies", "limit": 5 }) # result → '[{"id": "mem_abc123", "memory": "Alice is allergic to peanuts...", "score": 0.97, ...}]' ``` ```python # With explicit user filter result = await session.call_tool("search_memories", { "query": "project deadlines", "filters": {"AND": [{"user_id": "alice"}]}, "limit": 10 }) ``` ```python # Filter by date range result = await session.call_tool("search_memories", { "query": "trial parameters", "filters": { "AND": [ {"user_id": "alice"}, {"created_at": {"gte": "2024-01-01"}} ] } }) ``` ```python # Cross-entity search (user OR agent) result = await session.call_tool("search_memories", { "query": "onboarding workflow", "filters": { "OR": [ {"user_id": "alice"}, {"agent_id": "onboarding-agent"} ] } }) ``` -------------------------------- ### add_memory Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Saves a plain-text fact, preference, or structured conversation history to Mem0. Either 'text' or an explicit 'messages' list must be provided. The default 'user_id' from the environment is injected automatically when no entity scope is specified. ```APIDOC ## add_memory — Store a new memory ### Description Saves a plain-text fact, preference, or structured conversation history to Mem0 under an optional `user_id`, `agent_id`, `app_id`, or `run_id` scope. Either `text` (converted to a `user` message internally) or an explicit `messages` list must be provided. The default `user_id` from the environment is injected automatically when no entity scope is specified. ### Method `call_tool("add_memory", { ... })` ### Parameters - **text** (string) - Optional - The plain-text content of the memory. - **messages** (list) - Optional - A list of message objects representing a conversation history. - **role** (string) - Required - The role of the message sender (e.g., "user", "assistant"). - **content** (string) - Required - The content of the message. - **user_id** (string) - Optional - The ID of the user scope for the memory. - **agent_id** (string) - Optional - The ID of the agent scope for the memory. - **app_id** (string) - Optional - The ID of the application scope for the memory. - **run_id** (string) - Optional - The ID of the run scope for the memory. - **metadata** (object) - Optional - Additional metadata to associate with the memory. - **enable_graph** (boolean) - Optional - Enables graph memory opt-in for agent scope. ### Request Example ```python # Via Python MCP client result = await session.call_tool("add_memory", { "text": "Alice is allergic to peanuts and shellfish.", "user_id": "alice" }) # With structured conversation history result = await session.call_tool("add_memory", { "messages": [ {"role": "user", "content": "My project deadline is March 31st."}, {"role": "assistant", "content": "Noted! I'll keep that in mind."} ], "user_id": "alice", "metadata": {"project": "phoenix", "priority": "high"} }) # With agent scope (graph memory opt-in) result = await session.call_tool("add_memory", { "text": "Agent successfully completed onboarding workflow.", "agent_id": "onboarding-agent", "run_id": "run_20240315", "enable_graph": True }) ``` ### Response #### Success Response (JSON string) Returns a JSON string representing the stored memory, including its ID and event type. - **id** (string) - The unique identifier for the memory. - **event** (string) - The type of event (e.g., "ADD"). ### Response Example ```json { "id": "mem_abc123", "event": "ADD", ... } ``` ``` -------------------------------- ### MCP client config for Docker HTTP transport Source: https://context7.com/mem0ai/mem0-mcp/llms.txt JSON configuration for an MCP client to connect to a Mem0 MCP server running in Docker via HTTP. ```json // MCP client config for Docker { "mcpServers": { "mem0-docker": { "type": "http", "url": "http://localhost:8080/mcp" } } } ``` -------------------------------- ### Retrieve a single memory by ID Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Fetches a full memory record using its exact memory_id. Handles cases where the ID does not exist. ```python result = await session.call_tool("get_memory", { "memory_id": "mem_abc123" }) # result → '{"id": "mem_abc123", "memory": "Alice is allergic to peanuts and shellfish.", "user_id": "alice", "created_at": "...", ...}' ``` ```python # Error case — non-existent ID result = await session.call_tool("get_memory", { "memory_id": "mem_nonexistent" }) # result → '{"error": "Memory not found", "status": 404, "payload": null}' ``` -------------------------------- ### search_memories Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Runs a natural-language semantic query against all stored memories. Accepts optional structured filters for narrowing results by entity, date range, or custom fields. The default `user_id` is automatically injected into filters if absent. ```APIDOC ## search_memories — Semantic search over memories ### Description Runs a natural-language semantic query against all stored memories. Accepts optional structured filters for narrowing results by entity, date range, or custom fields. The default `user_id` is automatically injected into filters if absent. ### Method `call_tool("search_memories", { ... })` ### Parameters - **query** (string) - Required - The natural-language query for semantic search. - **filters** (object) - Optional - Structured filters for narrowing search results. - **AND** (list) - A list of filter conditions that must all be met. - **OR** (list) - A list of filter conditions where at least one must be met. - **user_id** (string) - Filters memories by user ID. - **agent_id** (string) - Filters memories by agent ID. - **app_id** (string) - Filters memories by application ID. - **run_id** (string) - Filters memories by run ID. - **created_at** (object) - Filters memories by creation timestamp. - **gte** (string) - Greater than or equal to (ISO 8601 format). - **lte** (string) - Less than or equal to (ISO 8601 format). - **limit** (integer) - Optional - The maximum number of results to return. ### Request Example ```python # Simple query (user_id injected automatically from env) result = await session.call_tool("search_memories", { "query": "dietary restrictions and food allergies", "limit": 5 }) # With explicit user filter result = await session.call_tool("search_memories", { "query": "project deadlines", "filters": {"AND": [{"user_id": "alice"}]}, "limit": 10 }) # Filter by date range result = await session.call_tool("search_memories", { "query": "trial parameters", "filters": { "AND": [ {"user_id": "alice"}, {"created_at": {"gte": "2024-01-01"}} ] } }) # Cross-entity search (user OR agent) result = await session.call_tool("search_memories", { "query": "onboarding workflow", "filters": { "OR": [ {"user_id": "alice"}, {"agent_id": "onboarding-agent"} ] } }) ``` ### Response #### Success Response (JSON string) Returns a JSON string representing a list of memories that match the query and filters. - **id** (string) - The unique identifier for the memory. - **memory** (string) - The content of the memory. - **score** (float) - The semantic similarity score of the memory to the query. ### Response Example ```json [ { "id": "mem_abc123", "memory": "Alice is allergic to peanuts...", "score": 0.97, ... } ] ``` ``` -------------------------------- ### get_memories Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Pages through stored memories using structured filters instead of semantic search. Useful for enumeration, auditing, or bulk operations. Supports 1-indexed `page` and `page_size` for pagination. ```APIDOC ## get_memories — List memories with structured filters and pagination ### Description Pages through stored memories using structured filters instead of semantic search. Useful for enumeration, auditing, or bulk operations. Supports 1-indexed `page` and `page_size` for pagination. ### Method `call_tool("get_memories", { ... })` ### Parameters - **filters** (object) - Optional - Structured filters for narrowing memory retrieval. - **AND** (list) - A list of filter conditions that must all be met. - **OR** (list) - A list of filter conditions where at least one must be met. - **user_id** (string or object) - Filters memories by user ID. Can be a single ID or an object with an `in` operator for multiple IDs. - **in** (list) - A list of user IDs. - **agent_id** (string) - Filters memories by agent ID. - **app_id** (string) - Filters memories by application ID. - **run_id** (string) - Filters memories by run ID. - **created_at** (object) - Filters memories by creation timestamp. - **gte** (string) - Greater than or equal to (ISO 8601 format). - **lte** (string) - Less than or equal to (ISO 8601 format). - **page** (integer) - Optional - The 1-indexed page number for pagination. Defaults to 1. - **page_size** (integer) - Optional - The number of items per page. Defaults to a system-defined value. ### Request Example ```python # List all memories for the default user (page 1, default page size) result = await session.call_tool("get_memories", {}) # Paginated listing with user filter result = await session.call_tool("get_memories", { "filters": {"AND": [{"user_id": "alice"}]}, "page": 2, "page_size": 20 }) # Filter memories for a specific agent within a date window result = await session.call_tool("get_memories", { "filters": { "AND": [ {"agent_id": "onboarding-agent"}, {"created_at": {"gte": "2024-03-01"}} ] }, "page": 1, "page_size": 50 }) # Multiple users in one query result = await session.call_tool("get_memories", { "filters": {"AND": [{"user_id": {"in": ["alice", "bob", "carol"]}}]} }) ``` ### Response #### Success Response (JSON string) Returns a JSON string representing a list of memories matching the filters and pagination. - **id** (string) - The unique identifier for the memory. - **memory** (string) - The content of the memory. - **created_at** (string) - The timestamp when the memory was created (ISO 8601 format). ### Response Example ```json [ { "id": "mem_abc123", "memory": "...", "created_at": "2024-03-01T12:00:00Z", ... }, ... ] ``` ``` -------------------------------- ### Store a new memory using add_memory Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Use `add_memory` to save facts, preferences, or conversation history. Provide either `text` or `messages`. The default `user_id` is automatically injected if no scope is specified. Supports `agent_id`, `app_id`, `run_id` for scoping and `enable_graph` for graph memory. ```python # Via Python MCP client result = await session.call_tool("add_memory", { "text": "Alice is allergic to peanuts and shellfish.", "user_id": "alice" }) # result → '{"id": "mem_abc123", "event": "ADD", ...}' ``` ```python # With structured conversation history result = await session.call_tool("add_memory", { "messages": [ {"role": "user", "content": "My project deadline is March 31st."}, {"role": "assistant", "content": "Noted! I'll keep that in mind."} ], "user_id": "alice", "metadata": {"project": "phoenix", "priority": "high"} }) ``` ```python # With agent scope (graph memory opt-in) result = await session.call_tool("add_memory", { "text": "Agent successfully completed onboarding workflow.", "agent_id": "onboarding-agent", "run_id": "run_20240315", "enable_graph": True }) ``` -------------------------------- ### get_memory Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Retrieves a single memory by its unique ID. This is useful when the exact memory identifier is known. ```APIDOC ## get_memory ### Description Fetches the full record for one memory once its exact `memory_id` is known. ### Method `session.call_tool("get_memory", { ... }) ### Parameters #### Path Parameters - **memory_id** (string) - Required - The unique identifier of the memory to retrieve. ### Request Example ```python result = await session.call_tool("get_memory", { "memory_id": "mem_abc123" }) ``` ### Response #### Success Response (200) - **id** (string) - The memory ID. - **memory** (string) - The content of the memory. - **user_id** (string) - The ID of the user associated with the memory. - **created_at** (string) - Timestamp of memory creation. #### Response Example ```json { "id": "mem_abc123", "memory": "Alice is allergic to peanuts and shellfish.", "user_id": "alice", "created_at": "..." } ``` #### Error Response - **error** (string) - Description of the error, e.g., "Memory not found". - **status** (integer) - HTTP status code, e.g., 404. - **payload** (any) - Additional error details. #### Error Example ```json { "error": "Memory not found", "status": 404, "payload": null } ``` ``` -------------------------------- ### Bulk-delete memories within a scope Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Deletes all memories associated with a given user_id, agent_id, app_id, or run_id. If no scope is provided, it defaults to the server's configured user_id. ```python # Delete all memories for the default user result = await session.call_tool("delete_all_memories", {}) # Delete all memories for a specific user result = await session.call_tool("delete_all_memories", { "user_id": "alice" }) # result → '{"message": "All memories deleted successfully"}' # Delete all memories for a specific run result = await session.call_tool("delete_all_memories", { "run_id": "run_20240315" }) ``` -------------------------------- ### update_memory Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Overwrites the text content of an existing memory. Metadata and entity scopes are preserved. ```APIDOC ## update_memory ### Description Replaces the text of an existing memory once the caller has confirmed the exact `memory_id`. The original record is updated in-place; metadata and entity scopes are preserved. ### Method `session.call_tool("update_memory", { ... }) ### Parameters #### Path Parameters - **memory_id** (string) - Required - The unique identifier of the memory to update. - **text** (string) - Required - The new text content for the memory. ### Request Example ```python result = await session.call_tool("update_memory", { "memory_id": "mem_abc123", "text": "Alice is allergic to peanuts, shellfish, and tree nuts." }) ``` ### Response #### Success Response (200) - **id** (string) - The memory ID. - **memory** (string) - The updated content of the memory. - **user_id** (string) - The ID of the user associated with the memory. - **created_at** (string) - Timestamp of memory creation. #### Response Example ```json { "id": "mem_abc123", "memory": "Alice is allergic to peanuts, shellfish, and tree nuts.", "user_id": "alice", "created_at": "..." } ``` ``` -------------------------------- ### Remove an entity and cascade-delete its memories Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Permanently removes an entity record (user_id, agent_id, app_id, or run_id) and all associated memories. Requires at least one scope identifier. ```python # Delete a user entity and all its memories result = await session.call_tool("delete_entities", { "user_id": "alice" }) # result → '{"message": "User deleted successfully"}' # Delete an agent entity result = await session.call_tool("delete_entities", { "agent_id": "onboarding-agent" }) # Error — no scope provided result = await session.call_tool("delete_entities", {}) # result → '{"error": "scope_missing", "detail": "Provide user_id, agent_id, app_id, or run_id before calling delete_entities."}' ``` -------------------------------- ### Overwrite an existing memory's text Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Replaces the text of an existing memory using its memory_id. The original record is updated in-place, preserving metadata and entity scopes. ```python result = await session.call_tool("update_memory", { "memory_id": "mem_abc123", "text": "Alice is allergic to peanuts, shellfish, and tree nuts." }) # result → '{"id": "mem_abc123", "memory": "Alice is allergic to peanuts, shellfish, and tree nuts.", ...}' ``` -------------------------------- ### delete_all_memories Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Deletes all memories associated with a specified scope (user, agent, app, or run). ```APIDOC ## delete_all_memories ### Description Deletes every memory attached to the given `user_id`, `agent_id`, `app_id`, or `run_id` while leaving the entity record itself intact. Defaults to the server's configured `user_id` when no scope is provided. ### Method `session.call_tool("delete_all_memories", { ... }) ### Parameters #### Path Parameters - **user_id** (string) - Optional - The ID of the user whose memories should be deleted. - **agent_id** (string) - Optional - The ID of the agent whose memories should be deleted. - **app_id** (string) - Optional - The ID of the app whose memories should be deleted. - **run_id** (string) - Optional - The ID of the run whose memories should be deleted. ### Request Example ```python # Delete all memories for the default user result = await session.call_tool("delete_all_memories", {{}}) # Delete all memories for a specific user result = await session.call_tool("delete_all_memories", {{ "user_id": "alice" }}) # Delete all memories for a specific run result = await session.call_tool("delete_all_memories", {{ "run_id": "run_20240315" }}) ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message, e.g., "All memories deleted successfully". #### Response Example ```json { "message": "All memories deleted successfully" } ``` ``` -------------------------------- ### Delete a single memory by ID Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Removes a memory using its exact memory_id. Ensure user confirmation before calling to prevent accidental data loss. ```python result = await session.call_tool("delete_memory", { "memory_id": "mem_abc123" }) # result → '{"message": "Memory deleted successfully"}' ``` -------------------------------- ### delete_memory Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Deletes a single memory identified by its `memory_id`. Use with caution after user confirmation. ```APIDOC ## delete_memory ### Description Removes one memory by its exact `memory_id`. Should be called only after the user has confirmed the ID to prevent accidental loss. ### Method `session.call_tool("delete_memory", { ... }) ### Parameters #### Path Parameters - **memory_id** (string) - Required - The unique identifier of the memory to delete. ### Request Example ```python result = await session.call_tool("delete_memory", { "memory_id": "mem_abc123" }) ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message, e.g., "Memory deleted successfully". #### Response Example ```json { "message": "Memory deleted successfully" } ``` ``` -------------------------------- ### delete_entities Source: https://context7.com/mem0ai/mem0-mcp/llms.txt Permanently removes an entity (user, agent, app, or run) and all associated memories. ```APIDOC ## delete_entities ### Description Permanently removes a `user_id`, `agent_id`, `app_id`, or `run_id` entity record together with all memories it owns. At least one scope identifier must be supplied; the server returns a structured error otherwise. ### Method `session.call_tool("delete_entities", { ... }) ### Parameters #### Path Parameters - **user_id** (string) - Optional - The ID of the user entity to delete. - **agent_id** (string) - Optional - The ID of the agent entity to delete. - **app_id** (string) - Optional - The ID of the app entity to delete. - **run_id** (string) - Optional - The ID of the run entity to delete. ### Request Example ```python # Delete a user entity and all its memories result = await session.call_tool("delete_entities", {{ "user_id": "alice" }}) # Delete an agent entity result = await session.call_tool("delete_entities", {{ "agent_id": "onboarding-agent" }}) # Error — no scope provided result = await session.call_tool("delete_entities", {{}}) ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message, e.g., "User deleted successfully". #### Response Example ```json { "message": "User deleted successfully" } ``` #### Error Response - **error** (string) - Error code, e.g., "scope_missing". - **detail** (string) - Detailed error message. #### Error Example ```json { "error": "scope_missing", "detail": "Provide user_id, agent_id, app_id, or run_id before calling delete_entities." } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.