← All posts

Tutorial

How to give Claude Code and Codex persistent memory over MCP

Ten minutes of setup and your agents stop forgetting. Here's how to connect an MCP client to a shared memory server and put it to work.

By now you've probably felt the pain: your coding agent is great within a session and amnesiac across sessions. The fix is a persistent memory layer your agents can reach over the Model Context Protocol. This walkthrough uses Knownbase, a hosted MCP memory server, but the shape is the same for any MCP-compatible tool.

Step 1: Create a workspace and an API key

Sign up for a free workspace (no card required). Once you're in, open Settings → Workspace & MCP and generate an API key. It'll look like kb_.... Copy it now. For security the full key is shown only once.

A workspace is your memory boundary. Every note you store is scoped to it and isolated from every other tenant, so a personal project and a client project can each have their own key.

Step 2: Add the MCP server to your agent

Most MCP clients read a JSON config that maps a server name to a URL and headers. Point it at the Knownbase endpoint and pass your key as a bearer token:

{
  "mcpServers": {
    "knownbase": {
      "url": "https://knownbase.dev/mcp",
      "headers": {
        "Authorization": "Bearer kb_YOUR_KEY_HERE"
      }
    }
  }
}

Claude Code can add it from the command line instead of editing config by hand:

claude mcp add --transport http knownbase https://knownbase.dev/mcp \
  --header "Authorization: Bearer kb_YOUR_KEY_HERE"

Codex, Cursor, ChatGPT, and other clients take the same URL, key, and header. Drop them into wherever that client configures MCP servers. Restart the agent so it picks up the new server.

Step 3: Confirm the tools are live

After connecting, your agent should see a set of Knownbase tools. The ones you'll use most:

  • upsert_note: create or update a note (title, project, body, tags, status).
  • search_notes: full-text and semantic search across the workspace.
  • get_note / get_notes: fetch full content by id, singly or in batches.
  • list_projects, list_note_revisions, workspace_info: browse and audit.

Ask your agent to "list the projects in Knownbase." An empty result means it's connected and working; you just don't have any notes yet.

Step 4: Store something worth remembering

Now put it to use. At the end of a working session, ask the agent to save a handoff:

"Save a handoff note to Knownbase in project billing summarizing what we decided about the webhook retry logic and what to do next."

Behind the scenes the agent calls upsert_note with a title, the billing project, and a markdown body. The note is now durable: it survives this session ending. (Not sure what to put in a handoff? See Agent handoffs.)

Step 5: Recall it in the next session

Tomorrow, in a fresh session (even in a different agent), start with:

"Search Knownbase for what we decided about billing webhooks before we continue."

The agent calls search_notes, pulls the relevant note, and picks up with full context instead of re-deriving it. That's the whole loop: store as you go, recall on demand.

Tips for getting the most out of it

  • Use projects and statuses. Organizing notes into projects with active/todo/done/blocked statuses keeps search results sharp.
  • Link related notes. A [[Note title]] reference in a body becomes a real backlink, so a handoff can point at the decision it depends on.
  • Add it to your agent's instructions. A line like "save decisions and handoffs to Knownbase, and search it before starting" makes the habit automatic.
  • Share a workspace with teammates. On Team and Business plans, everyone's agents read and write the same memory.

Connect your agent in the next ten minutes

Create a free Knownbase workspace, generate a key, and give Claude Code, Codex, or any MCP client a memory that lasts. No card required.

Create free workspace