One Brain on Cloudflare.
Two ways to give an agent on Cloudflare your team’s One Brain: its skills, knowledge files and memories. Connect the MCP server with no code, or build with @useonebrain/cloudflare on Cloudflare’s Agents SDK.
Integrations · Cloudflare
Without code: the MCP server.
One Brain’s MCP server is at <ONEBRAIN_URL>/mcp, which is https://api.useonebrain.com/mcp on the hosted One Brain (Streamable HTTP). It has six tools: search, read, list, remember, write and forget. A client signs in one of two ways:
- An agent key (
ob_...) as a Bearer token. The client then acts as that agent and sees what the key may see. Make one in the One Brain app under Agents, or withonebrain admin keys create <agent>. - OAuth. A client that connects without a key signs the person in to One Brain, and from then on sees what that person may see.
To check a key from a shell:
curl -s "$ONEBRAIN_URL/mcp" \
-H "Authorization: Bearer $ONEBRAIN_API_KEY" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | jq -r '.result.tools[].name'It prints the six tool names. An agent you build with the Agents SDK can also add the server itself, with addMcpServer: see the MCP page.
A Zero Trust MCP server portal.
A portal puts One Brain beside your other MCP servers, behind Cloudflare Access, at one URL. A portal connects to a server by OAuth, not with a fixed header, so each person signs in to One Brain with their own account.
- In the Cloudflare dashboard, go to Zero Trust > Access controls > MCP Portals, open the MCP servers tab and select Add MCP server (or Add a server).
- Enter
One Brainas the Server name andhttps://api.useonebrain.com/mcpas the HTTP URL. Keep Authentication type on OAuth with automatic credentials, not Manual credentials: Cloudflare registers itself with One Brain. - Add Access policies for who may see the server in a portal.
- Select Save and connect server, then Continue under Authentication required, and sign in to One Brain. That account is the server’s admin credential, which Cloudflare uses to list its tools. Wait until the server is Ready.
- Select Add server portal, name it, pick a domain, and add the One Brain server. Keep Require user auth on, so each user signs in to One Brain and sees only what they may see. With it off, every portal user gets the admin account’s access.
- (Optional) Under the portal’s servers, select the value in Tools authorized and turn off
writeandforgetif the portal’s users should only read and remember. - Add Access policies for who may use the portal, and select Save portal. MCP clients connect at
https://<subdomain>.<domain>/mcp.
The Workers AI Playground.
- Open the Workers AI Playground and stay in its Model mode.
- Select Custom MCP, then Add server. Enter
https://api.useonebrain.com/mcpas the Server URL and select Add server. - The server shows Authenticating until you sign in to One Brain in the window that opens.
One Brain’s tools are then listed, and the model in the chat can use them.
With code: the package.
For an agent you build with the Agents SDK, on Think or AIChatAgent. It runs in Workers with no node: imports. It gives the agent:
- Skills: your One Brain skills join the agent’s skill catalog (
activate_skill,read_skill_resource). - Recall and memory: a context block.
search_contextsearches One Brain, and its results are marked as One Brain data with their path or memory id.set_contextsaves a One Brain memory. - Capture: each finished turn goes to One Brain as a session, so its learning loop can propose improvements to your files.
npm install @useonebrain/cloudflare agents @cloudflare/think ai zod just-bashPut the agent key in the Worker’s ONEBRAIN_API_KEY secret, and the API’s address in ONEBRAIN_URL if you do not use the hosted One Brain. Think imports just-bash, so the Worker does not bundle without it.
import { Think, type ChatResponseResult } from '@cloudflare/think';
import { captureTurn, onebrainContext, onebrainSkills } from '@useonebrain/cloudflare';
export class Assistant extends Think<Env> {
getModel() {
return '@cf/deepseek-ai/deepseek-v4.1-flash-1017';
}
getSkills() {
return [onebrainSkills({ env: this.env })];
}
configureContext() {
return [onebrainContext({ env: this.env })];
}
onChatResponse(result: ChatResponseResult) {
this.ctx.waitUntil(captureTurn(this, result, { env: this.env }));
}
}Capture is on. After each finished turn, that turn’s messages go to One Brain as a session with the ref cloudflare:<agent name>#turn-<n>: the user’s and the assistant’s text, and the tool calls with their results. Skill contents and file data are left out. Each turn is sent once. Remove the onChatResponse line, or pass capture: false, to turn it off. A workspace agent key has no private space: give the agent a folder, or set a capture folder on the workspace.
MCP from code
addOneBrain(this, { env: this.env }) in onStart connects One Brain’s MCP server with the key, and withOneBrainApprovals() makes write and forget wait for the user:
import { Think } from '@cloudflare/think';
import { addOneBrain, withOneBrainApprovals } from '@useonebrain/cloudflare';
export class Assistant extends Think<Env> {
includeMcpTools = false; // added below, with approvals
waitForMcpConnections = true;
override async onStart() {
await addOneBrain(this, { env: this.env });
}
getTools() {
return withOneBrainApprovals(this.mcp.getAITools());
}
}The Agents SDK stores an MCP server’s headers, and so the key, in plain text in the Durable Object’s SQLite storage. addOneBrain(this, { oauth: true }) stores no key: each person signs in to One Brain.
Every option, AIChatAgent and the AI SDK on their own: the package README.
The template.
A whole agent: Think on Workers AI, with One Brain’s skills, recall, memory and capture, a chat page, and a token so only your callers reach your One Brain key.
npm create cloudflare@latest -- --template https://github.com/Ken-Technology/onebrain-cli/templates/cloudflareGive every person and agent the same brain.
$25 a seat at launch. 14 days free, no card.