Skip to main content
Glama
README.md
<p align="center">
  <a href="design/icons/"><img src="design/icons/linux/hicolor/scalable/apps/one-ai-memory.svg" width="168" alt="One AI Memory: an engraved squirrel on periwinkle"></a>
</p>

# One AI Memory

One memory for all your AI assistants: several Claude accounts, ChatGPT, Codex, Claude Code, Cursor, VS Code, Gemini and Antigravity.

It's a remote MCP server on **Cloudflare Workers**, with a **web interface** to read the memory and manage it from the browser, in English or Italian. The memory is a folder of **Markdown files in a private GitHub repository**: you can read it, edit it by hand and open it in Obsidian. Every change an AI makes becomes a commit that says which connection made it and from which app (for example "via: Claude work · Claude").

```
claude.ai (account 1) ─┐
claude.ai (account 2) ─┤                                  ┌─ private GitHub App (your account only)
ChatGPT ───────────────┼── OAuth ──▶ Worker /mcp ─────────┤
Codex, Cursor, … ──────┤                ▲                 └─ private memory repo (Markdown)
Claude Code ───────────┘                │
you, in the browser ────── session ──▶ Worker /  (web interface and /api)
```

## Install

You need a GitHub account and a Cloudflare account (the free plan is enough). You don't need to install anything on your computer or copy any tokens or keys.

