MCP Server Framework - v1.0.0
    Preparing search index...

    Interface ServiceClient

    Generic service client interface for connection management.

    This interface defines the minimum contract that any service client must implement to work with the MCP server framework's connection state management and tool execution.

    class MyServiceClient implements ServiceClient {
    readonly clientType = 'my-api';

    async healthCheck(): Promise<HealthCheckResult> {
    try {
    await this.ping();
    return { status: 'healthy' };
    } catch (error) {
    return { status: 'unhealthy', message: error.message };
    }
    }
    }
    interface ServiceClient {
        clientType: string;
        disconnect?(): Promise<void>;
        healthCheck?(): Promise<HealthCheckResult>;
    }
    Index

    Properties

    clientType: string

    Unique identifier for the client type. Used for logging and telemetry attribution.

    'my-api', 'docker', 'kubernetes'
    

    Methods

    • Gracefully release resources held by the client.

      This method is OPTIONAL. If provided, it is called by ConnectionStateManager during disconnect to allow the client to close sockets, drain pools, flush buffers, etc.

      Implementations should:

      • Release all held resources (connections, file handles, timers)
      • Be idempotent (safe to call multiple times)
      • NOT throw errors — log and swallow instead

      Returns Promise<void>

      Resolves when cleanup is complete

    • Performs a health check to verify connectivity.

      This method is OPTIONAL. If not provided, the framework assumes the client is healthy when connected.

      When provided, this method is called:

      • During initial connection to validate credentials
      • Periodically to monitor connection health
      • On reconnection attempts

      Implementations should:

      • Make a lightweight API call (e.g., ping, version check)
      • Return quickly (timeout recommended: 5-10 seconds)
      • NOT throw errors - return unhealthy status instead

      Returns Promise<HealthCheckResult>

      Health check result with status and optional details