context-kernel

context-kernel

Enables Claude to pull curated context from self-hosted Markdown files via a remote MCP connector, with an append-only journal for agent notes manually promoted by the owner.

Category
访问服务器

README

🧠 context-kernel

Self-hostable context memory for LLMs. Keep your professional context, preferences, and evolving knowledge in sync across Claude Code, Desktop, and chat—without re-pasting or semantic drift.


A lightweight, opinionated context memory built on Cloudflare Workers and KV. You curate Markdown files about yourself, your work, and your preferences. A Worker serves them to Claude (Claude Code, Desktop, chat) over a secure remote MCP connector. Agents extend the memory via an append-only journal—but only you decide what becomes permanent.

What it solves

Running agentic sessions across machines? Stop re-pasting:

  • Who you are and what you do
  • Your communication style and output preferences
  • How you want figures rendered
  • Evolving project status, goals, and constraints

Context-kernel puts this in one place you control, reachable everywhere Claude runs. Claude pulls it automatically; you never paste again.


Why not vector-memory tools?

Existing personal LLM memory systems (mem0, OpenMemory MCP) use semantic search over extracted facts. They're comprehensive—but have a known failure mode:

  • Fact stored: "Prod runs Postgres 14"
  • Fact updates: "Prod now runs Postgres 16"
  • Both sit in the index. Similarity search hands back whichever scores higher—usually the older, reinforced one.
  • Result: outdated info looks authoritative.

context-kernel avoids this by design:

Feature context-kernel Vector-memory
Source of truth Hand-edited Markdown Extracted facts in index
Agent write access Append-only journal Often can edit directly
Stale data retirement Manual—you remove it Hopes retrieval rank decays
Semantic search No Yes
Self-maintenance Low High
Trustworthiness High (you control it) Variable (retrieval can fail)

Tradeoff: Less automatic, no semantic search—but the memory stays trustworthy because you maintain it.


Architecture

