Module bbt

Source
Expand description

BBT (Better BibTeX) citekey database reader.

§What this does

Better BibTeX assigns citation keys to Zotero items. These keys (like “demilloHintsTestData1978”) are the primary way users reference items in the MCP tools. We need to map them to Zotero’s internal 8-char item keys (like “9MS26VH5”).

§The better-bibtex.migrated file

BBT stores its citekey assignments in ~/Zotero/better-bibtex.migrated, a SQLite database with a citationkey table:

CREATE TABLE citationkey (
    itemID INTEGER,
    itemKey TEXT,
    libraryID INTEGER,
    citationKey TEXT,
    pinned INTEGER
);

This is much faster than calling BBT’s JSON-RPC API (~0.01ms vs ~300ms).

Structs§

BbtDb
Read-only connection to the BBT citekey database.

Functions§

all_citekeys_from_zotero_sqlite
Load all citekeys from zotero.sqlite (most complete source).
citekey_from_zotero_sqlite
Read citekeys directly from zotero.sqlite (field name = “citationKey”).
item_key_from_zotero_sqlite
Reverse lookup: find item key by citekey in zotero.sqlite.