search_behaviors
Retrieve behavior targeting options for Meta ads campaigns. Specify access token and limit to get JSON results with id, name, and audience size.
Instructions
Get all available behavior targeting options.
Args:
access_token: Meta API access token (optional - will use cached token if not provided)
limit: Maximum number of results to return (default: 50)
Returns:
JSON string containing behavior targeting options with id, name, audience_size bounds, path, and descriptionInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_token | No | ||
| limit | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- meta_ads_mcp/core/targeting.py:458-480 (handler)The main handler implementation of the search_behaviors tool. It queries the Meta Ads API 'search' endpoint with type='adTargetingCategory' and class='behaviors' to retrieve behavior targeting options. Returns JSON with id, name, audience_size bounds, path, and description.
@mcp_server.tool() @meta_api_tool async def search_behaviors(access_token: Optional[str] = None, limit: int = 50) -> str: """ Get all available behavior targeting options. Args: access_token: Meta API access token (optional - will use cached token if not provided) limit: Maximum number of results to return (default: 50) Returns: JSON string containing behavior targeting options with id, name, audience_size bounds, path, and description """ endpoint = "search" params = { "type": "adTargetingCategory", "class": "behaviors", "limit": limit } data = await make_api_request(endpoint, access_token, params) return json.dumps(data, indent=2) - meta_ads_mcp/core/targeting.py:458-459 (registration)The tool is registered via the @mcp_server.tool() decorator on the search_behaviors async function, which makes it available as an MCP tool.
@mcp_server.tool() @meta_api_tool - meta_ads_mcp/__init__.py:58-58 (registration)Re-export of search_behaviors at the package level, making it accessible from meta_ads_mcp.search_behaviors.
search_behaviors, - meta_ads_mcp/core/__init__.py:44-44 (registration)Core package __init__ includes search_behaviors in __all__ and re-exports it for public API access.
'search_behaviors', - meta_ads_mcp/core/targeting.py:1-7 (helper)Imports used by search_behaviors: json for serialization, Optional from typing, meta_api_tool decorator and make_api_request from .api, and mcp_server from .server for the @mcp_server.tool() decorator.
"""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