Skip to main content
Glama
dhawalshah

meta-ads-mcp

get_ads_by_campaign

Retrieve ads from a specific Facebook campaign with filtering, pagination, and field selection. Get details like status, creative, and targeting for analysis.

Instructions

Retrieves ads associated with a specific Facebook campaign.

This function allows querying all ads belonging to a specific campaign, with filtering options, pagination, and field selection.

Args: campaign_id (str): The ID of the campaign to retrieve ads from. fields (Optional[List[str]]): A list of specific fields to retrieve for each ad. If None, a default set of fields will be returned. Common fields include: - 'id': The ad's ID - 'name': The ad's name - 'adset_id': The ID of the ad set this ad belongs to - 'creative': The ad creative details - 'status': The current status of the ad - 'effective_status': The effective status including review status - 'bid_amount': The bid amount for this ad - 'created_time': When the ad was created - 'updated_time': When the ad was last updated - 'targeting': Targeting criteria - 'preview_shareable_link': Link for previewing the ad filtering (Optional[List[dict]]): A list of filter objects to apply to the data. Each object should have 'field', 'operator', and 'value' keys. limit (Optional[int]): Maximum number of ads to return per page. Default is 25. after (Optional[str]): Pagination cursor for the next page. From response['paging']['cursors']['after']. before (Optional[str]): Pagination cursor for the previous page. From response['paging']['cursors']['before']. effective_status (Optional[List[str]]): Filter ads by their effective status. Options include: 'ACTIVE', 'PAUSED', 'DELETED', 'PENDING_REVIEW', 'DISAPPROVED', 'PREAPPROVED', 'PENDING_BILLING_INFO', 'ADSET_PAUSED', 'ARCHIVED', 'IN_PROCESS', 'WITH_ISSUES'.

Returns: Dict: A dictionary containing the requested ads. The main results are in the 'data' list, and pagination info is in the 'paging' object.

Example: ```python # Get all active ads from a campaign ads = get_ads_by_campaign( campaign_id="23843211234567", fields=["name", "adset_id", "effective_status", "created_time"], effective_status=["ACTIVE"], limit=50 )

# Fetch the next page if available using the pagination cursor
next_page_cursor = ads.get("paging", {}).get("cursors", {}).get("after")
if next_page_cursor:
    next_page = get_ads_by_campaign(
        campaign_id="23843211234567",
        fields=["name", "adset_id", "effective_status", "created_time"],
        effective_status=["ACTIVE"],
        limit=50,
        after=next_page_cursor
    )
```

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
afterNo
limitNo
beforeNo
fieldsNo
filteringNo
campaign_idYes
effective_statusNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.6/5.0
Behavior4/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It explains pagination cursors, default limit, how filtering works, and the response structure. It does not mention error behavior, rate limits, or auth requirements, but for a read-only retrieval tool the disclosed behavior is substantial and accurate.

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

Conciseness5/5

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

The description is organized in clear sections: a one-line purpose, an args list with precise detail, a returns line, and a practical example. Nothing is redundant; the length is justified by the density of useful information. The example demonstrates both basic use and pagination without padding.

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

Completeness5/5

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

For a 7-parameter tool with no annotations ret and no visible output schema, this description covers purpose, all parameters, return format, and common usage patterns. The pagination example is particularly valuable. An agent has everything needed to call this tool correctly.

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 must fully compensate. It does: every parameter is explained with types, defaults, and options. The 'fields' parameter lists common field names, 'effective_status' enumerates allowed values, and 'after'/'before' explicitly state they come from the paging cursor. This far exceeds what the bare schema provides.

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 opens with a specific verb and resource: 'Retrieves ads associated with a specific Facebook campaign.' This unambiguously distinguishes it from siblings like get_ads_by_adset and get_ads_by_adaccount by naming the campaign scope, so an agent can immediately identify what this tool does.

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

Usage Guidelines4/5

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

The description clearly establishes the context: use when you have a campaign_id and need its ads. It explains filtering, pagination, and field selection with a worked example, implying the appropriate use case. It does not explicitly name alternatives or exclusions, so it misses the fifth point by not stating when not to use it.

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