API

Package librovore

Model Context Protocol (MCP) server for Sphinx documentation.

librovore.main()

Entrypoint.

Module librovore.interfaces

Common enumerations and interfaces.

class librovore.interfaces.DisplayFormat(value)

Bases: Enum

Enumeration for CLI display formats.

Variables:
class librovore.interfaces.FilterCapability(*, name, description, type, values=None, required=False)

Bases: DataclassObject

Describes a filter supported by a processor.

Variables:
class librovore.interfaces.InventoryQueryDetails(value)

Bases: IntFlag

Enumeration for inventory query detail levels.

Variables:
class librovore.interfaces.MatchMode(value)

Bases: str, Enum

Enumeration for different term matching modes.

Variables:
class librovore.interfaces.ProcessorCapabilities(*, processor_name, version, supported_filters, results_limit_max=None, response_time_typical=None, notes=None)

Bases: DataclassObject

Complete capability description for a processor.

Variables:
class librovore.interfaces.ProcessorGenera(value)

Bases: Enum

Enumeration for processor types/genera.

Variables:
class librovore.interfaces.SearchBehaviors(*, match_mode=MatchMode.Fuzzy, fuzzy_threshold=50)

Bases: DataclassObject

Search behavior configuration for the search engine.

Variables:

Module librovore.cacheproxy

HTTP cache for documentation URL access.

type librovore.cacheproxy.HttpClientFactory = collections.abc.Callable[[], httpx.AsyncClient]
type librovore.cacheproxy.ContentResponse = appcore.generics.Result[bytes, Exception]
type librovore.cacheproxy.ProbeResponse = appcore.generics.Result[bool, Exception]
type librovore.cacheproxy.RobotsResponse = appcore.generics.Result[urllib.robotparser.RobotFileParser, Exception]
class librovore.cacheproxy.Cache(*, error_ttl=absence.absent, success_ttl=absence.absent, delay_function=<function sleep>)

Bases: Object

Cache base with shared configuration attributes.

Variables:
acquire_mutex_for(url)

Acquires mutex for HTTP request deduplication.

Parameters:
  • self

  • url (str)

class librovore.cacheproxy.CacheContext(*, content_cache, probe_cache, robots_cache)

Bases: DataclassObject

Context carrying configured cache instances.

Variables:
classmethod from_configuration(configuration)

Creates cache context from application configuration.

Parameters:
Return type:

typing_extensions.Self

class librovore.cacheproxy.CacheEntry(*, timestamp, ttl)

Bases: DataclassObject

Cache entry base.

Variables:
property invalid

Checks if cache entry has exceeded its TTL.

Parameters:

self

Return type:

bool

class librovore.cacheproxy.ContentCache(*, robots_cache=absence.absent, memory_max=absence.absent, **base_initargs)

Bases: Cache

Cache manager for URL content (GET requests) with memory tracking.

Variables:
async access(url)

Retrieves cached content if valid.

Parameters:
  • self

  • url (str)

Return type:

tuple[ bytes, httpx.Headers ] | absence.objects.AbsentSingleton

determine_ttl(response)

Determines appropriate TTL based on response type.

Parameters:
Return type:

float

classmethod from_configuration(configuration, robots_cache=absence.absent)

Creates ContentCache instance from application configuration.

Parameters:
Return type:

typing_extensions.Self

async retrieve_url(url, /, *, duration_max=30.0, client_factory=<class 'httpx.AsyncClient'>)

Convenience method for retrieving URL content.

Parameters:
Return type:

bytes

async store(url, response, headers, ttl)

Stores content in cache with memory management.

Parameters:
class librovore.cacheproxy.ContentCacheEntry(*, timestamp, ttl, response, headers, size_bytes)

Bases: CacheEntry

Cache entry for URL content with size tracking.

Variables:
property memory_usage

Calculates total memory usage including metadata.

Parameters:

self

Return type:

int

class librovore.cacheproxy.ProbeCache(*, robots_cache=absence.absent, entries_max=absence.absent, **base_initargs)

Bases: Cache

Cache manager for URL probe results (HEAD requests).

Variables:
async access(url)

Retrieves cached probe result if valid.

Parameters:
  • self

  • url (str)

