get_states
Retrieve all states or provinces for any country using ISO country codes. This tool provides geographic data through the ApogeoAPI MCP server for location-based applications.
Instructions
Get all states/provinces for a country. Requires Starter plan or above.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| country_code | Yes | ISO2 or ISO3 country code | |
| page | No | ||
| limit | No | ||
| fields | No |
Implementation Reference
- src/tools/states.ts:15-23 (handler)The handler function that executes the logic for the 'get_states' tool, fetching data from the API.
async ({ country_code, page, limit, fields }) => { const params = new URLSearchParams(); if (page) params.set('page', String(page)); if (limit) params.set('limit', String(limit)); if (fields) params.set('fields', fields); const qs = params.toString() ? `?${params}` : ''; const data = await apiGet(`/v1/api/geo/countries/${country_code.toUpperCase()}/states${qs}`); return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } - src/tools/states.ts:6-24 (registration)The registration of the 'get_states' tool with the MCP server, including its schema definition.
server.tool( 'get_states', 'Get all states/provinces for a country. Requires Starter plan or above.', { country_code: z.string().min(2).max(3).describe('ISO2 or ISO3 country code'), page: z.number().int().positive().optional(), limit: z.number().int().min(1).max(100).optional(), fields: z.enum(['basic', 'standard', 'full']).optional(), }, async ({ country_code, page, limit, fields }) => { const params = new URLSearchParams(); if (page) params.set('page', String(page)); if (limit) params.set('limit', String(limit)); if (fields) params.set('fields', fields); const qs = params.toString() ? `?${params}` : ''; const data = await apiGet(`/v1/api/geo/countries/${country_code.toUpperCase()}/states${qs}`); return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } );