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

if [ ! -f .pamie.env ]; then
  umask 077
  printf "PAMIE_TOKEN=%s\nPAMIE_TOKEN_ID=local\nPAMIE_TOKEN_SCOPES=all\n" \
    "$(openssl rand -hex 32)" > .pamie.env
fi

set -a
. ./.pamie.env
set +a
printf "MCP endpoint: http://127.0.0.1:8080/mcp\nBearer token: %s\n" "$PAMIE_TOKEN"

pamie --addr 127.0.0.1:8080 --data-dir ./data

Or run the published Docker image:

docker volume create pamie-data

if [ ! -f .pamie.env ]; then
  umask 077
  printf "PAMIE_TOKEN=%s\nPAMIE_TOKEN_ID=local\nPAMIE_TOKEN_SCOPES=all\n" \
    "$(openssl rand -hex 32)" > .pamie.env
fi

set -a
. ./.pamie.env
set +a
printf "MCP endpoint: http://127.0.0.1:8080/mcp\nBearer token: %s\n" "$PAMIE_TOKEN"

docker run --rm \
  --name pamie \
  -p 127.0.0.1:8080:8080 \
  -v pamie-data:/data \
  --env-file .pamie.env \
  kurocho/pamie:latest

Keep `.pamie.env` local and out of version control. 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:8080/health
curl http://127.0.0.1:8080/ready

3. Connect the MCP client

Configure the agent or MCP client to call `http://127.0.0.1:8080/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:8080/mcp
Authorization header: Bearer <PAMIE_TOKEN from .pamie.env>
curl -i -X POST http://127.0.0.1:8080/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.