search_demographics
Retrieve demographic targeting options for Meta ads, including life events, industries, income, and user details, to define ad audience segments.
Instructions
Get demographic targeting options.
Args:
access_token: Meta API access token (optional - will use cached token if not provided)
demographic_class: Type of demographics to retrieve. Options: 'demographics', 'life_events',
'industries', 'income', 'family_statuses', 'user_device', 'user_os' (default: 'demographics')
limit: Maximum number of results to return (default: 50)
Returns:
JSON string containing demographic targeting options with id, name, audience_size bounds, path, and descriptionInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_token | No | ||
| demographic_class | No | demographics | |
| limit | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- meta_ads_mcp/core/targeting.py:483-507 (handler)The main implementation of the 'search_demographics' tool. It's an async function decorated with @mcp_server.tool() and @meta_api_tool, that makes an API request to Meta's 'search' endpoint with type 'adTargetingCategory' and the provided demographic_class and limit parameters, returning JSON results.
@mcp_server.tool() @meta_api_tool async def search_demographics(access_token: Optional[str] = None, demographic_class: str = "demographics", limit: int = 50) -> str: """ Get demographic targeting options. Args: access_token: Meta API access token (optional - will use cached token if not provided) demographic_class: Type of demographics to retrieve. Options: 'demographics', 'life_events', 'industries', 'income', 'family_statuses', 'user_device', 'user_os' (default: 'demographics') limit: Maximum number of results to return (default: 50) Returns: JSON string containing demographic targeting options with id, name, audience_size bounds, path, and description """ endpoint = "search" params = { "type": "adTargetingCategory", "class": demographic_class, "limit": limit } data = await make_api_request(endpoint, access_token, params) return json.dumps(data, indent=2) - meta_ads_mcp/core/targeting.py:1-8 (helper)Imports used by search_demographics: json, typing, make_api_request, meta_api_tool, and the mcp_server instance from the server module.
"""Targeting search functionality for Meta Ads API.""" import json from typing import Optional, List, Dict, Any, Union import os from .api import meta_api_tool, make_api_request from .server import mcp_server - meta_ads_mcp/__init__.py:33-33 (registration)Exports search_demographics in the package-level __all__ list.
'search_demographics', - meta_ads_mcp/__init__.py:59-59 (registration)Imports search_demographics from core module for package-level access.
search_demographics, - meta_ads_mcp/core/__init__.py:14-14 (registration)Imports search_demographics from the targeting module into the core package.
from .targeting import search_interests, get_interest_suggestions, estimate_audience_size, search_behaviors, search_demographics, search_geo_locations