Configure Context Graph
Context Graph keeps its settings in one configuration file. Setup writes it,
and the config command changes it. This page also covers how to
use your own Memgraph,
send one agent’s memory to another Memgraph,
run setup again to change your choices,
choose what is recorded, and
update or uninstall
Context Graph.
Configuration file
Setup writes the configuration to ~/.config/context-graph/config.toml,
readable only by you. Set the CONTEXT_GRAPH_CONFIG environment variable to
use another path.
The file lists every key with a comment, and keys you haven’t set are
commented out with their defaults. Setup and config set rewrite the file,
keeping your values, [redact] patterns,
profiles and line endings, but
not your comments.
Agents run hooks without your shell’s environment, so the hooks read settings only from this file. Three environment variables choose where settings come from, but never set a value:
CONTEXT_GRAPH_CONFIG: the configuration file.CONTEXT_GRAPH_PROFILE: the profile.CONTEXT_GRAPH_AGENT: the agent an MCP server runs for.
Change settings with the config command:
memgraph-context-graph config show
memgraph-context-graph config get memgraph.url
memgraph-context-graph config set identity.user_id alice
memgraph-context-graph config set recall.turns_k ""An empty value, as in the last command, sets a key back to its default, except
for capture.connectors, where it records nothing. config set checks each
value and refuses one that Context Graph can’t use, so a typo doesn’t break
recording later. It takes these keys:
| Key | Default | What it sets |
|---|---|---|
identity.user_id | Your git user.name, set by setup | Your user ID. Your sessions and memories are filed under it, and recall searches only its sessions. |
memgraph.url | bolt://localhost:7687 | The Memgraph Bolt URL |
memgraph.user | None | The Memgraph user name |
memgraph.password | None | The Memgraph password. config set memgraph.password without a value prompts for it. |
memgraph.database | memgraph | The database, on a Memgraph with multi-tenancy |
capture.connectors | skills-graph, actions-graph, sessions-graph | What the hooks record. See Choose what is recorded. |
capture.redact | true | Whether secrets are redacted before they’re stored. See Redact secrets. |
capture.max_chars | 100000 | The most characters kept from one text field, such as a tool’s output. 0 keeps everything. See Shorten long text. |
capture.exclude_tools | None | Tools whose calls and results aren’t recorded, by name or glob. See Exclude tools and projects. |
capture.exclude_projects | None | Directories in which nothing is recorded, by path or glob |
memory.backend | native | context-graph when Context Graph is the agents’ memory, native when they keep their own. Set it with setup’s --memory-backend, which also changes the agents’ settings. |
session_start.resume | true | Whether a session starts with the note on where you left off |
recall.* | See Recall configuration | How recall searches and what it returns |
reconcile.auto_reconcile | false | Whether the knowledge graph is built after each session |
ontology.path | The default ontology | An ontology file for the knowledge graph |
ontology.derive | extend | Whether Context Graph adds types to your ontology: extend or off |
extraction.* | See Extraction configuration | How sessions are read into the knowledge graph |
llm.anthropic_api_key | None | An Anthropic API key, used only to learn your ontology. Used instead of an OpenAI key when both are set. |
llm.openai_api_key | None | An OpenAI API key, used only to learn your ontology |
llm.derive_model | claude-sonnet-5-5 with Anthropic, gpt-5 with OpenAI | The model that learns your ontology |
edition | community | enterprise to use shared spaces. Set it with memgraph-context-graph join. |
github.token | None | A GitHub token for resources-graph, used instead of your gh login. Prompts for the value. |
Only [redact] patterns are edited in the file directly, because you name
them yourself. See Redact secrets.
The file holds your Memgraph password and API keys in plain text. Setup
creates it with permissions 0600; keep it that way.
Recall configuration
The recall.* keys set how
recall
searches and what it returns:
memgraph-context-graph config set recall.token_budget 8000
memgraph-context-graph config set recall.lanes "memories, turns, text"| Key | Default | What it sets |
|---|---|---|
recall.embedding_model | BAAI/bge-small-en-v1.5 | The model Memgraph computes embeddings with |
recall.lanes | All six | The searches to run, as a comma-separated subset of memories, turns, text, entities, facts and user_facts |
recall.memories_k | 5 | Memory files returned |
recall.turns_k | 8 | Messages found by meaning |
recall.text_k | 8 | Messages found by words |
recall.entities_k | 15 | Entities matched |
recall.edges_per_entity | 6 | Facts read from each matched entity |
recall.facts_k | 15 | Facts matched |
recall.fact_turns_k | 8 | Messages added for the matched facts |
recall.user_fact_types | 2 | Fact types gathered in full, for questions that count or list things |
recall.user_facts_k | 30 | Facts gathered for those types |
recall.turn_chars | 1500 | Characters shown per message |
recall.query_instruction | Depends on the model | Text added before the question when it’s embedded. The English bge models get their retrieval instruction; other models get none |
recall.packing | exchanges | How results are grouped: exchanges (each message with its neighbors) or turns (messages and facts as separate rows) |
recall.token_budget | 6000 | Tokens exchanges packing returns per space |
recall.supplemental_search | true | Whether exchanges packing adds exchanges where a problem was solved |
exchanges packing is available since memgraph-context-graph 0.12.0;
earlier releases return turns. It counts tokens with the cl100k_base
encoding, which it downloads the first time recall runs. Without network
access, recall fails with an error that says how to preload it; turns packing
needs no download.
exchanges packing also raises recall.turns_k and recall.text_k to at
least 24 and recall.fact_turns_k to at least 16, and 0 still turns a
search off.
Supplemental search runs only for questions with words such as issue, problem,
error, fix, resolve, debug or troubleshoot. It needs the turns and text
searches and MAGE, and takes at most a quarter of the budget left after memory
files.
Changing recall.embedding_model computes all embeddings again with the new
model, which Memgraph downloads on first use.
Extraction configuration
The extraction.* keys set how the
knowledge graph reads
your sessions. Reconciliation and ontology learning use the same settings, so
a session is always read the same way.
memgraph-context-graph config set extraction.entity_threshold 0.3| Key | Default | What it sets |
|---|---|---|
extraction.model | fastino/gliner2.5-base-v1 | The GLiNER2 model |
extraction.entity_threshold | GLiNER2’s default | The lowest confidence, from 0 to 1, at which an entity is kept |
extraction.relation_threshold | GLiNER2’s default | The lowest confidence, from 0 to 1, at which a fact is kept |
extraction.chunk_size | GLiNER2’s default | Words per chunk |
extraction.chunk_overlap | GLiNER2’s default | Words shared by neighboring chunks |
Use your own Memgraph
By default, setup starts Memgraph in Docker on your machine. To use another Memgraph, such as a shared server or a high availability cluster, pass its URL to setup. If the instance has authentication, set the user and password first, because setup connects with them:
memgraph-context-graph config set memgraph.user alice
memgraph-context-graph config set memgraph.password
memgraph-context-graph setup --memgraph-url bolt://memgraph.example.com:7687For a high availability cluster, use a coordinator’s neo4j:// URL, so writes
go to the MAIN instance:
memgraph-context-graph config set memgraph.url neo4j://coordinator.example.com:7687Writes through a neo4j:// URL need memgraph-context-graph 0.12.5 or later.
The instance needs the Memgraph version, MAGE and memory listed in the
prerequisites. To see all
labels and properties with SHOW SCHEMA INFO, start it with
--schema-info-enabled=true. The Memgraph that setup starts has it enabled.
Each user on a shared Memgraph should have their own identity.user_id. On a
shared Memgraph with Memgraph Enterprise, shared spaces
give each user a database of their own.
Send one agent’s memory to another Memgraph
By default, every agent uses the Memgraph set at the top level of the
configuration file. A profile is a named set of Memgraph settings in the
same file, and the [agents] table maps agents to it. Available since
memgraph-context-graph 0.13.0.
To move only Codex to a team’s
shared spaces, join with --agent,
then set up Codex:
memgraph-context-graph join bolt://memgraph.example.com:7687 alice --agent codex
memgraph-context-graph setup codex --memory-backend context-graphjoin --agent writes the login into a profile named after the URL’s host, with
dots and other characters a name can’t hold turned into hyphens
(memgraph-example-com), or into --profile NAME, and maps Codex to it. Setup
saves memory.backend in that profile.
Without shared spaces, set the profile’s login if needed, then name it in setup:
CONTEXT_GRAPH_PROFILE=work memgraph-context-graph config set memgraph.user alice
CONTEXT_GRAPH_PROFILE=work memgraph-context-graph config set memgraph.password
memgraph-context-graph setup codex --profile work --memgraph-url bolt://memgraph.example.com:7687setup codex --profile default moves Codex back to the top level.
-
What a profile holds:
edition, thememgraph.*keys andmemory.backend. A key it leaves out takes its default, not the top level’s value. Other settings, such as[redact], are shared;doctorreports any other key in a profile. -
Memory: agents on different profiles don’t share it.
-
Commands that use the agent’s profile: the hooks, the MCP server,
setup RUNTIMEanddoctor --runtime RUNTIME. Run setup once per profile. The Claude Code and Codex plugins name their agent withCONTEXT_GRAPH_AGENT. Beforememgraph-context-graph0.13.1 and the Claude Code and Codex plugins released with it, therecallandmemorytools of those plugins use the top level; runmemgraph-context-graph update. -
Other commands: they use the top level, unless
CONTEXT_GRAPH_PROFILEnames a profile.config setthen writes into that profile:CONTEXT_GRAPH_PROFILE=memgraph-example-com memgraph-context-graph config show
Run setup again
Every choice in setup is also a flag of memgraph-context-graph setup. To
change a choice, run setup again with its flag:
memgraph-context-graph setup codex --memgraph-url bolt://memgraph.example.com:7687| Flag | What it sets |
|---|---|
RUNTIME ... | The runtime names of the agents to connect. The default is every agent on your PATH. |
--project-dir DIR | A project to connect the per-project agents in. Repeat it for more projects. The default is the current directory. |
--memgraph-url URL | The Memgraph to use, instead of setup’s own container. |
--user-id NAME | Your user ID in the graph. The default is the configured one, then your git user.name. |
--memory-backend BACKEND | context-graph makes Context Graph the agents’ memory; native gives memory back to the agent. |
--profile NAME | The profile the named agents use, created if it’s new. default moves them back to the top level of the file. |
--memgraph-container NAME | Setup’s own container, which it finds or starts. The default is context-graph-memgraph. |
--no-viewer | Don’t install the terminal viewer. |
--plan | Print what setup would do and change nothing. |
--no-tui | Print plain output, even on a terminal. |
For example, to connect the per-project agents in more projects:
memgraph-context-graph setup cursor --project-dir ~/work/billing --project-dir ~/work/crawlerChoose what is recorded
capture.connectors lists the packages the hooks send events to. Each one
records one part of a session:
| Connector | Records |
|---|---|
actions-graph | Prompts, replies, tool calls and tool results |
skills-graph | The agent skills a session used |
sessions-graph | The session, its user and project, and memories. Recall needs it. |
resources-graph | The GitHub resources a session read. Off by default. |
For example, to also remember GitHub resources:
memgraph-context-graph config set capture.connectors "skills-graph, actions-graph, sessions-graph, resources-graph"
memgraph-context-graph setupSetup installs the connectors the setting names. An empty value records nothing, without disconnecting the agents.
Update Context Graph
Context Graph doesn’t update itself. The update command upgrades the packages
and refreshes the plugins, hook files and Model Context Protocol (MCP)
registrations that setup wrote:
memgraph-context-graph updateIt runs these steps in order:
- Upgrades the packages:
memgraph-context-graphand its connectors. - Updates the Claude Code and Codex plugins from the Memgraph
marketplace, moving a plugin installed from the earlier
context-graph-pluginsmarketplace. - Rewrites the hook files and MCP registrations of the per-project agents,
in the current directory or the
--project-dirdirectories. - Creates the indexes and constraints in Memgraph that are missing.
- Adds the refused events, the events your install kept while the graph refused them, to the graph, with their original times.
- Checks the setup, the same way as
doctor.
Then restart running agent sessions, which keep the hooks they started with.
| Flag | What it does |
|---|---|
RUNTIME ... | Update only these agents. The default is every connected agent. |
--project-dir DIR | A project whose per-project agents to update. Repeat it for more projects. The default is the current directory. |
--no-upgrade | Skip the package upgrade, and run the other steps, including adding the refused events |
update doesn’t change your own hooks, the configuration file or the data
already in the graph, and running it twice changes nothing more.
If another install, such as uv tool install sessions-graph, holds the
sessions-graph or resources-graph command on your PATH, update leaves
it and says so. Remove that install and run update again.
When a newer Context Graph changes the graph
A newer Context Graph sometimes changes how a connector’s part of the graph is stored, as for a version 2 ontology. Older installs on the same graph then stop writing that part, and also stop reading it when the change affects reads.
Their agents keep running, and two places say so:
doctorfails itsgraph versioncheck with a line likethis graph needs a newer Context Graph to write sessions-graph than the one installed here; run memgraph-context-graph update.- The session-start note tells the agent that Context Graph is paused for that
part of the graph, and to ask you to run
memgraph-context-graph update.
While the graph refuses writes, the hooks keep the refused events, filtered
as in Keep text out of the graph,
in ~/.local/state/context-graph/refused-events.jsonl on the machine. The file
is readable only by you. At 64 MB it stops growing, and each further event is
dropped and logged as a RefusedEventSpoolFull failure in the log of failed
recordings. Run update to upgrade and add the events to the graph.
Update the plugins manually
If you manage plugins yourself, update the plugin with the agent’s commands. In Claude Code:
claude plugin marketplace update memgraph
claude plugin update context-graph@memgraphCodex has no update command, so refresh the marketplace and add the plugin:
codex plugin marketplace upgrade memgraph
codex plugin add context-graph@memgraphThen upgrade the packages the hooks run with memgraph-context-graph update or
uv tool upgrade memgraph-context-graph.
Codex can’t load the context-graph-plugins marketplace
Before memgraph-context-graph 0.13.1, setup installed the plugin from the
context-graph-plugins marketplace, which no longer exists. update moves
that install to the Memgraph marketplace. If Codex refreshed the old
marketplace first, its plugin commands fail with an error like this, and
update can’t see the old install:
Error: failed to load configured marketplace snapshot(s):
- `context-graph-plugins` at ...: marketplace root does not contain a supported manifestRemove the old plugin and marketplace, then run setup:
codex plugin remove context-graph@context-graph-plugins
codex plugin marketplace remove context-graph-plugins
memgraph-context-graph setup codexUninstall Context Graph
The uninstall command disconnects your agents: it removes the plugins, hook files and MCP
registrations, and gives the agents’ memory back.
memgraph-context-graph uninstallOn a terminal, it then asks about each of these, and keeps it unless you answer yes:
- The graph: the Memgraph container that setup started and its data volume, with every recorded session and memory.
- The configuration: the configuration file and the log of failed recordings.
- The tool: the
memgraph-context-graphcommand and its packages.
To remove all three without questions, for example in a script:
memgraph-context-graph uninstall --allDeleting the configuration leaves two state files behind: the
refused events and
graph-version.json, the last graph version check. Delete them by hand:
rm ~/.local/state/context-graph/refused-events.jsonl ~/.local/state/context-graph/graph-version.json| Flag | What it does |
|---|---|
RUNTIME ... | Disconnect only these agents. The default is every connected agent. |
--project-dir DIR | A project to disconnect the per-project agents from. Repeat it for more projects. The default is the current directory. |
--graph | Also delete the graph: setup’s Memgraph container and its volume |
--config | Also delete the configuration file and the log of failed recordings |
--tool | Also uninstall the memgraph-context-graph tool |
--all | --graph, --config and --tool together |
--memgraph-container NAME | The container setup started. The default is context-graph-memgraph. |
--no-tui | Don’t ask; remove the agent connections and what the flags name |
Without a terminal, uninstall removes only the agent connections and what the
flags name. It deletes only the container setup started, by name, never a
Memgraph you run yourself. On Windows, the running tool can’t remove itself,
so uninstall prints the uv tool uninstall command to run afterwards.
Deleting the graph deletes everything your agents recorded, including your memories, and can’t be undone.