Skip to main content
Glama

get_ads

Retrieve Meta advertising campaign data with filtering options for specific campaigns or ad sets to analyze performance and manage ads.

Instructions

Get ads for a Meta Ads account with optional filtering.

Args:
    account_id: Meta Ads account ID (format: act_XXXXXXXXX)
    access_token: Meta API access token (optional - will use cached token if not provided)
    limit: Maximum number of ads to return (default: 10)
    campaign_id: Optional campaign ID to filter by
    adset_id: Optional ad set ID to filter by

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
access_tokenNo
limitNo
campaign_idNo
adset_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The get_ads tool handler: Retrieves ads from a specified Meta Ads account ID, with optional filtering by adset_id or campaign_id, using the Meta Ads API. Returns JSON-formatted list of ads.
    @mcp_server.tool()
    @meta_api_tool
    async def get_ads(account_id: str, access_token: Optional[str] = None, limit: int = 10, 
                     campaign_id: str = "", adset_id: str = "") -> str:
        """
        Get ads for a Meta Ads account with optional filtering.
        
        Args:
            account_id: Meta Ads account ID (format: act_XXXXXXXXX)
            access_token: Meta API access token (optional - will use cached token if not provided)
            limit: Maximum number of ads to return (default: 10)
            campaign_id: Optional campaign ID to filter by
            adset_id: Optional ad set ID to filter by
        """
        # Require explicit account_id
        if not account_id:
            return json.dumps({"error": "No account ID specified"}, indent=2)
        
        # Prioritize adset_id over campaign_id - use adset-specific endpoint
        if adset_id:
            endpoint = f"{adset_id}/ads"
            params = {
                "fields": "id,name,adset_id,campaign_id,status,creative,created_time,updated_time,bid_amount,conversion_domain,tracking_specs",
                "limit": limit
            }
        # Use campaign-specific endpoint if campaign_id is provided
        elif campaign_id:
            endpoint = f"{campaign_id}/ads"
            params = {
                "fields": "id,name,adset_id,campaign_id,status,creative,created_time,updated_time,bid_amount,conversion_domain,tracking_specs",
                "limit": limit
            }
        else:
            # Default to account-level endpoint if no specific filters
            endpoint = f"{account_id}/ads"
            params = {
                "fields": "id,name,adset_id,campaign_id,status,creative,created_time,updated_time,bid_amount,conversion_domain,tracking_specs",
                "limit": limit
            }
    
        data = await make_api_request(endpoint, access_token, params)
        
        return json.dumps(data, indent=2)
  • Imports and re-exports the get_ads function from ads.py module, making it available at the core package level for MCP tool registration.
    from .ads import get_ads, get_ad_details, get_ad_creatives, get_ad_image, update_ad
    from .insights import get_insights
  • Re-exports get_ads from core package in the main package __init__.py, including it in __all__ for top-level package access.
    get_ads,
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions 'optional filtering' and parameter defaults, but lacks critical information: authentication requirements beyond the access_token parameter, rate limits, pagination behavior (the 'limit' parameter suggests but doesn't explain), error conditions, or what 'cached token' means. For a read operation with 5 parameters and no annotation coverage, this is insufficient behavioral context.

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 appropriately sized with a clear purpose statement followed by a structured parameter list. Every sentence earns its place - the opening statement establishes context, and each parameter explanation is necessary. It could be slightly more front-loaded with behavioral context, but overall it's efficient with minimal waste.

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 tool has an output schema (which handles return values), 5 parameters with 0% schema coverage, and no annotations, the description does well on parameter semantics but lacks sufficient behavioral context. For a read operation that likely involves API authentication, rate limits, and pagination, the description should provide more operational guidance to be complete. The presence of an output schema reduces but doesn't eliminate this gap.

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?

With 0% schema description coverage, the description fully compensates by providing clear semantics for all 5 parameters. It explains each parameter's purpose, format requirements ('act_XXXXXXXXX'), optionality, defaults, and relationships (filtering by campaign/adset). This adds significant value beyond the bare schema, which only provides titles and types with no descriptive content.

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

Purpose4/5

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

The description clearly states 'Get ads for a Meta Ads account with optional filtering' - this specifies the verb ('Get'), resource ('ads'), and scope ('Meta Ads account'). It distinguishes from siblings like 'get_ad_details' (specific ad) and 'get_ad_creatives' (different resource), though not explicitly. The purpose is clear but sibling differentiation is only implicit through resource naming.

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?

The description implies usage through 'optional filtering' and the parameter list suggests filtering capabilities, but provides no explicit guidance on when to use this tool versus alternatives like 'search_ads_archive' or 'get_ad_details'. The agent must infer usage from the tool name and parameters alone, with no when/when-not statements or named alternatives.

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