EU Parliament Monitor — API Documentation - v0.9.24
    Preparing search index...

    Class EuropeanParliamentMCPClient

    Base MCP connection managing JSON-RPC 2.0 transport over stdio or HTTP gateway. Extended by domain-specific clients to add tool wrapper methods.

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    _recordToolFailure safeCallTool _buildReliabilityTimeoutError _callToolOnceWithReliabilityTimeout _decideReliabilityAttemptError callToolWithReliabilityTimeout safeCallToolWithReliabilityTimeout getFailedTools getSlowFeedWarnings getFeedHealthSummary getToolErrorSummary getMEPs getPlenarySessions searchDocuments getParliamentaryQuestions getCommitteeInfo monitorLegislativePipeline analyzeLegislativeEffectiveness assessMEPInfluence analyzeCoalitionDynamics detectVotingAnomalies comparePoliticalGroups getMEPDetails getVotingRecords analyzeVotingPatterns trackLegislation generateReport analyzeCommitteeActivity trackMEPAttendance analyzeCountryDelegation generatePoliticalLandscape getCurrentMEPs getSpeeches getEvents getMeetingActivities getMeetingDecisions getMEPDeclarations getIncomingMEPs getOutgoingMEPs getHomonymMEPs getLatestVotes getPlenaryDocuments getCommitteeDocuments getPlenarySessionDocuments getPlenarySessionDocumentItems getControlledVocabularies getExternalDocuments getMeetingForeseenActivities getProcedureEvents getMeetingPlenarySessionDocuments getMeetingPlenarySessionDocumentItems networkAnalysis sentimentTracker earlyWarningSystem comparativeIntelligence correlateIntelligence getAllGeneratedStats getMEPsFeed getEventsFeed getProceduresFeed getAdoptedTextsFeed getMEPDeclarationsFeed getDocumentsFeed getPlenaryDocumentsFeed getCommitteeDocumentsFeed getPlenarySessionDocumentsFeed getExternalDocumentsFeed getCommissionWorkProgramme getCouncilPresidencyProgramme getParliamentaryQuestionsFeed getCorporateBodiesFeed getControlledVocabulariesFeed getProcedureEventById getServerHealth getProcedures getFreshProcedures getAdoptedTexts getDueAdoptedTextsForReprobe resolveAdoptedText escalateStalePendingDocuments getPendingDocumentsSummary isConnected isGatewayMode getGatewayUrl getGatewayApiKey getMcpSessionId getConnectionHealth connect disconnect handleMessage sendRequest listTools callTool reconnect callToolWithRetry

    Properties

    Constructors

    Methods

    • Record a tool failure and log a warning.

      Parameters

      • toolName: string

        MCP tool name that failed

      • errorText: string

        Raw error text from the failure

      • fallbackText: string

        JSON text for the fallback result

      Returns MCPToolResult

      Fallback MCPToolResult

    • Generic error-safe wrapper around callToolWithRetry. Catches any error thrown by the tool (or by the args factory), logs a warning, and returns a fallback payload.

      Parameters

      • toolName: string

        MCP tool name

      • args: object | (() => object)

        Tool arguments or a factory that builds them

      • fallbackText: string

        JSON text to return when the tool is unavailable

      Returns Promise<MCPToolResult>

      Tool result or fallback

    • Build a standardized per-tool timeout error.

      Parameters

      • toolName: string

        MCP tool identifier

      • timeoutMs: number

        Timeout threshold in milliseconds

      • Optionalcause: Error

        Optional underlying error

      Returns Error

      Formatted timeout error

    • Execute one MCP tool attempt with a per-tool timeout guard.

      Parameters

      • toolName: string

        MCP tool identifier

      • args: object

        Tool arguments

      • timeoutMs: number

        Timeout threshold in milliseconds

      Returns Promise<MCPToolResult>

      Tool result or throws on timeout

    • Decide retry/throw behavior for a failed reliability-timed attempt.

      Parameters

      • toolName: string

        MCP tool identifier

      • timeoutMs: number

        Timeout threshold in milliseconds

      • error: Error

        The error that occurred

      • timeoutObserved: boolean

        Whether a timeout was previously observed

      • attempt: number

        Current attempt number

      • timeoutRetries: number

        Maximum allowed timeout retries

      Returns { retry: boolean; timeoutObserved: boolean; error?: Error }

      Decision object with retry flag and error details

    • Call a tool with per-tool timeout and one timeout-only retry budget.

      Parameters

      • toolName: string

        MCP tool identifier

      • args: object

        Tool arguments

      • timeoutMs: number = TOOL_RELIABILITY_TIMEOUT_MS

        Timeout threshold in milliseconds

      • timeoutRetries: number = TOOL_RELIABILITY_TIMEOUT_RETRIES

        Maximum allowed timeout retries

      Returns Promise<MCPToolResult>

      Tool result

    • Wrapper variant of safeCallTool that enforces per-tool timeout/retry policy.

      Parameters

      • toolName: string

        MCP tool name

      • args: object | (() => object)

        Tool arguments or arg factory

      • fallbackText: string

        JSON fallback payload

      Returns Promise<MCPToolResult>

      Tool result or fallback

    • Get a summary of tools that returned fallback data in the current session.

      Returns ReadonlyMap<string, string>

      Map of tool name to error description

    • Get tools that experienced a timeout but the failure was downgraded to a warning.

      Returns ReadonlyMap<string, string>

      Map of tool name to warning description

    • Get a human-readable feed health summary for diagnostics.

      Returns string

      Formatted summary of feed availability

    • Get a per-error-code breakdown of tool-level rejections.

      Returns string

      Formatted summary of tool errors by code

    • Get connection health metrics for telemetry

      Returns { timeoutCount: number; reconnectCount: number; connected: boolean }

      Object with timeout count, reconnection count, and current connection status

    • Send a request to the MCP server

      Type Parameters

      • T = unknown

      Parameters

      • method: string

        RPC method name

      • params: Record<string, unknown> = {}

        Method parameters

      Returns Promise<T>

      Server response

    • Attempt to reconnect to the MCP server. Deduplicates concurrent calls — only one reconnect runs at a time.

      Returns Promise<void>

      Resolves when reconnect succeeds or all attempts are exhausted

    • Call an MCP tool with automatic retry on timeout or connection loss. Reconnects automatically if the connection was lost between attempts.

      Only transient failures are retried (see isRetriableError). Non-retriable errors — rate-limit (429), session-expired (401), and programmer errors such as TypeError — are re-thrown immediately without consuming any retry budget.

      Parameters

      • name: string

        Tool name

      • args: object = {}

        Tool arguments (plain object, non-null, not an array)

      • OptionalmaxRetries: number

        Override the default retry count from options

      Returns Promise<MCPToolResult>

      Tool execution result

    Properties

    _failedTools: Map<string, string> = ...

    Tracks tools that returned fallback data in the current session

    _calledTools: Set<string> = ...

    Tracks tools that have been called (attempted) in the current session

    _slowFeedWarnings: Map<string, string> = ...

    Tracks tools that experienced a timeout but the failure was downgraded to a warning. Unlike _failedTools, entries here are NOT counted against the reliability score.

    _pendingDocumentsStorePath: string | undefined

    Path to the pending-documents sidecar file. Undefined means "use the module-level default (<cwd>/data/pending-documents.json)".

    serverLabel: string

    Human-readable server name for log messages