Return type:

bool | absence.objects.AbsentSingleton

determine_ttl(response)

Determines appropriate TTL based on response type.

Parameters:
Return type:

float

classmethod from_configuration(configuration, robots_cache=absence.absent)

Creates ProbeCache instance from application configuration.

Parameters:
Return type:

typing_extensions.Self

async probe_url(url, /, *, duration_max=10.0, client_factory=<class 'httpx.AsyncClient'>)

Convenience method for probing URL existence.

Parameters:
Return type:

bool

async store(url, response, ttl)

Stores probe result in cache.

Parameters:
class librovore.cacheproxy.ProbeCacheEntry(*, timestamp, ttl, response)

Bases: CacheEntry

Cache entry for URL probe results.

Variables:
class librovore.cacheproxy.RobotsCache(*, entries_max=absence.absent, ttl=absence.absent, request_timeout=absence.absent, user_agent=absence.absent, **base_initargs)

Bases: Cache

Cache manager for robots.txt files with crawl delay tracking.

Variables:
async access(domain)

Retrieves cached robots.txt parser if valid.

Parameters:
  • self

  • domain (str)

Return type:

urllib.robotparser.RobotFileParser | absence.objects.AbsentSingleton

assign_delay(domain, delay_seconds)

Sets next allowed request time for domain.

Parameters:
  • self

  • domain (str)

  • delay_seconds (float)

calculate_delay_remainder(domain)

Returns remaining crawl delay time for domain.

Parameters:
  • self

  • domain (str)

Return type:

float

determine_ttl(response)

Determines appropriate TTL based on response type.

Parameters:
Return type:

float

classmethod from_configuration(configuration)

Creates RobotsCache instance from application configuration.

Parameters:
Return type:

typing_extensions.Self

async store(domain, response, ttl)

Stores robots.txt parser in cache.

Parameters:
class librovore.cacheproxy.RobotsCacheEntry(*, timestamp, ttl, response)

Bases: CacheEntry

Cache entry for robots.txt parser.

Variables:
librovore.cacheproxy.prepare(auxdata)

Prepares cache instances from configuration.

Returns cache instances constructed from application configuration.

Parameters:

auxdata (appcore.state.Globals)

Return type:

tuple[ librovore.cacheproxy.ContentCache, librovore.cacheproxy.ProbeCache, librovore.cacheproxy.RobotsCache ]

async librovore.cacheproxy.probe_url(cache, url, *, duration_max=10.0, client_factory=<class 'httpx.AsyncClient'>)

Cached HEAD request to check URL existence.

Parameters:
Return type:

bool

async librovore.cacheproxy.retrieve_url(cache, url, *, duration_max=30.0, client_factory=<class 'httpx.AsyncClient'>)

Cached GET request to fetch URL content as bytes.

Parameters:
Return type:

bytes

async librovore.cacheproxy.retrieve_url_as_text(cache, url, *, duration_max=30.0, charset_default='utf-8', client_factory=<class 'httpx.AsyncClient'>)

Cached GET request to fetch URL content as text.

Parameters:
Return type:

str

Module librovore.detection

Documentation source detection system for plugin architecture.

class librovore.detection.DetectionsCache(*, ttl=3600, _entries=<factory>)

Bases: DataclassObject

Cache for source detection results with TTL support.

Variables:

ttl (int)

access_detection_optimal(source)

Returns the best detection for source, if unexpired.

Parameters:
  • self

  • source (str)

Return type:

librovore.processors.Detection | absence.objects.AbsentSingleton

access_detections(source)

Returns all detections for source, if unexpired.

Parameters:
  • self

  • source (str)

Return type:

collections.abc.Mapping[ str, librovore.processors.Detection ] | absence.objects.AbsentSingleton

add_entry(source, detections)

Adds or updates cache entry with fresh results.

Parameters:
Return type:

typing_extensions.Self

clear()

Clears all cached entries.

Parameters:

self

Return type:

typing_extensions.Self

remove_entry(source)

Removes specific source from cache, if present.

Parameters:
  • self

  • source (str)

Return type:

collections.abc.Mapping[ str, librovore.processors.Detection ] | absence.objects.AbsentSingleton

