API¶
Package librovore¶
🐲📚 Librovore - CLI and MCP server for consuming documentation.
- librovore.main()¶
Entrypoint.
Module librovore.interfaces¶
Common enumerations and interfaces.
- class librovore.interfaces.DisplayFormat(value)¶
Bases:
EnumEnumeration for CLI display formats.
- Variables:
Markdown (librovore.interfaces.DisplayFormat)
- class librovore.interfaces.FilterCapability(*, name, description, type, values=None, required=False)¶
Bases:
DataclassObjectDescribes a filter supported by a processor.
- class librovore.interfaces.MatchMode(value)¶
-
Enumeration for different term matching modes.
- Variables:
Exact (librovore.interfaces.MatchMode)
Similar (librovore.interfaces.MatchMode)
Pattern (librovore.interfaces.MatchMode)
- class librovore.interfaces.ProcessorCapabilities(*, processor_name, version, supported_filters, results_limit_max=None, response_time_typical=None, notes=None)¶
Bases:
DataclassObjectComplete capability description for a processor.
- Variables:
- render_as_json()¶
Renders capabilities as JSON-compatible dictionary.
- class librovore.interfaces.ProcessorGenera(value)¶
Bases:
EnumEnumeration for processor types/genera.
- Variables:
Inventory (librovore.interfaces.ProcessorGenera)
Structure (librovore.interfaces.ProcessorGenera)
- class librovore.interfaces.SearchBehaviors(*, match_mode=MatchMode.Similar, similarity_score_min=50, contains_term=True, case_sensitive=False)¶
Bases:
DataclassObjectSearch behavior configuration for the search engine.
- Variables:
match_mode (librovore.interfaces.MatchMode)
similarity_score_min (int)
contains_term (bool) – Enable substring matching in Exact and Similar modes. When enabled, allows terms to match as substrings.
case_sensitive (bool) – Enable case-sensitive matching. When False, performs case-insensitive matching (default).
Module librovore.cacheproxy¶
HTTP cache for documentation URL access.
- type librovore.cacheproxy.HttpClientFactory = collections.abc.Callable[[], httpx.AsyncClient]¶
- 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:
ObjectCache base with shared configuration attributes.
- class librovore.cacheproxy.CacheEntry(*, timestamp, ttl)¶
Bases:
DataclassObjectCache entry base.
- class librovore.cacheproxy.ContentCache(*, robots_cache=absence.absent, memory_max=absence.absent, **base_initargs)¶
Bases:
CacheCache manager for URL content (GET requests) with memory tracking.
- async access(url)¶
Retrieves cached content if valid.
- determine_ttl(response)¶
Determines appropriate TTL based on response type.
- classmethod from_configuration(configuration, robots_cache=absence.absent)¶
Creates ContentCache instance from application configuration.
- Parameters:
cls
configuration (collections.abc.Mapping[ str, typing_extensions.Any ])
robots_cache (librovore.cacheproxy.RobotsCache | absence.objects.AbsentSingleton)
- 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:
self
url (urllib.parse.ParseResult)
duration_max (float)
client_factory (collections.abc.Callable[ [ ], httpx.AsyncClient ])
- Return type:
- class librovore.cacheproxy.ContentCacheEntry(*, timestamp, ttl, response, headers, size_bytes)¶
Bases:
CacheEntryCache entry for URL content with size tracking.
- Variables:
- class librovore.cacheproxy.ProbeCache(*, robots_cache=absence.absent, entries_max=absence.absent, **base_initargs)¶
Bases:
CacheCache manager for URL probe results (HEAD requests).
- async access(url)¶
Retrieves cached probe result if valid.
- determine_ttl(response)¶
Determines appropriate TTL based on response type.
- classmethod from_configuration(configuration, robots_cache=absence.absent)¶
Creates ProbeCache instance from application configuration.
- Parameters:
cls
configuration (collections.abc.Mapping[ str, typing_extensions.Any ])
robots_cache (librovore.cacheproxy.RobotsCache | absence.objects.AbsentSingleton)
- 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:
self
url (urllib.parse.ParseResult)
duration_max (float)
client_factory (collections.abc.Callable[ [ ], httpx.AsyncClient ])
- Return type:
- class librovore.cacheproxy.ProbeCacheEntry(*, timestamp, ttl, response)¶
Bases:
CacheEntryCache entry for URL probe results.
- class librovore.cacheproxy.RobotsCache(*, entries_max=absence.absent, ttl=absence.absent, request_timeout=absence.absent, user_agent=absence.absent, **base_initargs)¶
Bases:
CacheCache 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.
- calculate_delay_remainder(domain)¶
Returns remaining crawl delay time for domain.
- determine_ttl(response)¶
Determines appropriate TTL based on response type.
- Parameters:
self
response (appcore.generics.Result[ urllib.robotparser.RobotFileParser, Exception ])
- Return type:
- classmethod from_configuration(configuration)¶
Creates RobotsCache instance from application configuration.
- Parameters:
cls
configuration (collections.abc.Mapping[ str, typing_extensions.Any ])
- Return type:
typing_extensions.Self
- async store(domain, response, ttl)¶
Stores robots.txt parser in cache.
- Parameters:
self
domain (str)
response (appcore.generics.Result[ urllib.robotparser.RobotFileParser, Exception ])
ttl (float)
- class librovore.cacheproxy.RobotsCacheEntry(*, timestamp, ttl, response)¶
Bases:
CacheEntryCache entry for robots.txt parser.
- Variables:
timestamp (float)
ttl (float)
response (appcore.generics.Result[ urllib.robotparser.RobotFileParser, Exception ])
- 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:
cache (librovore.cacheproxy.ProbeCache)
url (urllib.parse.ParseResult)
duration_max (float)
client_factory (collections.abc.Callable[ [ ], httpx.AsyncClient ])
- Return type:
- 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:
url (urllib.parse.ParseResult)
duration_max (float)
client_factory (collections.abc.Callable[ [ ], httpx.AsyncClient ])
- Return type:
- 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:
url (urllib.parse.ParseResult)
duration_max (float)
charset_default (str)
client_factory (collections.abc.Callable[ [ ], httpx.AsyncClient ])
- Return type:
Module librovore.detection¶
Documentation source detection system for plugin architecture.
- class librovore.detection.DetectionsCache(*, ttl=3600, _entries=<factory>)¶
Bases:
DataclassObjectCache 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:
self
source (str)
detections (collections.abc.Mapping[ str, librovore.processors.Detection ])
- Return type:
typing_extensions.Self
- clear()¶
Clears all cached entries.
- Parameters:
self
- Return type:
typing_extensions.Self
- class librovore.detection.DetectionsCacheEntry(*, detections, timestamp, ttl)¶
Bases:
DataclassObjectCache entry for source detection results.
- Variables:
detections (collections.abc.Mapping[ str, librovore.processors.Detection ])
timestamp (float)
ttl (int)
- invalid(current_time)¶
Checks if cache entry has expired.
- 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:
auxdata (librovore.state.Globals)
source (str)
- 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:
auxdata (librovore.state.Globals)
source (str)
processors (collections.abc.Mapping[ str, librovore.processors.Processor ])
- 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.
- async librovore.detection.detect_inventory(auxdata, source, /, *, processor_name=absence.absent)¶
Detects inventory processors for source through cache system.
- async librovore.detection.detect_structure(auxdata, source, /, *, processor_name=absence.absent)¶
Detects structure processors for source through cache system.
- 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:
auxdata (librovore.state.Globals)
source (str)
processors (collections.abc.Mapping[ str, librovore.processors.Processor ])
- Return type:
librovore.processors.Detection | absence.objects.AbsentSingleton
Module librovore.functions¶
Core business logic shared between CLI and MCP server.
- async librovore.functions.detect(auxdata, location, /, genus, processor_name=absence.absent)¶
Detects relevant processors of particular genus for location.
- async librovore.functions.query_content(auxdata, location, term, /, *, processor_name=absence.absent, search_behaviors=SearchBehaviors(match_mode=<MatchMode.Similar: 'similar'>, similarity_score_min=50, contains_term=True, case_sensitive=False), filters=frigid.dictionaries.Dictionary( {} ), content_id=absence.absent, results_max=10, lines_max=None)¶
Searches documentation content with relevance ranking.
- Parameters:
auxdata (librovore.state.Globals)
location (str) – URL or file path to documentation location.
term (str)
processor_name (str | absence.objects.AbsentSingleton)
search_behaviors (librovore.interfaces.SearchBehaviors)
filters (collections.abc.Mapping[ str, typing_extensions.Any ])
content_id (str | absence.objects.AbsentSingleton)
results_max (int)
lines_max (int | None)
- Return type:
librovore.results.ContentQueryResult
- async librovore.functions.query_inventory(auxdata, location, term, /, *, processor_name=absence.absent, search_behaviors=SearchBehaviors(match_mode=<MatchMode.Similar: 'similar'>, similarity_score_min=50, contains_term=True, case_sensitive=False), filters=frigid.dictionaries.Dictionary( {} ), results_max=5)¶
Searches object inventory by name.
Returns configurable detail levels. Always includes object names plus requested detail flags (signatures, summaries, documentation).
- Parameters:
auxdata (librovore.state.Globals)
location (str) – URL or file path to documentation location.
term (str)
processor_name (str | absence.objects.AbsentSingleton)
search_behaviors (librovore.interfaces.SearchBehaviors)
filters (collections.abc.Mapping[ str, typing_extensions.Any ])
results_max (int)
- Return type:
librovore.results.InventoryQueryResult
Module librovore.search¶
Centralized search engine for universal matching across processors.
- librovore.search.filter_by_name(objects, term, /, *, search_behaviors=SearchBehaviors(match_mode=<MatchMode.Similar: 'similar'>, similarity_score_min=50, contains_term=True, case_sensitive=False))¶
Filters objects by name using specified match mode and options.
- Parameters:
objects (collections.abc.Sequence[ librovore.results.InventoryObject ])
term (str)
search_behaviors (librovore.interfaces.SearchBehaviors)
- Return type:
tuple[ librovore.results.SearchResult, … ]
Module librovore.cli¶
Command-line interface.
- class librovore.cli.Cli(*, display=<factory>, command, logfile=None)¶
Bases:
DataclassObjectMCP server CLI.
- Variables:
display (librovore.cli.DisplayOptions)
command (librovore.cli.DetectCommand | librovore.cli.QueryInventoryCommand | librovore.cli.QueryContentCommand | librovore.cli.SurveyProcessorsCommand | librovore.cli.ServeCommand)
logfile (str | None) – Path to log capture file.
- 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:
_CliCommandDetect which processors can handle a documentation source.
- class librovore.cli.DisplayOptions(*, format=DisplayFormat.Markdown, target_stream=TargetStream.Stderr, target_file=None, color=True)¶
Bases:
DataclassObjectConsolidated display configuration for CLI output.
- Variables:
format (librovore.interfaces.DisplayFormat)
target_stream (librovore.cli.TargetStream | None)
target_file (pathlib.Path | None)
color (bool)
- decide_rich_markdown(stream)¶
Determines whether to use Rich markdown rendering.
- async provide_stream(exits)¶
Provides the target output stream.
- Parameters:
self
exits (contextlib.AsyncExitStack)
- Return type:
- class librovore.cli.QueryContentCommand(*, location, term, search_behaviors=<factory>, filters=<factory>, results_max=10, lines_max=40, content_id=None, reveal_internals=False)¶
Bases:
_CliCommandSearches documentation with flexible preview/extraction modes.
Workflows:
Sample: Use –lines-max 5-10 to preview results and identify relevant content
Extract: Use –content-id from sample results to retrieve full content
Direct: Search with higher –lines-max for immediate full results
- Variables:
location (str)
term (str)
search_behaviors (librovore.interfaces.SearchBehaviors)
filters (collections.abc.Mapping[ str, typing_extensions.Any ])
results_max (int)
lines_max (int)
content_id (str | None)
reveal_internals (bool)
- class librovore.cli.QueryInventoryCommand(*, location, term, filters=<factory>, search_behaviors=<factory>, results_max=5, reveal_internals=False)¶
Bases:
_CliCommandExplores documentation structure and object inventory.
Use before content searches to:
Discover available topics and object types
Identify relevant search terms and filters
Understand documentation scope and organization
- Variables:
location (str)
term (str)
filters (collections.abc.Mapping[ str, typing_extensions.Any ])
search_behaviors (librovore.interfaces.SearchBehaviors)
results_max (int)
reveal_internals (bool)
- class librovore.cli.ServeCommand(*, port=None, transport=None, extra_functions=False, serve_function=<function serve>)¶
Bases:
_CliCommandStarts MCP server.
- Variables:
port (int | None)
transport (str | None)
extra_functions (bool)
serve_function (collections.abc.Callable[ [ librovore.state.Globals ], collections.abc.Awaitable[ None ] ])
- class librovore.cli.SurveyProcessorsCommand(*, genus, name=None)¶
Bases:
_CliCommandList processors for specified genus and their capabilities.
- Variables:
name (str | None)
- librovore.cli.decide_rich_markdown(stream, colorize)¶
Determines whether to use Rich markdown rendering.
- librovore.cli.execute()¶
Entrypoint for CLI execution.
- librovore.cli.intercept_errors()¶
Decorator for CLI handlers to intercept exceptions.
Catches Omnierror exceptions and renders them appropriately. Other exceptions are logged and formatted simply.
Module librovore.server¶
MCP server implementation.
- class librovore.server.SearchBehaviorsMutable(*, match_mode=MatchMode.Similar, similarity_score_min=50)¶
Bases:
objectMutable 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:
match_mode (librovore.interfaces.MatchMode)
similarity_score_min (int)
- librovore.server.intercept_errors(func)¶
Decorator for MCP functions to intercept self-rendering exceptions.
Catches Omnierror exceptions and returns their JSON representation instead of raising them. Other exceptions are re-raised unchanged.
- Parameters:
func (collections.abc.Callable[ ..., collections.abc.Awaitable[ dict[ str, typing_extensions.Any ] ] ])
- Return type:
collections.abc.Callable[ …, collections.abc.Awaitable[ dict[ str, typing_extensions.Any ] ] ]
Module librovore.exceptions¶
Family of exceptions for package API.
- exception librovore.exceptions.ContentExtractFailure(processor_name, source, meaningful_results, requested_objects)¶
Bases:
StructureProcessFailureFailed to extract meaningful content from documentation.
- exception librovore.exceptions.ContentIdInvalidity(content_id, cause)¶
Bases:
Omnierror,ValueErrorContent ID has invalid format or encoding.
- exception librovore.exceptions.ContentIdLocationMismatch(content_id_location, term_location)¶
Bases:
Omnierror,ValueErrorContent ID location does not match term query location.
- exception librovore.exceptions.ContentIdObjectAbsence(object_name, location)¶
Bases:
Omnierror,ValueErrorObject specified in content ID not found in location.
- exception librovore.exceptions.DetectionConfidenceInvalidity(confidence)¶
Bases:
Omnierror,ValueErrorDetection confidence value is out of valid range.
- exception librovore.exceptions.DocumentationContentAbsence(url)¶
Bases:
Omnierror,ValueErrorDocumentation main content container not found.
- exception librovore.exceptions.DocumentationInaccessibility(url, cause)¶
Bases:
Omnierror,RuntimeErrorDocumentation file or resource absent or inaccessible.
- exception librovore.exceptions.DocumentationObjectAbsence(object_id, url)¶
Bases:
Omnierror,ValueErrorRequested object not found in documentation page.
- exception librovore.exceptions.DocumentationParseFailure(url, cause)¶
Bases:
Omnierror,ValueErrorDocumentation HTML parsing failed or content malformed.
- exception librovore.exceptions.ExtensionCacheFailure(cache_path, message)¶
Bases:
Omnierror,RuntimeErrorExtension cache operation failed.
- exception librovore.exceptions.ExtensionConfigurationInvalidity(extension_name, message)¶
Bases:
Omnierror,ValueErrorExtension configuration is invalid.
- exception librovore.exceptions.ExtensionInstallFailure(package_spec, message)¶
Bases:
Omnierror,RuntimeErrorExtension package installation failed.
- exception librovore.exceptions.ExtensionRegisterFailure(message)¶
-
Invalid plugin could not be registered.
- exception librovore.exceptions.ExtensionVersionConflict(package_name, required, available)¶
Bases:
Omnierror,ImportErrorExtension has incompatible version requirements.
- exception librovore.exceptions.HttpContentTypeInvalidity(url, content_type, operation)¶
Bases:
Omnierror,ValueErrorHTTP content type is not suitable for requested operation.
- exception librovore.exceptions.InventoryFilterInvalidity(message)¶
Bases:
Omnierror,ValueErrorInventory filter is invalid.
- exception librovore.exceptions.InventoryInaccessibility(source, cause=None)¶
Bases:
Omnierror,RuntimeErrorInventory file or resource absent or inaccessible.
- exception librovore.exceptions.InventoryInvalidity(source, cause)¶
Bases:
Omnierror,ValueErrorInventory has invalid format or cannot be parsed.
- exception librovore.exceptions.InventoryUrlInvalidity(source)¶
Bases:
Omnierror,ValueErrorInventory URL is malformed or invalid.
- exception librovore.exceptions.InventoryUrlNoSupport(url, component, value=absence.absent)¶
Bases:
Omnierror,NotImplementedErrorInventory URL has unsupported component.
- exception librovore.exceptions.Omnierror(*posargs, **nomargs)¶
Bases:
Omniexception,ExceptionBase for error exceptions with self-rendering capability.
- abstract render_as_json()¶
Renders exception as JSON-compatible dictionary.
- Parameters:
self
- Return type:
frigid.dictionaries.Dictionary[ str, typing_extensions.Any ]
- abstract render_as_markdown(*, reveal_internals=True)¶
Renders exception as Markdown lines for display.
- exception librovore.exceptions.Omniexception(*posargs, **nomargs)¶
Bases:
Object,BaseExceptionBase for all exceptions raised by package API.
- exception librovore.exceptions.ProcessorGenusInvalidity(genus)¶
Bases:
Omnierror,ValueErrorInvalid processor genus provided.
Bases:
Omnierror,RuntimeErrorNo processor found to handle source.
Renders processor unavailability as JSON-compatible dictionary.
- Parameters:
self
- Return type:
frigid.dictionaries.Dictionary[ str, typing_extensions.Any ]
- exception librovore.exceptions.ProcessorInvalidity(expected, actual)¶
-
Processor has wrong type.
- exception librovore.exceptions.StructureIncompatibility(processor_name, source)¶
Bases:
Omnierror,ValueErrorDocumentation structure incompatible with processor.
- exception librovore.exceptions.StructureProcessFailure(processor_name, source, cause)¶
Bases:
Omnierror,RuntimeErrorStructure processor failed to complete processing.
- exception librovore.exceptions.ThemeDetectFailure(processor_name, source, theme_error)¶
Bases:
StructureProcessFailureTheme detection failed during processing.
- exception librovore.exceptions.UrlImpermissibility(url, user_agent)¶
Bases:
Omnierror,PermissionErrorURL access blocked by robots.txt directive.