Freshness gate for AI agents: verify a belief is still true against the live world before you act.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows)
Open-source client libraries for Kaval. Register the payers and pages you
care about once. Kaval watches them, extracts structured records against a schema you define, and
delivers each policy update β plus a monthly PDF + manifest rollup β as a webhook the moment it
lands, instead of you polling or re-researching it. check() is the second half: before an agent
acts on one of those facts, send Kaval the action and it answers ALLOW, REVIEW, or BLOCK with a
signed receipt.
Policy engines decide whether an action is permitted under the rules; Kaval verifies whether the facts those rules depend on are still true.
These are thin HTTP clients for the hosted Kaval API (https://api.usekaval.com). Create an API
key at usekaval.com.
| Package | Language | Install | Source |
|---|---|---|---|
@usekaval/kaval | Node / TypeScript | npm i @usekaval/kaval | sdks/node |
kaval | Python | pip install kaval | sdks/python |
@usekaval/mcp | MCP server | npx -y @usekaval/mcp | packages/mcp |
The 0.7.3 portfolio methods are available in the Node SDK and MCP server.
The Python SDK does not yet expose contracts, fact imports, bulletins, or training review.
The primary loop needs no LLM call and no polling loop of your own:
No schema, or want a one-off pull instead of waiting for the next document? createPolicyUpdate({ payer_id, period, extraction_schema_id }) requests a single payer + period run on demand;
getPolicyUpdate() / listPolicyUpdates() report its lifecycle
(processing β retry β succeeded / review_required / failed), and
listPolicyUpdatePackages() lists the monthly PDF + manifest rollup each payer/period is packaged
into. This is the schema-bound successor to the free-text bulletin methods (listBulletins(),
getBulletin()), which are soft-deprecated but keep working.
check() is what you call next, right before an agent acts on a fact this loop delivered β it is
covered in the next section.
0.6 was a breaking release. Nine MCP tools collapsed to seven (before later portfolio/policy-update tools landed). The whole verification surface collapsed to one call. Every removed endpoint now answers a structured
410 {"error":"tool_retired","replacement":"/v1/check"}, and the clients translate that into an error that namescheckby name. See Migrating from 0.5.
check() is not required to keep facts current β the webhook loop above does that β but it is the
call to make right before an agent relies on one, because it re-derives the verdict from current
state and hands back a signed receipt:
What comes back:
| field | meaning |
|---|---|
decision | ALLOW (every material fact holds on fresh evidence) Β· REVIEW Β· BLOCK |
reason_codes | why, from a closed eight-code taxonomy |
facts[] | one row per fact: status (holds/changed/unknown), materiality, and the sources it rests on |
receipt | { id, signature, signed_at } β fetch the full signed document with getReceipt(id) |
latency_ms | { compile, lookup, live, total } |
A check on facts a watched source already covers is a database read: no model call, no fetch,
nothing on the wire. A cold check does live research before it answers β search, fetch, adjudicate β
and the server lets that run for up to 100s by default, so give the call room. mode: "fast"
(equivalently max_wait_ms: 0) skips research entirely and reports anything it could not settle as
unknown, which is REVIEW.
The decision table is published, so the receipt's fact list re-derives the verdict offline, and the
Ed25519 public keys are served unauthenticated at GET /v1/proof-verification-keys/:kid β checking a
receipt needs no Kaval account and no API key.
The verifier that does it for you ships inside the SDK: @usekaval/kaval/verify is a
dependency-free subpath export of @usekaval/kaval, and the same package ships a
kaval-receipt-verify CLI. Neither needs a Kaval account, an API key, or Kaval's database; the only
request either can make is for the public keyset, and that request is optional. Hand it a receipt and
a keyset. It answers three questions by default and one optional verdict question:
key_id active or benignly retired, rather than revoked or compromised?fresh, recheck_due, expired, not_yet_issued, or unknown.A valid signature proves who sealed those exact bytes. It does not prove the claim is still true, or that the key is still trusted, which is why the three answers never collapse into one boolean.
Exit 0 means the signature is valid and the key is trusted; a stale receipt still exits 0,
because freshness is a separate fact β pass --require-fresh to make anything but fresh non-zero.
Exit 1 is a completed but unaccepted verification, 2 an input, I/O, or discovery failure. Parse
untrusted receipt text with parseJsonStrict, not JSON.parse: duplicate members and lossy numbers
are evidence, and JSON.parse throws that evidence away before any verifier can see it.
A check is a database read when the facts it needs are already backed by a watched source, and a bounded research run when they are not. Registering the name of an authority is usually enough:
Kaval resolves that to the pages that publish it, polls them adaptively (slower when nothing
changes, faster when it does), and re-evaluates the dependent facts when they move. kind: "url"
watches one page; kind: "push" is a document your own system sends in with sendEvent(). You do
not have to register first β a source a check cites is auto-watched β but registering ahead of time
is what makes the first check on a fact fast.
Naming an entity is what enqueues the discovery that works out how to acquire the pages behind it.
A kind: "url" source registered directly does not get one, so recompileSource(id) is how you ask
for one β and it is also the only way back once a source's acquisition plan breaks. It answers 202 { source_id, job_id, created }; created: false means an open job already covered it.
Watching is only half of it. Subscribe to fact_state.delta and Kaval pushes you what changed and
what it flipped, instead of you discovering it on the next check:
Each delivery names the source, the old and new content hashes, a diff summary, and the facts whose
state changed β {fingerprint, text, old_state β new_state, basis} β plus a pointer to the receipt
covering the re-evaluation. Manage subscriptions with listWebhooks(), setWebhookEnabled(),
deleteWebhook(), and re-drive a dead letter with replayWebhookDelivery().
For documents Kaval cannot fetch β a contract, an internal policy, a customer upload β push the new version and let the background loop do the rest:
Kaval diffs it against the previous version, marks the dependent facts stale, re-evaluates them, and
emits the delta webhook. Checks that land mid-re-evaluation honestly return REVIEW.
Thirty-one tools run over stdio. They cover checks, receipts, contracts, bulk imports, policy
updates (extraction schemas, runs, monthly packages), the soft-deprecated bulletin tools, training
review, watched sources, outcomes, and the deprecated verify alias.
Eleven JSON resources expose contract issues, bulletin extraction status, and the prior read models. Explicit consent is available, but model promotion and bulletin requeue remain internal. See packages/mcp.
MCP clients cancel a tool call well before 100s, so the server narrows check's research budget to
fit inside that envelope instead of inheriting the full default. A cold check over MCP therefore
comes back REVIEW more often than the same call through an SDK β register the sources it depends
on and the warm path removes the difference.
Everything below folded into check. The old routes answer 410 tool_retired; the clients raise
KavalRetiredError (Node) / KavalRetiredError (Python) naming the replacement, and the MCP server
returns {"error":"tool_retired"} with a message telling the agent to call check.
| 0.5 tool | 0.6 |
|---|---|
currentness_check | check β { action } or { claims: ["β¦"] } |
currentness_verify | check β branch on decision === "ALLOW" instead of act |
currentness_extract_and_check | check β pass the paragraph as action/context; Kaval compiles the facts itself |
currentness_scan_store | check β { claims: [...] }, up to 20 per call |
currentness_monitor | add_source + a fact_state webhook subscription β deltas are pushed, not swept |
proof_audit | check β the receipt is the proof; get_receipt fetches it in full |
proof_gate | check β the warm path re-checks from stored state; nothing to re-apply separately |
report_outcome | report_outcome (unchanged; pass receipt.id) |
verify | verify, now deprecated β move to check |
| 0.5 | 0.6 |
|---|---|
audit(), gate(), gateAction()/gate_action() | check() |
check(belief) / check(belief=β¦) | check({ action }) / check(action=β¦) |
verifyBelief() / legacy_verify_belief() | check({ action, context }) |
extractAndCheck() / extract_and_check() | check({ action: theText }) |
scanStore() / scan_store() | check({ claims: [...] }) |
monitor() | addSource() + subscribeFactStateDeltas() |
kaval() / kavalBatch() / kaval_batch() | check({ claims: [{subject, predicate, object, scope}] }) |
verify() | verify(), deprecated β check() |
| β | new: getReceipt, listSources, recompileSource, sendEvent, webhooks |
ProofNotFoundError / KavalProofNotFoundError | removed with /v1/gate |
| 0.5 belief status | 0.6 |
|---|---|
current + act: true | decision: "ALLOW", every fact holds |
stale / contradicted | fact changed β REVIEW or BLOCK by materiality |
unsupported / insufficient / conflicting | fact unknown β REVIEW (BLOCK if critical) |
Contract mutations, fact imports, extraction schema creation, policy-update run creation, deprecated
verify(), and webhook creation carry an Idempotency-Key. The client generates a key when you omit
one.
A check reads current state. The server does not replay it, so a retry recomputes the result.
Two names exist on purpose β they are not interchangeable:
| Consumer | Variable | Reads env? |
|---|---|---|
| Python SDK / MCP | KAVAL_BASE_URL | yes |
Node @usekaval/kaval | β | pass baseUrl in constructor |
Marketing site proxy (apps/web) | KAVAL_API_URL | yes (server only) |
Use the same origin value in both vars when self-hosting (e.g. http://localhost:8787, the port the
server image listens on). The self-host guide ships with the server distribution rather than here β
Kaval's core repo is private, so there is no public link to give you.
Demo results carry no organizational authority; a production ALLOW requires a customer-bound
action policy and applicable empirical calibration; REVIEW is never permission to act.
Everything above is hermetic: it fakes the API, which is why a client that aborts its own headline call, or an endpoint that 404s, can pass it. Two suites talk to a real server, and both skip themselves when their credentials are absent:
These need a running Kaval server and an issued API key, so they are opt-in and self-skip without one. They are not a release gate here: this repository cannot reach the server's source, and there is no staging deployment β the only deployment is production, and pointing a publish gate at it would write test sources, receipts and outcome reports into the live product on every tag.
The real client-vs-server contract test lives in the Kaval server repository's CI, where a real Postgres and the server both exist. It boots the server, issues a scoped key, and drives these same clients against it on every push. Publishing from this repository gates on the hermetic suites, which is what this repository can honestly verify on its own.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/kaval)<a href="https://allmcps.com/mcp/kaval"><img src="https://allmcps.com/api/badge/kaval?style=directory" alt="Kaval on AllMCPs" /></a>