aegean.mcp_server¶
The aegean-mcp Model Context Protocol server (the [mcp] extra): it exposes the toolkit's
read/analysis surface to agents as MCP tools. The tool functions are plain, JSON-returning
callables; build_server registers them with the SDK's MCPServer (mcp>=2, imported
lazily, so import aegean never pulls the MCP SDK).
mcp_server ¶
An MCP server exposing pyaegean to agents (Claude Code and other MCP clients).
The [mcp] extra installs the Model Context Protocol SDK; aegean-mcp then runs a
stdio MCP server that wraps the toolkit's read/analysis surface as tools, so an agent can
use pyaegean without writing Python:
- corpora & search:
list_corpora,corpus_info,show_document,search_signs,search_text(diacritic-insensitive SQLite FTS5 across corpora, LXX, NT editions, and Patrologia Graeca),balance_accounts,query_corpus,cite_corpus,geo_sites,corpus_diagnose, anddata_status; - library:
library_status(all 47 datasets + 10 packs + disk footprint) andlibrary_search(search corpora, works, commentaries, lexica, and models); - Greek NLP:
greek_pipeline,greek_explain,greek_scan,greek_catalog,greek_work,greek_gloss, andkoine_gloss; - Biblical, Septuagint & Patristic Greek:
biblical_strongs,biblical_word_study,biblical_psalm,biblical_nomina_sacra,biblical_catalog,biblical_lxx,biblical_compare_editions,biblical_witnesses, andbiblical_commentary.
Two conventions hold across every tool. Corpora and works are addressed by registry
name or catalogue work id only: no tool accepts a filesystem path, so the server
never reads or writes arbitrary local files. Domain misses return a structured
{"error": ...} payload carrying a did-you-mean hint instead of raising.
Tool implementations live in domain modules under :mod:aegean.mcp; this facade
re-exports the public surface, TOOLS, build_server, and main.
biblical_catalog ¶
biblical_catalog(kind: str = 'editions', book: str | None = None, section: str | None = None) -> dict[str, Any]
Offline catalogue of Biblical & Koine Greek resources: 'editions' (9 Greek NT editions), 'witnesses' (13 2nd–5th c. CE manuscripts), 'lxx' (56 Septuagint books including Ecclesiastes), or 'commentaries' (112 Greek patristic volumes across 11 Church Fathers / traditions including 26 John Chrysostom commentary series).
biblical_commentary ¶
biblical_commentary(book: str = 'John', work_id: str | None = None, kind: str | None = None, query: str | None = None, limit: int = 5) -> dict[str, Any]
Read or search Greek patristic biblical commentaries across 112 indexed works (NT Catenae, Origen, 26 John Chrysostom commentary/homily series, Cyril of Alexandria, Methodius, Eusebius, Clement of Alexandria, Procopius of Gaza, Photius, Oecumenius, and Theophylact of Bulgaria). Fetches the requested work or collection on first use.
biblical_compare_editions ¶
biblical_compare_editions(book: str, ref: str = '1.18', editions: list[str] | None = None) -> dict[str, Any]
Compare up to 9 Greek New Testament critical editions (nestle1904, sblgnt, srgnt, bhp, tisch, wh, byz, antoniades, tr) with word-level textual diffs (uses cached nt-editions locally; never downloads unexpectedly).
biblical_lxx ¶
biblical_lxx(book: str = 'Gen', ref: str | None = '1.1-5', query: str | None = None, numbering: str = 'lxx', interlinear: bool = False, limit: int = 15) -> dict[str, Any]
Read or search the Greek Septuagint (Swete LXX + Ecclesiastes, 56 books) offline.
Uses cached 56-book lxx-corpus when present, or the bundled Genesis 1 +
Psalm 22 LXX sample. Supports Masoretic Psalm numbering (numbering='mt')
and automatic offline interlinear enrichment (interlinear=True).
biblical_nomina_sacra ¶
Expand early Greek NT manuscript nomina sacra contractions (e.g. θς → θεός, ις → ἰησοῦς, χς → χριστός, πνα → πνεῦμα) with an explicit list of expanded tokens.
biblical_psalm ¶
Convert a Psalm number between Masoretic (Hebrew/English, 'mt') and Septuagint ('lxx') numbering, including the First1KGreek Swete LXX work ID (tlg0527.tlg027).
biblical_strongs ¶
biblical_strongs(query: str, roots: bool = False, search: bool = False, limit: int = 15) -> dict[str, Any]
Look up or search Strong's & Extended Strong's Greek Lexicon entries (offline Dodson or locally cached 11,142-entry Extended Strong's; never fetches over the network).
biblical_witnesses ¶
biblical_witnesses(book: str, ref: str = '1.18', sigla: list[str] | None = None, hand: str = 'original') -> dict[str, Any]
Compare extant 2nd–5th c. CE Greek NT manuscript witnesses (Sinaiticus 01, Vaticanus 03, Alexandrinus 02, Bezae 05, P45–P75) with nomina sacra expansions and scribal corrections (uses cached nt-witnesses locally).
biblical_word_study ¶
Unified Koine Greek word study (Strong's entry, roots, NT distribution, morphology, and verse concordance) over the cached full NT or bundled offline Nestle 1904 sample.
balance_accounts ¶
balance_accounts(corpus: str, doc_id: str | None = None, exact: bool = False, tolerance: float = 0.1, limit: int = 0, offset: int = 0) -> list[dict[str, Any]] | dict[str, Any]
Accounting reconciliation: each stated total (KU-RO / TO-SO) vs the summed items.
Returns one row per total marker (whole corpus, or one doc_id, forgivingly
matched): doc, marker, stated (the written total), computed (the summed
items or subtotals), difference (computed minus stated), items (the count fed
into the sum), and balances. An empty list means the document(s) carry no total
markers. The rows are the shared :func:aegean._view.balance_rows mapping, so this
tool, the aegean balance command, and the terminal UI cannot disagree.
exact=True uses rational equality without an allowance. The rows also
expose exact discrepancy and account eligibility (at least one qualifying
total on intact text); tolerance retains the legacy absolute-one floor.
limit (> 0) and offset (>= 0) paginate whole-corpus results.
Arithmetic agreement does not verify disputed readings or metrology.
cite_corpus ¶
cite_corpus(corpus: str, style: str = 'plain', site: str | None = None, period: str | None = None, scribe: str | None = None, support: str | None = None) -> dict[str, Any]
Cite a corpus (or, with metadata filters, the exact subset) for a paper.
style is 'plain' (one line), 'bibtex' (a @misc entry), or 'apa'. Any of site,
period, scribe, support filters the corpus first (exact match, combined
with AND); the citation then names the subset, so it states exactly what was used.
documents is the cited document count.
corpus_diagnose ¶
A descriptive corpus-health report for a corpus, as structured JSON.
corpus is a name from list_corpora. Reports, as OBSERVABLE facts: the
reading-status profile (certain / unclear / restored / lost, and how many documents
carry apparatus), provenance and citation, the accounting reconciliation for the
Aegean accounting scripts (a discrepancy is a lead, not a verdict on the scribe —
Aegean metrology is imperfectly understood), numeral-parse anomalies, and the
annotation-review state. deep adds a sign-frequency scan (hapax signs and labels
absent from the inventory) for the Aegean syllabic scripts. Every section that does
not apply to a corpus is marked applicable: false rather than raising.
Loading a fetch-on-demand corpus ('nt', 'damos', 'sigla', 'isicily', 'iip', 'iospe',
'igcyr', 'edh', 'ddbdp') downloads it on first use; a cold-cache offline failure
returns the structured error. 'ddbdp' is heavy (57k papyri materialise), and deep
over a large corpus is expensive; check data_status first.
corpus_info ¶
Overview of a corpus: script, document count, source, license, and a citation.
corpus is a name from list_corpora (e.g. 'lineara', 'damos', 'nt'). Loading a
fetch-on-demand corpus ('nt', 'damos', 'sigla', 'isicily', 'iip', 'iospe', 'igcyr',
'edh', 'ddbdp') downloads it on first use (a one-time fetch into the local data
store); check data_status first to see what is already stored. 'ddbdp' is heavy:
loading it materialises 57k papyri (prefer aegean db search ddbdp from the
shell).
data_status ¶
The local data store: every fetchable dataset with its downloaded state, on-disk size, size note, and license.
Read-only (nothing is downloaded or deleted here). The corpora that load by name
over MCP appear under their asset names ('nt-corpus', 'damos-corpus', 'sigla-corpus',
'isicily-corpus', 'iip-corpus', 'iospe-corpus', 'igcyr-corpus', 'edh-corpus',
'ddbdp-corpus'); a dataset that is not downloaded is fetched automatically
(sha256-verified) the first time something needs it, or explicitly from the shell
with aegean data fetch NAME.
geo_sites ¶
Find-site geography for a corpus: coordinates (WGS84), Pleiades ids, and the
contested-provenance flag; with word, the per-site attestation counts of that
word (case-insensitive) instead.
Bundled gazetteer, offline. Only the Aegean inscription corpora yield sites
(lineara, linearb, cypriot, cyprominoan, sigla, damos); alphabetic Greek corpora
(greek, nt) carry no find-spot, and the Greek epigraphy corpora record find-places
outside the Aegean gazetteer, so they yield no rows. A non-empty contested value
is the reason a find-spot is disputed; treat such sites as unverified provenance.
list_corpora ¶
List the corpora that can be loaded by name.
Five are bundled and load offline; the rest ('damos', 'nt', 'sigla', 'isicily', 'iip',
'iospe', 'igcyr', 'edh', 'ddbdp') download into the local data store on first use
(data_status shows what is already stored).
query_corpus ¶
query_corpus(corpus: str, where: list[dict[str, Any]], output_kind: str = 'inscriptions', limit: int = 50, view: str | None = None, count_unit: str = 'document', statuses: list[str] | None = None, offset: int = 0) -> dict[str, Any]
Run the compound query engine over a corpus and cite the exact result set.
Each where row is {"field", "value"} plus optional "connector"
('and'/'or', default 'and') and "negate" (default false); rows chain in order,
and an empty list matches the whole corpus. Fields: id-contains, site-is, scribe-is,
period-is, support-is, has-image, has-annotation, ins-contains-word (inscription
scope); word-contains, word-prefix, word-suffix, word-min-syllables,
word-max-syllables, word-contains-sign, word-cooccurs-with, word-sign-pattern (word
scope). output_kind is 'inscriptions' or 'words'; a word's count is its document
frequency (how many distinct inscriptions carry it), not its token frequency.
limit caps the returned id/word lists (limit <= 0 returns all from offset);
offset paginates through results and truncated / next_offset report
whether more entries remain. The totals are always the full counts. citation
cites exactly this result set.
view selects surface/normalized/lemma keys; omitted keeps legacy predicates.
Normalized/lemma preserve diacritics and iota subscript (NFC, lowercase,
final-sigma fold). Missing lemmas are excluded. count_unit selects document
or token frequency; statuses selects whole tokens and editorial segments.
metadata records normalization, population denominators, and exclusions.
search_signs ¶
search_signs(corpus: str, pattern: str, limit: int = 50, offset: int = 0) -> list[dict[str, Any]] | dict[str, Any]
Words matching a wildcard sign pattern (e.g. 'KU-*-RO'), with frequencies.
limit caps the matches (limit <= 0 returns every match from offset);
offset skips the first offset matches for pagination.
search_text ¶
search_text(query: str, target: str = 'nt', book: str | None = None, edition: str | None = None, limit: int = 20, exact: bool = False) -> dict[str, Any]
Fast diacritic-insensitive full-text search across any registered corpus (lineara, damos, isicily, aphrodisias, crete, apostolic-fathers, pseudepigrapha, byzantine, homer-scholia, nt, ddbdp, patrologia), lxx (56 Septuagint books), nt-editions (9 NT editions), a Patrologia Graeca volume (e.g. PG073), or a CTS work ID (e.g. tlg0012.tlg001). Never accepts filesystem paths; uses local cached datasets and SQLite FTS5 sidecar indexes (offline-only, never downloads).
show_document ¶
One document's metadata and text, line by line.
doc_id is e.g. 'HT13'; case and spacing are forgiven ('ht13', 'py ta 641'
resolve), and a miss reports the closest ids. A source-aligned document also
includes its exact source_text and one alignment object per token.
greek_catalog ¶
greek_catalog(query: str | None = None, author: str | None = None, title: str | None = None, source: str | None = None, limit: int = 40, offset: int = 0) -> dict[str, Any]
Search the bundled catalogue of ~1,800 loadable Greek works (Perseus canonical-greekLit + First1KGreek): id, author, English and Greek title.
All filters are case-insensitive substrings combined with AND; query matches
across id, author, and both titles; source limits to 'perseus' or 'first1k'.
limit caps the returned rows (limit <= 0 returns all from offset; total
is always the full match count, and truncated / next_offset report whether
more rows remain). Bundled metadata: offline and instant. Pass an id to
greek_work to load the text itself (fetched into the local data store on its
first use).
greek_explain ¶
Explain what the (baseline, offline) Greek pipeline did to each token.
One row per token, in pipeline order, carrying token, upos, lemma,
lemma_source (the lemma's evidence class: attested / neural_lookup / neural_edit /
neural / rule / seed / paradigm / identity / unresolved / punct / user),
needs_review (True selects identity/unresolved lemma fallbacks;
False does not certify correctness or human verification),
morphology (the UD FEATS string when a neural backend filled one, else None),
and note (a one-line, plain-language account of what that evidence class means).
The evidence class records provenance, not a correctness verdict. The flag does not
assess POS, morphology, or dependencies. There are deliberately no confidence
numbers (the neural pipeline's calibrated confidence needs the trained model, which
this server does not load). This tool runs the pipeline over text and renders
the records it gets back, exactly as greek_pipeline maps its own, so the two
cannot disagree about the same text; they share no state, so calling both analyzes
that text twice.
greek_gloss ¶
Gloss a Greek word from a registry dictionary: lsj (classical, the default), middle-liddell, cunliffe (Homeric), autenrieth (Homeric), abbott-smith, or dodson (Koine NT).
The word is looked up as given and lemmatized on a miss, so inflected forms resolve.
full adds the complete entry body, not just the concise gloss.
Dodson is bundled and answers immediately. Every other dictionary is fetched into the local data store on first use, and the call blocks for the whole fetch: the compressed index runs from 0.13 MB (abbott-smith) through 0.6 MB (autenrieth), 1.3 MB (cunliffe), and 2.3 MB (middle-liddell) to 15.4 MB (lsj), plus whatever the network costs. Should the prebuilt lsj index be unreachable, the fallback is the 27-file Perseus LSJ TEI source, a far larger download built into an index locally.
Later calls are offline but not free: the index is loaded and parsed on the first call of a session, and lsj expands to a 60 MB, 116,414-entry table. With the index already in the store, that first call costs roughly 0.2 s for abbott-smith, 0.5 s for autenrieth and cunliffe, 0.8 s for middle-liddell, and about 6 s for lsj; lookups after it are immediate. Times are machine-dependent.
greek_pipeline ¶
Run the (baseline, offline) Greek NLP pipeline: one row per token.
Each row carries text, upos, lemma, lemma_source (the lemma's
evidence class: attested / neural_lookup / neural_edit / neural / rule / seed / paradigm /
identity / unresolved / punct / user), lemma_resolved, lemma_verified, and
review_recommended (plus the deprecated lemma_known alias), sentence/index position, and
the parser/neural fields (head, relation, xpos, feats; None under
the baseline), plus alignment_* source identity, exact text, Unicode span,
whitespace, and normalization fields. The rows are the shared
:func:aegean._view.pipeline_rows mapping, so this tool, the aegean greek pipeline
command, and the terminal UI emit identical rows. review_recommended selects
identity/unresolved lemma fallbacks; False does not certify correctness or human
verification and does not assess POS, morphology, or dependencies. The baseline is
a deterministic first pass whose rule and lookup results may still be wrong.
greek_scan ¶
Scan a Greek verse line. meter is 'hexameter' / 'pentameter' / 'trimeter' or an
aeolic line type ('sapphic_hendecasyllable', 'glyconic', …). Reports the glyph pattern,
or scans: false with the reason if the line does not fit.
greek_work ¶
Load a real Greek work by its CTS-style catalogue id (e.g. 'tlg0012.tlg001', the Iliad), whole or one section, and summarize it with a short text preview.
work_id is an id from greek_catalog (Perseus canonical-greekLit /
First1KGreek), never a filesystem path. ref selects a section by citation
address: '1' (a book), '1.2' (a chapter), '1.1-1.50' (a verse line-range), a
margin milestone outside the CTS
greek_gloss's dictionaries. Returns the work summary (documents, tokens,
first document id, name, source, data_version) plus preview: the first
preview_lines lines of the first document (preview_lines <= 0 sends none).
An unknown or malformed id returns a structured error pointing at the catalog.
koine_gloss ¶
Koine (NT) gloss for a Greek word via the bundled Dodson lexicon (offline, CC0).
library_search ¶
library_search(query: str, category: str | None = None, installed_only: bool = False, limit: int = 25) -> dict[str, Any]
Search across all 47 hosted datasets, 5 bundled corpora, 3,844 categorized Greek collection works, 1,778 Perseus/First1KGreek works, 112 patristic commentaries, 5 lexica, and neural models by ID, author, title, or alias. Offline, strictly read-only.
library_status ¶
Inspect the unified pyaegean library: bundled vs installed corpora, 10 themed packs (biblical, church-fathers, patristic, ancient-greek, byzantine-pack, aegean, epigraphy, literary, lexica, neural), 3,844 categorized Greek collection works, cached Perseus/ First1KGreek works, and total disk footprint. Strictly read-only, never downloads.
build_server ¶
Build an MCPServer with every pyaegean tool registered (needs the [mcp] extra).