get_sub_regions
Retrieve hierarchical geographic subdivisions from the eBird database to navigate bird observation regions. Specify region type and parent code to get countries, states, or counties.
Instructions
Get sub-regions within a parent region. Examples: get_sub_regions('country', 'world') for all countries, get_sub_regions('subnational1', 'US') for US states.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region_type | Yes | Type of sub-regions | |
| parent_region_code | Yes | Parent region code, or 'world' for countries | |
| fmt | No | Response format | json |
Implementation Reference
- src/index.ts:556-560 (handler)The handler function for the 'get_sub_regions' tool. It fetches sub-regions by making an API request to `/ref/region/list/${region_type}/${parent_region_code}` with optional fmt parameter and returns the result as JSON-formatted text content.async (args) => { const result = await makeRequest(`/ref/region/list/${args.region_type}/${args.parent_region_code}`, { fmt: args.fmt, }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
- src/index.ts:551-555 (schema)Input schema for the 'get_sub_regions' tool using Zod validation: region_type (enum), parent_region_code (string), fmt (enum with default 'json').{ region_type: z.enum(["country", "subnational1", "subnational2"]).describe("Type of sub-regions"), parent_region_code: z.string().describe("Parent region code, or 'world' for countries"), fmt: z.enum(["json", "csv"]).default("json").describe("Response format"), },
- src/index.ts:548-562 (registration)Registration of the 'get_sub_regions' tool using server.tool(), including name, description, input schema, and inline handler function.server.tool( "get_sub_regions", "Get sub-regions within a parent region. Examples: get_sub_regions('country', 'world') for all countries, get_sub_regions('subnational1', 'US') for US states.", { region_type: z.enum(["country", "subnational1", "subnational2"]).describe("Type of sub-regions"), parent_region_code: z.string().describe("Parent region code, or 'world' for countries"), fmt: z.enum(["json", "csv"]).default("json").describe("Response format"), }, async (args) => { const result = await makeRequest(`/ref/region/list/${args.region_type}/${args.parent_region_code}`, { fmt: args.fmt, }); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } );