Skip to content

Agents: MCP and REST

Both interfaces wrap the same functions (assertion_ledger.server.tools), so they return identical JSON.

MCP server

pip install "assertion-ledger[mcp]"
assertion-ledger --db sqlite:///ledger.db mcp --agent-id support-bot

Client configuration (Claude Desktop, Claude Code, and other MCP clients):

{"mcpServers": {"assertion-ledger": {
  "command": "assertion-ledger",
  "args": ["--db", "sqlite:////abs/path/ledger.db", "mcp", "--agent-id", "support-bot"]}}}
Tool Returns
resolve_fact(subject, predicate, as_of?) status, value, winner with quote, overridden claims, drift, guidance
explain_fact(subject, predicate, as_of?) the human-readable trace
fact_history(subject, predicate) every claim, retraction and approval, in order
list_facts(subject) the predicate names held for a subject
list_conflicts(subject?) open conflicts
propose_assertion(subject, predicate, value, evidence, source_ref?) a tier-0 proposal for a human

Every resolution includes guidance, so the answering rule travels with the answer:

Status Guidance
RESOLVED use this value and cite the winning source
CONFLICT don't pick one; say it's disputed, list the candidates, and say a human must settle it
UNKNOWN say you don't know; don't guess from other documents
STALE the only evidence is too old to trust
PENDING_APPROVAL a value exists but awaits approval

Some details: - Ledger errors, such as an unknown subject or a bad date, reach the agent as tool errors with their message. Other failures stay on the server. - The transport is stdio only: the client launches the server as a local process, so there's no network listener.

Agents propose, never assert

propose_assertion stores the claim under the policy's propose_only source (tier 0). It never changes what resolve_fact returns. It waits for a human in ledger.proposals() / assertion-ledger proposals, and a human promotes it by asserting it from an authoritative source.

REST API

pip install "assertion-ledger[rest]"
export ASSERTION_LEDGER_API_KEY=$(openssl rand -hex 24)
assertion-ledger --db sqlite:///ledger.db serve --host 127.0.0.1 --port 8000

The server won't start without a key. Every /v1 route needs the X-API-Key header, and keys are compared in constant time.

Method Path
GET /healthz no auth
GET /v1/resolve?subject=&predicate=&as_of=&known_at= resolution JSON
GET /v1/explain?subject=&predicate=&as_of= plain text
GET /v1/history?subject=&predicate= timeline
GET /v1/facts?subject= predicates for a subject
GET /v1/conflicts?subject= open conflicts
GET / POST /v1/proposals list proposals / file one (subject, predicate, value, evidence, source_ref?, proposed_by?)

Errors return 400 with {"detail": ...}; a missing or wrong key returns 401.

Demo

examples/demo_agent/ asks the same four questions two ways: plain RAG, and a Gemini agent using this MCP server over stdio. On the injected "official price ₹1", RAG answered ₹1 and the agent answered ₹89,000, citing the contract.