whodis-mcp-server
Version:
Whodis MCP Server for checking the availability of domain names using WHOIS lookups.
50 lines (49 loc) • 2.1 kB
TypeScript
/**
* Interface for IP API credentials.
* Note: API token is optional for the free tier.
*/
export interface IpApiCredentials {
apiToken?: string;
}
/**
* Interface for HTTP request options
*/
export interface RequestOptions {
method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
headers?: Record<string, string>;
body?: unknown;
}
/**
* Retrieves IP API credentials from configuration.
* Specifically checks for IPAPI_API_TOKEN.
* @returns IpApiCredentials object containing the API token if found.
*/
export declare function getIpApiCredentials(): IpApiCredentials;
/**
* Fetches data specifically from the ip-api.com endpoint.
* Handles URL construction, authentication (if token provided), and query parameters.
* Relies on the generic fetchApi function for the actual HTTP request.
*
* @param path The specific IP address or path component (e.g., "8.8.8.8"). Empty string for current IP.
* @param options Additional options like HTTP method, headers, body, and ip-api specific params.
* @param options.useHttps - Use HTTPS (requires paid plan for ip-api.com). Defaults to false.
* @param options.fields - Specific fields to request from ip-api.com.
* @param options.lang - Language code for response data.
* @returns The response data parsed as type T.
* @throws {McpError} If the request fails, including network errors, API errors, or parsing issues.
*/
export declare function fetchIpApi<T>(path: string, options?: RequestOptions & {
useHttps?: boolean;
fields?: string[];
lang?: string;
}): Promise<T>;
/**
* Generic and reusable function to fetch data from any API endpoint.
* Handles standard HTTP request setup, response checking, basic error handling, and logging.
*
* @param url The full URL to fetch data from.
* @param options Request options including method, headers, and body.
* @returns The response data parsed as type T.
* @throws {McpError} If the request fails, including network errors, non-OK HTTP status, or JSON parsing issues.
*/
export declare function fetchApi<T>(url: string, options?: RequestOptions): Promise<T>;