ucde
UCDE is a local, append-only evidence ledger for experimental and computational research. Each observation keeps its source, locator, measurement context and complete revision history in one SQLite file. Corrections and retractions add revisions instead of overwriting, so a past search can be rerun exactly, cited and checked by someone else.
The first workflow uses plant breeding and phenotyping records. The examples also cover an assay-method record, a published wheat sensing dataset and two releases of the public JARVIS materials-simulation database. UCDE preserves independent observations even when they disagree.
Why UCDE
Spreadsheets overwrite. Databases keep the latest value. Vector stores lose track of where an answer came from. UCDE is built for the questions those tools cannot answer.
Question | How UCDE answers it |
What did we know on 1 March? |
|
Where did this number come from? | Every hit returns its source, locator, optional source SHA-256, revision number and ranking components. |
What changed since the analysis? | Corrections, retractions and restorations are new revisions with their own provenance. Each write states the revision it expects, so one edit cannot silently replace another. Save a search as a packet, then compare or replay it later. |
Can a reviewer check it without trusting us? |
|
Can we share it in a standard format? |
|
Can an AI agent use it safely? | A read-only MCP server exposes search, history and receipts. Its instructions tell agents to cite the source and to treat evidence text as data, never as instructions. An agent can attach a packet digest to its answer, and anyone can replay it later against the ledger. |
The core is Python 3.11+ and SQLite: FTS5 for BM25 text search, plus optional dense vectors that you supply. It has no runtime dependencies and makes no network or model calls. The optional Ollama commands run only when you invoke them.
Related MCP server: studyproof
Install
pip install ucde # Python library and ucde CLI, no dependencies
pip install "ucde[mcp]" # adds the MCP server for AI agentsUCDE needs SQLite with FTS5 and JSON functions, which the python.org, Homebrew and common Linux builds include. To try it without installing, run uvx ucde --help with uv.
Quick start
See the whole idea in a minute, with no data of your own:
uvx ucde demoThen try it on your own records. Save a measurement as plot-18.json:
{"id": "plot-18", "subject": "W-017", "variable": "plant height", "method": "ruler-v1", "scale": "cm",
"observed_at": "2025-09-05T05:30:00Z", "text": "W-017 measured 81 cm in plot 18.",
"source": "fieldbook-2025.csv", "locator": "row 18"}Save its later correction as plot-18-fixed.json:
{"id": "plot-18", "subject": "W-017", "variable": "plant height", "method": "ruler-v1", "scale": "cm",
"observed_at": "2025-09-05T05:30:00Z", "text": "W-017 measured 86 cm in plot 18 after re-measurement.",
"source": "fieldbook-2025-v2.csv", "locator": "row 18"}Record both, then search the present and the past:
ucde --db evidence.db init
ucde --db evidence.db put plot-18.json # revision 1: note the recorded_at it prints
ucde --db evidence.db put plot-18-fixed.json --expected-revision 1 # revision 2: the correction
ucde --db evidence.db search "plant height" --subject W-017 # returns the 86 cm correction
ucde --db evidence.db search "plant height" --subject W-017 --known-at <recorded_at of revision 1>
ucde --db evidence.db history plot-18 # both revisions with their sources
ucde --db evidence.db verify # audit the file; exit 1 on any problemThe search with --known-at returns the original 81 cm revision and its source, fieldbook-2025.csv, because the correction was recorded later. Every command prints JSON, so the output works with jq, scripts and notebooks.
Use it from Python
from ucde import Evidence, MemoryStore
store = MemoryStore("breeding-evidence.db")
observation = Evidence(
id="north-2025-plot-18", subject="W-017", variable="plant height",
method="ruler-v1", scale="cm", observed_at="2025-09-05T05:30:00Z",
text="W-017 measured 81 cm in plot 18.",
source="north-2025-fieldbook.csv", locator="csv-row:18",
context={"site": "north", "treatment": "rainfed", "trial": "2025"},
)
store.put(observation)
result = store.search("plant height", subject="W-017", method="ruler-v1",
scale="cm", context={"site": "north", "treatment": "rainfed"})
for hit in result.hits:
print(hit.revision.evidence.source, hit.revision.evidence.locator, hit.score)The write above expects a new observation ID. Keep the returned revision and pass its revision to store.put(corrected, expected_revision=...) when correcting the observation. Use known_at to reconstruct which revision was available at a cutoff, and observed_after and observed_before to constrain when the measurement happened. Both observation endpoints are inclusive. target_at adds a soft date preference under adaptive ranking. Use strategy="nearest" with target_at when closeness in observation time should take priority over lexical relevance. See ucde search --help for the corresponding CLI options.
store.search(
"plant height", subject="W-017", method="ruler-v1", scale="cm",
observed_after="2025-09-01T00:00:00Z", observed_before="2025-09-08T00:00:00Z",
target_at="2025-09-05T00:00:00Z", strategy="nearest",
)Source locators and optional checksums are provided by the caller. The engine does not resolve source content.
Connect an AI agent (MCP)
ucde[mcp] adds a Model Context Protocol server with four read-only tools.
Tool | Returns |
| Ranked hits with exact selectors, |
| Every retained revision of one observation, including corrections, retractions and restorations, in pages |
| The same search as a portable packet with a SHA-256 receipt, pinned to the latest recorded change unless |
| Checks a quoted receipt: reruns the packet's search on this ledger and reports what changed |
Point the server at an existing ledger by its absolute path. On Windows, write the path with forward slashes, such as C:/research/evidence.db. With uv installed, the configurations below fetch everything else.
Claude Code:
claude mcp add ucde -- uvx --from "ucde[mcp]" ucde-mcp --db /absolute/path/evidence.dbClaude Desktop, Cursor, Windsurf and other clients that read an mcpServers file:
{
"mcpServers": {
"ucde": {
"command": "uvx",
"args": ["--from", "ucde[mcp]", "ucde-mcp", "--db", "/absolute/path/evidence.db"]
}
}
}VS Code, in .vscode/mcp.json:
{
"servers": {
"ucde": {
"type": "stdio",
"command": "uvx",
"args": ["--from", "ucde[mcp]", "ucde-mcp", "--db", "/absolute/path/evidence.db"]
}
}
}Without uv, run pip install "ucde[mcp]" and use ucde-mcp --db /absolute/path/evidence.db as the command. From 0.2.1, ucde --db /absolute/path/evidence.db mcp starts the same server.
The server opens the file read-only and refuses a file whose schema UCDE did not create. Tool errors do not echo paths or database details. The server uses the MCP Python SDK 2.3 and accepts both the initialize handshake (protocol 2025-11-25) and the per-request protocol (2026-07-28). Read the threat model before you open a store to an agent.
Answers with receipts
When an answer must be checkable later, the agent calls export_evidence_packet with the same search arguments. Without known_at, the packet is pinned to the ledger's latest recorded change and holds the hits that search_evidence returned. The agent quotes the evidence IDs, the sources and the packet's 64-character SHA-256 digest with its answer. Keep the packet, the tool's text result, as a JSON file: checking a receipt needs the packet as well as the digest.
To check a receipt later, run the command below, or ask an agent to call replay_evidence_packet with the packet and the digest. A match exits 0. Corrections recorded after the cutoff leave the result unchanged, while a purge or rewrite of the history it covers makes replay report what changed.
ucde --db evidence.db replay packet.json --expected-sha256 <digest>A receipt shows which results one ledger returned at one cutoff. It is not a signature, and it does not show that the sources are correct.
Guide
Load and replay dataset releases
Use store.apply_batch(...) to commit a complete set of changes as one event. Pass EvidenceWrite for new or corrected records and EvidenceRetraction for records that should cease to be active. Each change carries the current expected revision, with 0 for a new identifier. All revisions in a batch share one recorded_at. store.get(id, known_at=cutoff) returns the active revision by ID using the recording cutoff alone. Earlier revisions remain available through store.history(id).
The JARVIS release replay applies these operations to two checksummed public archives. Its recording clock uses each publisher release instant to reconstruct historical availability.
Export a historical evidence packet
Use ucde export to save a scoped text search, its recording cutoff, and the exact results with citations and revision numbers. A collaborator can read the JSON and verify the packet offline. The cutoff is any ISO 8601 time with a UTC offset, such as the recorded_at of your latest write.
ucde --db breeding-evidence.db export "plant height" --subject W-017 --known-at <cutoff> --output height-packet.json
ucde verify-packet height-packet.jsonThe export prints a SHA-256 receipt. To compare a copy against a digest received separately, pass that digest to ucde verify-packet with --expected-sha256. The Python SDK also provides export_packet and verify_packet. Public examples and attribution.
Compare two packets
ucde compare earlier-packet.json later-packet.jsonThe report matches records by evidence ID and shows changes to the evidence, citation, revision, and ranking. It also shows differences in search settings and the effective observation cutoff for each packet. A record present in just one result can reflect the query, the result limit, or the ledger state. Supply --before-sha256 and --after-sha256 to check the files against digests received separately. The SDK equivalent is compare_packets.
Replay a packet against a ledger
ucde --db breeding-evidence.db replay height-packet.jsonReplay runs the saved query and selectors at the packet's recording cutoff. It opens the ledger read-only and reports whether the new result has the same digest. A difference report includes changes to returned records, citations, ranking, and search candidate counts. The command exits 0 for a match and 1 for a difference or invalid packet. To supply a separately obtained digest, use --expected-sha256. The SDK equivalent is replay_packet.
Check a ledger
ucde --db evidence.db verify audits a file without changing it. It runs SQLite's integrity check, then confirms each ledger invariant against the stored payloads, for example that an observation's revisions are consecutive, that recording times stay in order, and that every search entry matches the payload it indexes. It prints a JSON report and exits 1 when it finds a problem, so it can gate a backup, a restore or a scheduled job. MemoryStore.verify() returns the same report in Python. Every open also refuses a file whose schema UCDE did not create, such as one that defines a trigger or view.
Save and check a ledger checkpoint
ucde --db evidence.db checkpoint # prints known_at and sha256
ucde --db evidence.db checkpoint --known-at <known_at> --expected-sha256 <sha256>Save the reported cutoff and SHA-256 separately from the ledger, for example in a lab notebook. Rechecking compares every retained revision through that cutoff, including retractions. Commits recorded after the cutoff preserve the checkpoint. A purge of covered history or a change to a covered citation produces a mismatch and exit code 1. The CLI opens the ledger read-only and returns the digest and counts. The Python SDK provides the same check through MemoryStore.checkpoint().
Enable and verify a persistent ledger chain
ucde --db evidence.db enable-chain --output evidence-v3.db
ucde --db evidence-v3.db chain-head > trusted-head.json
ucde --db evidence-v3.db verify --head-file trusted-head.jsonIn Windows PowerShell 5.1, save the head with | Set-Content -Encoding utf8 trusted-head.json instead, because > in that shell writes UTF-16.
enable-chain audits and upgrades a new SQLite copy. The source remains the schema 2 backup when upgrading from schema 2. Save the chain head separately from the database. Verification checks the saved prefix and every commit that follows it, so later valid writes preserve the check and an older backup fails it. A purge retains opaque commitments and commit coordinates while removing the payload and nonce from the ledger. The SDK provides MemoryStore.enable_chain(), chain_head(), and verify(expected_head=...). Schema 3 format and migration.
Export a portable history archive
ucde --db evidence.db archive --output evidence-history.jsonl # prints a receipt with its sha256
ucde verify-archive evidence-history.jsonl --expected-sha256 <sha256>The archive contains the full stored payload for every retained revision through its recording cutoff, including earlier versions, retractions, and stored vectors. Use --known-at to select a specific cutoff. The archive bytes hash to the same SHA-256 as a checkpoint at that cutoff. A recipient can verify the file offline using the digest you saved separately. The verifier returns exit 1 if the digest differs or the archive is malformed. Python applications can use MemoryStore.export_archive() and verify_archive().
Package an archive for research exchange
ucde crate evidence-history.jsonl --expected-sha256 <sha256> --output research-crate --name "Study evidence" --description "Retained measurement revisions" --date-published 2026-12-05 --license "Internal research use"
ucde verify-archive research-crate/history.jsonl --expected-sha256 <sha256>ucde crate validates the archive before packaging it with its checkpoint receipt, RO-Crate metadata, and a JSON-LD provenance graph. The graph records source locators and digests, revision links, and recording and observation times. Supply the title, description, publication date, and licence or terms that apply to your package. The Python equivalent is create_crate(). RO-Crate 1.2 · W3C PROV-O.
Run from a source checkout
python -m pip install .
python examples/evidence_walkthrough.py
python examples/agicam_wheat.py --wheat spring --variety 9 --sensor AG13 --vi NDVI --through 2022-06-10
python -m unittest discover -s tests -v
python -m benchmarks.run_memory --output my-memory-benchmark.jsonpython -m pip install . can fetch the pinned build dependency when needed. If build and setuptools 84.2.1 are already available, build and install entirely offline with python -m build --no-isolation --wheel followed by python -m pip install --no-index --no-deps --find-links dist ucde. To run without installing, set PYTHONPATH to python and use python -m ucde as the CLI command. The walkthroughs use temporary databases. The AGIcam example returns the original CSV line and measurement context from a small published dataset excerpt. Dataset and licence.
Optional integrations
ucde modelsanducde generate --model <installed-model> --prompt "Example"connect to an already running Ollama daemon on numeric loopback.ucde.ollama.OllamaClient.embedcomputes an embedding explicitly. Use one pinned embedding space for compatible vectors. The ledger and MCP server never send retrieved evidence to Ollama. Disable cloud features and block outbound connectivity in offline deployments. Ollama FAQ.With Docker Compose,
docker compose run --rm ucdeinitializes a named volume in an isolated container. Pass CLI arguments afterucdefor subsequent runs. The image contains the core CLI only and builds using the Docker base image and the pinned build backend. CI builds it and round-trips evidence with no network and a read-only root file system.
Project status
UCDE is alpha software for research evidence. It has no clinical workflow or enterprise service. Start with the Phase 0 assessment, algorithm specification, and benchmark. The development status records verified results, current limits and the next research milestone, and the roadmap lists what comes next. The threat model explains the local trust boundary. Use separate files and OS permissions for different principals.
Support and services
Ask questions in GitHub Discussions Q&A and report bugs through GitHub issues. The maintainer also offers paid help to research groups: setting up a ledger for a breeding or phenotyping programme, importing existing trial data with source locators, connecting AI assistants over MCP with receipts, training and priority fixes. The maintainer is open to collaborating on grant proposals that need reproducible handling of evidence. To ask about either, start a discussion in General and keep confidential details out of the post. The support page has the details.
Contributing
Bug reports, research use cases and pull requests are welcome. Read the contributing guide and the code of conduct. Report security problems privately as described in the security policy. If UCDE is useful to you, a star on GitHub helps other researchers find it.
Citation and licence
To cite UCDE, use CITATION.cff or the "Cite this repository" button on GitHub. The DOI 10.5281/zenodo.24884835 cites all versions. On Zenodo, each release also has its own DOI. UCDE is licensed under Apache-2.0. See LICENSE.
Created and maintained by Muhammad Q Farooqi.
Available Tools
4 toolsevidence_historyEvidence historyARead-onlyIdempotent
List the retained revisions of one evidence ID in ascending order, including corrections, retractions and restorations. Results come in pages: pass next_after_revision from a response as after_revision to read the next page.
Inputs: id (required), limit, after_revision. Returns: revisions, next_after_revision
export_evidence_packetExport evidence receiptARead-onlyIdempotent
Run the same search as search_evidence and return it as a portable evidence packet: the exact request, the ordered results with citations, and a SHA-256 digest. Quote the digest with your answer. Anyone with the packet can later replay it against this ledger, with replay_evidence_packet or the ucde replay command, to see whether the evidence is unchanged.
Inputs: query (required), limit, scale, method, +8 more. Returns: format, sha256, payload
replay_evidence_packetReplay evidence receiptARead-onlyIdempotent
Check a quoted receipt. Confirm that the packet matches the quoted digest, rerun its saved search against this ledger at the packet's cutoff, and report whether the results are unchanged and, if not, which records, citations or revisions differ. For large packets, use the ucde replay command.
Inputs: packet (required), expected_sha256 (required). Returns: format, matched, comparison, result_changes
search_evidenceSearch evidenceARead-onlyIdempotent
Rank stored observations for a query and return each hit with its revision, source and locator. All hits come from one consistent snapshot. Use known_at to read the ledger as it stood at an earlier time, observed_before to exclude later observations, and target_at to favour observations made near a date.
Inputs: query (required), limit, scale, method, +8 more. Returns: hits, dense_candidates, lexical_candidates, vector_scan_truncated
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct role: search for ranked hits, export for a portable packet, replay for verification, and history for revision lineage. The main overlap is that export_evidence_packet runs the same search as search_evidence, so an agent chooses based on output form, but the descriptions make the distinction clear.
All names use snake_case and consistently reuse evidence terminology. Three names follow a verb_noun pattern, while evidence_history is noun-based, which is a minor deviation from the otherwise predictable convention.
Four tools is well-scoped for a read-only evidence ledger: search, revision history, packet export, and packet replay each cover a distinct workflow. None appears redundant, and no obvious core operation is missing for this narrow purpose.
The toolset covers the core audit loop: search a consistent snapshot, inspect revision history, export a digest-backed packet, and replay it to detect changes. Minor gaps include no direct full-record fetch by evidence ID or source listing, though agents can work around these via search and history.
Maintenance
Related MCP Connectors
Read-only evidence reports on AI agents: search, fetch a report, check trust. Not a certification.
Read-only gateway for durable agent identity, consent, recognized work, and signed receipts.
Append-only evidence receipts for AI records: seal, verify, cite, chain-check, anchor status.
Issue & verify signed (ed25519), hash-chained, timestamped provenance receipts for agent actions.
Related MCP Servers
FlicenseNot gradedqualityBmaintenanceEnables agents to search, retrieve, and list open-licensed documents with verifiable provenance, attaching sha256, DOI, and OpenTimestamps proof to every response.2,222 npm-- AlicenseNot gradedqualityCmaintenanceProvides read-only search and context-pack creation over a local source library, letting AI assistants retrieve relevant excerpts and audit cited quotations.20MIT
- AlicenseNot gradedqualityCmaintenanceEnables local read-only search and retrieval of approved, current evidence via hybrid lexical and dense methods, with tools to get exact source spans, answer from cited passages, and create and verify recheckable evidence packets.MIT
- FlicenseNot gradedqualityBmaintenanceProvides a local, evidence-first knowledge base over source snapshots and summaries stored in SQLite, with bounded search and exact readback while preserving provenance.-