class librovore.detection.DetectionsCacheEntry(*, detections, timestamp, ttl)

Bases: DataclassObject

Cache entry for source detection results.

Variables:
invalid(current_time)

Checks if cache entry has expired.

Parameters:
  • self

  • current_time (float)

Return type:

bool

property detection_optimal

Returns the detection with highest confidence.

Parameters:

self

Return type:

librovore.processors.Detection | absence.objects.AbsentSingleton

async librovore.detection.access_detections(auxdata, source, /, *, genus)

Accesses detections via appropriate cache.

Parameters:
Return type:

tuple[ collections.abc.Mapping[ str, librovore.processors.Detection ], librovore.processors.Detection | absence.objects.AbsentSingleton ]

async librovore.detection.access_detections_ll(auxdata, source, /, *, cache, processors)

Accesses detections via appropriate cache.

Detections are performed to fill cache, if necessary.

Low-level function accepting arbitrary cache and processors list.

Parameters:
Return type:

tuple[ collections.abc.Mapping[ str, librovore.processors.Detection ], librovore.processors.Detection | absence.objects.AbsentSingleton ]

async librovore.detection.detect(auxdata, source, /, genus, *, processor_name=absence.absent)

Detects processors for source through cache system.

Parameters:
Return type:

librovore.processors.Detection

async librovore.detection.detect_inventory(auxdata, source, /, *, processor_name=absence.absent)

Detects inventory processors for source through cache system.

Parameters:
  • auxdata (librovore.state.Globals)

  • source (str)

  • processor_name (str | absence.objects.AbsentSingleton)

Return type:

librovore.processors.InventoryDetection

async librovore.detection.detect_structure(auxdata, source, /, *, processor_name=absence.absent)

Detects structure processors for source through cache system.

Parameters:
  • auxdata (librovore.state.Globals)

  • source (str)

  • processor_name (str | absence.objects.AbsentSingleton)

Return type:

librovore.processors.StructureDetection

async librovore.detection.determine_detection_optimal_ll(auxdata, source, /, *, cache, processors)

Determines which processor can best handle the source.

Low-level function accepting arbitrary cache and processors list.

Parameters:
Return type:

librovore.processors.Detection | absence.objects.AbsentSingleton

async librovore.detection.probe_source_with_patterns(auxdata, source)

Probes source with URL pattern extension.

Parameters:
  • auxdata (librovore.state.Globals)

  • source (str)

Return type:

str | absence.objects.AbsentSingleton

librovore.detection.resolve_source_url(url)

Resolves source URL through redirect cache, returns working URL.

Parameters:

url (str)

Return type:

str

Module librovore.functions

Core business logic shared between CLI and MCP server.

type librovore.functions.DocumentationResult = collections.abc.Mapping[str, typing_extensions.Any]
type librovore.functions.SearchResult = collections.abc.Mapping[str, typing_extensions.Any]
type librovore.functions.LocationArgument = str
async librovore.functions.detect(auxdata, location, /, genus, processor_name=absence.absent)

Detects relevant processors of particular genus for location.

Parameters:
Return type:

dict[ str, typing_extensions.Any ]

librovore.functions.normalize_location(location)

Normalizes location URL by stripping index.html.

Parameters:

location (str)

Return type:

str

async librovore.functions.query_content(auxdata, location, term, /, *, processor_name=absence.absent, search_behaviors=SearchBehaviors(match_mode=<MatchMode.Fuzzy: 'fuzzy'>, fuzzy_threshold=50), filters=frigid.dictionaries.Dictionary( {} ), include_snippets=True, results_max=10)

Searches documentation content with relevance ranking.

Parameters:
Returns:

Documentation content search results with relevance ranking. Contains documents with signatures, descriptions, content snippets, relevance scores, and match reasons.

Return type:

dict[ str, typing_extensions.Any ]

async librovore.functions.query_inventory(auxdata, location, term, /, *, processor_name=absence.absent, search_behaviors=SearchBehaviors(match_mode=<MatchMode.Fuzzy: 'fuzzy'>, fuzzy_threshold=50), filters=frigid.dictionaries.Dictionary( {} ), details=<InventoryQueryDetails.Documentation: 4>, results_max=5)

Searches object inventory by name.

