-
Notifications
You must be signed in to change notification settings - Fork 1
Configuration
Set these before starting the server, or in the systemd service file.
| Variable | Default | Description |
|---|---|---|
KG_ORPHAN_GRACE_DAYS |
see constants.py
|
Days before orphaned archived nodes are permanently deleted |
KG_GRACE_PERIOD_DAYS |
see constants.py
|
Days after node creation before it becomes eligible for archival. Updates and reads do not reset this. |
KG_STORAGE_ROOT |
~/.knowledge-graph |
Root directory for all graph data (centralized storage) |
KG_HTTP_PORT |
8765 |
Server port |
KG_HTTP_HOST |
127.0.0.1 |
Server host binding |
KG_LOG_LEVEL |
INFO |
Logging level (DEBUG, INFO, WARNING, ERROR) |
Note: KG_SAVE_INTERVAL is no longer critical — write-through persistence means every mutation saves to disk immediately. The periodic save thread (30s) handles maintenance tasks only (compaction, orphan pruning).
Example:
KG_ORPHAN_GRACE_DAYS=60 kg-memory startOr set them in your shell profile for persistence:
export KG_ORPHAN_GRACE_DAYS=60The graph's size budget is exact rendered characters, not estimated tokens, and it is deliberately not configurable (the old KG_MAX_TOKENS variable is gone as of 0.9.16): 17,500 characters per graph level for compaction, 40,000 for a whole kg_read result. The estimator measures the very strings kg_read renders — render equals charge — so the budget arithmetic guarantees the output always lands inline in Claude's context instead of spilling to a persisted file. A knob would break that guarantee. If a graph ever exceeds what fits (e.g. one maintained by an older server), the output degrades gracefully: lowest-scored archived anchors are hidden first, then lowest-value edges, never active knowledge — and the output says so.
-
Storage root (
KG_STORAGE_ROOT) — Override where all graph data is stored. Default is~/.knowledge-graph/. - Grace periods — How long before nodes can be archived or orphans deleted. Longer = more disk usage, shorter = more aggressive cleanup.
-
Log level — Set to
DEBUGfor troubleshooting,WARNINGfor quiet operation.
| Setting | Value | Why |
|---|---|---|
| Storage layout | ~/.knowledge-graph/projects/<slug>/graph.json |
Centralized, plain JSON |
| User graph path | ~/.knowledge-graph/user.json |
Single shared file |
| Sessions path | ~/.knowledge-graph/sessions.json |
Central session tracking |
| Session TTL | 24 hours | Sessions expire after inactivity |
| Session ID length | 8 hex chars | Short enough for tool args |
| Char budget per level | 17,500 | Compaction threshold — exact rendered characters (see above) |
| Read output ceiling | 40,000 chars | Hard cap on a kg_read result; degrades gracefully, never overflows |
| Search output ceiling | 10,000 chars | Hard cap on a kg_search result |
| Compaction target ratio | 0.8 | Archiving compacts down to this fraction of the budget; refill fills back up to the same ceiling |
| Archived budget ratio | 0.30 | Max fraction of the budget that archived anchor lines may occupy before orphaning |
| Archived-edge weight | 0.2 | Connectedness weight of an edge to an archived neighbour (active = 1.0, orphaned = 0) |
| Scoring formula | 0.25×recency + 0.40×connectedness + 0.35×usefulness |
Weighted sum of tie-aware percentile ranks. Connectedness = in×0.66 + out×0.33 (archived neighbours at reduced weight). Usefulness = decaying kg_useful endorsements (90-day half-life). |
| Likes per session | 5 |
kg_useful budget — endorsement, not traffic |
These are defined in server/core/constants.py. You can modify them if you clone/fork the code, but they're not exposed as env vars.
Leave everything at defaults. The system is designed to work well out of the box with small-to-medium graphs.
export KG_ORPHAN_GRACE_DAYS=60 # Keep archived nodes longer
export KG_GRACE_PERIOD_DAYS=7 # Longer protection windowexport KG_ORPHAN_GRACE_DAYS=7 # Quick cleanupexport KG_LOG_LEVEL=DEBUG # Verbose loggingThe plugin's .mcp.json tells Claude Code where the server is:
{
"mcpServers": {
"kg": {
"type": "http",
"url": "http://127.0.0.1:8765/"
}
}
}If you change KG_HTTP_PORT, update this file to match.
The visual editor has its own env vars (separate from the MCP server):
| Variable | Default | Description |
|---|---|---|
EDITOR_PORT |
8766 |
Visual editor web server port |
EDITOR_HOST |
127.0.0.1 |
Host binding |
MCP_SERVER_URL |
http://127.0.0.1:8765 |
Where to find the MCP server |