Korely

Coding agents

Codex

Give Codex memory that survives the session. One entry in config.toml connects the Korely MCP server over Streamable HTTP: no package to install, just your API key, read from an environment variable.

Connect Korely's MCP server and Codex can ask Korely for the current facts and the relevant memories before it answers, and save new ones as you work. Korely does the heavy part on its own servers: it reads each memory, writes the facts, closes an older fact when a newer one contradicts it, and keeps both dates of a fact (bi-temporal). Codex only calls the tools.

Prerequisites

  • A Korely API key (kor_live_...) from agent signup. The hobby plan is free; Pricing lists its limits.
  • Codex CLI installed (codex --version). Remote Streamable HTTP MCP servers need a current build.

Add the Korely MCP server

Korely's agent memory is a remote MCP server at https://api.korely.ai/agent/mcp (Streamable HTTP), authenticated with your key in a header, no browser login. Codex reads the key from an environment variable at connect time, so export it first:

Terminal window
export KORELY_API_KEY=kor_live_...
codex mcp add korely \
--url https://api.korely.ai/agent/mcp \
--bearer-token-env-var KORELY_API_KEY

Or add it to ~/.codex/config.toml directly:

[mcp_servers.korely]
url = "https://api.korely.ai/agent/mcp"
bearer_token_env_var = "KORELY_API_KEY"

Then export the key in the same shell before launching Codex:

Terminal window
export KORELY_API_KEY=kor_live_...
codex

It's the env-var name, not the token. bearer_token_env_var takes the name of an environment variable, not the literal key. Codex reads that variable's value at connect time and sends it as Authorization: Bearer <value>. So export KORELY_API_KEY=kor_live_... must run in the same shell/session that launches Codex. The CLI command and the config.toml block are two ways to register the same server, use one, not both.

Save every session without asking. In the repository, run korely init --tool codex (korely-memory 0.1.26 or later): hooks hand Codex the repository's memory when a session starts and save the session to it as a memory of kind session. Each prompt and each final answer is saved, at most 3,000 characters per message. Before anything leaves your machine, the hook masks private key blocks, credentials in URLs and long random-looking strings. It masks by shape, so a hexadecimal token or a short password typed in a sentence stays as plain text: keep secrets out of what you type. Trust the five korely hooks once in /hooks. It also writes a local [mcp_servers.korely] table to .codex/config.toml in the repository (~/.codex/config.toml with --global), replacing a korely table already there; with --no-mcp it removes that table and adds none. Without --global, that table goes into the repository's .codex/config.toml, which Codex reads ahead of ~/.codex/config.toml in a trusted repository, so there the local korely server takes the place of the remote one configured above. To keep the remote server, run korely init --tool codex --no-mcp. Codex loads the repository's .codex/ config and hooks only once you trust the repository. The local server has four of the six tools below (no korely_correct_fact or korely_forget_memory). See Connect a coding assistant.

Korely MCP also supports OAuth, so Codex can sign you in instead of using a key. The Codex documentation describes OAuth for remote MCP servers. Korely has not tested OAuth with Codex. See Connect with OAuth.

What Codex can do

The Korely server offers six memory tools:

ToolWhat it does
korely_get_contextThe recall call: returns the current facts plus the most relevant memories as one block of text, ready to put in a prompt (the context block). It does not call a language model.
korely_addStore a memory. Korely writes facts from it on its servers, each as (subject, predicate, object), and closes an earlier fact, with its end date, when a model decides a new one replaces it.
korely_searchSearch by meaning over the stored memories, best match first.
korely_get_factsThe facts known about an end user, with point-in-time queries: as_of (what was true then) and known_as_of (what the store knew then).
korely_correct_factFix or end one fact by its id. Give a new subject, predicate or object and the old fact is closed and a corrected one is written, both kept in history. With close=true the fact is only closed, which is how you forget a fact. Needs a key with the memories:write permission.
korely_forget_memoryForget one memory by its id. It drops out of every read and the facts only it stated are closed; with erase=true it is removed for good. Needs memories:write.

Use it

Korely MCP sends its client short instructions: call korely_get_context before answering, and korely_add once a decision or preference is settled. If Codex follows them, a session looks like this (an example, not a recording):

You › Remember that this repo deploys to Hetzner, not Render.
→ korely_add("This repo deploys to Hetzner, not Render")
# next session, days later
You › How do we deploy this?
→ korely_get_context("deploy") → "This repo deploys to Hetzner..."
Codex › This repo deploys to Hetzner (you told me earlier), not Render. ...

Scoping

The four tools korely_get_context, korely_add, korely_search and korely_get_facts accept an optional user_id so one key can serve many end users: a read that names "user-b" never returns a memory written for "user-a". Omit it on a write and the memory belongs to no end user (a key confined to one end user writes to that one). Omit it on a read and the read covers every end user the key can see. korely_add and the three read tools also accept an optional agent_id. korely_correct_fact and korely_forget_memory take the id of a fact or a memory instead, and treat an id from another project (or, for a confined key, from another end user) as not found. The Korely MCP page lists every argument.

Why this is more than a notepad. Korely keeps each memory's text as written and also extracts typed facts with bi-temporal validity from it. When something changes ("this repo now deploys to Hetzner, not Render"), Korely closes the old fact with its end date instead of overwriting it, so korely_get_context returns what's true now, and as_of can still replay what was true before. The Cloud runs on servers in Helsinki; Data and governance says where text is processed.

Server not detected? Upgrade Codex to a current build, then confirm KORELY_API_KEY is exported in the same shell that launches Codex.

Related