search_geo_locations
Search and retrieve geographic targeting locations for Meta Ads campaigns using a query and optional filters like location type or limit. Returns JSON with location details for precise ad targeting.
Instructions
Search for geographic targeting locations.
Args:
access_token: Meta API access token (optional - will use cached token if not provided)
query: Search term for locations (e.g., "New York", "California", "Japan")
location_types: Types of locations to search. Options: ['country', 'region', 'city', 'zip',
'geo_market', 'electoral_district']. If not specified, searches all types.
limit: Maximum number of results to return (default: 25)
Returns:
JSON string containing location data with key, name, type, and geographic hierarchy information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_token | No | ||
| limit | No | ||
| location_types | No | ||
| query | No |
Implementation Reference
- meta_ads_mcp/core/targeting.py:506-538 (handler)The primary handler function for the 'search_geo_locations' MCP tool. It performs a search on the Meta Ads API '/search' endpoint with type='adgeolocation', handles parameters like query, location_types, and limit, and returns formatted JSON results. Registered via @mcp_server.tool() decorator.@mcp_server.tool() @meta_api_tool async def search_geo_locations(query: str, access_token: Optional[str] = None, location_types: Optional[List[str]] = None, limit: int = 25) -> str: """ Search for geographic targeting locations. Args: query: Search term for locations (e.g., "New York", "California", "Japan") access_token: Meta API access token (optional - will use cached token if not provided) location_types: Types of locations to search. Options: ['country', 'region', 'city', 'zip', 'geo_market', 'electoral_district']. If not specified, searches all types. limit: Maximum number of results to return (default: 25) Returns: JSON string containing location data with key, name, type, and geographic hierarchy information """ if not query: return json.dumps({"error": "No search query provided"}, indent=2) endpoint = "search" params = { "type": "adgeolocation", "q": query, "limit": limit } if location_types: params["location_types"] = json.dumps(location_types) data = await make_api_request(endpoint, access_token, params) return json.dumps(data, indent=2)
- meta_ads_mcp/core/__init__.py:14-14 (registration)Import statement that brings search_geo_locations into the core module namespace, enabling its use and registration when core is imported.from .targeting import search_interests, get_interest_suggestions, estimate_audience_size, search_behaviors, search_demographics, search_geo_locations
- meta_ads_mcp/__init__.py:60-60 (registration)Package-level import and __all__ inclusion (line 34) that exports search_geo_locations for use at the top-level package.search_geo_locations