EU Parliament Monitor โ€” API Documentation - v0.8.48
    Preparing search index...

    Module MCP/EPOpenDataClient

    Direct HTTP fallback client for the European Parliament Open Data Portal (https://data.europarl.europa.eu/api/v2/) โ€” specifically the /decision endpoint that exposes roll-call voting records.

    The EP MCP server tool get_voting_records relies on an EP feed that publishes roll-call data with a 4โ€“6 week delay (documented limitation, see .github/prompts/07-mcp-reference.md ยง11 item #6). That lag can leave the most recent voting window empty in MCP even when the EP Open Data Portal /api/v2/decision endpoint already exposes the underlying roll-call records directly. This client therefore queries that endpoint whenever the MCP layer returns an empty votes array, improving freshness without limiting the fallback to older date ranges.

    Call getVotingRecordsWithFallback to execute the decision tree:

    (a) MCP returns non-empty votes  โ†’ use MCP result (source: "mcp")
    (b) MCP empty, Portal has data โ†’ use Portal result (source: "ep-open-data-portal")
    (c) Both empty โ†’ emit ๐Ÿ”ด unavailable marker (source: "unavailable")
    • Uses the native Node 25 fetch() โ€” no extra runtime dependency.
    • Every call has an independent AbortController with a configurable timeout (EP_OPEN_DATA_TIMEOUT_MS, default 30 s).
    • Errors (HTTP 4xx/5xx, network faults, JSON parse failures, abort) are caught and converted to an empty-votes envelope matching the MCP fallback shape, so consumers that already expect response.content[0]?.text to hold a JSON blob keep working without change.

    All data returned by this client originates from the EP Open Data Portal which is published under the CC BY 4.0 licence. Every fallback response includes a _attribution field with the canonical citation string.

    Environment variables:

    • EP_OPEN_DATA_BASE_URL โ€” override base URL (default https://data.europarl.europa.eu/api/v2).
    • EP_OPEN_DATA_TIMEOUT_MS โ€” per-request timeout (default 30000).

    Functions

    getVotingRecordsWithFallback
    getEPOpenDataClient
    closeEPOpenDataClient

    Classes

    EPOpenDataClient

    Interfaces

    VotingRecordsFallbackResult
    VotingRecordsFallbackOptions

    Type Aliases

    VotingDataSource

    Variables

    EP_OPEN_DATA_TOOLS
    EPOpenDataPortalClient