Returns configurable detail levels. Always includes object names plus requested detail flags (signatures, summaries, documentation).

Parameters:
Returns:

Inventory search results with configurable detail levels. Contains project metadata, matching objects, and search metadata with applied filters.

Return type:

dict[ str, typing_extensions.Any ]

librovore.functions.serialize_for_json(obj)

Recursively serializes dataclass objects to JSON-compatible format.

Parameters:

obj (typing_extensions.Any)

Return type:

typing_extensions.Any

async librovore.functions.summarize_inventory(auxdata, location, /, term='', *, processor_name=absence.absent, search_behaviors=SearchBehaviors(match_mode=<MatchMode.Fuzzy: 'fuzzy'>, fuzzy_threshold=50), filters=frigid.dictionaries.Dictionary( {} ), group_by=None)

Provides structured summary of inventory data.

Parameters:
Returns:

Human-readable summary of inventory contents.

Return type:

dict[ str, typing_extensions.Any ]

async librovore.functions.survey_processors(auxdata, /, genus, name=None)

Lists processor capabilities for specified genus, filtered by name.

Parameters:
Return type:

dict[ str, typing_extensions.Any ]

Module librovore.search

Centralized search engine for universal matching across processors.

class librovore.search.SearchResult(*, object, score, match_reasons)

Bases: DataclassObject

Represents a search match with score and metadata.

Variables:
librovore.search.filter_by_name(objects, query, /, *, match_mode=MatchMode.Fuzzy, fuzzy_threshold=50)

Filter objects by name using specified match mode.

Parameters:
Return type:

list[ librovore.search.SearchResult ]

librovore.search.score_by_relevance(results, query)

Score and rank results by relevance (already done by filter_by_name).

Parameters:
Return type:

list[ librovore.search.SearchResult ]

Module librovore.cli

Command-line interface.

class librovore.cli.Cli(*, display, display_format=DisplayFormat.Markdown, command, logfile=None)

Bases: DataclassObject

MCP server CLI.

Variables:
prepare_invocation_args()

Prepares arguments for initial configuration.

Parameters:

self

Return type:

collections.abc.Mapping[ str, typing_extensions.Any ]

class librovore.cli.DetectCommand(*, location, genus, processor_name=None)

Bases: _CliCommand

Detect which processors can handle a documentation source.

Variables:
class librovore.cli.QueryContentCommand(*, location, term, search_behaviors=<factory>, filters=<factory>, include_snippets=True, results_max=10, lines_max=40)

Bases: _CliCommand

Searches documentation content with relevance ranking and snippets.

Variables:
class librovore.cli.QueryInventoryCommand(*, location, term, details=<InventoryQueryDetails.Documentation: 4>, filters=<factory>, search_behaviors=<factory>, results_max=5)

Bases: _CliCommand

Searches object inventory by name with fuzzy matching.

Variables:
class librovore.cli.ServeCommand(*, port=None, transport=None, extra_functions=False, serve_function=<function serve>)

Bases: _CliCommand

Starts MCP server.

Variables:
class librovore.cli.SummarizeInventoryCommand(*, location, term='', filters=<factory>, group_by=None, search_behaviors=<factory>)

Bases: _CliCommand

Provides human-readable summary of inventory.

Variables:
class librovore.cli.SurveyProcessorsCommand(*, genus, name=None)

Bases: _CliCommand

List processors for specified genus and their capabilities.

Variables:
librovore.cli.execute()

Entrypoint for CLI execution.

Module librovore.server

MCP server implementation.

type librovore.server.FiltersMutable = dict[str, typing_extensions.Any]
type librovore.server.GroupByArgument = str | None
type librovore.server.IncludeSnippets = bool
type librovore.server.TermArgument = str
type librovore.server.ResultsMax = int
type librovore.server.LocationArgument = str
class librovore.server.SearchBehaviorsMutable(*, match_mode=MatchMode.Fuzzy, fuzzy_threshold=50)

Bases: object

Mutable version of SearchBehaviors for FastMCP/Pydantic compatibility.

Note: Fields are manually duplicated from SearchBehaviors to avoid immutable dataclass internals leaking into JSON schema generation.

