Memstate + Any MCP Client
Connect Memstate to any agent that supports the Model Context Protocol.
Memstate works with any MCP-compatible AI agent. If your agent isn't listed in our specific guides, follow these universal steps.
Looking for a specific agent?
We have dedicated guides for Claude, Cursor, Cline, Kilo Code, Windsurf, Gemini CLI, and GitHub Copilot.
Get Your API Key
Sign up for free — no credit card required.
Sign Up FreeAlready have an account? Go to API Keys →
Add the MCP Server
Add the following JSON to your agent's MCP configuration file. Replace YOUR_API_KEY_HERE with your key.
{
"mcpServers": {
"memstate": {
"command": "npx",
"args": ["-y", "@memstate/mcp"],
"env": {
"MEMSTATE_API_KEY": "YOUR_API_KEY_HERE"
}
}
}
}How to find your agent's MCP config file
Most MCP clients use a JSON file with an mcpServers key. Common locations:
Check your agent's documentation for the exact path. The JSON structure above works for all standard MCP clients.
Add Agent Instructions
Paste these instructions into your agent's memory or instruction file. This tells your agent to use Memstate automatically — loading context before tasks and saving summaries after.
# Memstate Memory
This project uses the Memstate MCP server for persistent, versioned memory.
## Before each task
Call `memstate_get(project_id="<your_project>")` to load existing context.
## After each task
Call `memstate_remember(project_id="<your_project>", content="<markdown summary>")` to save what was done.
## Project naming
Use a short snake_case name matching your repo or topic (e.g. `my_app`, `api_service`). Keep all related memories in the same project.
## Tools at a glance
- `memstate_remember` — save markdown summaries, notes, architecture docs
- `memstate_get` — retrieve all memories for a project
- `memstate_search` — semantic search across memories
- `memstate_set` — store a single key/value fact
- `memstate_history` — view version history of a memoryFor agents with a rules system (Cline, Kilo, Cursor), create a file called use-memstate-memory.md in your rules directory instead. For agents without rules, paste this at the top of your project's AGENTS.md or equivalent.
Test It — Onboard Your Project
Restart your agent, open a project, and paste this prompt. It will create your first memories and confirm everything is working.
Replace <your_project> with a short name for your repo (e.g. my_app).
I'm onboarding Memstate AI memory for this project. Please:
1. Analyze this codebase and write a concise high-level architecture overview in markdown — covering the main components, tech stack, key directories, and how data flows through the system.
2. Save it to Memstate using: memstate_remember(project_id="<your_project>", content="<the markdown>", source="agent")
3. Then call memstate_get(project_id="<your_project>") and show me the memory tree so I can confirm it worked.What to expect
Your agent will analyze the codebase, write an architecture overview, save it to Memstate, then display the memory tree. You'll see structured memories like project.my_app.architecture — this context is now available in every future session automatically.