Context Layer
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Context Layer
One memory for every AI agent.
A self-hostable, remote MCP server that gives every agent you use (Claude, Claude Code, Cursor, ChatGPT, …) the same durable memory about you. Vendor-independent. Your data, on your own Cloudflare account.
Hosted beta · Self-host · MCP tools · Contributing
Why
Every agent you use keeps its own notes about you, and none of them talk to each other. Switch from Claude to Cursor to ChatGPT and you start from zero each time. Context Layer is a single MCP endpoint that all of them connect to, so a lesson learned in one tool applies in every other.
Vendor-independent. Works with any MCP client via OAuth 2.1 or a personal token.
User-owned. Runs on your Cloudflare account. Export or delete everything at any time.
Agent-driven setup. Paste one line into any agent and it configures itself, modeled on Notion's agent setup prompt.
Durable, not just a scratchpad. Memories with supersede history, versioned Markdown documents, reusable skills, and "lessons" (mistakes an agent made with you and what to do instead).
Multi-user and isolated. Invite-only accounts, per-user vector namespaces, every query scoped by
user_id.
Related MCP server: clude-mcp
Quick start
Use the hosted version
The hosted instance is an invite-only beta. Join the waitlist at https://context-layer.winter-limit-1658.workers.dev. Once you have an account, paste this into any agent:
Set up my Personal Context Layer by following https://context-layer.winter-limit-1658.workers.dev/setupThe agent connects over MCP, installs custom instructions for when to read and write, creates an Agent Operating Guide, and optionally imports existing context.
Connect a client manually
Client type | How |
OAuth clients (Claude, Cursor, ChatGPT, …) | Add |
Header-only clients | Create a token under Settings → Tokens and send |
Claude Code |
|
Self-hosting
You need a Cloudflare account with Workers, D1, KV, Vectorize and Workers AI enabled (all available on the free tier).
git clone https://github.com/kuehlpaul/personal-context-layer.git
cd personal-context-layer
npm install
# 1. Create the resources and put their IDs into wrangler.jsonc
npx wrangler d1 create context-layer
npx wrangler kv namespace create OAUTH_KV
npx wrangler vectorize create context-layer --dimensions=1024 --metric=cosine
# 2. Set secrets
npx wrangler secret put SESSION_SECRET # openssl rand -hex 32
npx wrangler secret put CONSENT_SECRET # openssl rand -hex 32
npx wrangler secret put RESEND_API_KEY # optional, enables email sending
# 3. Migrate and deploy
npm run db:migrate:remote
npx wrangler deployThen set PUBLIC_URL and ADMIN_EMAIL in wrangler.jsonc, open https://<your-worker>/join and sign up with the admin email. The first signup with that address needs no invite code and becomes the admin account.
Configuration
Name | Where | Purpose |
|
| Public base URL of the Worker, no trailing slash |
|
| May sign up once without an invite and becomes admin |
|
| Workers AI model for embeddings, default |
|
| Optional sender for invite and reset emails |
| secret | Signs browser sessions |
| secret | Signs the OAuth consent step |
| secret | Optional. Without it, invite and reset links are shown in the admin panel to copy manually |
Upgrading an existing deployment
git pull
npm install
npm run db:migrate:remote
npx wrangler deployMigrations are additive. 0003 introduces accounts and tags pre-existing single-owner data as owner; the ADMIN_EMAIL account inherits it on first signup, re-embeds it into its own namespace, and existing OAuth grants keep working. The old OWNER_PASSWORD secret is no longer used and can be deleted.
How it works
┌───────────┐ ┌────────────┐ ┌────────┐ ┌─────────┐
│ Claude │ │ Claude Code│ │ Cursor │ │ ChatGPT │ … any MCP client
└─────┬─────┘ └──────┬─────┘ └───┬────┘ └────┬────┘
└───────────────┴────────────┴─────────────┘
│ OAuth 2.1 or pcl_… token
▼
┌───────────────────────┐
│ Cloudflare Worker │ /mcp · /setup · /ui · /admin
└──┬──────┬──────┬──────┘
│ │ │
┌──▼─┐ ┌──▼──┐ ┌─▼────────┐
│ D1 │ │ KV │ │Vectorize │ + Workers AI embeddings
└────┘ └─────┘ └──────────┘Concern | Implementation |
MCP endpoint | Worker with |
Auth |
|
Storage | D1 for accounts, waitlist, invites, memories, documents, skills, lessons, settings, activity |
Semantic search | Vectorize (one namespace per user) + Workers AI |
OAuth grants | KV |
Daily loop | Cron |
Routes
Path | Who | What |
| public | Landing page and waitlist form |
| public | The setup guide agents follow end to end (contains no personal data) |
| invited | Create an account with an invite code |
| users | Email + password sessions, password reset |
| users | Memories, documents, skills, lessons, settings (tokens, connected apps, export, delete account), activity |
| admins | Turn waitlist entries into invites, create or revoke invites, enable, disable or delete accounts |
| agents | MCP endpoint. Every token is bound to exactly one account |
MCP tools
Read
Tool | Description |
| Profile, operating guide, exclusions, active lessons, recent memories and documents, available skills. Call once per session. |
| Semantic + keyword search across memories, documents, skills and lessons |
| One memory by id, including source, dates and supersede history |
| Full Markdown of a document, optionally an older revision |
| Earlier versions of a document and who wrote them |
| Names of enabled skills, and the full instructions of one |
Write (requires scope mcp:write)
Tool | Description |
| Save one durable memory. Near-duplicates are detected and returned instead of saved |
| Edit in place, supersede (keeps history) or archive a memory |
| Permanently delete a memory and block the same content from coming back |
| Create or update a versioned Markdown document |
| Record what went wrong with this user and what every agent should do instead |
| Create or update a reusable |
| Update the short "About me" profile |
| Create or replace the Agent Operating Guide |
Security and access control
Waitlist entries grant nothing. An admin turns one into a single-use invite bound to that email (14 days). Free-form invites with N uses and an optional expiry exist too.
Accounts are isolated. Every table carries
user_id, every query insrc/store.tsfilters on it, and vectors live in a per-user Vectorize namespace.Disabling an account kills its sessions, tokens and OAuth grants immediately and is checked on every MCP request. Deleting removes all rows, vectors and grants. Changing a password signs out every other session.
Legacy grants from before accounts existed are bound once, at claim time, to the account that adopted the single-owner data, and never re-resolved from roles.
Independently audited for cross-account access on 2026-11-07. Findings were fixed in migration
0004and the matching code.
Found a vulnerability? Please open a private security advisory on GitHub instead of a public issue.
Development
npm install
cp .dev.vars.example .dev.vars # fill in the secrets
npm run db:migrate:local
npm run dev # http://localhost:8787Workers AI and Vectorize have no local emulation and need a remote connection (account_id in wrangler.jsonc). Without them, search falls back to keyword matching.
Script | What it does |
| Local Worker with hot reload |
|
|
| Regenerate |
| Apply D1 migrations |
| Deploy to Cloudflare |
Project layout
src/
index.ts Router, OAuth provider wiring, cron entry
mcp.ts MCP server and tool definitions
store.ts All D1 + Vectorize access, bound to one user
accounts.ts Users, passwords, sessions, waitlist, invites, personal tokens
auth.ts OAuth 2.1 server, token auth, login / join / reset pages
admin.ts Admin panel
ui.ts User-facing web app
setup.ts /setup guide content served to agents
setup-page.ts Docs-style HTML shell for /setup
landing.ts Public landing page and waitlist
daily.ts Daily maintenance report (cron)
html.ts Shared HTML helpers and layout
migrations/ D1 schema, applied in orderContributing
Issues and pull requests are welcome.
Fork the repo and create a branch from
main.Run
npm run typecheckbefore opening a PR.Schema changes go into a new numbered file in
migrations/. Never edit an applied migration.Anything that touches
src/store.tsmust keep filtering onuser_id.
For larger changes, open an issue first so we can discuss the approach.
License
MIT © 2026 Paul Kühl
This server cannot be deployed
Maintenance
Related MCP Connectors
Cloud-hosted MCP server for durable AI memory
Hosted memory for AI agents over MCP. One memory shared by all your agents.
Cloudflare Workers MCP server: agent-memory
An MCP memory server. One memory your agents share — across models, devices and apps.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceSelf-hosted MCP server giving AI agents persistent memory for personalization and context across conversations.152 PyPI282Apache 2.0
- AlicenseNot gradedqualityDmaintenanceA self-hosted MCP server that gives AI agents persistent, searchable memory with importance scoring, knowledge graphs, and autonomous memory consolidation.1MIT
- AlicenseNot gradedqualityCmaintenanceA self-hostable MCP server that provides permanent memory for AI agents using Postgres + pgvector for semantic search and Markdown file sync.5 npmMIT
- AlicenseNot gradedqualityBmaintenanceSelf-hosted MCP memory server with a web UI, enabling multiple AI agents to share and manage persistent memories over a single SQLite store via HTTP.14 npmMIT