list_campaigns
Retrieve and filter advertising campaigns from a Meta Ads account to manage marketing initiatives and analyze performance data.
Instructions
List campaigns for an ad account with optional filters.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ad_account_id | Yes | ||
| meta_access_token | No | ||
| page_size | No | ||
| status_filter | No | ||
| objective_filter | No | ||
| page_cursor | No |
Implementation Reference
- The `list_campaigns` tool handler, implemented using `mcp_server.tool()` and a helper `meta_api_tool` decorator.
@mcp_server.tool() @meta_api_tool async def list_campaigns( ad_account_id: str, meta_access_token: Optional[str] = None, page_size: int = 10, status_filter: str = "", objective_filter: Union[str, List[str]] = "", page_cursor: str = "", ) -> str: """List campaigns for an ad account with optional filters.""" if not ad_account_id: return _json({"error": "No account ID specified"}) params: Dict[str, Any] = { "fields": ( "id,name,objective,status,effective_status,daily_budget,lifetime_budget,buying_type," "start_time,stop_time,created_time,updated_time,bid_strategy,advantage_state_info" ), "page_size": int(page_size), } if status_filter: params["effective_status"] = [status_filter] objectives = _normalize_objectives(objective_filter) if objectives: params["filtering"] = [{"field": "objective", "operator": "IN", "value": objectives}] if page_cursor: params["page_cursor"] = page_cursor payload = await make_api_request(f"{ad_account_id}/campaigns", meta_access_token, params) return _json(payload)