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:

KeyDefaultWhat it sets
identity.user_idYour git user.name, set by setupYour user ID. Your sessions and memories are filed under it, and recall searches only its sessions.
memgraph.urlbolt://localhost:7687The Memgraph Bolt URL
memgraph.userNoneThe Memgraph user name
memgraph.passwordNoneThe Memgraph password. config set memgraph.password without a value prompts for it.
memgraph.databasememgraphThe database, on a Memgraph with multi-tenancy
capture.connectorsskills-graph, actions-graph, sessions-graphWhat the hooks record. See Choose what is recorded.
capture.redacttrueWhether secrets are redacted before they’re stored. See Redact secrets.
capture.max_chars100000The most characters kept from one text field, such as a tool’s output. 0 keeps everything. See Shorten long text.
capture.exclude_toolsNoneTools whose calls and results aren’t recorded, by name or glob. See Exclude tools and projects.
capture.exclude_projectsNoneDirectories in which nothing is recorded, by path or glob
memory.backendnativecontext-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.resumetrueWhether a session starts with the note on where you left off
recall.*See Recall configurationHow recall searches and what it returns
reconcile.auto_reconcilefalseWhether the knowledge graph is built after each session
ontology.pathThe default ontologyAn ontology file for the knowledge graph
ontology.deriveextendWhether Context Graph adds types to your ontology: extend or off
extraction.*See Extraction configurationHow sessions are read into the knowledge graph
llm.anthropic_api_keyNoneAn Anthropic API key, used only to learn your ontology. Used instead of an OpenAI key when both are set.
llm.openai_api_keyNoneAn OpenAI API key, used only to learn your ontology
llm.derive_modelclaude-sonnet-5-5 with Anthropic, gpt-5 with OpenAIThe model that learns your ontology
editioncommunityenterprise to use shared spaces. Set it with memgraph-context-graph join.
github.tokenNoneA 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"
KeyDefaultWhat it sets
recall.embedding_modelBAAI/bge-small-en-v1.5The model Memgraph computes embeddings with
recall.lanesAll sixThe searches to run, as a comma-separated subset of memories, turns, text, entities, facts and user_facts
recall.memories_k5Memory files returned
recall.turns_k8Messages found by meaning
recall.text_k8Messages found by words
recall.entities_k15Entities matched
recall.edges_per_entity6Facts read from each matched entity
recall.facts_k15Facts matched
recall.fact_turns_k8Messages added for the matched facts
recall.user_fact_types2Fact types gathered in full, for questions that count or list things
recall.user_facts_k30Facts gathered for those types
recall.turn_chars1500Characters shown per message
recall.query_instructionDepends on the modelText added before the question when it’s embedded. The English bge models get their retrieval instruction; other models get none
recall.packingexchangesHow results are grouped: exchanges (each message with its neighbors) or turns (messages and facts as separate rows)
recall.token_budget6000Tokens exchanges packing returns per space
recall.supplemental_searchtrueWhether 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
KeyDefaultWhat it sets
extraction.modelfastino/gliner2.5-base-v1The GLiNER2 model
extraction.entity_thresholdGLiNER2’s defaultThe lowest confidence, from 0 to 1, at which an entity is kept
extraction.relation_thresholdGLiNER2’s defaultThe lowest confidence, from 0 to 1, at which a fact is kept
extraction.chunk_sizeGLiNER2’s defaultWords per chunk
extraction.chunk_overlapGLiNER2’s defaultWords 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:7687

For 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:7687

Writes 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-graph

join --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:7687

setup codex --profile default moves Codex back to the top level.

  • What a profile holds: edition, the memgraph.* keys and memory.backend. A key it leaves out takes its default, not the top level’s value. Other settings, such as [redact], are shared; doctor reports 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 RUNTIME and doctor --runtime RUNTIME. Run setup once per profile. The Claude Code and Codex plugins name their agent with CONTEXT_GRAPH_AGENT. Before memgraph-context-graph 0.13.1 and the Claude Code and Codex plugins released with it, the recall and memory tools of those plugins use the top level; run memgraph-context-graph update.

  • Other commands: they use the top level, unless CONTEXT_GRAPH_PROFILE names a profile. config set then 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
FlagWhat it sets
RUNTIME ...The runtime names of the agents to connect. The default is every agent on your PATH.
--project-dir DIRA project to connect the per-project agents in. Repeat it for more projects. The default is the current directory.
--memgraph-url URLThe Memgraph to use, instead of setup’s own container.
--user-id NAMEYour user ID in the graph. The default is the configured one, then your git user.name.
--memory-backend BACKENDcontext-graph makes Context Graph the agents’ memory; native gives memory back to the agent.
--profile NAMEThe profile the named agents use, created if it’s new. default moves them back to the top level of the file.
--memgraph-container NAMESetup’s own container, which it finds or starts. The default is context-graph-memgraph.
--no-viewerDon’t install the terminal viewer.
--planPrint what setup would do and change nothing.
--no-tuiPrint 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/crawler

Choose what is recorded

capture.connectors lists the packages the hooks send events to. Each one records one part of a session:

ConnectorRecords
actions-graphPrompts, replies, tool calls and tool results
skills-graphThe agent skills a session used
sessions-graphThe session, its user and project, and memories. Recall needs it.
resources-graphThe 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 setup

Setup 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 update

It runs these steps in order:

  1. Upgrades the packages: memgraph-context-graph and its connectors.
  2. Updates the Claude Code and Codex plugins from the Memgraph marketplace, moving a plugin installed from the earlier context-graph-plugins marketplace.
  3. Rewrites the hook files and MCP registrations of the per-project agents, in the current directory or the --project-dir directories.
  4. Creates the indexes and constraints in Memgraph that are missing.
  5. Adds the refused events, the events your install kept while the graph refused them, to the graph, with their original times.
  6. Checks the setup, the same way as doctor.

Then restart running agent sessions, which keep the hooks they started with.

FlagWhat it does
RUNTIME ...Update only these agents. The default is every connected agent.
--project-dir DIRA project whose per-project agents to update. Repeat it for more projects. The default is the current directory.
--no-upgradeSkip 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:

  • doctor fails its graph version check with a line like this 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@memgraph

Codex has no update command, so refresh the marketplace and add the plugin:

codex plugin marketplace upgrade memgraph
codex plugin add context-graph@memgraph

Then 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 manifest

Remove 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 codex

Uninstall 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 uninstall

On 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-graph command and its packages.

To remove all three without questions, for example in a script:

memgraph-context-graph uninstall --all

Deleting 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
FlagWhat it does
RUNTIME ...Disconnect only these agents. The default is every connected agent.
--project-dir DIRA project to disconnect the per-project agents from. Repeat it for more projects. The default is the current directory.
--graphAlso delete the graph: setup’s Memgraph container and its volume
--configAlso delete the configuration file and the log of failed recordings
--toolAlso uninstall the memgraph-context-graph tool
--all--graph, --config and --tool together
--memgraph-container NAMEThe container setup started. The default is context-graph-memgraph.
--no-tuiDon’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.