1. **Press the button.**

   [![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/AndrianLeah/one-ai-memory)

   Cloudflare copies the project to your GitHub, creates the Worker and its storage, and publishes it. It asks you for one thing only: **your GitHub username** (`OWNER_GITHUB_LOGIN`). Only that account will be able to set up and open the memory.

2. **Open the Worker's address** (you'll find it at the end of the deploy; it ends in `.workers.dev`) and follow the guided setup. It has four steps:
   1. **Connect GitHub.** One click creates a private GitHub App, just for you: One AI Memory uses it to read and write the memory and to recognize you when you sign in. On GitHub, press "Create GitHub App", then "Authorize". The suggested name is `one-ai-memory-<your-username>`. App names are unique across all of GitHub: if that one is taken, change it on the GitHub page. Any name works.
   2. **Create the memory.** GitHub opens with a **private** repository already filled in: create it. Then install the app: choose "Only select repositories" and tick only the memory repository. If you pick "All repositories", the install is refused and the guided setup explains how to change it. The setup then puts four starter files in the repository. A public repository is refused: the memory must stay private.
   3. **Introduce yourself.** Your name, the language the assistants should reply in, what you do, and the rules that apply to every assistant: the setup writes them into `context.md`.
   4. **Connect your assistants.** Pick the apps you use: for each one you get the quickest way to connect it (see [below](#connect-your-assistants)).

**From your computer, instead of the button:** clone the repository and, with Node 22.18 or newer, run

```powershell
npm install
```

```powershell
npm run setup
```

The script asks for your GitHub username, has you sign in to Cloudflare in the browser, publishes the Worker and opens the guided setup.

<details>
<summary>Manual setup (advanced), without the guided setup</summary>

If you'd rather use your own OAuth App and *fine-grained* token, save them as Worker secrets. When `GITHUB_TOKEN`, `MEMORY_REPO` and `ALLOWED_GITHUB_USER_ID` are all set, the guided setup doesn't appear.

- An OAuth App on GitHub (Settings → Developer settings → OAuth Apps) with *Authorization callback URL* `https://<your-worker>/callback`.
- A *fine-grained* token with access to the memory repository only, and *Contents* set to read and write.
- The repository needs at least one commit, for example `context.md`: the starter files are in [`src/templates.ts`](src/templates.ts).

Save **all** the values as secrets, even the ones that aren't secret, like `MEMORY_REPO`. From the project folder, one at a time: the command asks for the value and saves it in the Worker.

```powershell
npx wrangler secret put GITHUB_TOKEN
```

| Secret | What it holds |
|---|---|
| `GITHUB_TOKEN` | The *fine-grained* token |
| `MEMORY_REPO` | The memory repository, for example `your-username/ai-memory` |
| `ALLOWED_GITHUB_USER_ID` | Your numeric ID: the `id` field of `https://api.github.com/users/<your-username>` |
| `GITHUB_CLIENT_ID`, `GITHUB_CLIENT_SECRET` | The OAuth App's *Client ID* and one of its *Client secrets* |
| `PUBLIC_URL` (optional) | The server's public address, if you want to pin it. Without it, the server uses the address you open it from |
| `MEMORY_BRANCH` (optional) | The memory's branch, if it isn't `main` |
| `PROTECTED_PATHS` (optional) | The files and folders protected at the start, separated by commas (for example `context.md, rules/`). Without it, only `context.md` is protected. You can change them later in Settings |

Why secrets and not variables: every `wrangler deploy` replaces the variables set in the Cloudflare dashboard with the ones in `wrangler.jsonc`, which only has `OWNER_GITHUB_LOGIN`. The variables vanish at the next deploy and the Worker goes back to the guided setup, without warning. Secrets stay.

**If you set them as variables** (as earlier versions of these instructions said), move them to secrets before the next deploy: copy the values, delete the variables from the dashboard (Workers & Pages → the Worker → Settings → Variables and secrets) and save them again with `npx wrangler secret put <NAME>`.

</details>

## Connect your assistants

In the interface, **Connections → Connect an assistant** sets up the connection for each app. The address is always `https://<your-worker>/mcp`. The first time, a consent page opens: give the connection a name you'll recognize (for example "Claude work"), choose whether it can also write, and sign in with GitHub.

| App | How |
|---|---|
| Claude (web, desktop app, phone) | A button opens Claude with the connector already filled in: press "Add". Once per account; Claude Code signed in with the same account finds it by itself |
| Cursor · Grok Build, VS Code (Copilot), LM Studio | A direct install button |
| Claude Code, Codex, Gemini CLI · Antigravity | A command to copy, the block for the configuration file, or a message to paste into the assistant so it sets itself up |
| ChatGPT | Guided steps: the full connection is available on the Business, Enterprise and Edu plans |
| Other apps with remote MCP and OAuth (Zed, Warp, Raycast, Devin…) | The address and the JSON configuration |

The rules already come from the server. The one thing the server can't guarantee is that the assistant calls `memory_context` at the start: to make that more reliable, the same page gives you a line to add to the preferences of each account or app.

## The web interface

Open the Worker's address in the browser, even on your phone, and sign in with GitHub: only your account gets in. It has a light and a dark theme, and comes in English or Italian.

- **Memory**: the library of notes and the open note, with the Markdown already formatted. Rules show up as cards with "When" and "Why", and next to the note you see its outline and who wrote it, taken from the git history. From here you edit, create and delete notes; <kbd>Ctrl</kbd> <kbd>K</kbd> searches the whole memory.
- **Proposals**: the rules the assistants propose. When you approve one, the rule goes into the rules section of its file (in `context.md`, under "Global rules") and the proposal is removed from the proposals file; you can edit its wording first. Every decision you make here becomes a commit ("Proposal approved: …" or "Proposal discarded: …") and shows up in the Approved and Discarded tabs; decisions made by hand outside the interface don't show up.
- **Connections**: every connected assistant, with the name you gave it, its permissions, its last use and its activity over the last two weeks. From here you revoke a connection or connect a new one.
- **Settings**: the protected files and folders and the sensitive-data check, which apply to the assistants right away; the interface's theme and language, which apply to that browser; the memory repository and GitHub access, shown for reference (the app's access renews by itself).

From the interface you write as yourself, under your GitHub name: you can edit protected files too (the protection is for AIs), and every change becomes a commit marked "via: <your-username> · web".

## The same for every AI

The memory doesn't depend on any client: Claude, ChatGPT, Gemini and Codex get the same rules, in the same way.

- **The rules of use are in the result of `memory_context`**, the first tool every assistant calls: where the global and project rules are, how to save, what not to touch. Not every client passes an MCP server's system instructions to the model, but they all pass on a tool's result.
- **The tool descriptions stand on their own** and name the protected files.
- **The server enforces the limits**, not the model's good will: protected files, version control, secrets, paths. An AI that ignores the instructions still gets a refusal.
- **The content is plain Markdown**, with standard links and no syntax tied to a specific app.

## Global rules and project rules

- **Global rules** live in `context.md`: every assistant gets them at the start, with `memory_context`.
- **Project rules** live in the "Project rules" section of each project file (`projects/<name>.md`, or `progetti/<nome>.md` in an Italian memory): whoever works on that project reads them.
- Each rule says when it applies and why, so it doesn't get applied where it doesn't belong.
- **Only you edit `context.md`.** The server refuses changes from AIs (variants like `Context.md` included). AIs propose new rules in the proposals file (`proposals.md`, or `proposte.md` in an Italian memory), and `memory_context` shows how many are waiting for your review. You approve or discard them on the **Proposals** page, or by hand from GitHub, Obsidian or a local clone.
- **You decide which files are protected, on the Settings page.** At the start only `context.md` is protected. You can protect other files or folders (for example `rules/`) or remove a protection, even the one on `context.md`: then connections with edit permission can change it, and the interface asks you to confirm first.

## What the assistants can do

| Tool | What it does |
|---|---|
| `memory_context` | Loads the memory's rules of use, `context.md` (who you are, global rules, map) and the index of all files |
| `memory_search` | Searches for words, ignoring case and accents |
| `memory_read` | Reads a file and its *version* |
| `memory_history` | Latest changes: when, why, from which connection |
| `memory_write` | Creates or replaces a file. Replacing one needs the *version* read earlier, so one AI doesn't wipe out another's work |
| `memory_append` | Adds to the end of a file, with the date and the connection's name (logs, journal) |
| `memory_delete` | Deletes a file (it can still be recovered from the git history) |

The write tools only show up in connections you allowed to edit, and they can't touch protected files.

## Security

- **One user only.** Only the GitHub account named during the deploy can set up the memory, and the app the setup creates must belong to it. From then on, only that account's numeric ID is accepted, and it doesn't change even if you rename the account. Every setup step either needs you to be signed in or checks with GitHub (signing with the app's key) that the installation is yours.
- **A GitHub App with the bare minimum.** The app the setup creates is private and must be installed only on the memory repository, with "Only select repositories": an install on "All repositories" is refused. To do its work, the server asks GitHub for tokens that last one hour, signed with the app's key and limited to the memory repository: they can read and write files (*Contents*) and read metadata, nothing else. There's no personal token to renew. The app's key and secret stay in Cloudflare's KV, which Cloudflare encrypts at rest: anyone with access to your Cloudflare account could read them, as with any Worker secret.
- **The memory stays private.** The setup refuses public repositories.
- **Consent for every app.** Every new connection shows a consent page with the app's name, where the tokens will go, the name you give the connection and the permissions (read only, or read and write). The consent page, cookies and `state` are handled by [`@cloudflare/workers-oauth-provider`](https://github.com/cloudflare/workers-oauth-provider), Cloudflare's official library, with the protections the MCP specification asks for: no framing, a form that can't be forged, `state` tied to the browser, PKCE.
- **The sign-in token isn't kept.** It's only used to read your ID, and it's revoked right away.
- **Encrypted tokens.** In Cloudflare's KV, connection tokens are stored only as hashes, and the data each token carries is encrypted. What stays readable is your GitHub ID and what the Connections page needs: the names of the connection and of the app, the permissions, the last use and the day-by-day activity.
- **Protected global rules.** As long as `context.md` stays among the protected paths (it is at the start), no connection can change or delete it, and the same goes for the other protected paths: one AI can't change the rules for all the others.
- **A locked-down web interface.** The session is a random identifier in an `HttpOnly`, `Secure`, `SameSite=Strict` cookie; only its hash is kept in the KV, and the account is checked again on every request. Changes are accepted only when they come from the app itself. Notes written by AIs can't run code: HTML inside the Markdown is never interpreted, and a strict Content Security Policy blocks scripts and external images.
- **No sensitive data in the memory**, so that if the repository were ever breached, nothing sensitive would leak. The content exists in plain text in two places: the GitHub repository and the cache in Cloudflare's KV. The server refuses writes that contain passwords, API keys, tokens, private keys, card numbers, IBANs or Italian tax codes. Cards, IBANs and tax codes are verified with their checksums, to avoid false alarms. Free-form sensitive data (health, private details about other people) can't be recognized reliably: the rule every assistant gets from `memory_context` and from the tool descriptions forbids it. The filter applies to future writes; what's already in the git history stays there.
- **You have the last word.** When the filter blocks a write, the AI must tell you what it found and why it's risky. If you insist, it can retry the write with `allow_sensitive: true`. The commit records "Sensitive-data check overridden at the user's request" and the kind of data, so every exception leaves a trace. The same check applies when you write from the interface, which warns you and saves only if you confirm; the commit then records "Sensitive-data check overridden by the owner". You can also turn the check off in Settings: writes that would have triggered it are still marked in the commit ("Sensitive-data check disabled in settings"). Settings lists the exceptions from the last 100 changes.
- **Checked paths.** Only `.md` files are allowed, with no `..`, no hidden folders, and a limit of 200 KB per file.
- **Few dependencies**, all pinned to exact versions. The server uses the official MCP SDK, Cloudflare's OAuth library, `zod` and `@cfworker/json-schema`. The interface uses React, `react-markdown` with `remark-gfm`, the `lucide-react` icons and the Geist and Newsreader fonts, bundled with the app instead of loaded from Google.

## Revoke access

- **One connection:** on the **Connections** page, press *Revoke*: the assistant loses access right away. You can also remove the connector from the app. Tokens that aren't used expire after 90 days.
- **The web interface:** *Sign out* in your account menu ends the session in that browser. Sessions last 30 days.
- **Everything, right now:** on GitHub, in Settings → Applications → Installed GitHub Apps, suspend or uninstall the memory's app: nobody will be able to read or write it any more.
- **Start over:** on GitHub, delete the app (Settings → Developer settings → GitHub Apps → the app → Advanced → Delete GitHub App), then open the Worker's address again. The server notices, and the guided setup starts again from step 1. Your notes stay in the repository: in step 2 you can give the new app the same repository, and nothing in it is overwritten.

  Or you can reset the setup by hand, from the project folder, and then open the address again:

  ```powershell
  npx wrangler kv key delete install:v1 --binding OAUTH_KV --remote
  ```

  If the old app still exists, its name is already taken: give the new app another name, or delete the old one first.

## Languages

The interface is available in English and Italian: you pick the language during setup, on the sign-in page and in Settings. The memory's starter notes also come in the language you pick during setup (`proposals.md` or `proposte.md`, `projects/` or `progetti/`), and the server understands both. Adding another language is easy: the texts are files in the project, and [CONTRIBUTING.md](CONTRIBUTING.md) explains how.

## Development

```powershell
npm run check
```

The command type-checks the server and the interface, runs all the tests (unit tests, end-to-end tests with a real MCP client, and tests of the interface's API and of the guided setup, always against a simulated GitHub that also plays the part of the GitHub App), builds the interface, and builds the Worker in *dry run* mode.

To see the interface with sample notes, proposals and connections, with no account and no secrets:

```powershell
npm run demo
```

then open `http://localhost:8790/login`: the demo skips GitHub and signs you straight in. You can see each step of the guided setup at `http://localhost:8790/api/demo/setup/<step>` (`github`, `signin`, `repo`, `public`, `choose`, `profile`, `connect`); `http://localhost:8790/api/demo/app` takes you back to the app. Everything lives in memory and resets on every restart.

To try the MCP server in Cloudflare's real runtime, still with no account, open two terminals:

```powershell
npm run smoke:worker
```

```powershell
npm run smoke:client
```

To try the real setup locally, create a `.dev.vars` file with `OWNER_GITHUB_LOGIN=<your-username>` and run `npm run dev` (it builds the interface and starts the Worker at `http://localhost:8787`): the guided setup creates a separate GitHub App, only for the local address, named `one-ai-memory-local-<your-username>`. While you work on the interface, `npm run dev:web` in a second terminal serves it at `http://localhost:5173` with live reload and passes everything else to the Worker. After signing in with GitHub you land on `http://localhost:8787`: open `http://localhost:5173` again; the session works there too.

### How it works

- `src/index.ts`: sets up OAuth and routes the requests. `/mcp` is protected by OAuth; the OAuth library handles `/oauth/` and `/.well-known/`; `/api/setup` and `/setup/` go to `setup.ts`; `/authorize` goes to `auth.ts`; `/callback` to `auth.ts` or to `web.ts`, depending on the web sign-in cookie; `/login` and `/api/` to `web.ts`; everything else is served from the interface's files.
- `src/config.ts`: where the configuration comes from (the guided setup, saved in the KV, or the manual setup's secrets), and the GitHub App's tokens, reused while they're valid.
- `src/githubapp.ts`: the GitHub App created in one click from its *manifest*, the RS256 signing of the app's JWTs, and the installation tokens.
- `src/setup.ts`, `src/templates.ts`: the steps of the guided setup and the memory's starter files, in English and Italian.
- `src/auth.ts`, `src/html.ts`: the consent page for connecting an assistant, and the account check.
- `src/signin.ts`: the GitHub sign-in, shared by the assistants and the web interface.
- `src/mcp.ts`: the *stateless* MCP endpoint (a new server for each request, JSON responses, no Durable Objects).
- `src/tools.ts`: the 7 tools, the rules of use that `memory_context` delivers, and the file protection.
- `src/web.ts`: the web interface's session and the API it uses (notes, search, history, proposals, connections, settings).
- `src/proposals.ts`: reads the proposals and puts approved rules in the right section, in both languages.
- `src/settings.ts`, `src/usage.ts`: the settings saved in the KV, and the last use of each connection.
- `src/i18n.ts`: the server's texts (consent page, errors, commits) in English and Italian.
- `src/store.ts`: reads the whole memory at the latest commit with a single download (tarball), caches it in the KV per commit, and writes through GitHub's Contents API with version control. The date and author of each file's last change come from GraphQL (one request per 200 files), also cached per commit.
- `src/guard.ts`: checks on paths, sizes and secrets.
- `web/`: the interface (React and Vite), with the translations in `web/src/i18n/` and the instructions for each app in `web/src/clients.ts`. The colors in `web/src/styles/tokens.css` come from the mockup's variables in `design/one-ai-memory-ui.figcraft`.

Limits: the memory is meant for a few thousand Markdown files. On the Workers free plan, the practical limit is the KV (1,000 writes a day), far above personal use. Writes to the KV come from:

- the cached copy of the memory, one per new commit (including commits made directly on GitHub), plus one for the files' dates when you open the library;
- the GitHub App's token, at most about once an hour;
- the last use, at most once every 10 minutes for each active connection;
- the OAuth library, when you connect an assistant and when the assistant renews its token (about once an hour while you use it);
- the web interface, two for each sign-in and one each time you save the settings, plus a few during setup.

## License

MIT: you can use, change and redistribute it freely, including for work, as long as you keep the copyright notice. The full text is in [LICENSE](LICENSE).