Ken
Enables Claude to interact with local document vaults as searchable knowledge graphs, providing MCP tools for ingestion, search, and memory consolidation without cloud dependencies.
README
Ken
A frontend-free memory layer that turns any folder of documents into a searchable knowledge graph. Ken converts, ingests, links, and retrieves your files locally, with no cloud and no runtime dependencies on external repositories.
Quick Start
Install Ken globally (or run it on demand with npx):
npm install -g @foresights/ken
# or
npx @foresights/ken <command>
Turn any folder into a vault. Files are never moved, copied, or renamed. Ken only creates a .ken/ directory inside the folder.
ken init ~/Documents/my-notes
Search it:
ken search "quarterly revenue trends"
Results come back in two flavors: DIRECT hits (text match) and GRAPH hits (linked neurons surfaced by Personalized PageRank).
Claude Desktop Integration
Ken speaks the Model Context Protocol (MCP) over stdio. Add it to your Claude Desktop config file.
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"ken": {
"command": "npx",
"args": ["-y", "@foresights/ken", "mcp", "--vault", "/path/to/vault"]
}
}
}
Replace /path/to/vault with the absolute path to your Ken vault folder. Restart Claude Desktop and Ken's tool catalog becomes available to the agent.
CLI Commands
| Command | Description |
|---|---|
ken init <path> |
Turn an existing folder of documents into a Ken vault. Creates .ken/ inside the folder. |
ken sync <folder> |
Sync the vault with folder changes. Ingests new and changed files, marks deleted files as orphaned. |
ken ingest <file> |
Ingest a single document into the vault. Converts non-text formats automatically. |
ken search <query> |
Search the vault. Returns direct text matches plus graph-surfaced results. |
ken convert <file> |
Convert a document to Markdown using Ken's native Rust converter. |
ken converters |
Check which converters are available (native Rust, OCR, Whisper). |
ken serve |
Start the Ken HTTP server (default port 7700, 44 REST routes). |
ken mcp |
Start the MCP stdio server for Claude Desktop and other MCP clients. |
ken health |
Vault diagnostics. Reports brain health score, graph stats, orphans, stale pages, dead links, contradictions. |
ken brief |
Print an orientation packet summarizing the vault. |
ken consolidate |
Run the nightly memory consolidation worker (replay, stale-marking, edge decay). |
ken review |
List neurons due for spaced repetition review. |
ken recall <neuronId> |
Record a memory recall event (updates FSRS state and contribution score). |
ken observe |
Run the observation pipeline. Finds neuron clusters for synthesis. |
ken expand <query> |
Show the PMI-expanded query for debugging search recall. |
ken reindex-pmi |
Rebuild the PMI co-occurrence matrix from all neuron content. |
ken models |
Detect local LLM backends (Ollama, LM Studio, llama.cpp) and store selection in .ken/config.json. |
ken validate |
Validate the vault's schema.yaml. |
ken tasks |
List conversion tasks by review state (pending, submitted, accepted, rejected, expired). |
ken graph export |
Export the knowledge graph as HTML, SVG, GraphML, JSON, or Mermaid. |
ken graph affected <neuronId> |
Show reverse impact analysis for a neuron (what depends on it). |
ken graph tour <topic> |
Generate a guided knowledge tour starting from a topic. |
ken graph benchmark <query> |
Measure token reduction achieved by graph-first retrieval versus raw documents. |
ken semantic build |
Build the optional semantic layer (LSI word similarities and node2vec embeddings). Requires Python with numpy. |
ken semantic query <word> |
Show semantically similar words from the LSI model. |
How It Works
Ken has three layers working together.
-
Rust conversion core. A native Rust binary converts 11 document formats to Markdown. No system calls to Python, LibreOffice, or external tools. The binary ships inside the npm package.
-
TypeScript service layer. The orchestration logic (ingestion, search, graph algorithms, memory lifecycle, MCP server, HTTP server) is written in TypeScript and runs on Node.js.
-
SQLite storage. Every vault stores its data in a single
.ken/data.dbSQLite file. Full-text search uses SQLite FTS5. Graph structure, embeddings, FSRS state, and task queues all live in the same database.
The retrieval model is graph-first. When you search, Ken does not just match text. It follows synapses (links between neurons) to surface related knowledge that may not share any keywords with your query.
Search Architecture
Ken search runs four layers in sequence. Each layer adds recall without sacrificing precision.
-
FTS5 full-text search. The base layer. SQLite FTS5 matches your query tokens against neuron content with BM25 ranking. This is always available and requires no model.
-
PMI query expansion. Ken builds a Pointwise Mutual Information co-occurrence matrix from all neuron content. When you search, it expands your query terms with their statistical neighbors. Searching "revenue" also hits neurons about "income", "ARR", "MRR". Run
ken reindex-pmito rebuild this matrix. -
Personalized PageRank. Seed neurons from layers 1 and 2 become the personalization vector for a PageRank walk over the synapse graph. High-authority neurons connected to your seeds get boosted, even if they had no direct text match. This is what produces the GRAPH results.
-
Semantic embeddings (optional). If you run
ken semantic build, Ken computes LSI word similarities and node2vec graph embeddings using a bundled Python script. This adds latent semantic matching on top of the graph. Requires Python with numpy. Ken works fully without it.
Memory Lifecycle
Ken treats knowledge like biological memory, not like a static index.
-
FSRS spaced repetition. Every neuron has an FSRS (Free Spaced Repetition Scheduler) state tracking its stability and retrievability. When you recall a neuron (via
ken recallor through the MCP tools), its stability increases and its next review date moves out. Neurons you never recall gradually become stale. -
Hebbian strengthening. Synapses that get traversed frequently during search and recall get stronger. Infrequently used synapses decay. Run
ken consolidateto apply this. -
Nightly consolidation. The consolidation worker (
ken consolidate) does three things: (1) replays high-contribution neurons to boost their stability, (2) marks neurons whose retrievability has dropped below the threshold for review, and (3) prunes decayed synapses and edges. This keeps the vault from accumulating dead weight. -
Observation and synthesis. The
ken observecommand clusters related neurons and presents them for synthesis. The agent (or you) can then create new neurons that capture higher-level patterns. -
Self-improvement proposals. Ken generates typed metric facts with provenance and can detect contradictions. It proposes improvements (new synapses, entity merges, schema updates) as tasks that require human approval before they take effect.
Supported File Formats
Native Rust converters (11 formats)
| Format | Extension(s) |
|---|---|
| CSV | .csv |
| RTF | .rtf |
| HTML | .html, .htm |
| DOCX | .docx |
| XLSX | .xlsx |
.pdf |
|
| EPUB | .epub |
| PPTX | .pptx |
| ODT | .odt |
| ODS | .ods |
| ODP | .odp |
Plain text formats (read directly)
Markdown (.md, .markdown), plain text (.txt), JSON (.json), YAML (.yaml, .yml), XML (.xml), HTML (.html, .htm).
Code file formats (40+, read as plain text)
TypeScript (.ts), JavaScript (.js, .mjs, .cjs), Python (.py), Rust (.rs), Go (.go), Java (.java), C (.c, .h), C++ (.cpp, .cc, .cxx, .hpp, .hh), C# (.cs), Ruby (.rb), PHP (.php), Swift (.swift), Kotlin (.kt), Scala (.scala), Shell (.sh, .bash, .zsh), SQL (.sql), Lua (.lua), Perl (.pl, .pm), R (.r, .R), Julia (.jl), Dart (.dart), Clojure (.clj), Haskell (.hs), Erlang (.erl), Elixir (.ex, .exs), F# (.fs), Lisp (.lisp, .cl), Nim (.nim), Zig (.zig), Crystal (.cr), OCaml (.ml), Vue (.vue), Svelte (.svelte), CSS (.css), SCSS (.scss), Less (.less), TOML (.toml), INI (.ini, .cfg), Dockerfile, Makefile, and more.
Self-Contained
Ken has zero runtime dependencies on external repositories, cloud services, or API keys.
- Works offline. No network calls are required for ingestion, conversion, search, or graph analysis.
- No cloud. Your documents never leave your machine. Everything runs locally.
- No external repos. The Rust conversion binary ships inside the npm package. The optional semantic layer bundles its own Python script.
- No API keys. Ken does not call OpenAI, Anthropic, or any external model. The optional local LLM integration (
ken models) talks to your own Ollama, LM Studio, or llama.cpp instance on localhost. - Single database file. The entire vault (content, graph, embeddings, FSRS state, task queue) lives in one SQLite file at
.ken/data.db.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。