┌──────────────────────┐
│  content/*.md        │  ← Hand-curated (sacred, never auto-written)
│  (your source truth) │
└──────────────────────┘
           │
           v
┌──────────────────────────────────────────────────────┐
│                  npm run build                       │
│   Compile → Validate → KV bulk-upload artifact      │
└──────────────────────────────────────────────────────┘
           │
           v
┌──────────────────────────────────────────────────────┐
│  Cloudflare KV                                       │
│  • context:full:md     (whole context)              │
│  • section:<name>:md   (individual sections)        │
│  • journal:*           (append-only agent notes)    │
└──────────────────────────────────────────────────────┘
           │
           v
┌──────────────────────────────────────────────────────┐
│  Cloudflare Worker (Remote MCP Server)              │
│  📡 Token-gated, constant-time auth                 │
│                                                      │
│  Read Tools (READ_TOKEN):                           │
│  • get_context() → full context or section          │
│  • list_sections() → available topics               │
│  • get_meta() → metadata (timestamps, versions)     │
│                                                      │
│  Write Tools (WRITE_TOKEN):                         │
│  • append_journal(entry) → dated note               │
└──────────────────────────────────────────────────────┘
           │
           v
┌──────────────────────────────────────────────────────┐
│  Claude Code / Desktop / Chat                       │
│  Connects via MCP connector (auto-loads context)    │
└──────────────────────────────────────────────────────┘
           │
           v
┌──────────────────────────────────────────────────────┐
│  npm run promote                                     │
│  You review journal, cherry-pick what becomes      │
│  permanent in content/ (manual gate = no rot)       │
└──────────────────────────────────────────────────────┘

Key design principles

Manual promotion gate: Agents append to a disposable journal. You review and hand-promote what becomes curated. This is what keeps the memory from rotting—stale content is retired because you remove it, not by accident.

Two-token security model: Read token pulls context; write token appends to journal only. Give write token to servers/agents, read token to yourself. Read token never reaches write operations.

Markdown as source of truth: No vector embeddings, no fact extraction, no semantic search. You edit plain text, version it, deploy it. What you see is what agents know.

Security model

Aspect Detail
Token auth Every request authenticated before any data read
Read token Serves your context to Claude. Safe to embed in Claude Code config.
Write token Allows journal appends only. No read, no delete. Give to agents/servers.
Leaked write token Agent can leave poisoned notes—but manual promotion means it can't silently corrupt your curated context. You see it.
Leaked read token Attacker sees your context. Rotate immediately.
Token comparison Constant-time (no timing attacks).
Secrets storage Cloudflare Workers secrets (encrypted, never in repo). wrangler.toml and .dev.vars are git-ignored.

See SECURITY.md for the detailed threat model and incident reporting.


Quick start

Self-host on Cloudflare

You bring your own content/ (this repo ships only templates in content.example/).

npm install
cp wrangler.toml.example wrangler.toml     # fill in your Cloudflare KV namespace IDs + route

wrangler kv namespace create CONTEXT_KV
wrangler kv namespace create CONTEXT_KV --preview   # paste both into wrangler.toml
wrangler kv namespace create OAUTH_KV
wrangler kv namespace create OAUTH_KV --preview

wrangler secret put READ_TOKEN
wrangler secret put WRITE_TOKEN

cp -r content.example content               # edit content/*.md with your context

npm run build
wrangler kv bulk put artifacts/kv-bulk.json --binding CONTEXT_KV
wrangler deploy

Note your deployed Worker URL (e.g., https://my-context-kernel.myname.workers.dev/mcp).

Connect Claude Code

claude mcp add --transport http context-kernel \
  https://my-context-kernel.myname.workers.dev/mcp \
  --header "Authorization: Bearer <READ_TOKEN>"

Replace <READ_TOKEN> with your token. On session start, .claude/skills/context-kernel/SKILL.md auto-loads your context.

Known limitation: OAuth for claude.ai chat not yet working (library runtime incompatibility). Claude Code CLI (above) and local dev work fine with Bearer tokens.

Full deploy walkthrough

See HANDOFF.md §9 for step-by-step with local-dev setup.

Journal promotion (human review gate)

scripts/promote.ts (npm run promote) lets you review journal entries before promoting them into curated content/. Optional subagents:

  • .claude/agents/context-promoter.md — runs the promotion review
  • .claude/agents/mcp-tester.md — smoke-tests a deployed Worker

Prior art, and why not just use it

Personal memory layers for LLMs already exist and are more mature than this project. Worth naming honestly:

  • OpenMemory MCP (mem0): self-hostable, user-owned memory across MCP clients, with a dashboard, per-client ACLs, and audit logs.
  • mem0-mcp-selfhosted: self-hosted memory for Claude Code with an optional knowledge graph.
  • Claude Code's own Auto Memory / Session Memory: already extracts and carries forward notes and summaries between sessions, no extra infra required.

If the goal were only "stop re-pasting who I am," any of these would work today.

The reason this project exists anyway: those tools are vector-store-backed, they extract facts automatically and retrieve by semantic similarity. That design has a known failure mode, described plainly by one such tool's own author: self-hosting fixes where memory lives, it does not fix what happens when a stored fact stops being true. If an agent writes "prod runs on Postgres 14" and it later becomes 16, both rows sit in the store, and similarity search hands back whichever scores higher, usually the older, more-reinforced one. Nothing retracts a fact.

That failure mode maps directly onto how a research context actually changes: current projects, course load, and priorities shift term to term, and a system that quietly keeps surfacing last term's status alongside this term's is worse than no memory at all, because it looks authoritative.

context-kernel avoids this by construction, not by tuning:

  • The curated store is hand-edited Markdown, not extracted facts in a vector index. Nothing becomes "memory" without a human writing or approving the sentence.
  • Agents can only append to a disposable journal. They cannot edit curated context, so they cannot silently overwrite or contradict it.
  • Promotion is a manual, human-run step. Stale or superseded content is retired because the owner removes it, not because a retrieval score happened to favor the newer entry.

The tradeoff is honest: this is less automatic than a vector-memory tool, and it does not do semantic search over your history. It optimizes for the memory being trustworthy over it being self-maintaining.

Sections

profile, goals, current-work, resume, writing-prefs, figure-prefs, answer-prefs, skills, env-constants. Add only what an authorized Claude session should see; leave out contact-heavy details.

Repository hygiene

Committed: engine source, tests, artifact generator, promotion script, personal skill, subagent definitions, content.example/ templates, config example. Ignored: content/ (your real data), generated artifacts/, node_modules/, real wrangler.toml, .dev.vars, .promoted-ids.json (local promotion-review state).

License

MIT. See LICENSE.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选