Shared spaces Enterprise
Shared spaces let a team run Context Graph on one Memgraph. Each user gets a personal space, a database only they can read, and teams get shared spaces, databases whose members read and write the same memory files. An agent can save a decision to a shared space, and every member’s agents recall it.
Shared spaces need Memgraph Enterprise. Memgraph enforces the isolation between spaces with multi-tenancy, role-based access control and label-based access control. Context Graph itself doesn’t filter what a user can read.
Without shared spaces, Context Graph runs as the Community edition: one user and one database. Nothing changes for Community users when the shared spaces package is installed.
How spaces work
- Identity is your Memgraph login. It replaces
identity.user_id. - Your personal space is the database
u_LOGIN. It holds your sessions, memories and knowledge graph, and only you can read it. - A shared space is the database
space_NAME. Members can read everything in it, and write only memory files. - Shared memory files appear to the agent under
/memories/spaces/NAME/, and listing/memoriesshows each shared space you can read. The agent writes there only when you want something shared. At the start of a session, each shared space adds up to 20 files to the memory index. - Recall searches your personal space and every shared space you can read, in parallel. If a space doesn’t answer within 10 seconds, recall returns the other results and names the space it’s missing.
Your own sessions stay in your personal space. A shared space holds only the memory files members put there, and the knowledge graph built from them.
Set up spaces as an admin
Spaces need a Memgraph with an Enterprise license,
multi-tenancy and MAGE. The admin
commands are in the context-graph-spaces package:
pip install context-graph-spacesCreate the admin login
plan and apply need a login with Memgraph’s admin role, or its
privileges. On an instance with no users, init creates one, cgadmin or
--admin NAME, and prints its password once:
context-graph-spaces --url bolt://memgraph.example.com:7687 initOn an instance with users, pass an existing admin with --user and
--password, or MEMGRAPH_USER and MEMGRAPH_PASSWORD. init checks the
license, the login’s privileges on every database and that MAGE’s
embeddings.text loads recall’s model, reports the memory limit, and exits
with code 1 if a check fails.
To make another login, LOGIN, an admin, either give it the role:
SET ROLE FOR LOGIN TO admin;Or grant the privileges directly:
GRANT CONFIG, STATS, AUTH, MULTI_DATABASE_EDIT, MULTI_DATABASE_USE, PROFILE_RESTRICTION,
MATCH, CREATE, MERGE, SET, DELETE, REMOVE, INDEX, CONSTRAINT TO LOGIN;
GRANT DATABASE * TO LOGIN;The admin login can’t be named admin or start with u_, space_ or cg_.
If it lacks a privilege, init, plan and apply name it and print these
commands.
Declare and apply the spaces
Declare the members and spaces in a spec file, such as spaces.toml:
members = ["alice", "bob"]
personal_memory_limit_mb = 2048
[spaces.payments]
members = ["alice", "bob"]
memory_limit_mb = 4096| Key | What it sets |
|---|---|
members (at the top) | Every user who gets a personal space |
personal_memory_limit_mb | Each personal space’s memory cap, with a tenant profile |
[spaces.NAME] | A shared space, its members and memory_limit_mb. labels and edge_types set what members may write, memory files by default. |
Apply the spec as the admin login:
export MEMGRAPH_URL=bolt://memgraph.example.com:7687
export MEMGRAPH_USER=ADMIN_USER
export MEMGRAPH_PASSWORD=ADMIN_PASSWORD
context-graph-spaces plan spaces.toml
context-graph-spaces apply spaces.tomlADMIN_USER and ADMIN_PASSWORD are the login init created (cgadmin or
your --admin NAME) and the password it printed, or your existing admin’s
login and password.
plan prints what apply would change. apply creates what’s missing and
prints a one-time join command with the password of each new login, and the
cg_service password. These are the only copies. If apply fails partway, it
still prints them; run it again after fixing the error.
apply creates and maintains:
| Object | Name | Access |
|---|---|---|
| Personal database | u_LOGIN | Its owner only |
| Shared database | space_NAME | Members read everything and write the spec’s labels |
| Roles | cg_u_LOGIN_HASH, space_NAME_member_HASH, cg_worker_HASH | Named after what they grant |
| Service user | cg_service | Writes the knowledge graph in shared spaces |
| Tenant profiles | cg_MBmb | The memory caps from the spec |
Removing a user from the spec revokes their access, and removing a space
revokes access to it. apply drops users and databases only with --prune,
and only touches objects whose names start with u_, space_ or cg_.
Run the shared space worker
The worker builds the knowledge graph and embeddings in shared spaces, as the
cg_service user. Run it with the password apply printed:
export CG_SERVICE_PASSWORD=SERVICE_PASSWORD
context-graph-spaces reconcile spaces.toml --watchEvery 30 seconds, for each shared space, the worker removes what deleted files left behind and extracts the changed memory files. It uses no LLM. Personal spaces are extracted on each user’s machine, as in the Community edition.
Without the worker, shared memory files are still stored and read, but recall can’t find them by meaning or through the knowledge graph.
Run spaces on Kubernetes
The
high availability Helm chart
runs data instances with a read-only root filesystem, so Memgraph can’t
download the embedding model into $HOME/.cache/huggingface, and recall times
out. In the chart’s values, point the cache at the data volume:
extraEnv:
data:
- name: HF_HOME
value: /var/lib/memgraph/huggingfaceIf extraEnv.data is already set, add the entry to it. The first download,
about 130 MB, needs outbound HTTPS to huggingface.co.
Without that access, download recall’s model, BAAI/bge-small-en-v1.5 unless
you set another recall.embedding_model, on a machine that has access:
pip install huggingface_hub
HF_HOME=./huggingface hf download BAAI/bge-small-en-v1.5Copy the huggingface directory’s contents to /var/lib/memgraph/huggingface
on every data instance, and add an entry with name: HF_HUB_OFFLINE and
value: "1" to extraEnv.data.
Every data instance needs the model, or recall fails after a failover. init
checks only the instance it connects to.
Join as a user
Each user runs the join command with the Memgraph URL and their login:
memgraph-context-graph join bolt://memgraph.example.com:7687 alicejoin prompts for the password, installs context-graph-spaces if needed,
writes edition = "enterprise", the URL, the login and the password to the
configuration file,
checks the login, and prints your spaces:
Wrote /home/alice/.config/context-graph/config.toml: edition = enterprise, login 'alice'.
Personal space: u_alice. Shared spaces: payments.
Next: memgraph-context-graph setup <runtime> (e.g. claude-code) --memory-backend context-graph
Shared spaces are reached through the memory tool, which only that backend turns on.Agents reach shared memory files only through Context Graph’s memory tool,
so run setup next with
--memory-backend context-graph, unless join says it’s already on.
- Some agents only: add
--agent RUNTIMEonce per agent, as in--agent codex --agent cursor. The login goes into a configuration profile for those agents. - High availability cluster: join with a coordinator’s
neo4j://URL.
join writes the configuration file before it checks the login. If the check
fails, it says why:
-
Wrong password:
Wrote PATH, but the login doesn't work yet: Memgraph refused the login 'alice'; check its passwordPATHis the configuration file’s path. Runjoinagain with the right password. -
A login
applydidn’t provision:Wrote PATH, but the login doesn't work yet: The login 'alice' has no personal space: its main database is 'memgraph', not 'u_alice'. Ask your admin to add alice to the spaces spec's members and run context-graph-spaces apply.Ask your admin to add the login to the spec’s
membersand runapply.
In the terminal viewer,
press w to switch to the next space you can read.