Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
KHWAN_CORENoSelect an isolated core (brain). Defaults to the account's default core. The core must already exist.
KHWAN_USERNoIsolated sub-brain per end-user within a core (paid plans); sets the X-Khwan-User header.
KHWAN_API_KEYYesYour Khwan key from https://app.khwan.ai (kwk_live_...). It authenticates you to Khwan; it is not your model provider's key.
KHWAN_BASE_URLNoOverride the API base URL, e.g. http://127.0.0.1:8010 for a self-hosted engine.

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

This server publishes no instructions, or was last inspected before Glama recorded them.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": false
}
prompts
{
  "listChanged": false
}
resources
{
  "subscribe": false,
  "listChanged": false
}
experimental
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
khwan_prepareA

Pull the memory-enriched context for a turn BEFORE you answer.

Khwan builds context from memory + the brain's constitution + a coherence gate. No model is called. Ground your reply in the returned context and respect allowed/reason. Keep the returned turn_token and pass it to khwan_record after you answer.

Args: input: The user's message / the turn you are about to answer.

Returns: context: ready-to-use messages (memory + constitution) to ground your reply. coherence: optional float — how coherent this turn is with the brain (may be None). allowed: whether Khwan's coherence gate permits answering. reason: why, when not allowed (else None). turn_token: opaque token — pass it verbatim to khwan_record.

khwan_recordA

Hand your answer back to Khwan AFTER you reply, so it persists + learns.

Args: turn_token: the exact token returned by the matching khwan_prepare. answer: the answer you gave the user for that turn.

Returns: Khwan's record acknowledgement (persisted state / next-turn hints).

khwan_recallA

SEED a session/subagent with a COMPACT, bounded set of relevant memories.

The token-smart entry point for a caching host (Claude Code, Claude Desktop): call it ONCE at the start of a session or subagent — or when you need a fact that has scrolled out of context — NOT on every turn. It returns only the relevant facts (not Khwan's full prepared prompt), so you seed a fresh, bounded context instead of replaying a transcript. No model is called.

Two limits are worth knowing, because neither is this tool's to set:

  • Three facts is the ceiling. The server ranks a wider candidate pool and keeps its top three, so limit can only narrow that further, never widen it. Asking for more returns three.

  • A relevance floor applies, so an EMPTY facts is an answer. It means the brain has nothing close to this question — read it as "not known here", not as a failure. Do not retry with a reworded query hoping for more, and do not fill the gap with whichever fact happened to be nearest.

Lessons — what synthesis distilled from many turns — come back alongside the raw exchanges and LEAD the seed text: a rule earned over months outranks any single turn that happens to sit nearby in the index.

Args: query: the task or topic to recall memory for. Phrase it as the work you are about to do, not as a keyword — it is matched on meaning. limit: cap on facts returned, 1-3. The server's own ceiling is 3, so this can only lower it. Leave it alone unless you want fewer than three.

Returns: lessons: rules synthesis distilled from many past turns. facts: [{you_said, khwan_knows}] — the relevant remembered exchanges. count: how many facts were returned. seed_text: a ready-to-drop-in memory block for a subagent's brief ("" if none).

khwan_rememberA

Persist a durable fact/preference so FUTURE sessions can recall it.

A convenience over the prepare→record loop for the common "just remember this" case: it stores fact in the brain (no model call) so it outlives this session's context window and is available to the next khwan_recall.

Reach for this the moment you are corrected. A user rejecting your work, or telling you how they want it done, is the most durable thing a session produces and the easiest to lose — you fix the thing, the session ends, and the next one makes the same mistake. If the user is telling you something for the second time, the first time should have been stored here.

Write the standing RULE, not the utterance. "Deploys go to staging first, never straight to production" survives into a session that never saw the conversation; "no, not like that" does not.

Args: fact: the durable rule/preference to store, phrased to stand alone.

Returns: stored: whether the fact was persisted; reason when not.

khwan_memoryA

Inspect what this brain currently remembers, newest first.

A DEBUGGING window on the brain, not a way to seed a session. It returns recent entries in time order and ignores what you are working on, so it answers "is anything in here / did that write land" — not "what is relevant to this task". For the latter use khwan_recall, which ranks by meaning and returns a bounded set. No model is called.

Reach for it when a recall came back empty and you want to know whether the brain is empty or merely has nothing close, when confirming a khwan_remember persisted, or when the user asks what Khwan knows.

Args: limit: max entries to return, newest first (default 20).

Returns: The brain's recent memory entries, in the order they were written.

khwan_coresA

List the isolated cores (brains) available on this account.

Each core is a fully isolated brain (own memory/identity/learning). Select one for the session via the KHWAN_CORE environment variable.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/khwanlabs/khwan-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server