Skip to main content
Glama

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 description

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
access_tokenNo
demographic_classNodemographics
limitNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • 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)
  • 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
  • Exports search_demographics in the package-level __all__ list.
    'search_demographics',
  • Imports search_demographics from core module for package-level access.
    search_demographics,
  • 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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must fully disclose behavioral traits. It only describes a read operation but fails to mention any side effects, authentication requirements, rate limits, or error handling. The return format is described, but behavioral transparency is lacking.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is reasonably concise with structured parameter and return sections. Could be slightly more terse but avoids unnecessary fluff. Each line adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema, the description covers parameter details and return format. However, it lacks context on error conditions, pagination, or authentication nuances. For a tool with no required parameters, it is adequate but not fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description carries the full burden. It adds significant meaning: explains demographic_class options, notes access_token can be cached, and describes limit default. This goes beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves demographic targeting options, with a specific verb 'Get' and resource 'demographic targeting options'. It lists specific demographic classes that differentiate it from siblings like search_behaviors and search_interests.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

While the description implies usage for targeting options, it does not explicitly state when to use this tool versus alternatives. No guidance on when not to use or context for selection among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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