khwan-mcp
Give Claude a memory that learns. An MCP server that plugs Khwan — a pure AI-memory layer — into Claude Code, Claude Desktop, or any MCP client.
Khwan never runs a model. The client is the model. In Claude Code that means Claude itself is the "your model" step of Khwan's only loop:
khwan_prepare(input) → Claude answers (grounded in memory) → khwan_record(answer)
Each turn is persisted and distilled into lessons, so the next prepare is
sharper. One account can hold many isolated cores (brains), and — on paid
plans — an isolated sub-brain per end-user.
Install
pip install khwan-mcp # or: uvx khwan-mcp
Connect to Claude Code
claude mcp add khwan \
-e KHWAN_API_KEY=kwk_live_xxx \
-e KHWAN_CORE=default \
-- khwan-mcp
Then, in a session, ask Claude to remember something — it will call
khwan_prepare before answering and khwan_record after. The server's
instructions tell Claude to run the loop; you can reinforce it in your project's
CLAUDE.md ("always call khwan_prepare before answering, khwan_record
after").
Connect to Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"khwan": {
"command": "khwan-mcp",
"env": {
"KHWAN_API_KEY": "kwk_live_xxx",
"KHWAN_CORE": "default"
}
}
}
}
Configuration (environment)
| Var | Required | Purpose |
|---|---|---|
KHWAN_API_KEY |
yes | Your key from the Khwan dashboard (kwk_live_…). |
KHWAN_CORE |
no | Select an isolated core/brain (default: the account's default core). |
KHWAN_USER |
no | Isolated sub-brain per end-user (paid); sets X-Khwan-User. |
KHWAN_BASE_URL |
no | Override the API base — e.g. http://127.0.0.1:8010 for a local engine. |
Tools
| Tool | When |
|---|---|
khwan_prepare(input) |
before answering — returns memory context + a turn_token. |
khwan_record(turn_token, answer) |
after answering — persists the turn so Khwan learns. |
khwan_memory(limit=20) |
inspect what the brain currently remembers. |
khwan_cores() |
list the isolated cores on the account. |
Pass the exact turn_token from khwan_prepare back into khwan_record — it
ties the answer to the right turn.
Always-on memory (Claude Code hooks)
The tools above are called when Claude decides to. For deterministic
memory on every turn — 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. Run either approach, or both.
License
Proprietary — © Khwan Labs.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file khwan_mcp-0.1.0.tar.gz.
File metadata
- Download URL: khwan_mcp-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea41c83abb4bee8f1e0814273262fd5a1569274230cd0d6d2ba1cd65620b7389
|
|
| MD5 |
acdabc3d89196d63e8d9b67598509226
|
|
| BLAKE2b-256 |
7668bb0da1b7bcdfc8f5819fd6930d99b714c6c1b2fc71f9fab9452b8188c22f
|
File details
Details for the file khwan_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: khwan_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1ebfc0bdec4eb1cd69aeaf0a632ae11e0a2df69087066784c1d5609b8a74952
|
|
| MD5 |
7538f9c83885aeb0b4ff973342bb368e
|
|
| BLAKE2b-256 |
844eb8bd15ff8ae4b1da22699f78f17c7d7f6b4f0a3ae426f313a9172d4e98e6
|