MongoDB

If your team already runs MongoDB, Recall can keep its memory there, on Atlas or your own servers. Every Recall capability works on it: typed facts, corrections, history, keyword search, cached reads, and agent resume, with agent writes committed in one transaction with their lease. No Atlas Search index is needed.

Before you start

Run the memory server on MongoDB

  1. Start MongoDB as a single-node replica set, if you are not using Atlas:

    docker run -d --name mongo -p 27017:27017 mongo:8.0 --replSet rs0 --bind_ip_all
    docker exec mongo mongosh --eval 'rs.initiate({_id:"rs0",members:[{_id:0,host:"localhost:27017"}]})'
  2. Add Recall to Claude Code as an MCP server:

    claude mcp add recall \
      -e RECALL_BACKEND=mongodb \
      -e MONGODB_URI='mongodb://localhost:27017/recall?directConnection=true' \
      -- recall mcp -write

    For Atlas, use the mongodb+srv:// connection string Atlas gives you; put the password in MONGODB_PASSWORD instead of the string if you prefer. Add -agent for the agent resume tools. Other MCP hosts take the same command and variables, or the flags recall -backend mongodb -url mongodb://... mcp -write.

  3. Restart Claude Code and ask it to remember something. The first write creates the collection.

recall setup and the Recall plugin set up a polign_db connection. With MongoDB, add the MCP server yourself as in step 2.

Use it from Go

import (
	"github.com/Polign/recall"
	"github.com/Polign/recall/backend/mongodb"
)

backend, err := mongodb.New(mongodb.Config{
	URL: os.Getenv("MONGODB_URI"),
})
defer backend.Close()
client, err := recall.NewClient(recall.Config{
	Backend:    backend,
	Collection: "team_memory",
	Registry:   recall.DefaultRegistry(),
	Embedder:   recall.LexicalEmbedder{},
})

mongodb.Config also takes a Database (default: the connection string's path, then recall) and a Client to share a *mongo.Client you already have. The package uses the official MongoDB Go driver, which a program pulls in only by importing it.

What gets stored

RecallMongoDB
A collectionA collection named rc_ and the collection's name, created on the first write with the first vector's size
An eventA document: the event ID as _id, the vector, the metadata as JSON so it reads back exactly as written, and its scalar fields as {k, v} pairs for filtering
IndexesA compound index on the metadata pairs, and a text index on the event text for keyword search
Bookkeepingrecall_collections maps each collection and counts its writes, which is what cached reads check; recall_leases holds agent leases

Metadata is filtered through the pairs rather than as document fields, so Recall's field names, which can contain dots, never turn into MongoDB paths.

Agent resume and fenced writes

Leases are documents in recall_leases, taken and renewed in one atomic update that judges expiry by the server's clock, so recall mcp -agent and Client.Resume work as they do on polign_db. On a replica set, each agent write commits in one transaction with a write to its lease document. A takeover that changes the lease conflicts with the in-flight write, so a process that stalled past its lease cannot land a late write over its successor's. See Resume for how actions and leases fit together.

Good to know

If something goes wrong

What you seeWhat to do
unknown backend "mongodb"Your recall is older than 0.21.0. Upgrade it.
server selection errorMongoDB is not reachable at that address. For a local single-node replica set, add directConnection=true to the connection string.
connection string must start with mongodb:// or mongodb+srv://Check MONGODB_URI.
holds 256-dimensional vectors, not 384The collection was created with another embedder. Use a new -collection when you change embedders.
lease_held on resumeAnother process holds the agent, or one died less than a lease time ago. Wait for the lease to expire.

Source & license

The MongoDB backend is part of Recall, open source under the Apache License 2.0, in github.com/Polign/recall. Bug reports and pull requests go there.