ping
Verify Bitrefill API availability to ensure cryptocurrency shopping functions operate correctly before transactions.
Instructions
Check if the Bitrefill API is available
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers/tools.ts:402-432 (handler)MCP tool registration and handler for 'ping': registers the tool with empty input schema and handles execution by calling MiscService.ping(), formatting the response as JSON text, with error handling./** * Ping tool * Checks if the API is available * @returns Ping response */ server.tool( "ping", "Check if the Bitrefill API is available", {}, async () => { try { const ping = await MiscService.ping(); return { content: [ { type: "text" as const, text: JSON.stringify(ping, null, 2) } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text" as const, text: JSON.stringify({ error: errorMessage }, null, 2), }, ], isError: true, }; } } );
- src/schemas/misc.ts:9-14 (schema)Zod schema defining the structure of the ping API response (used for type safety in services).export const PingResponseSchema = z.object({ meta: z.object({ _endpoint: z.string(), }), message: z.string().describe("Ping response message"), });
- src/services/misc.ts:25-27 (helper)MiscService.ping(): Thin wrapper that delegates to the authenticated API client ping method.public static async ping(): Promise<PingResponse> { return authenticatedApiClient.ping(); }
- AuthenticatedApiClient.ping(): Makes the actual HTTP GET request to the '/ping' endpoint on Bitrefill API.public async ping(): Promise<PingResponse> { return this.makeRequest<PingResponse>( "ping", { method: "GET", headers: DEFAULT_HEADERS, } ); }