Skip to content

Multi-Tenant Setup ​

Keep each customer's memory under a domain of their own. A domain is a label inside one account, not an access boundary: every key of the account can read and write every domain, so your server sets the domain from the signed-in customer.

How It Works ​

Mnemoverse writes and reads take a domain parameter. Use it to file memories by tenant:

python
from mnemoverse import MnemoClient

client = MnemoClient(api_key="mk_live_YOUR_KEY")

# Tenant A — support conversation
client.write(
    "Customer uses PostgreSQL, migrating from MySQL",
    concepts=["database", "migration"],
    domain="tenant:customer-a",
)

# Tenant B — a different customer, a different domain
client.write(
    "Customer prefers weekly reports via email",
    concepts=["reports", "email"],
    domain="tenant:customer-b",
)

Reading One Tenant's Domain ​

When reading, pass the domain. Results come from that domain, with two exceptions: a read that carries a fingerprint can return the matching memory from any domain, and expanded_concepts comes from the account's association graph, which has no domains, so it can name concepts learned in another tenant's domain. A read without a domain covers every domain in the account.

python
# A read in Customer A's domain
memories = client.read(
    "What database does this customer use?",
    domain="tenant:customer-a",
)
# → "Customer uses PostgreSQL, migrating from MySQL"

# A read in Customer B's domain does not return Customer A's memories
memories = client.read(
    "What database does this customer use?",
    domain="tenant:customer-b",
)
# → No results about PostgreSQL

Domain Naming Convention ​

We recommend this naming pattern:

ScopeDomain PatternExample
Per customertenant:{customer_id}tenant:acme-corp
Per useruser:{user_id}user:alice@acme.com
Per projectproject:{project_id}project:website-redesign
Shared knowledgeshared:{category}shared:product-docs
Agent-specificagent:{agent_name}agent:support-bot

Reading Several Domains ​

Domain names match exactly, byte for byte. There is no prefix or parent matching, so tenant:acme does not cover tenant:acme:notes. To read in priority order, make one call per domain:

python
# Check tenant-specific first, then shared knowledge
tenant_memories = client.read(query, domain="tenant:acme-corp")

if not tenant_memories.items:
    # Fall back to shared product knowledge
    shared_memories = client.read(query, domain="shared:product-docs")

To search several domains in one call, POST /memory/query takes a list of domains.

MCP Server With Tenants ​

When using the MCP server, the agent passes the tenant domain on each tool call. Name it in the agent's instructions, for example a line in its CLAUDE.md or AGENTS.md: "Store and look up memories in domain tenant:acme-corp." (This is the local stdio server — no URL to paste; the core.mnemoverse.com URLs in the next section are the REST API, not an MCP endpoint — connector URL and setup: Agent Setup.) With MCP the model passes the domain on each call, so the instruction keeps it to one domain by convention only: the model can read any domain of the account.

json
{
  "mcpServers": {
    "mnemoverse": {
      "command": "npx",
      "args": ["-y", "@mnemoverse/mcp-memory-server"],
      "env": {
        "MNEMOVERSE_API_KEY": "mk_live_YOUR_KEY"
      }
    }
  }
}

REST API ​

Writes and reads accept domain in the request body:

bash
# Write to specific tenant
curl -X POST https://core.mnemoverse.com/api/v1/memory/write \
  -H "X-Api-Key: mk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Customer prefers dark mode",
    "domain": "tenant:customer-123"
  }'

# Read from specific tenant
curl -X POST https://core.mnemoverse.com/api/v1/memory/read \
  -H "X-Api-Key: mk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "UI preferences",
    "domain": "tenant:customer-123"
  }'

Monitoring ​

Check how many memories you have and which domains hold them:

bash
curl https://core.mnemoverse.com/api/v1/memory/stats \
  -H "X-Api-Key: mk_live_YOUR_KEY"

The response's domains list names the account's domains, and any key of the account can see it.

Limits ​

Domains have no limits of their own. The account's limits on Pricing cover all domains together.

What a Domain Does Not Separate ​

Everything below works on the whole account, whatever domain your tenants use:

  • Every key of the account, and every connector signed in to it, reaches every domain.
  • A read or a list of recent memories without a domain covers every domain.
  • Calls that ignore the domain: GET /memory/stats and GET /memory/domains list the account's domain names, GET /memory/export streams the whole account, POST /memory/graph reads the account's association graph, and reads and deletes by atom ID check the account, not the domain.
  • A read that carries a fingerprint returns the matching memory from any domain, so never reuse one fingerprint across tenants.
  • expanded_concepts in a read response can name concepts learned in another tenant's domain, so do not show it to a tenant as it is.

So keep the key on your server, set the domain there from the signed-in customer, pass it on every read, and keep the calls above away from your customers and from any model that serves them. When a customer's memory must stay out of reach of the key that serves the others, that customer needs a Mnemoverse account of their own: the database keeps accounts apart (Security). One API key for many people compares the setups.

Organizing Memory Between Agents ​

The same domain pattern keeps agents' working notes apart. It separates how memory is used, not access: every agent that holds the key can read every domain.

python
# Each agent keeps its own working notes
client.write("Identified 3 relevant APIs", domain="agent:researcher")
client.write("Draft ready for review", domain="agent:writer")

# Shared project context — all agents can read
client.write("Deadline is Friday", domain="project:acme")

# Agent reads own memory + shared context
own = client.read("what have I found?", domain="agent:researcher")
shared = client.read("project deadlines", domain="project:acme")

Multi-Agent Architecture ​

Multi-Agent System
├── agent:planner        ← planning decisions
├── agent:researcher     ← research findings
├── agent:coder          ← code patterns learned
├── agent:reviewer       ← review criteria
├── project:acme         ← shared project context (all agents read)
├── team:engineering     ← shared team knowledge (all agents read)
└── tenant:customer-123  ← customer-specific

Each agent writes its working notes to its own domain. Shared domains (project:*, team:*) enable coordination. Agent reads in priority order: own → project → team → tenant.

This pattern scales from 2 agents to hundreds without architectural changes. The same API, the same domains.