Skip to main content

A YAML+markdown card substrate for agentic and human knowledge work

Project description

mddb

A minimal YAML-frontmatter + markdown-body card substrate for agentic and human knowledge work.

Cards live as .md files in a directory under git. A derived SQLite index at ~/.cache/mddb/ provides fast structured + full-text queries. Rationales live in commit messages. The substrate has no domain knowledge — flat YAML. The substrate filing vocabulary is id, title, summary, relpath, and tags (structures the substrate provides; the names are user choice). Anything heavier is layer code or an agent reasoning in a REPL.

Quickstart

import mddb

db = mddb.MDDB.init("~/my-mddb")  # or mddb.MDDB(path) to open an existing one

with db.editor(rationale="bought today") as editor:
    card = editor.create(
        title="Shed inventory",
        summary="Tools and equipment kept in the shed.",
        tags=["shed"],
        yaml={"location": "shed"},
        body="A wheelbarrow.",
    )

# read by id
card = db.read(card.id)

# mutate and write back
card.yaml["location"] = "barn"
with db.editor(rationale="moved to barn") as editor:
    editor.update(card, summary="Tools and equipment, moved to the barn.")

db.editor() is the only mutation primitive. Batch many mutations into one commit + one SQLite transaction. A body exception inside the with block discards the buffer; on-disk state is unchanged.

with db.editor(rationale="bulk import") as editor:
    for item in ["fridge", "shed", "loft"]:
        editor.create(title=item.title(), summary=f"contents of the {item}")

# full-text via raw SQL — no DSL
ids = [r[0] for r in db.conn.execute(
    "SELECT id FROM entries WHERE rowid IN "
    "(SELECT rowid FROM entries_fts WHERE entries_fts MATCH ?)",
    ("wheelbarrow",),
)]

# history
for commit in db.history(card.id):
    print(commit["sha"][:7], commit["message"])

See CLAUDE.md for the philosophy and the SQLite schema, src/mddb/schema.sql for the schema itself.

MCP server (optional)

For cross-process agents (Codex, Clawde), the mddb[mcp] extra ships a FastMCP server. One server serves many decks — each tool call passes the deck path.

pip install mddb[mcp]
claude mcp add mddb -- mcp-mddb

Two tools: read(deck, op=list|get|history|query|blob, ...) and editor(deck, rationale, ops) (a JSON-array of operations applied as one commit). For example, read(deck="/home/me/finance", op="list") or editor(deck="/home/me/home", rationale="...", ops='[{"op":"create",...}]'). A non-existent/non-deck path errors clearly rather than reading empty; bootstrap a new deck with editor(deck, rationale, ops='[{"op":"init"}]'). The core import mddb does not pull in the MCP dependency.

Status

Prototype. Linux only. Concurrent mddb writers (multiple processes / MCP agents) are serialised by a short .git/mddb.lock and a base-vs-HEAD conflict check — a stale write raises mddb.ConflictError (re-read and retry) rather than silently clobbering; capture base = db.head() with your read and later pass db.editor(base=base) to guard that read→write span. Raw external git commits and uncommitted editor edits are not yet guarded.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mddb-0.0.13.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mddb-0.0.13-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file mddb-0.0.13.tar.gz.

File metadata

  • Download URL: mddb-0.0.13.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for mddb-0.0.13.tar.gz
Algorithm Hash digest
SHA256 3db363cd9bf2c1647de5ac4cc2bb03c9053ec560039d94084d458156bf1d0419
MD5 44a1fa1fd1b1f2b4d1d3bd1d20b68f07
BLAKE2b-256 d8fb53fcde8f6e53e738ab65de99c85d1b84fbf557edae331a5d5073111146f2

See more details on using hashes here.

File details

Details for the file mddb-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: mddb-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for mddb-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 9544f37f4f847b8320ce9b1d49255180aa29c25dc4afcd82628efc9422d4e633
MD5 5be8c4877659e55aa31959ebd8726e1e
BLAKE2b-256 02b5288a0823604d6408c0f110da35d445f89a2e1540dfd1fede396498f3a8dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page