get_areas_nearby
Retrieve load shedding areas near specified GPS coordinates. Solves the problem of identifying the area name when only location coordinates are known.
Instructions
Find load shedding areas near a GPS location. Useful when you know coordinates but not the area name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | Latitude (e.g. -33.9249 for Cape Town) | |
| lon | Yes | Longitude (e.g. 18.4241 for Cape Town) | |
| test | No | Use test data (does not count against your quota) |
Implementation Reference
- src/index.ts:156-196 (registration)Tool registration of 'get_areas_nearby' on the MCP server. Defines the handler that receives {lat, lon, test} input, calls the API client, and formats the response.
server.tool( "get_areas_nearby", "Find load shedding areas near a GPS location. Useful when you know coordinates but not the area name.", { lat: z.number().describe("Latitude (e.g. -33.9249 for Cape Town)"), lon: z.number().describe("Longitude (e.g. 18.4241 for Cape Town)"), test: z .boolean() .optional() .default(false) .describe("Use test data (does not count against your quota)"), }, async ({ lat, lon, test }) => { const data = await client.getAreasNearby(lat, lon, test); if (!data.areas.length) { return { content: [{ type: "text", text: "No areas found near those coordinates." }], }; } const list = data.areas .map((a) => `- **${a.name}** (${a.region})\n ID: \`${a.id}\` | Nearby count: ${a.count}`) .join("\n"); return { content: [ { type: "text", text: [ `## 📍 Areas near (${lat}, ${lon})`, "", list, "", "Use the area ID with `get_area_schedule` to see upcoming events.", ].join("\n"), }, ], }; } ); - src/index.ts:159-167 (schema)Input schema (Zod) for 'get_areas_nearby': lat (number), lon (number), and optional test (boolean) parameters.
{ lat: z.number().describe("Latitude (e.g. -33.9249 for Cape Town)"), lon: z.number().describe("Longitude (e.g. 18.4241 for Cape Town)"), test: z .boolean() .optional() .default(false) .describe("Use test data (does not count against your quota)"), }, - src/client.ts:80-85 (handler)Client method getAreasNearby that performs the HTTP GET request to /areas_nearby with lat/lon params, returning an AreasNearby response.
async getAreasNearby(lat: number, lon: number, test = false): Promise<AreasNearby> { const params: Record<string, string | number> = { lat, lon }; if (test) params.test = "true"; const { data } = await this.http.get<AreasNearby>("/areas_nearby", { params }); return data; } - src/client.ts:38-40 (schema)Type definition for AreasNearby interface: an array of Area objects with an additional count field.
export interface AreasNearby { areas: (Area & { count: number })[]; }