Skip to main content
Glama
APOGEOAPI
by APOGEOAPI

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
NameRequiredDescriptionDefault
country_codeYesISO2 or ISO3 country code
pageNo
limitNo
fieldsNo

Implementation Reference

  • 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) }] };
    }
  • 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) }] };
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/APOGEOAPI/apogeoapi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server