Python API¶
The modules behind the server, rendered from their docstrings. The MCP tools themselves are listed on the tools reference; this page is for reading or extending the code.
Server¶
The MCP server: endoflife.date queries exposed as read-only MCP tools.
build_server ¶
Create the MCP server and register its tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
Settings
|
Resolved settings. |
required |
service
|
EndOfLife | None
|
The endoflife.date service to use. By default one is built from
|
None
|
Returns:
| Type | Description |
|---|---|
MCPServer
|
The server, ready to run. |
Configuration¶
Settings, resolved from CLI options, environment variables and a TOML config file.
Precedence, highest first: CLI option > ENDOFLIFE_MCP_* environment variable >
config file > default. The config file is $XDG_CONFIG_HOME/endoflife-mcp-server/config.toml
(~/.config/endoflife-mcp-server/config.toml when XDG_CONFIG_HOME is unset), or the
file passed with --config.
ConfigFileNotFoundError ¶
Bases: FileNotFoundError
The config file passed with --config does not exist.
Settings ¶
Bases: BaseSettings
Runtime settings for the server.
settings_customise_sources
classmethod
¶
settings_customise_sources(
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]
Read CLI values, then the environment, then the TOML config file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings_cls
|
type[BaseSettings]
|
The settings class being built. |
required |
init_settings
|
PydanticBaseSettingsSource
|
Values passed to the constructor (the CLI options). |
required |
env_settings
|
PydanticBaseSettingsSource
|
|
required |
dotenv_settings
|
PydanticBaseSettingsSource
|
Unused; |
required |
file_secret_settings
|
PydanticBaseSettingsSource
|
Unused; secret files are not read. |
required |
Returns:
| Type | Description |
|---|---|
tuple[PydanticBaseSettingsSource, ...]
|
The sources in precedence order. |
default_config_file ¶
Return where the config file lives when --config is not given.
Returns:
| Type | Description |
|---|---|
Path
|
|
Path
|
|
load_settings ¶
Resolve settings from every source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_file
|
Path | None
|
An explicit config file. It must exist. When |
None
|
**overrides
|
Any
|
Values given on the command line. |
{}
|
Returns:
| Type | Description |
|---|---|
Settings
|
The resolved settings. |
Raises:
| Type | Description |
|---|---|
ConfigFileNotFoundError
|
If |
ValidationError
|
If any source holds an invalid value. |
Service¶
The endoflife.date service: typed, validated calls to the endoflife.date v1 API.
Requests go through the client generated from api/external/endoflife.yaml; this
module adds name validation, error mapping and the shapes the MCP tools return.
DEFAULT_API_URL
module-attribute
¶
The public endoflife.date v1 API.
USER_AGENT
module-attribute
¶
USER_AGENT = f"endoflife-mcp-server/{__version__} (+https://github.com/rossedman/endoflife-mcp-server)"
Sent with every request so endoflife.date can tell where traffic comes from.
EndOfLife ¶
EndOfLife(
api_url: str = DEFAULT_API_URL,
timeout: float = 10.0,
*,
transport: AsyncBaseTransport | None = None,
)
An async client for the endoflife.date API that returns plain JSON-ready data.
Use it as an async context manager, or call :meth:aclose when done, so the
underlying HTTP connection pool is released.
Create the service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_url
|
str
|
Base URL of the endoflife.date v1 API. |
DEFAULT_API_URL
|
timeout
|
float
|
Seconds to wait for each request before giving up. |
10.0
|
transport
|
AsyncBaseTransport | None
|
An httpx transport to send requests through instead of the network, used by tests. |
None
|
product_summaries
async
¶
Fetch the summary of every product endoflife.date tracks.
Returns:
| Type | Description |
|---|---|
list[ProductSummary]
|
One summary per product, in the API's order. |
Raises:
| Type | Description |
|---|---|
EndOfLifeError
|
If the request fails. |
product_names
async
¶
List the canonical name of every product endoflife.date tracks.
Returns:
| Type | Description |
|---|---|
list[str]
|
Product names such as |
Raises:
| Type | Description |
|---|---|
EndOfLifeError
|
If the request fails. |
product
async
¶
Fetch everything endoflife.date knows about a product, including all releases.
Aliases (k8s) are resolved to the canonical product (kubernetes).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The product name or alias. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The product details, as JSON-ready data. |
Raises:
| Type | Description |
|---|---|
InvalidNameError
|
If |
NotFoundError
|
If there is no such product; the message suggests close names. |
EndOfLifeError
|
If the request fails for another reason. |
release
async
¶
Fetch one release cycle of a product, such as Python 3.12.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_name
|
str
|
The product name or alias. |
required |
release
|
str
|
The release cycle name, as listed in the product's releases. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The release cycle, as JSON-ready data. |
Raises:
| Type | Description |
|---|---|
InvalidNameError
|
If either name is invalid. |
NotFoundError
|
If the product or the release cycle does not exist. |
EndOfLifeError
|
If the request fails for another reason. |
latest_release
async
¶
Fetch the newest release cycle of a product.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product_name
|
str
|
The product name or alias. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
The latest release cycle, as JSON-ready data. |
Raises:
| Type | Description |
|---|---|
InvalidNameError
|
If the name is invalid. |
NotFoundError
|
If the product does not exist. |
EndOfLifeError
|
If the request fails for another reason. |
categories
async
¶
List the product categories, such as lang, os or database.
Returns:
| Type | Description |
|---|---|
list[str]
|
Category names. |
Raises:
| Type | Description |
|---|---|
EndOfLifeError
|
If the request fails. |
category_products
async
¶
List the products in a category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
A category name from :meth: |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
A summary of each product in the category. |
Raises:
| Type | Description |
|---|---|
InvalidNameError
|
If the name is invalid. |
NotFoundError
|
If the category does not exist. |
EndOfLifeError
|
If the request fails for another reason. |
tags
async
¶
List the product tags, such as linux-distribution or amazon.
Returns:
| Type | Description |
|---|---|
list[str]
|
Tag names. |
Raises:
| Type | Description |
|---|---|
EndOfLifeError
|
If the request fails. |
tag_products
async
¶
List the products with a tag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
A tag name from :meth: |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
A summary of each product with the tag. |
Raises:
| Type | Description |
|---|---|
InvalidNameError
|
If the name is invalid. |
NotFoundError
|
If the tag does not exist. |
EndOfLifeError
|
If the request fails for another reason. |
Product names¶
Validation for the names that end up in endoflife.date URL paths.
Names come from a model, so they can be anything: mixed case, padded with spaces, or crafted to escape the path segment they are placed in. Normalizing and checking them here keeps every request on the endpoint it was meant for.
MAX_NAME_LENGTH
module-attribute
¶
Longest name accepted. Real endoflife.date names are well under 50 characters.
normalize_slug ¶
Normalize a product, category or tag name and check it is a valid slug.
endoflife.date names are lowercase slugs such as python, amazon-eks or
linux-distribution. Surrounding whitespace is stripped and the name is
lowercased, so " Python " becomes "python".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The name as given by the caller. |
required |
kind
|
str
|
What the name identifies, used in error messages. |
'product'
|
Returns:
| Type | Description |
|---|---|
str
|
The normalized name. |
Raises:
| Type | Description |
|---|---|
InvalidNameError
|
If the name is empty, too long, or contains characters that never appear in endoflife.date names. |
normalize_release ¶
Normalize a release cycle name and check it is safe to put in a URL path.
Release cycles keep their case (some products use names like R2 or SP1), so
only surrounding whitespace is stripped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The release cycle name as given by the caller, such as |
required |
Returns:
| Type | Description |
|---|---|
str
|
The normalized release cycle name. |
Raises:
| Type | Description |
|---|---|
InvalidNameError
|
If the name is empty, too long, or contains characters that never appear in release cycle names. |
Suggestions¶
Suggest product names for a name endoflife.date doesn't know.
suggest_products ¶
suggest_products(
name: str,
products: Iterable[ProductSummary],
limit: int = 5,
cutoff: float = 0.6,
) -> list[str]
Return the canonical names of the products closest to name.
Both canonical names and aliases are matched, so "postgres" finds
postgresql and a typo such as "pyhton" finds python. Each product is
listed at most once, by its canonical name, closest match first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The normalized product name that was not found. |
required |
products
|
Iterable[ProductSummary]
|
Product summaries from the products list endpoint. |
required |
limit
|
int
|
The most suggestions to return. |
5
|
cutoff
|
float
|
The minimum similarity ratio (0 to 1) for a suggestion. |
0.6
|
Returns:
| Type | Description |
|---|---|
list[str]
|
Up to |
Errors¶
Errors raised by the endoflife.date service.
Every failure the service anticipates is an :class:EndOfLifeError, so callers (the MCP
tools) can turn it into a message for the model without catching unrelated exceptions.
EndOfLifeError ¶
Bases: Exception
Base class for every error the service raises on purpose.
InvalidNameError ¶
Bases: EndOfLifeError, ValueError
A product, release, category or tag name cannot be a valid endoflife.date name.
NotFoundError ¶
Bases: EndOfLifeError
endoflife.date has no entry for the requested name.
RateLimitedError ¶
Bases: EndOfLifeError
endoflife.date asked the client to slow down (HTTP 429).
Build the error from the response's Retry-After header.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
retry_after
|
str | None
|
The raw |
required |
UpstreamError ¶
Bases: EndOfLifeError
endoflife.date could not be reached, or answered with something unexpected.