cairn-cloud
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.
cairn-cloud
跨 Agent 共享的长期记忆 MCP 服务(Cloudflare Workers + Durable Objects SQLite + 内置 Web 管理页),并 100% 兼容原版 cairn v1(同样的 5 个 MCP 工具、SQLite FTS5 + BM25 + CJK bigram 检索算法、版本历史与本地 cairn.db 双向迁移)。
适用客户端:CloudCLI、Claude Code、Codex、Grok、Cursor、Antigravity 及任意支持 Streamable HTTP 的 MCP 客户端。
特性
零外部数据库、免费可跑:基于 Cloudflare Workers Free + Durable Objects SQLite(单实例专属嵌入式 SQLite,原生支持 FTS5 + BM25 + 强一致同步事务,免费层每天 10 万请求 / 500 万行读 / 10 万行写 / 5 GB 存储)。
高质量中英混合检索:沿用 cairn v1 的 FTS5
porter unicode61+ CJK 二字词组(bigram)+ 驼峰词拆分 + 子串兜底策略,无需 Embedding API、无需向量库。双模式鉴权:支持
Authorization: Bearer <TOKEN>与X-API-Key: <TOKEN>,开箱兼容 CloudCLI UI 与全部主流 Coding Agent。内置 Web 管理页:同域名直接打开,用同一个
CAIRN_TOKEN登录(HttpOnly Cookie),支持 Markdown 渲染、搜索、按 Scope/归档筛选、新建/编辑、归档/恢复、查看完整版本历史、导入/导出 JSON、一键复制各客户端 MCP 配置,以及单条记忆公开只读分享(支持自定义过期时间、续期、永不过期、随时撤销与访问计数)。与原版 cairn v1 完全兼容:
MCP 工具名、参数、返回结构、乐观锁(
revision/REVISION_CONFLICT)与/cairnSkill 保持一致;支持直接运行
cairn-cloud serve挂载本地~/.cairn/cairn.db(同时获得 Web 管理页);提供
import-sqlite/export-sqlite命令,在本地 v1cairn.db与公网 Cloudflare DO 之间无损双向迁移(含完整id与memory_versions历史)。
Related MCP server: Zymor MCP Server
快速部署到 Cloudflare(单人自部署,约 2 分钟)
1. 安装依赖并登录 Cloudflare
npm install
npx wrangler login2. 部署 Worker(自动创建 SQLite Durable Object)
npm run deploy无需在 Cloudflare 后台提前创建数据库,
wrangler.jsonc中的migrations会在首次部署时自动初始化 SQLite-backed Durable Object。
3. 设置访问密钥 CAIRN_TOKEN
先生成一个高强度随机 Token(例如 openssl rand -hex 24),然后写入 Cloudflare Secret:
npx wrangler secret put CAIRN_TOKEN安全保护:未配置
CAIRN_TOKEN时,公网 Worker 会拒绝/mcp和/api/*请求(返回503),避免数据裸奔。
4. 打开 Web 管理页 & 绑定自定义域名(推荐)
浏览器访问
https://cairn-cloud.<your-subdomain>.workers.dev,输入刚设置的CAIRN_TOKEN登录即可管理记忆。国内直连
*.workers.dev可能不稳定,建议在 Cloudflare Dashboard → Workers & Pages →cairn-cloud→ Settings → Domains & Routes 中绑定自己的域名(例如https://cairn.example.com)。
接入各个 Agent(MCP)
公网 MCP 端点为 https://<你的域名>/mcp(Streamable HTTP),鉴权 Header 为 Authorization: Bearer <你的 CAIRN_TOKEN>(也兼容 X-API-Key: <你的 CAIRN_TOKEN>)。
方式一:一键安装脚本(自动配置各家 CLI + /cairn Skill)
export CAIRN_TOKEN="<你的 Token>"
node bin/cairn-cloud.mjs install \
--url https://cairn.example.com/mcp \
--token "$CAIRN_TOKEN" \
--dry-run # 确认无误后去掉 --dry-run 执行方式二:CloudCLI UI 手动添加
在 CloudCLI 的 Settings → MCP Servers 中新增 HTTP 服务:
Name: cairn
Transport: HTTP
URL: https://cairn.example.com/mcp
Headers:
Authorization=Bearer <你的 Token>给 Codex 配置时,也可以不在 Headers 里写明文,改为在 Bearer Token Environment Variable 填
CAIRN_TOKEN(并在运行环境中export CAIRN_TOKEN=...)。
方式三:各家命令行手动添加
# Claude Code
claude mcp add -s user --transport http cairn https://cairn.example.com/mcp \
--header "Authorization: Bearer $CAIRN_TOKEN"
# Codex
codex mcp add cairn --url https://cairn.example.com/mcp \
--bearer-token-env-var CAIRN_TOKEN
# Grok
grok mcp add -s user --transport http cairn https://cairn.example.com/mcp \
-H "Authorization: Bearer $CAIRN_TOKEN"Cursor(~/.cursor/mcp.json)与 Antigravity(~/.gemini/config/mcp_config.json,键名用 serverUrl):
{
"mcpServers": {
"cairn": {
"url": "https://cairn.example.com/mcp",
"headers": {
"Authorization": "Bearer <YOUR_CAIRN_TOKEN>"
}
}
}
}兼容旧版 cairn v1 与数据迁移
把本地 ~/.cairn/cairn.db 一键迁移到公网
# replace 模式会原样保留 #1, #2... 编号和全部修订历史(适合首次迁移)
node --disable-warning=ExperimentalWarning bin/cairn-cloud.mjs import-sqlite \
~/.cairn/cairn.db \
--url https://cairn.example.com \
--token "$CAIRN_TOKEN" \
--mode replace如果公网库已有数据,改用 --mode merge(自动跳过标题/范围/正文完全重复的条目)。
把公网数据拉回本地(生成兼容 v1 的 SQLite 文件)
node --disable-warning=ExperimentalWarning bin/cairn-cloud.mjs export-sqlite \
./cairn-backup.db \
--url https://cairn.example.com \
--token "$CAIRN_TOKEN"本地直接运行(带 Web 管理页,兼容旧版 SQLite 文件)
无需部署 Cloudflare 也能在本地直接跑(依赖 Node.js 22.13+,零 npm 运行时依赖):
# 不设 CAIRN_TOKEN 时默认仅监听 127.0.0.1(兼容原版免鉴权本地模式)
npm run serve -- --db ~/.cairn/cairn.db --port 7841
# 浏览器打开 http://127.0.0.1:7841本地调试 Cloudflare Workers 运行时:
cp .dev.vars.example .dev.vars
npm run dev目录结构
src/
core/
text.mjs # CJK bigram / Porter stem / camelCase / snippet 算法(兼容 v1)
store.mjs # 存储无关核心逻辑(CRUD、FTS5 BM25、版本历史、快照导入导出)
mcp.mjs # 5 工具 MCP Streamable HTTP 处理器(search/get/save/update/archive)
auth.mjs # Bearer / X-API-Key / Web Cookie (HMAC-SHA256) 鉴权
http-app.mjs # Fetch API 统一路由(Workers 与 Node 共用)
drivers/
do-sqlite.mjs # Cloudflare Durable Objects SQLite 驱动
node-sqlite.mjs # Node.js 22 node:sqlite 驱动
worker.mjs # Cloudflare Worker 入口 + CairnVault Durable Object
node-server.mjs # 本地 Node HTTP 服务器
migrate.mjs # v1 SQLite <-> JSON 快照双向转换
install.mjs # 各 Agent MCP + Skill 安装器
public/ # 零构建 Web 管理页(HTML/CSS/JS)
bin/cairn-cloud.mjs # CLI 工具
skill/SKILL.md # /cairn Agent Skill
test/ # 单元测试与端到端测试运行测试
npm testLicense
MIT © wizyoung
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Shared persistent memory for AI agents to read, verify, continue, and connect knowledge.
Shared Markdown memory for your agents: docs, typed collections, files, skills and Dispatch.
Shared memory for your AI agents. Every fact shows its source, and stale facts get replaced.
A second brain for your AI agent. Shared memory for your team's AI agents, plus public and private knowledge bases — works with ChatGPT, Claude, Cursor and any MCP client.
Related MCP Servers
- AlicenseAqualityBmaintenanceDeterministic, Git-Native Knowledge Graph & Truth Maintenance Engine for AI Agents.53MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to write, search, browse, link, consolidate, and promote layered Markdown-backed memories with SQLite FTS5 indexing, rule checks, and optional semantic retrieval across projects.1Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables agents to persist, search, and consolidate durable cross-session memory through a dual-vault SQLite/FTS5 store with hybrid reranking, retrieval gating, temporal relations, and Markdown wiki projection.MIT
- AlicenseBqualityBmaintenanceEnables AI agents to store and retrieve long-term memories in a local SQLite file, with multilingual search, optional semantic search, and controlled read/write access.41MIT