Access memory management from MCP
AI coding assistants (collectively referred to as agents in this topic) require persistent long-term memory to carry project context across sessions. PolarDB memory management can be connected to mainstream agents. After the connection, agents automatically gain the ability to add, retrieve, and manage long-term memories without any code. This topic describes how to configure PolarDB memory management in Qoder, QoderWork, Claude Code, Codex, OpenCode, Hermes Agent, OpenClaw, and the Python MCP SDK.
Prerequisites
Before you start, obtain the connection parameters and make sure that your environment meets the connection requirements.
Connection parameters
Parameter | Description |
Endpoint | In the Note The client environment must be able to connect to PolarDB memory management over the network. If the client runs on your on-premises machine or in an environment outside the same VPC, apply for a Public network address first and add the public IP address of your machine to the application whitelist. |
MCP endpoint | Append the |
Transport protocol | Streamable HTTP, based on the JSON-RPC 2.0 specification. |
Authentication method | Carry the API key in the request header Note For managed platforms that cannot customize request headers, |
Placeholder and environment variable conventions
The <API_KEY>, <host>, and <port> placeholders in the examples of this topic must be replaced with your actual API key and endpoint. Store the API key in the MEM0_API_KEY environment variable and set it in your operating system in advance:
export MEM0_API_KEY="<API_KEY>"Some configuration examples use the ${MEM0_API_KEY:-apikey} syntax, which reads the MEM0_API_KEY environment variable first and falls back to the default value apikey when the variable is not set.
Choose a connection method
Qoder, QoderWork, QwenWork, Claude Code, Codex, OpenCode, Hermes Agent, and OpenClaw all support quick connection. Choose a method from the following table.
Connection method | Applicable scenario | Automatic recall and saving |
Method 1 (recommended): Install and connect by using natural language | The agent reads the installation instructions and completes the connection by itself. No manual commands are required. | Yes |
Method 2 (recommended): Install and connect from the command line | Run the one-click installation command in a terminal yourself. | Yes |
Method 3: Configure the MCP server manually | You need to manage the MCP configuration file yourself, or your agent version does not support the one-click script. | No. You must explicitly ask the agent to read and write memories in the conversation. |
Method 1 and Method 2 are based on the same polarmemory CLI. They have different entry points but the same result: both automatically complete CLI installation, hooks or plug-in registration, skill installation, and connectivity verification. After the connection, relevant memories are automatically recalled on each query and new memories are automatically saved at the end of each conversation turn, so these two methods are recommended. If neither applies, use Method 3 to write the MCP configuration for a single agent manually.
Method 1 (recommended): Install and connect by using natural language
Copy the following text and send it to your agent. The agent automatically completes the installation and connection setup of the polarmemory CLI.
Read https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.md, install the polarmemory CLI as described there, and configure your own connection with API key <API_KEY> and endpoint http://<host>:<port>.After sending it, verify the connection result as described in Apply the configuration and verify the connection
Method 2: Install and connect from the command line
Run the one-click installation command in a terminal. Choose the Linux/macOS/WSL or Windows PowerShell version based on your operating system.
Installation commands
Qoder
You can download and install the plugin through the official Qoder marketplace. Download link: Qoder marketplace.
Linux/macOS/WSL:
curl -fsSL 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh' | sh -s -- --agent qoder --api-key <API_KEY> --base-url http://<host>:<port>Windows PowerShell:
& ([ScriptBlock]::Create((irm 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.ps1'))) -Agent qoder -ApiKey <API_KEY> -BaseUrl http://<host>:<port>
QoderWork
Linux/macOS/WSL:
curl -fsSL 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh' | sh -s -- --agent qoderwork --api-key <API_KEY> --base-url http://<host>:<port>Windows PowerShell:
& ([ScriptBlock]::Create((irm 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.ps1'))) -Agent qoderwork -ApiKey <API_KEY> -BaseUrl http://<host>:<port>
QwenWork
Linux/macOS/WSL:
curl -fsSL 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh' | sh -s -- --agent qwenwork --api-key <API_KEY> --base-url http://<host>:<port>Windows PowerShell:
curl -fsSL 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh' | sh -s -- --agent qwenwork --api-key <API_KEY> --base-url http://<host>:<port>
Claude Code
Linux/macOS/WSL:
curl -fsSL 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh' | sh -s -- --agent claude --api-key <API_KEY> --base-url http://<host>:<port>Windows PowerShell:
& ([ScriptBlock]::Create((irm 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.ps1'))) -Agent claude -ApiKey <API_KEY> -BaseUrl http://<host>:<port>
Codex
Linux/macOS/WSL:
curl -fsSL 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh' | sh -s -- --agent codex --api-key <API_KEY> --base-url http://<host>:<port>Windows PowerShell:
& ([ScriptBlock]::Create((irm 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.ps1'))) -Agent codex -ApiKey <API_KEY> -BaseUrl http://<host>:<port>
OpenCode
Linux/macOS/WSL:
curl -fsSL 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh' | sh -s -- --agent opencode --api-key <API_KEY> --base-url http://<host>:<port>Windows PowerShell:
& ([ScriptBlock]::Create((irm 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.ps1'))) -Agent opencode -ApiKey <API_KEY> -BaseUrl http://<host>:<port>
Hermes Agent
Linux/macOS/WSL:
curl -fsSL 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh' | sh -s -- --agent hermes --api-key <API_KEY> --base-url http://<host>:<port>Windows PowerShell:
& ([ScriptBlock]::Create((irm 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.ps1'))) -Agent hermes -ApiKey <API_KEY> -BaseUrl http://<host>:<port>
OpenClaw
Linux/macOS/WSL:
curl -fsSL 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh' | sh -s -- --agent openclaw --api-key <API_KEY> --base-url http://<host>:<port>Windows PowerShell:
& ([ScriptBlock]::Create((irm 'https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.ps1'))) -Agent openclaw -ApiKey <API_KEY> -BaseUrl http://<host>:<port>
After the installation, restart the agent and verify the connection as described in Apply the configuration and verify the connection. When multiple people share the same PolarDB memory management instance, you can append a memory isolation parameter to the installation command. For details, see Memory isolation.
Install the CLI manually (when the script is unavailable)
If you cannot access the script URL, install the CLI and complete the connection setup manually. The value of <agent> is the same as in the commands for each platform above.
npm install -g @aliyunpolar/polarmemory
polarmemory setup --agent <agent> --api-key <API_KEY> --base-url http://<host>:<port>After the installation, you also need to restart the corresponding agent to apply the configuration.
Method 3: Configure the MCP server manually
If you need to manage the MCP configuration file yourself, or your agent version does not support the one-click script, write the configuration manually according to the tab of your agent. This method only registers the MCP server and does not include hooks or the skill, so memories are not recalled or saved automatically. You must explicitly ask the agent to read and write memories in the conversation.
The following examples all use mem0 as the MCP server name. The commands hermes mcp test mem0 and codex mcp remove mem0 use mem0 to refer to this server name. The value of the type field that each agent uses to declare a remote server is different (Qoder uses http, QoderWork uses streamable-http, and OpenCode uses remote). Follow the example in the tab of your agent and do not reuse values across agents.
Qoder
MCP tools are available only in Agent mode of Qoder.
Use the console method for quick connection of a standalone environment. Use the configuration file method when team sharing or project-versioned management is required.
Quick connection through the console
Open Qoder Settings. On macOS, press
Shift+Command+,. On Windows, pressCtrl+Shift+,.Go to MCP Services > My Services > + Add.
Select Add by Configuration and paste the following JSON. What you paste in the console is a single server fragment without the
mcpServerswrapper.{ "mem0": { "type": "http", "url": "http://<host>:<port>/mcp", "headers": { "Authorization": "Token ${MEM0_API_KEY:-apikey}" } } }Set the API key in the
.envfile at the project root.MEM0_API_KEY=<API_KEY>
Connect through a configuration file
Qoder supports configuration files at three scopes. Their paths and recommended purposes are as follows:
Scope | Path | Recommended for Git commit |
User level (global) |
| — |
Project level (shared) |
| Yes |
Project level (local) |
| No (suitable for storing keys) |
For team sharing, use the project level (shared) scope and create
.mcp.jsonat the project root:{ "mcpServers": { "mem0": { "type": "http", "url": "http://<host>:<port>/mcp", "headers": { "Authorization": "Token ${MEM0_API_KEY:-apikey}" } } } }For personal use when you need to write the key directly, use the project level (local) scope. Enter the actual API key in
.qoder/settings.local.jsonand do not commit it to Git:{ "mcpServers": { "mem0": { "type": "http", "url": "http://<host>:<port>/mcp", "headers": { "Authorization": "Token <API_KEY>" } } } }
The top-level key that Qoder uses in configuration files is mcpServers, which differs from the servers format of VS Code. Do not mix them.
QoderWork
In QoderWork, go to Connectors and click + Add > Paste JSON Configuration.
Paste the following content in the dialog box:
{
"mcpServers": {
"mem0": {
"type": "streamable-http",
"url": "http://<host>:<port>/mcp",
"headers": {
"Authorization": "Token ${MEM0_API_KEY:-apikey}"
}
}
}
}Set the MEM0_API_KEY environment variable, or replace ${MEM0_API_KEY:-apikey} with your actual API key.
QwenWork
In QwenWork, go to Connectors and click + Add > Paste JSON Configuration.
Paste the following content in the dialog box:
{
"mcpServers": {
"mem0": {
"type": "streamable-http",
"url": "http://<host>:<port>/mcp",
"headers": {
"Authorization": "Token ${MEM0_API_KEY:-apikey}"
}
}
}
}Set the MEM0_API_KEY environment variable, or replace ${MEM0_API_KEY:-apikey} with your actual API key.
Claude Code
Applicable version: Claude Code 0.2.34 and later.
Use the command line method for quick connection of a standalone machine. Use a project-level configuration file for team sharing. Use the user-level scope when all projects need access.
Quick add from the command line
Run the following command in the terminal to register the MCP server in one line:
claude mcp add --transport http mem0 http://<host>:<port>/mcp \ --header "Authorization: Token <API_KEY>"Verify that the server is added:
claude mcp listAfter you enter the Claude Code interactive interface, type
/mcpto view the connection status.
Project-level configuration file (recommended for teams)
Create the
.mcp.jsonfile at the project root and commit it to Git to enable team sharing:{ "mcpServers": { "mem0": { "type": "http", "url": "http://<host>:<port>/mcp", "headers": { "Authorization": "Token ${MEM0_API_KEY:-apikey}" } } } }Set the environment variable in the terminal:
export MEM0_API_KEY="<API_KEY>"
User-level configuration (applies across projects)
To allow all projects to access PolarDB memory management, use the user-level scope:
claude mcp add --transport http mem0 --scope user \
http://<host>:<port>/mcp \
--header "Authorization: Token <API_KEY>"Codex
The command line method cannot specify the authentication header, and a complete connection still requires editing the configuration file, so using the configuration file method directly is recommended.
Quick add from the command line
Store the complete authentication header value in an environment variable.
export MEM0_AUTH_HEADER="Token <API_KEY>"Add the MCP server and verify.
codex mcp add mem0 --url http://<host>:<port>/mcp codex mcp list
The command line method cannot specify the authentication header directly. After adding the server, follow the Connect through a configuration file method below, and in ~/.codex/config.toml add env_http_headers for this server.
Connect through a configuration file
Codex configures MCP servers in TOML format and supports two scopes:
Scope | Path | Description |
User level |
| Applies to all projects. |
Project level |
| Loaded only in trusted project directories. |
Store the complete authentication header value in an environment variable.
export MEM0_AUTH_HEADER="Token <API_KEY>"Edit
~/.codex/config.tomland add the following configuration.[mcp_servers.mem0] url = "http://<host>:<port>/mcp" env_http_headers = { Authorization = "MEM0_AUTH_HEADER" }Verify that the server is added.
codex mcp list
MEM0_AUTH_HEADERstores the complete authentication header value and must include theTokenprefix. Entering only the API key causes a 401 error.Use
env_http_headersinstead ofhttp_headersto avoid hardcoding the key in the configuration file.Remove a configured server:
codex mcp remove mem0.
OpenCode
OpenCode supports configuration files at two scopes. The project-level configuration takes precedence over the user-level configuration. Use the project-level configuration for team sharing and the user-level configuration for reuse across projects.
Scope | Path | Recommended for Git commit |
User level (global) |
| — |
Project level |
| Yes |
Add the following content under the
mcpfield of the configuration file:{ "$schema": "https://opencode.ai/config.json", "mcp": { "mem0": { "type": "remote", "url": "http://<host>:<port>/mcp", "enabled": true, "headers": { "Authorization": "Token {env:MEM0_API_KEY}" } } } }Verify that the server is added:
opencode mcp list
You must set
"type": "remote"for a remote server. Otherwise, OpenCode starts it as a local process.The top-level key that OpenCode uses is
mcp, which differs from themcpServersformat of Qoder and Claude Code. Do not mix them.The environment variable syntax of OpenCode is
{env:VAR}, which differs from the${VAR}syntax of Qoder and Claude Code.Set
enabledtofalseto temporarily disable the server without deleting the configuration.
Hermes Agent
Applicable version: Hermes Agent 0.17 and later (built-in MCP client, depends on mcp==1.26.0).
The interactive add automatically saves the API key, verifies the connection, and writes the configuration, so it is recommended. If you need to manage the configuration content yourself, use the YAML configuration file method instead.
Interactive add
Run the following command to complete the add through an interactive guide:
hermes mcp add mem0 --url "http://<host>:<port>/mcp"The command automatically completes the following operations:
Prompts you to enter the API key and saves it to
~/.hermes/.env.Connects to the PolarDB memory management server to verify the connection and discovers the available MCP tools.
Writes the configuration to
~/.hermes/config.yaml.
Start Hermes to use it:
hermes
YAML configuration file
Store the API key.
echo 'MEM0_API_KEY=<API_KEY>' >> ~/.hermes/.envEdit
~/.hermes/config.yaml.mcp_servers: mem0: url: "http://<host>:<port>/mcp" headers: Authorization: "Token ${MEM0_API_KEY}" timeout: 180 connect_timeout: 60Verify the connection.
hermes mcp test mem0
Hermes environment variables support only the ${VAR_NAME} syntax. The default value syntax ${VAR:-default} is not supported.
Management commands
Command | Description |
| View the configured MCP servers. |
| Test the connection status of PolarDB memory management. |
| Remove the configured PolarDB memory management MCP server. |
(Optional) Advanced configuration
To customize the timeout, keepalive, tool filtering, or sampling capabilities, refer to the following configuration. The tools.include field takes MCP tool names. For the values, see Common MCP tools reference.
mcp_servers:
mem0:
url: "http://<host>:<port>/mcp"
headers:
Authorization: "Token ${MEM0_API_KEY}"
timeout: 180
connect_timeout: 60
keepalive_interval: 60 # Keepalive interval, in seconds
tools:
include: ["add_memory_v1_memories_post", "search_memories_v2_memories_search_post", "get_all_memories_v2_memories_post"]
sampling:
enabled: true
model: "gpt-4"
max_tokens_cap: 4096OpenClaw
Edit
~/.openclaw/openclaw.jsonand add the following content undermcp.servers:{ "mcp": { "servers": { "mem0": { "url": "http://<host>:<port>/mcp", "headers": { "Authorization": "Token <API_KEY>" } } } } }Verify that the server is added:
openclaw mcp statusYou can also use
openclaw mcp probe mem0to open a live connection and list the available tools.
Do not set
auth: "oauth". When it is enabled, the staticAuthorizationheader is ignored.The key that OpenClaw uses is
mcp.servers, which differs from both themcpServersformat of Qoder and Claude Code and themcpformat of OpenCode. Do not mix them.
Qoder Cloud Agents
The mcp_servers[] of Qoder Cloud Agents supports only the name, type, and url fields. Custom request headers are not supported, and authentication is injected by the platform from the Vault, so you must complete the configuration through the API. The $QODER_PAT in the following commands is your Qoder personal access token.
Connect through the API
The first three steps are one-time configuration. The Vault and the agent can be reused by multiple sessions. After that, you only need to run step 4 each time you start a session.
Create a Vault.
curl -X POST https://api.qoder.com/api/v1/cloud/vaults \ -H "Authorization: Bearer $QODER_PAT" \ -H "Content-Type: application/json" \ -d '{"display_name": "PolarDB Memory"}'Append a credential to the Vault. The
mcp_server_urlmust exactly match themcp_servers[].urlin the next step (including the trailing slash). The platform matches credentials by this URL exactly.curl -X POST https://api.qoder.com/api/v1/cloud/vaults/<vault_id>/credentials \ -H "Authorization: Bearer $QODER_PAT" \ -H "Content-Type: application/json" \ -d '{ "auth": { "type": "static_bearer", "mcp_server_url": "http://<host>:<port>/mcp", "token": "<API_KEY>" } }'Create an agent and declare the MCP endpoint in
mcp_servers.curl -X POST https://api.qoder.com/api/v1/cloud/agents \ -H "Authorization: Bearer $QODER_PAT" \ -H "Content-Type: application/json" \ -d '{ "name": "mem0-agent", "model": "ultimate", "system": "You can use the mem0 tool to read and write long-term memories. Retrieve relevant memories before answering.", "tools": [{"type": "agent_toolset_20260401", "enabled_tools": ["Bash", "Read", "Write"]}], "mcp_servers": [{"name": "mem0", "type": "url", "url": "http://<host>:<port>/mcp"}] }'When creating a session, associate the Vault through
vault_ids. The platform injects the credential automatically.curl -X POST https://api.qoder.com/api/v1/cloud/sessions \ -H "Authorization: Bearer $QODER_PAT" \ -H "Content-Type: application/json" \ -d '{ "agent": "<agent_id>", "vault_ids": ["<vault_id>"] }'
Apply the configuration and verify the connection
The configuration written by all three methods is loaded when the agent session starts. After the connection is complete, apply the configuration first and then verify the connection result.
Restart the corresponding agent or start a new session. For OpenClaw, run
openclaw gateway restart. A running graphical agent must be exited completely and then started again.If you connected through Method 1, Method 2, or a manual CLI installation, run the following command to view the connection status. In the output,
connected,hooks_installed, andskill_installedall showingtruemeans the connection succeeded.polarmemory status --agent <agent> --jsonIf you connected through Method 3, run the verification command given in the tab of your agent and confirm that the MCP server is registered and connected normally.
For Codex, you must also confirm that in ~/.codex/config.toml the [features] section has hooks = true set. Otherwise, memories are not recalled or saved automatically.
Memory isolation
Memories belong to a user_id. When multiple people share the same PolarDB memory management instance, you can specify different user_id values to isolate memories. How to specify it for each connection path is as follows:
One-click installation script and the
polarmemory setupcommand: append--user-id <id>(-UserId <id>in Windows PowerShell). The default value isdefault.Python MCP SDK sample script: pass
--user-id my_agent_001on the command line, or specify it through theuser_idparameter in the code.Calling the v2 API directly:
user_idmust be placed inside thefiltersobject.
Usage examples
Whichever method you use, you can start chatting directly after the connection is complete. An agent connected through Method 1 or Method 2 automatically recalls and saves memories based on the conversation. You can also explicitly ask it to read or write memories:
> Remember that my production database is PolarDB PostgreSQL 16, deployed in the Beijing region.
> Search my memories about database deployment.
> List all my memories.If no memory recall or saving appears in the conversation, first follow Apply the configuration and verify the connection to confirm that all three status fields are true, and then follow FAQ to troubleshoot.
Common MCP tools reference
After the connection is set up, the agent automatically selects the appropriate tool based on the conversation, so you usually do not need to remember the tool names. The following tool list is mainly for developers to reference when building custom agents.
Tool name | Description |
| Add a memory. |
| Search memories. |
| Retrieve all memories. |
| Delete a memory. |
| Merge memories. |
| Extract a user profile. |
When calling a tool of the v2 API, filters is a required field and user_id must be placed inside the filters object. For parameter descriptions, you can visit http://<host>:<port>/docs to view the real-time updated API documentation.
Connect through the Python MCP SDK (advanced usage)
To fine-tune the MCP connection and tool calls in a custom agent, you can use the Python MCP SDK. The run example and code integration example below are both based on the sample script mcp_client_example.py. The add_memory, search_memory, and get_all_memories in the script are Python function names wrapped by the script, and are not the same set of names as the MCP tool names in Common MCP tools reference. The two cannot be used interchangeably.
Install dependencies
pip install "mcp>=1.0" httpxRun the example
Set the API key and run the sample script:
export MEM0_API_KEY="<API_KEY>"
python mcp_client_example.py
python mcp_client_example.py --url http://<host>:<port>/mcp
python mcp_client_example.py --user-id my_agent_001Code integration example
The following example shows how to call the add_memory and search_memory functions wrapped by the sample script in a custom agent:
import asyncio
from mcp_client_example import add_memory, search_memory, get_all_memories
async def main():
user_id = "my_agent_001"
await add_memory(
user_id=user_id,
messages=[
{"role": "user", "content": "My project uses PolarDB."},
{"role": "assistant", "content": "OK, recorded."}
]
)
results = await search_memory(user_id=user_id, query="database")
print(results)
asyncio.run(main())FAQ
How do I confirm that the connection succeeded?
See Apply the configuration and verify the connection for the determination method: the connection succeeds when all three status fields connected, hooks_installed, and skill_installed show true.
How do I uninstall?
Run polarmemory uninstall --agent <agent> first, and then run npm uninstall -g @aliyunpolar/polarmemory. Reversing the order leaves stale hook entries in the agent configuration.
What do I do if the one-click installation script fails?
Troubleshoot in the following order:
Confirm that you can access the script URL:
curl -I https://cdn.jsdelivr.net/npm/@aliyunpolar/polarmemory/bootstrap/install.sh. If your network restricts access, use Install the CLI manually (when the script is unavailable) instead.Confirm that the Node.js version is 20 or later:
node -v. The script does not install Node.js automatically.Confirm that you passed
--base-url. This parameter is required.
What do I do if MCP tools are not visible after configuration?
Troubleshoot in the following order:
Confirm that the
MEM0_API_KEYenvironment variable is set correctly.Test the network connectivity from the client to the endpoint of PolarDB memory management, and confirm that the IP address of the client is added to the application whitelist.
Check the connection status by client type:
Claude Code: type
/mcpin the interactive interface.Qoder, QoderWork, and QwenWork: check the connection status of the entry in the MCP server list.
Codex: run
codex mcp list.OpenCode: run
opencode mcp list.Hermes Agent: run
hermes mcp test mem0.OpenClaw: run
openclaw mcp status.
What do I do if memories are not automatically recalled or saved after the connection?
Troubleshoot in the following order:
Restart the agent or start a new session as described in Apply the configuration and verify the connection, and confirm that all three status fields show
true.Run
polarmemory setup --agent <agent>again to repair the configuration. You do not need to pass the API key and endpoint again.For Codex, you must also confirm that in
~/.codex/config.tomlthe[features]section hashooks = trueset. Otherwise, memories are not recalled or saved automatically.
What do I do if the request returns 401 Unauthorized?
The authentication header format is Token <API_KEY> or Bearer <API_KEY>. The two are equivalent. Confirm that the API key is correct and has not expired, and that there is exactly one space between Token/Bearer and the key.
What do I do if a tool call reports filters is a required property?
The v2 API requires the filters field (see Common MCP tools reference for the constraints), and user_id must be placed inside the filters object. Example:
{
"query": "search content",
"filters": {"user_id": "your_user_id"}
}What do I do if the Python SDK occasionally returns 400 errors?
In a multi-worker deployment on the server side, a session cleanup request may reach a different worker. The tool call itself has already succeeded. The sample script uses the except* syntax of Python to ignore such errors safely, which does not affect the actual results of memory storage and retrieval.