Give your AI a Brain.

Ask your agent to install Brain. On its next task, it can read what you said before and cite the passage it used.

Prompt
Install Brain from https://brain.new/install.md

Read the install instructions. The CLI and MCP server come in one Python file. Live reads require an issued API connection.

On this page

Install in a terminal#

On macOS or Linux, use Python 3.9+ and curl. This verifies the downloaded file before installing or upgrading your user-local copy.

Shell
(
  set -eu
  dir="$HOME/.local/share/brain"
  mkdir -p "$dir"
  file=$(mktemp "$dir/.brain.py.XXXXXX")
  trap 'rm -f "$file"' EXIT
  curl --fail --silent --show-error --proto '=https' https://brain.new/install/brain.py -o "$file"
  python3 -c 'import hashlib, pathlib, sys; sys.exit(hashlib.sha256(pathlib.Path(sys.argv[1]).read_bytes()).hexdigest() != sys.argv[2])' "$file" 5ce9dc00ea372d4e036b5e5a78b2e54d8383aaae8a03640488efe6ca5000bc1f
  mv -f "$file" "$dir/brain.py"
  python3 "$dir/brain.py" --help
)

In the environment that launches the client, set BRAIN_API_BASE_URL to the issued API origin, BRAIN_API_KEY to its server credential, and BRAIN_PERSON and BRAIN_PROJECT to the person and project authorized for this agent. Supply the credential through your secret store. Keep it out of chat, client configuration files and source control.

Catch exhaust, get memory#

One line turns a person’s raw chat into their user.md, short guidance an agent reads before it answers. Run doctor first: it says whether your API serves POST /v1/user-md. On fictional data:

Shell
cat > chat.json <<'JSON'
[{"role": "user", "content": "Keep captions to one word at a time."},
 {"role": "assistant", "content": "Got it: one word per caption."},
 {"role": "user", "content": "Always export 9:16 for Reels."}]
JSON
python3 "$HOME/.local/share/brain/brain.py" user-md chat.json --product-name "Clipwise" --pack creator-video > user.md
cat user.md

Standard output is only the page; progress and errors go to standard error. A compile reads the new turns with Brain’s model and takes minutes, so user-md waits up to 600 seconds and says that it is compiling. Exit status 3 means the delivery outcome is unknown: rerun the same command with the same input to reconcile. Status 1 means nothing was delivered, and the message names the next step. Status 4 means the connection has no recorded consent for Brain’s hosted model; do not retry until it is recorded, and the message says whether the turns were already held. All options are in the install instructions.

Read your first brief#

Use a fictional test connection where you have saved a message. Check the API contract, then ask for a detail from that message.

Shell
python3 "$HOME/.local/share/brain/brain.py" doctor
python3 "$HOME/.local/share/brain/brain.py" brief --json "When did I ask you to call back?"

Look for the quoted words in text and the matching citation in lines. An empty brief can be a successful read. A partial brief may leave out relevant passages. doctor checks configuration and the public API contract. The brief tests your credential.

Save, then recall#

save sends one atomic batch to POST /v1/save. It redacts recognized credentials first and derives event IDs from the person, project, role, time and words, so an exact rerun is safe. Exit status 3 means the outcome is unknown: rerun the same words with the printed --at value, and never change them. Status 1 means Brain refused and nothing was saved.

Shell
python3 "$HOME/.local/share/brain/brain.py" save "Call me back after 6pm on weekdays."
python3 "$HOME/.local/share/brain/brain.py" brief "When should you call me back?"

Connect local MCP#

For Codex, put this entry in the selected profile’s config.toml. Use the absolute path to the installed file and start the host with the four environment variables available. Other stdio hosts use the same command and arguments.

TOML
[mcp_servers.brain]
command = "python3"
args = ["/absolute/path/to/.local/share/brain/brain.py", "mcp"]
env_vars = ["BRAIN_API_BASE_URL", "BRAIN_API_KEY", "BRAIN_PERSON", "BRAIN_PROJECT"]

