How to Add Memory to Cline
Cline is an incredible autonomous coding agent for VS Code, but it starts fresh every time you open a new task. This guide shows you how to give Cline persistent, structured memory using Memstate MCP — so it remembers your tech stack, API keys, and project context without you having to re-explain everything.
What You Need
- VS Code with the Cline extension installed
- Node.js 18+ installed on your machine
- A free Memstate AI account (no credit card required)
Step-by-Step Setup
1Get your Memstate API Key
Sign up at memstate.ai for free. Go to Dashboard → API Keys and create a new key. Copy it to your clipboard.
2Open Cline MCP Settings
In VS Code, open the Cline sidebar. Click the MCP Servers icon (it looks like a little plug) at the top, then click Edit MCP Settings. This will open your cline_mcp_settings.json file.
3Add the Memstate Server
Add the Memstate server configuration to the JSON file, pasting your API key where indicated:
{
"mcpServers": {
"memstate": {
"command": "npx",
"args": ["-y", "@memstate/mcp"],
"env": {
"MEMSTATE_API_KEY": "your-api-key-here"
}
}
}
}4Verify the Connection
Save the file. In the Cline sidebar, you should now see a green dot next to the Memstate server indicating it is connected. You can test it by asking Cline:
Please search my memory for the current database engine.
Crucial: Tell Cline When to Use Memory
Just giving Cline the MCP tools is not enough; you need to tell it when to use them. The best way to do this is by creating a .clinerules file in your project root, or running our init command to generate it for you:
npx @memstate/mcp init
This ensures Cline automatically checks memory before starting a task, and saves a summary after completing one.
Related Guides
Stop repeating yourself to Cline
Get structured, versioned memory that never gets confused.