API modules
The server page documents the compatibility entry point. Tool functions and helpers are documented under their implementation modules.
perseus_mcp
Perseus MCP package.
perseus_mcp.server
Backward-compatible entry point for notebooks, direct Python calls, and stdio MCP.
Implementation lives in the focused modules and perseus_mcp.tools.
Legacy attributes (including private test/embedding hooks) forward reads and
writes to their owning module so there is only one HTTP client and cache.
New internal code imports the owning modules, never this compatibility facade.
- perseus_mcp.server.main()[source]
Validate configuration and run the shared MCP server over stdio.
- Return type:
None
perseus_mcp.__main__
Module entry point for python -m perseus_mcp.
perseus_mcp._app
Create the shared MCP application and translate upstream failures at tool boundaries.
perseus_mcp._common
Normalize XML text, language names, and pagination arguments shared by the tools.
- perseus_mcp._common._bounded_list_limit(value, name='limit')[source]
Validate a result-page
limitand cap it at _MAX_LIST_LIMIT.These limits bound how many entries a single tool call can return. Without an upper bound, a caller (or an LLM guessing at arguments) could request an arbitrarily large limit and get back a payload sized for nothing in particular, which is wasteful for the upstream fetch and expensive to push into a model’s context window.
- Parameters:
value (int)
name (str)
- Return type:
int
- perseus_mcp._common._direct_child_texts(element, local_name)[source]
Return normalized, nonempty text values from matching direct children.
- Parameters:
element (Element)
local_name (str)
- Return type:
list[str]
- perseus_mcp._common._direct_children(element, local_name=None)[source]
Return direct children, optionally matching a case-insensitive local tag name.
- Parameters:
element (Element)
local_name (str | None)
- Return type:
list[Element]
- perseus_mcp._common._element_language(element)[source]
Read the XML language attribute, accepting expanded and literal spellings.
- Parameters:
element (Element)
- Return type:
str | None
- perseus_mcp._common._element_text(element)[source]
Join descendant XML text and normalize its whitespace.
- Parameters:
element (Element)
- Return type:
str
- perseus_mcp._common._local_name(tag)[source]
Return an XML tag name without its namespace.
- Parameters:
tag (str)
- Return type:
str
- perseus_mcp._common._non_negative_int(value, name)[source]
Return a nonnegative value or raise ValueError naming the argument.
- Parameters:
value (int)
name (str)
- Return type:
int
- perseus_mcp._common._normalize_cts_language(language)[source]
Map known Greek/Latin aliases to CTS codes and preserve other normalized codes.
- Parameters:
language (str | None)
- Return type:
str | None
- perseus_mcp._common._normalize_search_kind(search_kind)[source]
Validate form or lemma search, defaulting an empty value to form.
- Parameters:
search_kind (str | None)
- Return type:
str
- perseus_mcp._common._normalize_search_language(language)[source]
Normalize a user-facing search language to Scaife’s two-letter code.
Accepts “greek”/”grc”/”gr” and case-insensitive variants for Greek, and “latin”/”lat”/”la” for Latin (see _COMMON_LANGUAGE_CODES). A missing or blank value defaults to Greek. Any other value raises ValueError instead of being silently truncated to its first two characters, which previously produced a nonsensical Scaife language code with no indication that the input was not recognized.
- Parameters:
language (str | None)
- Return type:
str
- perseus_mcp._common._normalize_search_result_format(result_format)[source]
Validate instances or passages output, defaulting to instances.
- Parameters:
result_format (str | None)
- Return type:
str
perseus_mcp.http
Fetch and validate bounded upstream responses using a shared asynchronous HTTP client.
- exception perseus_mcp.http.UpstreamRateLimitWarning[source]
Warn that Perseus or Scaife rejected a request because of rate limiting.
- perseus_mcp.http._body_timeout_seconds()[source]
Read the positive finite total body deadline in seconds, defaulting to 60.
- Return type:
float
- async perseus_mcp.http._close_http_client(client, client_loop)[source]
Close a client without failing when its owning loop has already ended.
- Parameters:
client (AsyncClient)
client_loop (AbstractEventLoop | None)
- Return type:
None
- async perseus_mcp.http._get(url, params=None, timeout=20.0, *, validator=<function validate_text>)[source]
Fetch bounded response text, validate it, and map transport failures.
- Parameters:
url (str) – Upstream endpoint URL.
params (dict[str, Any] | None) – Optional query parameters.
timeout (float) – HTTPX per-operation timeout in seconds.
validator (Callable[[str], None]) – Callback that rejects unexpected response text.
- Returns:
Decoded text that passed the supplied validator.
- Raises:
UpstreamFailure – On access challenges, HTTP/transport failures, size or deadline limits, or invalid payloads. No automatic retry is made.
ValueError – If a response-size or body-deadline setting is invalid.
- Return type:
str
The total body deadline and decoded-byte limit are configured separately through
PERSEUS_MCP_BODY_TIMEOUT_SECONDSandPERSEUS_MCP_MAX_RESPONSE_BYTES.
- perseus_mcp.http._max_response_bytes()[source]
Read the positive response-size limit in decoded bytes, raising ValueError if invalid.
- Return type:
int
Return a process-wide httpx.AsyncClient, reused across tool calls.
Opening a brand new client (and therefore a new TCP/TLS connection) for every tool call is wasteful for a long-lived MCP server, especially for passage-processing workflows that make many sequential requests to the same Perseus/Scaife hosts. Reusing one client lets httpx pool and reuse connections instead.
The client is recreated if the running event loop has changed (or the previous client was closed), since an httpx.AsyncClient’s underlying transport is bound to the loop it was created on. In normal operation there is exactly one loop for the lifetime of the process; this check mainly matters for test suites that call
asyncio.run()per test.- Return type:
AsyncClient
perseus_mcp.cache
Store validated metadata in memory and on disk with expiry and atomic writes.
- exception perseus_mcp.cache.MetadataCacheWarning[source]
Warn that the optional metadata cache could not be updated.
- perseus_mcp.cache._cache_dir()[source]
Resolve an override or the platform’s shared per-user metadata cache.
- Return type:
Path
- perseus_mcp.cache._cache_enabled()[source]
Return whether the environment permits metadata caching.
- Return type:
bool
- perseus_mcp.cache._cache_key(parts)[source]
Hash a canonical JSON representation of request parameters for a disk-safe key.
- Parameters:
parts (dict[str, Any])
- Return type:
str
- perseus_mcp.cache._cache_path(namespace, key, extension='txt')[source]
Locate an entry within its cache namespace without creating directories.
- Parameters:
namespace (str)
key (str)
extension (str)
- Return type:
Path
- perseus_mcp.cache._cache_status()[source]
Serialize cache configuration, entry counts, and disk usage as JSON.
- Return type:
str
- perseus_mcp.cache._cache_ttl_seconds()[source]
Read the cache lifetime in seconds; zero disables expiry, not caching.
- Return type:
int
- async perseus_mcp.cache._cached_text(namespace, key_parts, fetcher, *, extension='xml', refresh=False, disk_validator=<function validate_text>)[source]
Cache validated fetch results; validate untrusted disk entries on load.
disk_validator runs only on disk loads, not memory hits or fresh fetches. Fetchers must validate before returning (the production fetchers use _get). Memory entries have already passed upstream or disk validation.
- Parameters:
namespace (str)
key_parts (dict[str, Any])
extension (str)
refresh (bool)
disk_validator (Callable[[str], None])
- Return type:
str
- perseus_mcp.cache._clear_cache()[source]
Clear generated metadata entries without recursively deleting user directories.
- Return type:
str
- perseus_mcp.cache._disk_cache_get(path)[source]
Read unexpired UTF-8 text; return None on a miss or unreadable entry.
- Parameters:
path (Path)
- Return type:
str | None
- perseus_mcp.cache._disk_cache_set(path, value)[source]
Write a cache entry atomically.
PERSEUS_MCP_CACHE_DIR is documented as safe to share across multiple local processes (an MCP server plus one or more notebook kernels). A plain
path.write_text(...)is not atomic, so two processes writing the same cache key around the same time could interleave and leave a corrupted file that fails to parse on the next read. Writing to a process-unique temporary file in the same directory and then usingos.replace(atomic on POSIX and Windows when source/destination are on the same volume) avoids that.- Parameters:
path (Path)
value (str)
- Return type:
None
- perseus_mcp.cache._memory_cache_get(name)[source]
Return an unexpired, previously validated memory entry or None.
- Parameters:
name (str)
- Return type:
str | None
- perseus_mcp.cache._memory_cache_set(name, value)[source]
Store validated text with its insertion time when caching is enabled.
- Parameters:
name (str)
value (str)
- Return type:
None
- perseus_mcp.cache._remove_readonly_cache_entry(function, path, error)[source]
Make a protected cache entry writable and retry its removal.
On Unix, a protected parent directory can prevent even
chmodfrom reaching the failed entry. Restore access to the parent first, then make the entry writable and retry the failed removal operation.- Parameters:
path (str)
error (BaseException)
- Return type:
None
perseus_mcp.cts
Request CTS documents, cache inventories and references, and parse passage/navigation XML.
- async perseus_mcp.cts._cts_request(request, urn=None, **extra_params)[source]
Fetch a CTS operation with optional URN and parameters, validating its envelope.
- Parameters:
request (str)
urn (str | None)
extra_params (Any)
- Return type:
str
- perseus_mcp.cts._first_urn_xml(urn, reference_urns)[source]
Build first-reference XML, reporting an empty reference list as an error.
- Parameters:
urn (str)
reference_urns (list[str])
- Return type:
str
- async perseus_mcp.cts._get_capabilities_cached(refresh=False)[source]
Return validated CTS inventory XML, optionally bypassing existing caches.
- Parameters:
refresh (bool)
- Return type:
str
- async perseus_mcp.cts._get_valid_references_cached(urn, level=None, refresh=False)[source]
Return validated reference XML for a URN and optional citation level.
- Parameters:
urn (str)
level (int | None)
refresh (bool)
- Return type:
str
- perseus_mcp.cts._is_xml_response(response_text, expected_root)[source]
Return whether safe XML parsing finds the expected local root name.
- Parameters:
response_text (str)
expected_root (str)
- Return type:
bool
- perseus_mcp.cts._passage_plaintext_from_xml(passage_xml)[source]
Extract readable text blocks from CTS/TEI XML without duplicating nested blocks.
- Parameters:
passage_xml (str)
- Return type:
str
- perseus_mcp.cts._prev_next_xml(urn, reference_urns)[source]
Build navigation XML from ordered references, reporting an absent URN as an error.
- Parameters:
urn (str)
reference_urns (list[str])
- Return type:
str
perseus_mcp.scaife
Build Scaife URLs, cache its catalogue, and apply author scopes to search results.
- perseus_mcp.scaife._add_author_scope_metadata(response_text, author, authors, text_group)[source]
Annotate object-shaped results with the author filter sent to Scaife.
- Parameters:
response_text (str)
author (str)
authors (list[dict[str, Any]])
text_group (str)
- Return type:
str
- perseus_mcp.scaife._extract_cts_urns(value)[source]
Recursively extract CTS URNs from strings, lists, and JSON object values.
- Parameters:
value (Any)
- Return type:
list[str]
- perseus_mcp.scaife._filter_scaife_search_response_by_author(response_text, author, authors)[source]
Filter the current result page by author URNs and annotate the scope/counts.
- Parameters:
response_text (str)
author (str)
authors (list[dict[str, Any]])
- Return type:
str
- async perseus_mcp.scaife._get_scaife_library_catalog_cached(refresh=False)[source]
Return validated Scaife catalogue JSON, optionally refreshing both caches.
- Parameters:
refresh (bool)
- Return type:
str
- perseus_mcp.scaife._quote_urn_path_segment(urn)[source]
Percent-encode a URN for safe use as a single URL path segment.
CTS URNs legitimately contain colons and periods, so those are left unescaped for readability; everything else (spaces, ‘#’, ‘?’, ‘%’, non-ASCII characters, etc.) is encoded so the value cannot truncate the URL, inject query parameters, or otherwise change the request target.
- Parameters:
urn (str)
- Return type:
str
- perseus_mcp.scaife._result_matches_author_scope(result, scope_urns)[source]
Return whether a search result contains any URN within the author scope.
- Parameters:
result (Any)
scope_urns (list[str])
- Return type:
bool
- perseus_mcp.scaife._scaife_library_url(urn)[source]
Build the JSON metadata URL for a safely encoded CTS URN.
- Parameters:
urn (str)
- Return type:
str
- perseus_mcp.scaife._scaife_passage_json_url(urn)[source]
Build the passage JSON URL for a safely encoded CTS URN.
- Parameters:
urn (str)
- Return type:
str
- perseus_mcp.scaife._scaife_passage_text_url(urn)[source]
Build the passage plaintext URL for a safely encoded CTS URN.
- Parameters:
urn (str)
- Return type:
str
- perseus_mcp.scaife._single_author_text_group_urn(authors)[source]
Return a textgroup URN only when exactly one nonempty author URN exists.
- Parameters:
authors (list[dict[str, Any]])
- Return type:
str | None
perseus_mcp.greek
Convert Beta Code to Unicode Greek and normalize search queries without network access.
- perseus_mcp.greek._betacode_to_greek(query)[source]
Convert Beta Code words while preserving surrounding punctuation and whitespace.
- Parameters:
query (str)
- Return type:
str
- perseus_mcp.greek._betacode_word_to_greek(word)[source]
Convert a Beta Code word, including accents, capitals, and final sigma, to NFC.
- Parameters:
word (str)
- Return type:
str
- perseus_mcp.greek._looks_like_betacode(query)[source]
Detect explicit Beta Code marks or short ASCII alphabetic queries heuristically.
- Parameters:
query (str)
- Return type:
bool
- perseus_mcp.greek._normalize_greek_query(query, query_format='auto')[source]
Normalize Unicode Greek or Beta Code search text to NFC Unicode Greek.
- Parameters:
query (str)
query_format (str)
- Return type:
str
- perseus_mcp.greek._normalize_query_for_search(query, language='greek', query_format='auto', preserve_operators=False)[source]
Validate a nonempty query and normalize Greek unless operators must be preserved.
- Parameters:
query (str)
language (str)
query_format (str)
preserve_operators (bool)
- Return type:
str
perseus_mcp.discovery
Parse and merge CTS and Scaife inventories to discover authors, works, and editions.
- perseus_mcp.discovery._author_name_matches_response(authors, query, language=None, limit=100, offset=0)[source]
Serialize a ranked page of author matches with pagination metadata.
- Parameters:
authors (list[dict[str, Any]])
query (str)
language (str | None)
limit (int)
offset (int)
- Return type:
str
- perseus_mcp.discovery._author_resources_from_capabilities(capabilities_xml, author, language=None)[source]
Serialize matching CTS authors with their editions and translations.
- Parameters:
capabilities_xml (str)
author (str)
language (str | None)
- Return type:
str
- perseus_mcp.discovery._capabilities_root(capabilities_xml)[source]
Parse inventory XML with entity expansion and unsafe constructs disabled.
- Parameters:
capabilities_xml (str)
- Return type:
Element
- perseus_mcp.discovery._language_from_cts_urn(urn)[source]
Infer Greek or Latin from a CTS namespace, returning None for other namespaces.
- Parameters:
urn (str | None)
- Return type:
str | None
- perseus_mcp.discovery._list_text_groups_from_capabilities(capabilities_xml, language=None, query=None, limit=100, offset=0)[source]
Return a JSON page of matching CTS authors and their works.
- Parameters:
capabilities_xml (str)
language (str | None)
query (str | None)
limit (int)
offset (int)
- Return type:
str
- perseus_mcp.discovery._matching_author_entries_from_capabilities(capabilities_xml, author, language=None, *, names_only=False)[source]
Find CTS authors by name or URN, with optional original-language filtering.
- Parameters:
capabilities_xml (str)
author (str)
language (str | None)
names_only (bool)
- Return type:
list[dict[str, Any]]
- perseus_mcp.discovery._matching_author_entries_from_scaife_catalog(catalog_json, author, language=None, *, names_only=False)[source]
Find authors in Scaife catalogue JSON, optionally matching names alone.
- Parameters:
catalog_json (str)
author (str)
language (str | None)
names_only (bool)
- Return type:
list[dict[str, Any]]
- perseus_mcp.discovery._merge_author_entries(*author_groups)[source]
Merge author inventories by URN, retaining metadata and avoiding duplicate works.
- Parameters:
author_groups (list[dict[str, Any]])
- Return type:
list[dict[str, Any]]
- perseus_mcp.discovery._query_match_rank(values, query)[source]
Rank exact, word-prefix, prefix, and substring matches, then prefer shorter values.
- Parameters:
values (list[str | None])
query (str)
- Return type:
tuple[int, int]
- async perseus_mcp.discovery._resolve_author_entries(author, language=None, *, names_only=False)[source]
Fetch both catalogues concurrently and merge matches; allow one source to fail.
- Parameters:
author (str)
language (str | None)
names_only (bool)
- Return type:
list[dict[str, Any]]
- perseus_mcp.discovery._resource_entry(element)[source]
Convert a CTS edition or translation element into a compact resource record.
- Parameters:
element (Element)
- Return type:
dict[str, Any]
- perseus_mcp.discovery._scaife_work_entry(work)[source]
Adapt a Scaife work to the shared inventory shape without inventing metadata.
- Parameters:
work (dict[str, Any])
- Return type:
dict[str, Any]
- perseus_mcp.discovery._text_group_entry(text_group, include_works=True)[source]
Convert a CTS textgroup into author names and an optional list of works.
- Parameters:
text_group (Element)
include_works (bool)
- Return type:
dict[str, Any]
- perseus_mcp.discovery._text_matches_query(values, query)[source]
Match a case-insensitive substring across values; an empty query matches all.
- Parameters:
values (list[str | None])
query (str | None)
- Return type:
bool
- perseus_mcp.discovery._work_entry(work)[source]
Convert a CTS work element into titles, language, and grouped resources.
- Parameters:
work (Element)
- Return type:
dict[str, Any]
perseus_mcp.upstream
Validate upstream representations without exposing response bodies in errors.
- perseus_mcp.upstream._retry_policy(configuration)[source]
Parse and cache retry overrides, rejecting unknown codes and non-boolean values.
- Parameters:
configuration (str)
- Return type:
dict[str, bool]
- perseus_mcp.upstream.validate_retry_policy()[source]
Reject invalid retry-policy configuration before starting the server.
- Return type:
None
- perseus_mcp.upstream.retry_allowed(code, status=None)[source]
Return the configured retry hint, otherwise using error-code and HTTP-status defaults.
- Parameters:
code (str)
status (int | None)
- Return type:
bool
- perseus_mcp.upstream.parse_retry_after(value, *, now=None)[source]
Convert Retry-After to a delay capped at one hour.
- Parameters:
value (str | None)
now (datetime | None)
- Return type:
int | None
- exception perseus_mcp.upstream.UpstreamFailure(code, message, status=None, *, retry_after_seconds=None)[source]
An expected upstream failure with a safe, stable public description.
- Parameters:
code (str)
message (str)
status (int | None)
retry_after_seconds (int | None)
- class perseus_mcp.upstream._PageMarkers[source]
Recognize HTML documents and Anubis challenge markers without rendering them.
- perseus_mcp.upstream.reject_challenge(text, status=None)[source]
Raise UPSTREAM_CHALLENGE when an HTML/XML prefix contains Anubis markers.
- Parameters:
text (str)
status (int | None)
- Return type:
None
- perseus_mcp.upstream._invalid()[source]
Raise a safe INVALID_PAYLOAD failure without including upstream response content.
- Return type:
None
- perseus_mcp.upstream.validate_text(text)[source]
Reject access challenges and HTML pages where plaintext is expected.
- Parameters:
text (str)
- Return type:
None
- perseus_mcp.upstream._json(text)[source]
Decode JSON after challenge detection, mapping parse failures to INVALID_PAYLOAD.
- Parameters:
text (str)
- Return type:
Any
- perseus_mcp.upstream._objects(value)[source]
Return whether a value is a list containing only JSON objects.
- Parameters:
value (Any)
- Return type:
bool
- perseus_mcp.upstream.validate_search(text)[source]
Validate Scaife search result shapes and nonnegative pagination counters.
- Parameters:
text (str)
- Return type:
None
- perseus_mcp.upstream.validate_catalogue(text)[source]
Validate Scaife textgroup catalogue JSON and reject embedded errors.
- Parameters:
text (str)
- Return type:
None
- perseus_mcp.upstream.validate_metadata(text)[source]
Require a CTS URN in Scaife metadata JSON and reject embedded errors.
- Parameters:
text (str)
- Return type:
None
- perseus_mcp.upstream.validate_passage_json(text)[source]
Validate Scaife passage metadata and require a string text_html field.
- Parameters:
text (str)
- Return type:
None
- perseus_mcp.upstream.validate_cts(text, request)[source]
Validate a CTS operation by local root name, independent of its namespace.
- Parameters:
text (str) – Upstream XML response, or an upstream error body.
request (str) – Expected CTS operation such as GetPassage or GetCapabilities.
- Raises:
UpstreamFailure – For challenges, invalid URNs, CTS errors, malformed XML, or an unexpected root. Error messages never include response bodies.
- Return type:
None
Accepts TEI passage roots, TextInventory capabilities, and GetPassage envelopes returned for GetPassagePlus.
perseus_mcp.validation
Bound caller-controlled strings and check CTS structure before cache or network use.
- perseus_mcp.validation.validate_text(value, name='query', *, maximum=2048, allow_empty=False)[source]
Reject oversized or non-text input before normalization, without echoing it.
- Parameters:
value (str)
name (str)
maximum (int)
allow_empty (bool)
- Return type:
str
- perseus_mcp.validation._identifier(value, *, hyphens=True)[source]
Recognize nonempty Unicode identifiers without CTS structural separators.
- Parameters:
value (str)
hyphens (bool)
- Return type:
bool
- perseus_mcp.validation._subreference(value)[source]
Accept one or two literal substrings with optional positive occurrence indexes.
- Parameters:
value (str)
- Return type:
bool
- perseus_mcp.validation._node(value)[source]
Check dotted citation labels and an optional Unicode substring reference.
- Parameters:
value (str)
- Return type:
bool
- perseus_mcp.validation._passage(value)[source]
Check a node or node range with at most one substring range per endpoint.
- Parameters:
value (str)
- Return type:
bool
- perseus_mcp.validation.validate_urn(value, name='urn')[source]
Validate bounded CTS syntax, retaining the catalogue’s no-final-colon spelling.
This checks structure, not whether a namespace, work, or citation exists. Author/work/edition/exemplar URNs may have an empty or omitted passage; passage labels, ranges, and Unicode subreferences remain supported.
- Parameters:
value (str)
name (str)
- Return type:
str
perseus_mcp.tools
MCP tool implementations, registered when the server compatibility module imports them.
perseus_mcp.tools.cts
Expose CTS passage, reference, label, and navigation operations as MCP tools.
- async perseus_mcp.tools.cts.count_valid_references(urn, level=None)[source]
Count valid citation references without returning the full reference list.
- Parameters:
urn (str)
level (int | None)
- Return type:
str
- async perseus_mcp.tools.cts.get_capabilities()[source]
Get the list of available texts and editions from Perseus CTS.
- Return type:
str
- async perseus_mcp.tools.cts.get_first_urn(urn)[source]
Get the first available reference URN for a work/edition URN.
- Parameters:
urn (str)
- Return type:
str
- async perseus_mcp.tools.cts.get_label(urn)[source]
Get label XML, falling back to GetPassage request metadata when needed.
- Parameters:
urn (str)
- Return type:
str
- async perseus_mcp.tools.cts.get_passage(urn)[source]
Get the text of a specific passage using a CTS URN.
Examples: - urn:cts:greekLit:tlg0012.tlg001:1.1-1.10 - urn:cts:greekLit:tlg0012.tlg001.perseus-grc1:1.1
- Parameters:
urn (str)
- Return type:
str
- async perseus_mcp.tools.cts.get_passage_plaintext(urn)[source]
Get a passage as plain readable text instead of raw CTS XML.
- Parameters:
urn (str)
- Return type:
str
- async perseus_mcp.tools.cts.get_passage_plus(urn)[source]
Get passage text plus surrounding metadata/context for a CTS URN.
- Parameters:
urn (str)
- Return type:
str
- async perseus_mcp.tools.cts.get_prev_next_urn(urn)[source]
Get previous and next URNs for a passage URN.
- Parameters:
urn (str)
- Return type:
str
perseus_mcp.tools.cache
Expose metadata cache inspection, refresh, and removal as MCP tools.
- async perseus_mcp.tools.cache.clear_metadata_cache()[source]
Clear local metadata cache files and in-memory cache entries.
- Return type:
str
perseus_mcp.tools.discovery
Expose author and work discovery from the upstream inventories as MCP tools.
- async perseus_mcp.tools.discovery.find_author_names(query, language=None, limit=100, offset=0)[source]
Find author/textgroup names by partial name match across Perseus catalogs.
This merges the legacy CTS capabilities inventory with Scaife’s library catalog, then matches author/textgroup name fields only, not work titles. A result can therefore be found when either upstream inventory contains it. limit must be between 1 and 500. Use offset with has_more to page through all matching authors. Examples: - query: “Hom” - query: “Plut”
- Parameters:
query (str)
language (str | None)
limit (int)
offset (int)
- Return type:
str
- async perseus_mcp.tools.discovery.get_author_resources(author, language=None)[source]
List CTS works/editions/translations for an author name or textgroup URN.
Examples: - author: “Homer” - author: “tlg0012” - author: “urn:cts:greekLit:tlg0012”
- Parameters:
author (str)
language (str | None)
- Return type:
str
- async perseus_mcp.tools.discovery.get_work_resources(urn_or_title, language=None)[source]
List editions/translations/resources for a matching work URN or title.
Optional language accepts values such as “greek”, “grc”, “latin”, or “lat” and filters by the original work language.
Examples: - urn_or_title: “urn:cts:greekLit:tlg0012.tlg001” - urn_or_title: “Iliad”
- Parameters:
urn_or_title (str)
language (str | None)
- Return type:
str
- async perseus_mcp.tools.discovery.list_text_groups(language=None, query=None, limit=100, offset=0)[source]
List authors/textgroups and their works from CTS capabilities.
Optional language accepts values such as “greek”, “grc”, “latin”, or “lat”. Optional query matches author names, textgroup URNs, or work titles. limit must be between 1 and 500. Use offset with has_more to page through matching textgroups.
- Parameters:
language (str | None)
query (str | None)
limit (int)
offset (int)
- Return type:
str
perseus_mcp.tools.search
Expose Scaife searches with Greek normalization and optional author scoping.
- async perseus_mcp.tools.search.get_passage_highlights(query, passage_urn, language='greek', query_format='auto', search_kind='form', preserve_operators=False)[source]
Get Scaife token highlight positions for a query within one passage.
- Parameters:
query (str)
passage_urn (str)
language (str)
query_format (str)
search_kind (str)
preserve_operators (bool)
- Return type:
str
- async perseus_mcp.tools.search.search_perseus(query, language='greek', query_format='auto', author=None, search_kind='form', preserve_operators=False, page_num=1, text_group=None, work=None, result_format='instances')[source]
Search Perseus texts via Scaife API.
For Greek searches, query may be Unicode Greek or Beta Code. The default query_format=”auto” detects explicit Beta Code marks such as =, /, (, ), and *, and also accepts short unaccented Beta Code queries such as logos. Set query_format=”betacode” to force conversion or query_format=”unicode” to preserve ASCII text in Greek searches. The language value determines whether Greek query normalization is applied; it is not sent to Scaife as a corpus language filter. Optional author resolves a CTS author/textgroup name or URN, then locally filters the current Scaife result page to matching CTS URN prefixes. search_kind may be “form” or “lemma”. Set preserve_operators=True for Scaife operator queries such as quoted phrases, -, |, *, or ~. Optional page_num, text_group, work, and result_format are passed to Scaife’s library search endpoint. When author resolves to exactly one CTS textgroup and no explicit text_group or work is supplied, the author scope is sent to Scaife as a server-side text_group filter.
- Parameters:
query (str)
language (str)
query_format (str)
author (str | None)
search_kind (str)
preserve_operators (bool)
page_num (int)
text_group (str | None)
work (str | None)
result_format (str)
- Return type:
str
- async perseus_mcp.tools.search.search_within_text(query, text_urn, language='greek', query_format='auto', search_kind='form', preserve_operators=False, size=10, offset=0)[source]
Search within a single Scaife text/edition URN.
size must be between 1 and 500.
- Parameters:
query (str)
text_urn (str)
language (str)
query_format (str)
search_kind (str)
preserve_operators (bool)
size (int)
offset (int)
- Return type:
str
perseus_mcp.tools.scaife
Expose Scaife metadata and passage representations as MCP tools.
- async perseus_mcp.tools.scaife.get_scaife_library_metadata(urn)[source]
Get Scaife JSON metadata for a textgroup, work, edition, or translation URN.
- Parameters:
urn (str)
- Return type:
str