Skip to main content
Glama

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
NameRequiredDescriptionDefault
access_tokenNo
limitNo
location_typesNo
queryNo

Implementation Reference

  • 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)
  • 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
  • Package-level import and __all__ inclusion (line 34) that exports search_geo_locations for use at the top-level package.
    search_geo_locations

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/pipeboard-co/meta-ads-mcp'

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