import { Tool } from "@modelcontextprotocol/sdk/types.js"; import type { Agent as HttpsAgent } from "node:https"; import { AuthProvider } from "./auth-provider.js"; import { OpenAPISpecLoader } from "./openapi-loader.js"; import { OpenAPIV3 } from "openapi-types"; /** * Client for making API calls to the backend service */ export declare class ApiClient { private axiosInstance; private toolsMap; private authProvider; private specLoader?; private openApiSpec?; private excludeTagsLower; /** * Create a new API client * * @param baseUrl - Base URL for the API * @param authProviderOrHeaders - AuthProvider instance or static headers for backward compatibility * @param specLoader - Optional OpenAPI spec loader for dynamic meta-tools * @param options - Optional HTTP client configuration */ constructor(baseUrl: string, authProviderOrHeaders?: AuthProvider | Record, specLoader?: OpenAPISpecLoader, options?: ApiClientOptions); private operationHasExcludedTag; /** * Set the available tools for the client * * @param tools - Map of tool ID to tool definition */ setTools(tools: Map): void; /** * Set the OpenAPI specification for dynamic meta-tools * * @param spec - The OpenAPI specification document */ setOpenApiSpec(spec: OpenAPIV3.Document): void; /** * Get a tool definition by ID * * @param toolId - The tool ID * @returns The tool definition if found */ private getToolDefinition; private resolveRequestBodyObject; private getRequestContentType; /** * Execute an API call based on the tool ID and parameters * * @param toolId - The tool ID in format METHOD-path-parts * @param params - Parameters for the API call * @returns The API response data */ executeApiCall(toolId: string, params: Record): Promise; /** * Execute an API call with optional retry on auth error * * @param toolId - The tool ID in format METHOD-path-parts * @param params - Parameters for the API call * @param isRetry - Whether this is a retry attempt * @returns The API response data */ private executeApiCallWithRetry; /** * Parse a tool ID into HTTP method and path * * @param toolId - Tool ID in format METHOD::pathPart * @returns Object containing method and path */ private parseToolId; /** * Process query parameters for GET requests * Converts arrays to comma-separated strings * * @param params - The original parameters * @returns Processed parameters */ private processQueryParams; /** * Sanitize error data to prevent information disclosure * Redacts sensitive data from authentication errors and truncates large responses * * @param data - The error response data * @param statusCode - The HTTP status code * @returns Sanitized error data string */ private sanitizeErrorData; /** * Handle the LIST-API-ENDPOINTS meta-tool * Returns a list of all available API endpoints from the loaded tools */ private handleListApiEndpoints; /** * Handle the GET-API-ENDPOINT-SCHEMA meta-tool * Returns the JSON schema for a specified API endpoint */ private handleGetApiEndpointSchema; /** * Handle the INVOKE-API-ENDPOINT meta-tool * Dynamically invokes an API endpoint with the provided parameters */ private handleInvokeApiEndpoint; /** * Make a direct HTTP request without going through the tool system * Used by dynamic meta-tools when we have OpenAPI spec but no corresponding tool */ private makeDirectHttpRequest; } export interface ApiClientOptions { excludeTags?: string[]; httpsAgent?: HttpsAgent; }