agent-fact-system

agent-fact-system

Local-first knowledge system for reasoning agents, exposing facts, evidence, documents, retrieval, and audit history through a thin stdio MCP server.

Category
Visit 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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured