Skip to main content
Glama
APOGEOAPI
by APOGEOAPI

get_cities

Retrieve cities for a specific state or province using its numeric ID. Supports pagination and customizable data fields for geographic information access.

Instructions

Get all cities for a state/province by state ID. Requires Starter plan or above.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
state_idYesNumeric state ID (from get_states response)
pageNo
limitNo
fieldsNo

Implementation Reference

  • The 'get_cities' tool is registered on the McpServer here, which includes both the tool definition (schema) and the execution logic (handler).
    server.tool(
      'get_cities',
      'Get all cities for a state/province by state ID. Requires Starter plan or above.',
      {
        state_id: z.number().int().positive().describe('Numeric state ID (from get_states response)'),
        page: z.number().int().positive().optional(),
        limit: z.number().int().min(1).max(100).optional(),
        fields: z.enum(['basic', 'standard', 'full']).optional(),
      },
      async ({ state_id, 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/states/${state_id}/cities${qs}`);
        return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
      }
    );
  • The execution handler for the 'get_cities' tool, which performs the API call to fetch city data.
    async ({ state_id, 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/states/${state_id}/cities${qs}`);
      return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
    }
  • The input schema definition for the 'get_cities' tool using Zod.
    {
      state_id: z.number().int().positive().describe('Numeric state ID (from get_states response)'),
      page: z.number().int().positive().optional(),
      limit: z.number().int().min(1).max(100).optional(),
      fields: z.enum(['basic', 'standard', 'full']).optional(),
    },

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