Variables:
async librovore.server.serve(auxdata, /, *, port=0, transport='stdio', extra_functions=False)

Runs MCP server.

Parameters:
  • auxdata (librovore.state.Globals)

  • port (int)

  • transport (str)

  • extra_functions (bool)

Module librovore.exceptions

Family of exceptions for package API.

exception librovore.exceptions.ContentExtractFailure(processor_name, source, meaningful_results, requested_objects)

Bases: StructureProcessFailure

Failed to extract meaningful content from documentation.

exception librovore.exceptions.DetectionConfidenceInvalidity(confidence)

Bases: Omnierror, ValueError

Detection confidence value is out of valid range.

exception librovore.exceptions.DocumentationContentAbsence(url)

Bases: Omnierror, ValueError

Documentation main content container not found.

exception librovore.exceptions.DocumentationInaccessibility(url, cause)

Bases: Omnierror, RuntimeError

Documentation file or resource absent or inaccessible.

exception librovore.exceptions.DocumentationObjectAbsence(object_id, url)

Bases: Omnierror, ValueError

Requested object not found in documentation page.

exception librovore.exceptions.DocumentationParseFailure(url, cause)

Bases: Omnierror, ValueError

Documentation HTML parsing failed or content malformed.

exception librovore.exceptions.ExtensionCacheFailure(cache_path, message)

Bases: Omnierror, RuntimeError

Extension cache operation failed.

exception librovore.exceptions.ExtensionConfigurationInvalidity(extension_name, message)

Bases: Omnierror, ValueError

Extension configuration is invalid.

exception librovore.exceptions.ExtensionInstallFailure(package_spec, message)

Bases: Omnierror, RuntimeError

Extension package installation failed.

exception librovore.exceptions.ExtensionRegisterFailure(message)

Bases: Omnierror, TypeError

Invalid plugin could not be registered.

exception librovore.exceptions.ExtensionVersionConflict(package_name, required, available)

Bases: Omnierror, ImportError

Extension has incompatible version requirements.

exception librovore.exceptions.HttpContentTypeInvalidity(url, content_type, operation)

Bases: Omnierror, ValueError

HTTP content type is not suitable for requested operation.

exception librovore.exceptions.InventoryFilterInvalidity(message)

Bases: Omnierror, ValueError

Inventory filter is invalid.

exception librovore.exceptions.InventoryInaccessibility(source, cause)

Bases: Omnierror, RuntimeError

Inventory file or resource absent or inaccessible.

exception librovore.exceptions.InventoryInvalidity(source, cause)

Bases: Omnierror, ValueError

Inventory has invalid format or cannot be parsed.

exception librovore.exceptions.InventoryUrlInvalidity(source)

Bases: Omnierror, ValueError

Inventory URL is malformed or invalid.

exception librovore.exceptions.InventoryUrlNoSupport(url, component, value=absence.absent)

Bases: Omnierror, NotImplementedError

Inventory URL has unsupported component.

exception librovore.exceptions.Omnierror(*posargs, **nomargs)

Bases: Omniexception, Exception

Base for error exceptions raised by package API.

exception librovore.exceptions.Omniexception(*posargs, **nomargs)

Bases: Object, BaseException

Base for all exceptions raised by package API.

exception librovore.exceptions.ProcessorGenusInvalidity(genus)

Bases: Omnierror, ValueError

Invalid processor genus provided.

exception librovore.exceptions.ProcessorInavailability(source)

Bases: Omnierror, RuntimeError

No processor found to handle source.

exception librovore.exceptions.ProcessorInvalidity(expected, actual)

Bases: Omnierror, TypeError

Processor has wrong type.

exception librovore.exceptions.StructureIncompatibility(processor_name, source)

Bases: Omnierror, ValueError

Documentation structure incompatible with processor.

exception librovore.exceptions.StructureProcessFailure(processor_name, source, cause)

Bases: Omnierror, RuntimeError

Structure processor failed to complete processing.

exception librovore.exceptions.ThemeDetectFailure(processor_name, source, theme_error)

Bases: StructureProcessFailure

Theme detection failed during processing.

exception librovore.exceptions.UrlImpermissibility(url, user_agent)

Bases: Omnierror, PermissionError

URL access blocked by robots.txt directive.