For Claude Code, add this to the project’s .mcp.json. Claude Code expands each ${VAR} from the environment that launched it, so the key stays out of the file. Cursor and other hosts that read an mcpServers file take the same command and arguments. Check whether your host expands variables before writing a value into the file, and never commit a key.

JSON
{
  "mcpServers": {
    "brain": {
      "command": "python3",
      "args": ["/absolute/path/to/.local/share/brain/brain.py", "mcp"],
      "env": {
        "BRAIN_API_BASE_URL": "${BRAIN_API_BASE_URL}",
        "BRAIN_API_KEY": "${BRAIN_API_KEY}",
        "BRAIN_PERSON": "${BRAIN_PERSON}",
        "BRAIN_PROJECT": "${BRAIN_PROJECT}"
      }
    }
  }
}

The server lists brain_brief and brain_user_md, which returns the person’s current user.md. It lists brain_save, and lets brain_user_md deliver messages, only when BRAIN_ALLOW_SAVE=1 is set in its environment. Leave it unset for a read-only agent.

Check for brain_brief in your agent’s tools. Give it a task, such as “When did I ask you to call back?” The tool makes one read for the configured person and project. Only connect an agent authorized to receive that person’s quotes.

Remember the chat automatically#

In Claude Code, this hook saves every prompt the person types as their words and gives the model a cited brief for it. Put it in .claude/settings.json or ~/.claude/settings.json. Credentials are redacted before the save, a brief is printed only when Brain has evidence, and a failure never blocks the prompt. Drop --brief to save without reading. Enable it only for a person who agreed to have their prompts saved.

JSON
{
  "hooks": {
    "UserPromptSubmit": [
      { "hooks": [{ "type": "command", "command": "python3 \"$HOME/.local/share/brain/brain.py\" hook --brief" }] }
    ]
  }
}

What the model gets#

The tool returns up to 2,048 UTF-8 bytes of cited brief text. Your agent supplies the model. A stated line records what someone said, a confirmed line records an explicit setting, and a reported line records a tool’s account. A reported outcome carries the authority of the reporting tool.

For an app reader, cite the passage that supplies the answer and any passage that identifies the subject. If two accounts disagree, show both. If the reason for a decision is missing, leave it unknown. The CLI’s --json view includes Original paths and byte ranges outside the text budget. Read the HTTP contract.

For source integrations, see Connectors.

Codex#

Download the Brain skill.

Download the skill and run this from your repo root. Commit the file to share it.

Shell
mkdir -p .agents/skills/brain-brief
cp -n "$HOME/Downloads/SKILL.md" .agents/skills/brain-brief/SKILL.md

Ask Codex to use brain-brief to add a read to your backend. Keep the key there. Codex skills docs

OpenClaw#

Download the Brain skill.

Download the skill and run this from your OpenClaw workspace.

Shell
mkdir -p skills/brain-brief
cp -n "$HOME/Downloads/SKILL.md" skills/brain-brief/SKILL.md
openclaw skills info brain-brief

For live recall, give OpenClaw a read-only tool backed by your app. OpenClaw skills docs

Grok Bot#

Expose Brief and Original reads from your backend. Keep the key there and authorize each read.

Brain’s hosted connector is still pending. Grok Bot connector docs

HTTP API#

Set the origin and key from your invite. Use the person and project IDs it supplies.

Shell
printf "Authorization: Bearer %s\n" "${BRAIN_API_KEY:?Set your Brain test key}" |
  curl --fail-with-body --silent --show-error --header @- \
    --header "Content-Type: application/json" \
    --data '{"person":"demo-maya","project":"support","task":"When can I call Maya back?"}' \
    "${BRAIN_API_ORIGIN:?Set your Brain API origin}/v1/brief"

Open a citation with the same key. Brief API reference