Skip to content

Use PrefsDB from an AI Agent

AI coding assistants such as Claude Code, Cursor and Claude Desktop can use PrefsDB to remember things between sessions, such as what they did last time, a to-do list or notes. They connect through the PrefsDB MCP server, a small program the assistant starts for itself.

Set it up

  1. Add the server to your assistant. For Claude Code:

    claude mcp add prefsdb -- npx -y @prefsdb/mcp
    

    For other assistants, add an MCP server with the command npx and the arguments -y @prefsdb/mcp. You need Node.js 20 or newer.

  2. Ask the assistant to log in to PrefsDB. It shows you a code.

  3. Open prefsdb.com/activate, sign in, type the code, and choose what the assistant's key may do (see Connect an AI Agent). The assistant is then connected. Its key stays on your computer, readable only by you.

Already have an API key from your dashboard, for example for a CI job? Set it as PREFSDB_KEY in the assistant's environment instead of logging in.

Make the assistant use it

Assistants use tools when they're told to. Add a line like this to your project's CLAUDE.md (or your assistant's instructions file):

At the start of a task, read the PrefsDB key last_task. At the end, save a one-line summary of what you did and what's next under last_task.

What the assistant can do

Tool What it does
prefsdb_get, prefsdb_set, prefsdb_delete Read, save or delete a value under a key.
prefsdb_list_keys See what's stored.
prefsdb_append, prefsdb_read_list Keep a list, such as findings or a log.
prefsdb_status Check the connection and what the key may do.
prefsdb_login_start, prefsdb_login_check Log in.

Everything goes into one project, agent-state by default, so the assistant can't reach the rest of your data. You can see it in the dashboard under My Data.

Safety

  • The assistant can delete one value at a time, never everything. Most assistants ask you before using a tool marked as destructive.
  • Values that look like passwords or API keys are refused, so a careless assistant can't copy credentials into PrefsDB.
  • The assistant is told that stored values are data, not instructions to follow.
  • Revoke the assistant's key in API Keys whenever you like.

From a terminal

The same package is a small command-line tool:

npx @prefsdb/mcp login          # connect, approving a code in your dashboard
npx @prefsdb/mcp set note "remember this"
npx @prefsdb/mcp get note
npx @prefsdb/mcp ls