get_country_rates
Retrieve calling rate prefixes and prices for a specific country using a two-letter country code to calculate international telephony costs.
Instructions
Get all calling rate prefixes and prices for a specific country.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| country_code | Yes | Two-letter country code (e.g. US, GB, DE) |
Implementation Reference
- src/tools/rates.ts:44-45 (handler)The handler function that executes get_country_rates logic - makes GET request to /rates/{country_code}
async (params) => callTool(() => client.get(`/rates/${params.country_code}`)) ); - src/tools/rates.ts:35-45 (registration)Full registration of the get_country_rates tool including name, description, input schema, annotations, and handler
server.registerTool( "get_country_rates", { description: "Get all calling rate prefixes and prices for a specific country.", inputSchema: { country_code: z.string().length(2).describe("Two-letter country code (e.g. US, GB, DE)"), }, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }, }, async (params) => callTool(() => client.get(`/rates/${params.country_code}`)) ); - src/tools/rates.ts:39-41 (schema)Input validation schema requiring a 2-letter country code using Zod
inputSchema: { country_code: z.string().length(2).describe("Two-letter country code (e.g. US, GB, DE)"), }, - src/tools/rates.ts:13-20 (helper)Helper function that wraps tool execution with error handling - catches ApiError and returns formatted error response
async function callTool<T>(fn: () => Promise<T>) { try { return toolResult(await fn()); } catch (err) { const apiErr = err as ApiError; return toolError(`API error (${apiErr.status}): ${apiErr.message}`); } } - src/client.ts:21-31 (helper)BubblyPhoneClient.get() method - makes authenticated HTTP GET request to the API
async get<T = unknown>(path: string, params?: Record<string, string>): Promise<T> { const url = new URL(`${this.baseUrl}${path}`); if (params) { for (const [key, value] of Object.entries(params)) { if (value !== undefined && value !== "") { url.searchParams.set(key, value); } } } return this.request<T>(url.toString(), { method: "GET" }); }