Khwan
ai.khwan由 khwan.ai 发布官方发布者v0.3.12更新于 Oct 24, 2026
Durable AI memory: recall distilled facts in a later session or subagent, and remember new ones.
概览
为助手提供持久 AI 记忆:可在之后的会话或子代理中召回提炼过的事实,并记住新的持久事实。
- 可以做什么
- Khwan 是一个记忆层,把提炼后的事实持久保存,让之后的会话或子代理直接召回,而不必重放旧对话记录。工具包括 khwan_recall(用合成的经验教训和最多三条相关事实为会话播种)、khwan_remember(保存持久事实或偏好)、khwan_prepare 与 khwan_record(供自定义代理使用的完整逐轮循环)、khwan_memory(查看当前记忆内容)和 khwan_cores(列出相互隔离的大脑)。记忆按 core 和子大脑完全隔离,一个账号可容纳多个独立大脑。
- 适用场景
- 当工作跨会话、跨项目或跨子代理,且希望决策、偏好和经验教训自动延续、无需重读长对话记录时使用。它面向 Claude Code、Claude Desktop 等客户端;在单个带缓存的会话内它只会增加 token 而不会节省,因此推荐做法是开始时播种一次、并记住持久事实。
- 运行要求
- 需要 Khwan 账号和 API 密钥,通过 KHWAN_API_KEY 提供(来自 Khwan 控制台的 kwk_live_ 值),这不是模型提供商的密钥。可作为远程端点使用,也可通过 khwan-mcp 的 PyPI 包在本地运行(pip install 或 uvx)。可选设置:KHWAN_CORE、KHWAN_USER、KHWAN_BASE_URL。需要访问 Khwan 服务的网络连接。
安装
在 SourceWeft 中
- 打开 控制台中的 Khwan,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Web executable,通过 Streamable HTTP。 远程服务在工作区中配置后即可从网页运行时运行。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
khwan-mcp
Durable memory that survives the session. An MCP server that plugs Khwan — a pure AI-memory layer — into Claude Code, Claude Desktop, or any MCP client.
Khwan never runs your model. The client is the model. Its job is to persist and distil what matters into a brain you can recall in a later session or seed a subagent with — a compact, bounded set of facts instead of a replayed transcript. One account can hold many isolated cores (brains), and — on paid plans — an isolated sub-brain per end-user.
Nothing on the read or write path costs you an inference call: khwan_recall and
khwan_remember make none. Khwan does run one model of its own, on a schedule —
a nightly pass that distils stored turns into standing lessons. A real production
run was 8 brains and 245 stored turns distilled into 11 lessons, for $0.0094.
That pass is Khwan's cost, not yours, and it is the whole difference from memory
layers that compress, graph, or consolidate on every turn.
How it saves tokens (and where it doesn't)
Be honest about the mechanism — an MCP adds to a host's context, it cannot replace the transcript the host already sends. So:
- Within one hot session, it does not save tokens. Claude Code caches its growing history (cache reads ≈ 0.1×), so re-injecting memory every turn only adds. Don't do that here.
- Across sessions and subagents, it does. A cache dies in minutes; a session ends. Khwan persists distilled facts so the next run recalls them cheaply — no cold-replay of an old transcript, and facts that already scrolled out of context are retrievable again.
The token-smart pattern: seed once, remember durable facts (below), rather
than running the full loop on every turn of a caching host. The full
prepare → record loop still shines in a custom agent on a non-caching host,
where replacing history with distilled memory bounds per-turn cost directly.
Install
Connect to Claude Code
--scope project writes .mcp.json into the repo, so the setting travels with
the project. Note what is not in that command: the key.
Keeping the key out of the repo
claude mcp add -e KHWAN_API_KEY=… writes the literal value into .mcp.json —
a file whose whole point is being committed. Two ways to avoid that, and the
second is the one that works everywhere:
Shell environment. Leave KHWAN_API_KEY out of the config entirely and
export it in the shell that launches claude. The server inherits it.
A launcher (works in the desktop app too). A desktop app is started from a dock or menu, not a login shell, so it inherits none of your shell exports and the approach above silently yields no key. Read it from a file instead:
Then point the config at the launcher and keep only non-secret settings inline:
.mcp.json is now safe to commit, and every new repo costs two lines instead of
a pasted key. Anyone else on the team writes their own ~/.khwan/env.
One brain per project
Memory is only useful if the right project's memory comes back. Two axes, and both give complete isolation:
A sub-brain is a full separate brain, not a filter: account::@web shares
nothing with account::@api. So the two axes multiply, and a free account
already holds four isolated brains — the core on its own, plus three
sub-brains:
Which means one-brain-per-project works on the free plan, for up to four
projects — and it needs no KHWAN_CORE at all:
Named cores are the paid axis. Reach for one when four brains stop being enough, or when you want them grouped per client rather than per repository:
Two things to know before you point KHWAN_CORE anywhere. A core must exist
first — an unknown slug answers 404, not "created it for you" — and they are
created in the dashboard. On the free plan there is nothing to point at: the
cap of one is spent on default, so creating a named core answers 402. Leave
KHWAN_CORE unset there and use KHWAN_USER. Sub-brains, by contrast, are
created on first write.
Recommended pattern (token-smart)
On a caching host like Claude Code, prefer seed + remember over the per-turn loop:
- Seed at the start of a session or subagent:
"Call
khwan_recall(query="<the task>")and use the returnedseed_textas context." - Remember durable facts as they emerge:
"That's a standing decision — call
khwan_remember(fact="…")."
Reinforce it in your project's CLAUDE.md, e.g.:
Seeding a subagent is where the win is clearest — hand it a bounded brief instead of the whole transcript:
"Recall deploy memory with
khwan_recall(query="deploy runbook"), then spawn a subagent whose brief is thatseed_textplus the task."
Connect to Claude Desktop
Claude Desktop and Claude Code keep separate MCP configuration — a server
added to one is invisible to the other, and claude mcp add does not touch this
file. Add to claude_desktop_config.json:
Use an absolute path: a desktop app does not get your shell's PATH either, so
a bare khwan-mcp may not resolve. One core is selected for the whole app —
there is no per-project switch here, so choose a broad one.
Configuration (environment)
Tools
khwan_recall / khwan_remember are the token-smart pair for a caching host;
khwan_prepare / khwan_record are the full loop for custom agents (pass the
exact turn_token from prepare back into record).
What comes back, and what an empty answer means
khwan_recall returns at most three facts — that ceiling is the server's,
so limit can lower it but not raise it — plus any lessons synthesis has
distilled from many past turns. Lessons lead the seed_text: a rule earned over
months outranks a single turn that happens to sit nearby in the index.
Retrieval applies a relevance floor, so an empty facts is an answer: the
brain has nothing close to this question. Read it as "not known here" rather than
as a failure, and do not fill the gap by leaning on whichever fact was nearest.
The floor is deliberately loose, because a memory wrongly dropped is invisible while a memory wrongly kept is not. Expect a returned fact to be plausibly related, not certainly relevant — read it before relying on it.
Seeding a brain from work you have already done
A new brain knows nothing, so its first weeks of recall are thin — while the
answers are often already sitting in the host's own transcripts, unread.
examples/backfill/ replays Claude Code transcripts into a
brain: deterministic, no model calls, dry-run by default.
Always-on memory (Claude Code hooks)
The tools above are called when Claude decides to. For deterministic memory
— no reliance on the model — use the hook preset in
examples/claude-code-hooks/: a UserPromptSubmit
hook injects memory on every prompt and a Stop hook records every answer.
⚠️ On a caching host this is the thorough option, not the cheap one — it adds per-turn tokens. Prefer it when recall reliability matters more than token cost (or on a non-caching client); otherwise use
khwan_recallat session start.
Source
github.com/khwanlabs/khwan-mcp — this server runs on your machine, with your key, reading what you type. Read it before you install it.
License
MIT — © Khwan Labs. See LICENSE.
来源:README.md,提交 b136474
工具
0版本历史
1- v0.3.12最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通必需25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式必需10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分