Cross-Application AI Memory: Tablestore OpenMemory MCP
Mem0 is a memory layer for AI agents that enables self-improving, personalized AI experiences across applications. Table Store Openmemory MCP builds on Mem0, using Table Store as a stable, scalable memory center to create a persistent memory system for AI applications.
Features
Tablestore Openmemory MCP includes four MCP tools:
-
add_memories: Adds, modifies, and deletes user memories.
-
search_memories: Searches user memories.
-
list_memories: Lists all user memories.
-
delete_all_memories: Deletes all user memories.
Prerequisites
-
Create an AccessKey pair for your Alibaba Cloud account or a RAM user with Tablestore permissions.
Deploy and connect MCP service
Tablestore Openmemory MCP supports two modes: Server-Side Encryption (SSE) and Standard Input/Output (stdio).
SSE mode
To deploy the Tablestore Openmemory MCP service in SSE mode, you need to prepare a server to run MCP. You can use an Alibaba Cloud ECS instance. To ensure Python dependencies download successfully, we recommend selecting the China (Hong Kong) region.
The ECS instance used in this topic runs the Alibaba Cloud Linux 3.2104 LTS 64-bit operating system. The default Python 3 version is 3.6.8, which must be upgraded.
1. Deploy the MCP service
You can use the uv tool to run the service directly without installing MCP.
-
Install the uv package manager.
pip3 install uv -
Configure the environment variables required to run the service.
echo "export OPENAI_API_KEY='sk-7*******************************'" >> ~/.bashrc echo "export OPENAI_BASE_URL='https://dashscope.aliyuncs.com/compatible-mode/v1'" >> ~/.bashrc echo "export TABLESTORE_ENDPOINT='https://k01r********.cn-hangzhou.ots.aliyuncs.com'" >> ~/.bashrc echo "export TABLESTORE_INSTANCE_NAME='k01r********'" >> ~/.bashrc echo "export TABLESTORE_ACCESS_KEY_ID='LTAI********************'" >> ~/.bashrc echo "export TABLESTORE_ACCESS_KEY_SECRET='Jy3H**************************'" >> ~/.bashrcAfter the configuration is complete, run the
source ~/.bashrccommand to apply the environment variables. The following table describes how to get the values for these variables.Parameter
Description
OPENAI_API_KEY
Go to API Key Management to view and copy your API key. If you do not have an API key, click Create API Key to create one.
OPENAI_BASE_URL
https://dashscope.aliyuncs.com/compatible-mode/v1TABLESTORE_ENDPOINT
Go to the Tablestore console. In the instance list, click an instance alias to go to the Instance Management page. Then, find and copy the instance name and instance endpoint. If you use an ECS instance, select an endpoint based on the region:
-
If your ECS instance and Tablestore instance are in the same region, select a public endpoint or a VPC endpoint.
-
If your ECS instance and Tablestore instance are in different regions, select a public endpoint.
ImportantBy default, new Tablestore instances do not allow public access. To use a public endpoint, go to the Network Management tab on the Instance Management page in the Tablestore console. Select Public for Allowed Network Types and click Set to save your changes.
TABLESTORE_INSTANCE_NAME
TABLESTORE_ACCESS_KEY_ID
The AccessKey ID of your Alibaba Cloud account or RAM user.
TABLESTORE_ACCESS_KEY_SECRET
The AccessKey Secret of your Alibaba Cloud account or RAM user.
-
-
Start the MCP service.
uvx tablestore-openmemory-mcp --transport=sseWhen you run the service for the first time, it downloads its dependencies. This process may take some time. If the download fails due to network issues, run the command again. After the service starts, the MCP service automatically creates the required data tables and Search Indexes in your Tablestore instance. The following log output indicates that the service has started successfully.
INFO: Started server process [43283] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:8765 (Press CTRL+C to quit)
2. Connect to the MCP service
Connection URL format: http://server_ip:port/mcp/client_name/sse/user_id
-
server_ip: The IP address of the server running the MCP service. -
port: The port on which the MCP service runs. The default port is 8765.ImportantTo access the MCP service on an ECS instance, you must add a security group rule to the inbound rules of the instance's security group. This rule must allow TCP traffic on the port used by the MCP service, which is 8765 by default.
-
client_nameanduser_id: Custom parameters that isolate memories for different users.
Cline
Fill in the Remote Servers information as shown in the following example, or click Edit Configuration and add the MCP service configuration to the cline_mcp_settings.json configuration file.
After the configuration is complete, enable the MCP service in the Cline conversation window.
After you enable the service, the switch next to the tablestore-openmemory-mcp entry in the MCP Servers panel turns green and a green status indicator appears, indicating that the MCP service is connected. You can also click the + button in the toolbar at the bottom of the conversation window to quickly add an MCP service.
Cherry Studio
In Cherry Studio, navigate to , click , and then fill in the following fields:
-
Name: A custom name for the MCP service.
-
Type: Select Server-Sent Events (sse).
-
URL: Enter the URL in the format described earlier.
After the MCP server is added, enable the MCP service in the conversation window.
Click the MCP icon in the toolbar at the bottom of the conversation window and select Tablestore OpenMemory Stdio from the server list.
Stdio mode
This section explains how to deploy the Tablestore Openmemory MCP service in Cline and Cherry Studio.
Cline
In Cline, configure the Tablestore Openmemory MCP service in the cline_mcp_settings.json configuration file. The following is an example configuration:
{
"mcpServers": {
"tablestore-openmemory-mcp": {
"autoApprove": [
"add_memories",
"list_memories",
"delete_all_memories",
"search_memories"
],
"disabled": false,
"timeout": 60,
"type": "stdio",
"command": "uvx",
"args": [
"tablestore-openmemory-mcp",
"--transport",
"stdio"
],
"env": {
"OPENAI_API_KEY": "sk-7*******************************",
"OPENAI_BASE_URL": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"TABLESTORE_ENDPOINT": "https://k01r********.cn-hangzhou.ots.aliyuncs.com",
"TABLESTORE_INSTANCE_NAME": "k01r********",
"TABLESTORE_ACCESS_KEY_ID": "LTAI********************",
"TABLESTORE_ACCESS_KEY_SECRET": "Jy3H**************************"
}
}
}
}
env environment variable configuration:
|
Parameter |
Description |
|
OPENAI_API_KEY |
On the API Key Management page, view and copy your API key. If you do not have an API key, click Create API Key to create one. |
|
OPENAI_BASE_URL |
|
|
TABLESTORE_ENDPOINT |
In the Tablestore console, go to the instance list and click an instance name to open the instance management page. From there, view and copy the instance name and instance endpoint. If you use an ECS instance, select an endpoint based on the region:
Important
By default, new Tablestore instances do not allow public network access. To use a public endpoint, go to the network management tab on the instance management page in the Tablestore console. For Allowed Network Types, select Public and then click Set. |
|
TABLESTORE_INSTANCE_NAME |
|
|
TABLESTORE_ACCESS_KEY_ID |
The AccessKey ID of your Alibaba Cloud account or RAM user. |
|
TABLESTORE_ACCESS_KEY_SECRET |
The AccessKey Secret of your Alibaba Cloud account or RAM user. |
After the configuration is complete, enable the MCP service in the Cline conversation window.
Click the + button in the toolbar at the bottom of the conversation window to open the MCP Servers panel. Ensure the switch for the tablestore-openmemory-mcp entry is enabled. A green status indicator confirms a successful connection.
Cherry Studio
In Cherry Studio, navigate to , click , and then fill in the following fields:
-
Name: The name of the MCP service. You can enter a custom name.
-
Type: Select standard input/output (stdio).
-
Command: The startup command. Enter
uvx. -
Arguments: Enter the following startup arguments.
tablestore-openmemory-mcp --transport stdio -
Environment Variables: Enter the environment variables required for startup, as shown in the following example.
OPENAI_API_KEY=sk-7******************************* OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1 TABLESTORE_ENDPOINT=https://k01r********.cn-hangzhou.ots.aliyuncs.com TABLESTORE_INSTANCE_NAME=k01r******** TABLESTORE_ACCESS_KEY_ID=LTAI******************** TABLESTORE_ACCESS_KEY_SECRET=Jy3H**************************The following table explains how to get the values for these environment variables.
Parameter
Description
OPENAI_API_KEY
On the API Key Management page, view and copy your API key. If you do not have an API key, click Create API Key to create one.
OPENAI_BASE_URL
https://dashscope.aliyuncs.com/compatible-mode/v1TABLESTORE_ENDPOINT
In the Tablestore console, go to the instance list and click an instance name to open the instance management page. From there, view and copy the instance name and instance endpoint. If you use an ECS instance, select an endpoint based on the region:
-
If your ECS instance and Tablestore instance are in the same region, select a public endpoint or a VPC endpoint.
-
If your ECS instance and Tablestore instance are in different regions, select a public endpoint.
ImportantBy default, new Tablestore instances do not allow public network access. To use a public endpoint, go to the network management tab on the instance management page in the Tablestore console. For Allowed Network Types, select Public and then click Set.
TABLESTORE_INSTANCE_NAME
TABLESTORE_ACCESS_KEY_ID
The AccessKey ID of your Alibaba Cloud account or RAM user.
TABLESTORE_ACCESS_KEY_SECRET
The AccessKey Secret of your Alibaba Cloud account or RAM user.
-
After you add the MCP server, enable the MCP service in the conversation window.
Click the MCP tool button (green square bracket icon) in the toolbar at the bottom of the conversation window and select Tablestore OpenMemory Stdio from the server selection panel.
Verify persistent memory
Tablestore Openmemory MCP provides persistent memory by storing it in Tablestore. During interactions with your AI application, you can add, retrieve, update, and delete this memory. This section demonstrates these operations using coding preferences as an example.
-
Add memory: Start a conversation in Cline and instruct the model to use a tool to remember your coding preferences.
Use a tool to remember the following: I am a programmer and I need your help with coding. I am proficient in Java and Python. I prefer to use PascalCase for function and class names, camelCase for variables, and all uppercase letters with underscores for constants.The large model calls the
add_memoriestool to store the memory in themem0table in Tablestore.You can view the memory data in the Tablestore console.
On the data management tab of the mem0 table, the memory data is stored as rows. These rows include columns such as document_id (primary key), tenant_id (primary key), embedding, payload, payload_source, and text. The default value of the tenant_id column is
__default, and the text column stores your coding preferences. -
Retrieve memory: To ensure the model retrieves information from its persistent memory instead of the current conversation context, start a new session before asking the following question in Cline.
What is my preferred variable naming convention?The large model calls the
search_memoriestool to retrieve the relevant memory from Tablestore and returns an accurate answer.The model returns the result and summarizes your preferred naming conventions: use camelCase for variables, such as
myVariableName; all uppercase with underscores for constants, such asMY_CONSTANT_VALUE; and PascalCase for functions and class names, such asMyClassName. -
Update memory: Start a conversation in Cline and instruct the model to use a tool to update your coding preferences.
Please remember that I now prefer to use lowercase letters with underscores for variable names.The large model calls the
add_memoriestool to update the relevant memory stored in Tablestore.You can view the updated memory data in the Tablestore console.
On the data management tab of the mem0 table, the text column now contains "The user now prefers to use lowercase letters with underscores for variable names," indicating the memory was successfully updated.
Cross-platform memory verification
Storing memory in Tablestore decouples it from applications and models, allowing you to access the same memory from different applications or models. This section uses Cline and Cherry Studio as an example. You will add personal information in Cline, and then generate a personalized travel plan in a different AI client, Cherry Studio.
-
Add personal information: Start a conversation in Cline and instruct the large language model to use a tool to save your personal information, such as your address and hobbies.
Remember the following information: I live in China (Hangzhou), I like spicy food, and I enjoy mystery novels and movies. I always like to try new things, even though they often disappoint me.The large language model calls the add_memories tool to store the memory in the mem0 data table in Tablestore.
You can view the memory data in the Tablestore console.
In the Tablestore console, on the data management tab for the mem0 data table, you can see the stored memory. The table includes the primary key columns
document_idandtenant_id, and the attribute columnsembedding,payload,payload_source, andtext. The default value oftenant_idis__default. -
Access memory across platforms: Start a conversation in Cherry Studio and instruct the model to create a personalized weekend plan based on your stored memory.
Based on my memory, help me create a weekend outing plan.The large language model calls the search_memories tool to retrieve the relevant memory from Tablestore and generates a plan based on that memory.
In Cherry Studio, the qwen-max model processes your request. The status of the search_memories tool call is completed, and the resulting plan provides a detailed schedule for the morning, noon, afternoon, and evening.
Deploy to production
When using Tablestore Openmemory MCP in a production environment, consider the following factors to ensure service stability, security, and scalability.
Deployment architecture optimization
Deploy the MCP service across multiple ECS instances and use Server Load Balancer (SLB) to balance the load between them. Alternatively, you can replace a single-ECS deployment with Container Service for Kubernetes (ACK) or Compute Nest. This approach provides auto-scaling and dynamic resource adjustment based on load, enabling you to handle traffic spikes and reduce costs during idle periods.
Security hardening
To secure production data, use RAM users and apply the principle of least privilege, granting them access only to specific Tablestore instances. In addition, restrict access by configuring IP whitelists in security groups, or deploy an API Gateway for centralized authentication, throttling, and logging.
Operations and monitoring
To ensure service health, use Cloud Monitor to set up monitoring and alerts for key metrics, such as CPU and memory, on your ECS instances or containers. Centralize your runtime logs in Log Service (SLS) for quick troubleshooting, performance analysis, and business insight.
Resource cleanup
To avoid unnecessary charges, clean up the resources you created in this tutorial:
-
Release the ECS instance: Go to the ECS console, find the target instance, and click .
-
Delete the Tablestore data table: In the Tablestore console, click the target instance alias on the Instance List page. On the Instance Management page, locate the target data table. First, click Index Management to the right of the data table to delete its search index. Then, click .
-
Release the Tablestore instance: Go to the Tablestore console and find the target instance in the Instance List. In the Actions column, click Release or .