Implementation guide

How to add long-term memory to MCP agents

Long-term memory for agents works best as a service with clear storage, search, authorization, and backup boundaries. Pamie gives MCP clients a protected memory endpoint backed by local SQLite.

How-to MCP endpoint SQLite-backed memory

1. Install and run Pamie

Use Homebrew for a local binary:

brew install kurocho/tap/pamie
pamie start
pamie status

Or run the published Docker image:

docker volume create pamie-data
export PAMIE_TOKEN="$(openssl rand -hex 32)"

docker run --rm \
  --name pamie \
  -p 127.0.0.1:17683:8080 \
  -v pamie-data:/data \
  -e PAMIE_TOKEN="$PAMIE_TOKEN" \
  -e PAMIE_TOKEN_ID=local \
  -e PAMIE_TOKEN_SCOPES=all \
  kurocho/pamie:latest

Keep tokens private. Use a service manager or secret store for production deployments.

2. Verify the server

Keep the server bound to localhost while testing. Check liveness and readiness before connecting an agent.

curl http://127.0.0.1:17683/health
curl http://127.0.0.1:17683/ready

3. Connect the MCP client

Configure the agent or MCP client to call `http://127.0.0.1:17683/mcp` with the Bearer token printed by the quickstart. Pamie exposes memory tools for saving, searching, updating, pinning, deleting, and inspecting recent memories.

MCP endpoint: http://127.0.0.1:17683/mcp
Authorization header: Bearer <token printed by pamie>

Create one token per client so access can be rotated independently:

pamie token create --id copilot --scopes memory:read,memory:write,stats:read
pamie token create --id codex --scopes memory:read,memory:write,stats:read
pamie token create --id claude --scopes memory:read,memory:write,stats:read

For GitHub Copilot in VS Code, add .vscode/mcp.json:

{
  "inputs": [
    {
      "type": "promptString",
      "id": "pamie-token",
      "description": "Pamie Bearer token",
      "password": true
    }
  ],
  "servers": {
    "pamie": {
      "type": "http",
      "url": "http://127.0.0.1:17683/mcp",
      "headers": {
        "Authorization": "Bearer ${input:pamie-token}"
      }
    }
  }
}

For Codex CLI or the Codex IDE extension:

export PAMIE_MCP_TOKEN="<token printed by pamie>"
codex mcp add pamie \
  --url http://127.0.0.1:17683/mcp \
  --bearer-token-env-var PAMIE_MCP_TOKEN

For Claude Code:

export PAMIE_MCP_TOKEN="<token printed by pamie>"
claude mcp add --transport http pamie http://127.0.0.1:17683/mcp \
  --header "Authorization: Bearer $PAMIE_MCP_TOKEN"

Claude.ai custom connectors need a public HTTPS endpoint because they connect from Anthropic infrastructure, not from your local machine.

curl -i -X POST http://127.0.0.1:17683/mcp \
  -H "Authorization: Bearer $PAMIE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

4. Decide what memory should retain

Start with durable project facts, agent preferences, and decisions that are useful across sessions. Avoid storing secrets. Stored memories are untrusted input and should be treated as context, not as instructions that bypass review.