agent-fact-system
Local-first knowledge system for reasoning agents, exposing facts, evidence, documents, retrieval, and audit history through a thin stdio MCP server.
README
Agent Fact System
中文 | English
<p align="center"> <img src="assets/afs-hero.jpg" alt="Agent Fact System" width="768"> </p>
Lightweight. Fast. Unconstrained.
Agent Fact System, or AFS, is a local-first knowledge system for reasoning agents. It keeps facts, evidence, revisions, documents, retrieval indexes, and audit history outside the model context, then exposes them through a compact CLI and a thin stdio MCP server.
AFS is purpose-built for the working style of frontier models such as DeepSeek V4 Pro. These models can plan, call tools, compare evidence, and revise conclusions. They work better with a small deterministic knowledge surface than with a large application framework surrounding them.
The design target is model-class specific and provider neutral. AFS does not contain a DeepSeek-only adapter and does not require a particular chat runtime. DeepSeek V4 Pro, another frontier model, or a local Agent can use the same contracts.
Why AFS exists
A strong model can reason across a difficult task. It still needs a reliable answer to a simpler question. What is true now, where did that claim come from, and what changed since the last run?
AFS gives the Agent one factual authority with explicit evidence and readback. The model remains free to reason. The knowledge layer stays small, inspectable, and recoverable.
What is implemented
- A transactional SQLite canonical store for facts and practices
- Evidence-bound proposals, revisions, status transitions, and idempotent writes
- Append-only Timeline events and revision history
- A portable Markdown document store with stable slugs and source line locators
- Structured, full-text, temporal, vector, and hybrid retrieval
- Tags, links, backlinks, and partial document resolution
- Extractive answers with citations
- A fixed allowlist of 14 Agent-facing MCP tools
- A thin JSON CLI for local operation and administration
- Rebuildable local and vector indexes
- Obsidian-compatible Agent projections and a narrow command inbox
- Verified backup, restore, health, and drift checks
- Fail-closed sensitivity rules that keep restricted content out of FTS, projections, exports, and remote embeddings
- Optional one-time GBrain migration and private cold-archive support
Why it fits DeepSeek V4 Pro class models
AFS gives a high-end Agent a compact set of operations instead of another orchestration framework.
- Small tool surface The MCP interface is capped at 14 tools.
- Deterministic contracts JSON schemas, idempotency keys, revision checks, and canonical readback make tool results verifiable.
- Evidence stays close Claims carry source locators, excerpts, hashes, and Timeline history.
- Context stays lean The Agent retrieves the exact record or document span it needs.
- Reasoning stays free AFS governs stored knowledge without prescribing how the model plans or thinks.
- The runtime stays light Python, SQLite, three direct runtime dependencies, and no mandatory daemon.
This is what “unconstrained” means here. AFS does not try to become the Agent, the planner, or the application shell. It provides durable knowledge and gets out of the way.
Architecture
Agent or MCP client
|
v
CLI / stdio MCP
|
+-------------------+
| |
v v
Canonical SQLite Markdown documents
| |
+---------+---------+
|
v
Rebuildable derived views
FTS / Timeline / vectors / Vault
Canonical data remains authoritative. Full-text indexes, vector generations, and Vault projections can be rebuilt.
Quick start
AFS requires Python 3.12 and uv.
git clone https://github.com/leoge007/agent-fact-system.git
cd agent-fact-system
uv sync --locked
export AFS_HOME="$HOME/.local/share/agent-fact-system"
install -d -m 0700 "$AFS_HOME"
uv run afs init --json
uv run afs doctor --json
Create a candidate fact through the public CLI.
uv run afs record propose --input - <<'JSON'
{"kind":"fact","subject":"projects/quickstart","claim":"AFS stores evidence-backed facts.","evidence":[{"locator":"inline:quickstart","excerpt":"AFS stores evidence-backed facts."}],"idempotency_key":"quickstart:propose:1"}
JSON
Build the local index and query it.
uv run afs index sync --json
uv run afs query 'evidence-backed facts' --mode fulltext --json
See docs/quickstart.md for MCP setup, documents, vectors, backup, and restore.
MCP setup
Any stdio MCP client can launch AFS with an explicit data directory.
{
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/agent-fact-system",
"run",
"python",
"-m",
"afs.mcp"
],
"env": {
"AFS_HOME": "/absolute/path/to/afs-data"
}
}
The repository also includes an Agent routing Skill at skills/agent-fact-system/SKILL.md.
Retrieval and embeddings
Local structured, full-text, temporal, and document retrieval work without a network service. Vector and hybrid retrieval are optional.
The current remote embedding adapter uses SiliconFlow with Qwen/Qwen3-Embedding-8B. Only records marked normal are eligible for remote embedding. Restricted content fails closed before an HTTP request is made.
export SILICONFLOW_API_KEY='...'
uv run afs embedding preflight --json
uv run afs index vector --json
uv run afs query 'your question' --mode hybrid --json
Deliberate boundaries
AFS currently targets Python 3.12. It does not run a daemon, scrape conversations automatically, promote model output into confirmed facts, or hide provider failures behind silent fallback. Owner-level mutations remain outside the normal MCP surface.
The remote embedding adapter is currently specific to SiliconFlow. The Agent model itself remains independent of that adapter.
Verification
uv sync --locked
uv run pytest --ignore=tests/live
Live embedding tests require an explicit API key and network authorization.
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 模型以安全和受控的方式获取实时的网络信息。