Skip to main content
Glama

Search Meta Ad Library by Keyword

search_meta_ads_by_keyword
Read-only

Use this when you want to discover ads by keyword or topic without knowing a specific brand, OR to find partnership/influencer ads a brand is running via creators (get_meta_ads only returns ads from the brand's own page). Searches the full Meta Ad Library with optional country, status, media type, and date filters. For UGC/creator-style or polished brand video ads, set style='ugc' or 'brand' (video only; 1 extra credit when new creatives get classified). For elections or political campaigns set ad_type='political_and_issue_ads' and country; for past periods add start_date/end_date (searches all statuses). get_playbook has written methods for hooks, scripts, angles and product research. The ads returned can be shown to the user as an inline visual carousel with show_ad_carousel (up to 20 per call).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "query": "<query>"
    },
    "name": "search_meta_ads_by_keyword"
  }
}

Input Schema

NameRequiredDescriptionDefault
trimNoTrue (default) returns trimmed ad fields.
limitNoMax ads to return (default 30 = 3 credits; 1 credit per 10 ads returned, at least 1; at most 10 pages). The response cursor fetches the next page.
queryYesKeyword or phrase, e.g. "running shoes".
styleNoVideo creative style: "ugc" (a creator or customer filming themselves, handheld/selfie feel) or "brand" (polished brand-produced footage, motion graphics, product UI). Video ads only (implies media_type="video"). Inferred from each video's cover frame; ads whose frame shows too little are kept after the matches with style "unknown". Filters the ads fetched, so a wider limit gives it more to work with (up to 60 new creatives are classified per call). Costs 1 extra credit per call when any creative is newly classified; creatives classified before are free.
cursorNoContinuation token from a previous response. Present when more ads exist beyond what was scanned.
statusNo"ALL", "ACTIVE" (default; "ALL" when start_date/end_date is set) or "INACTIVE".
ad_typeNo"all" (default) or "political_and_issue_ads".
contextNoOne plain sentence, 8-20 words, starting with a verb, stating what the user is trying to accomplish in this conversation. Name the brand, competitor, industry, or topic involved. Reuse the exact same sentence on every tool call in this conversation. Never include people's names, emails, phone numbers, credentials, or internal company details. Never describe this tool or why it was chosen. Example: 'Compare Notion and Coda Meta ads to find hooks for a productivity app launch.'
countryNoTwo-letter country code. Default: all countries; set it when the user names a market.
sort_byNo"relevancy_monthly_grouped" (default, stays on-topic, ads from the last month only), "total_impressions" (largest advertisers first, looser matches, any age), "longest_running" or "newest" (these two rank only the ads fetched).
end_dateNoFilter by impressions end date, YYYY-MM-DD.
media_typeNo"all" (default), "image" (static creatives, including image carousels; a filtered scan: at least 2 credits) or "video" (video only).
start_dateNoFilter by impressions start date, YYYY-MM-DD.
search_typeNo"keyword_unordered" (default) or "keyword_exact_phrase", better for multi-word product names.
conversation_idNoThe conversation_id this server returned earlier in this conversation, unchanged, including after later user messages. Omit it if you have none. Recorded for the server developer's analytics.
min_duration_daysNoOnly ads that have run for at least this many days, e.g. 90 for proven ads. A filtered scan: at least 2 credits.

Output Schema

NameRequiredDescriptionDefault
_mcp_instructionsNoServer-issued metadata for this conversation.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changed
    • addedInput schema / additionalProperties
      Added value: +false
    • changedInput schema / properties / conversation_id / description
      Previous value: -"Echo the conversation_id from the server's previous response. The server provides it on the first call — never invent one, and do not issue parallel tool calls until you have it."New value: +"The conversation_id this server returned earlier in this conversation, unchanged, including after later user messages. Omit it if you have none. Recorded for the server developer's analytics."
  2. Changed3 schema fields changed
    • changedInput schema / properties / limit / description
      Previous value: -"Max ads to return (default 30 = one page at 1 credit; at most 10 pages). The response cursor fetches the next page."New value: +"Max ads to return (default 30 = 3 credits; 1 credit per 10 ads returned, at least 1; at most 10 pages). The response cursor fetches the next page."
    • changedInput schema / properties / media_type / description
      Previous value: -"\"all\" (default), \"image\" (static creatives, including image carousels) or \"video\" (video only)."New value: +"\"all\" (default), \"image\" (static creatives, including image carousels; a filtered scan: at least 2 credits) or \"video\" (video only)."
    • changedInput schema / properties / min_duration_days / description
      Previous value: -"Only ads that have run for at least this many days, e.g. 90 for proven ads. Scans up to 5 pages (up to 5 credits)."New value: +"Only ads that have run for at least this many days, e.g. 90 for proven ads. A filtered scan: at least 2 credits."
  3. Changed1 schema field changed
    • addedInput schema / properties / style
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Video creative style: \"ugc\" (a creator or customer filming themselves, handheld/selfie feel) or \"brand\" (polished brand-produced footage, motion graphics, product UI). Video ads only (implies media_type=\"video\"). Inferred from each video's cover frame; ads whose frame shows too little are kept after the matches with style \"unknown\". Filters the ads fetched, so a wider limit gives it more to work with (up to 60 new creatives are classified per call). Costs 1 extra credit per call when any creative is newly classified; creatives classified before are free."
      +}
  4. Changed2 schema fields changed
    • addedInput schema / properties / min_duration_days
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "integer"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Only ads that have run for at least this many days, e.g. 90 for proven ads. Scans up to 5 pages (up to 5 credits)."
      +}
    • changedInput schema / properties / sort_by / description
      Previous value: -"\"relevancy_monthly_grouped\" (default, stays on-topic) or \"total_impressions\" (largest advertisers first, looser matches)."New value: +"\"relevancy_monthly_grouped\" (default, stays on-topic, ads from the last month only), \"total_impressions\" (largest advertisers first, looser matches, any age), \"longest_running\" or \"newest\" (these two rank only the ads fetched)."
  5. Changed1 schema field changed
    • changedInput schema / properties / status / description
      Previous value: -"\"ALL\", \"ACTIVE\" (default) or \"INACTIVE\"."New value: +"\"ALL\", \"ACTIVE\" (default; \"ALL\" when start_date/end_date is set) or \"INACTIVE\"."
  6. Changed2 schema fields changed
    • changedInput schema / properties / limit / default
      Previous value: -100New value: +30
    • changedInput schema / properties / limit / description
      Previous value: -"Max ads to return (default 100, at most 10 pages)."New value: +"Max ads to return (default 30 = one page at 1 credit; at most 10 pages). The response cursor fetches the next page."
  7. Changed12 schema fields changed
    • addedInput schema / properties / ad_type / description
      Added value: +"\"all\" (default) or \"political_and_issue_ads\"."
    • addedInput schema / properties / country / description
      Added value: +"Two-letter country code. Default: all countries; set it when the user names a market."
    • addedInput schema / properties / cursor / description
      Added value: +"Continuation token from a previous response. Present when more ads exist beyond what was scanned."
    • addedInput schema / properties / end_date / description
      Added value: +"Filter by impressions end date, YYYY-MM-DD."
    • addedInput schema / properties / limit / description
      Added value: +"Max ads to return (default 100, at most 10 pages)."
    • addedInput schema / properties / media_type / description
      Added value: +"\"all\" (default), \"image\" (static creatives, including image carousels) or \"video\" (video only)."
    • addedInput schema / properties / query / description
      Added value: +"Keyword or phrase, e.g. \"running shoes\"."
    • addedInput schema / properties / search_type / description
      Added value: +"\"keyword_unordered\" (default) or \"keyword_exact_phrase\", better for multi-word product names."
    • addedInput schema / properties / sort_by / description
      Added value: +"\"relevancy_monthly_grouped\" (default, stays on-topic) or \"total_impressions\" (largest advertisers first, looser matches)."
    • addedInput schema / properties / start_date / description
      Added value: +"Filter by impressions start date, YYYY-MM-DD."
    • addedInput schema / properties / status / description
      Added value: +"\"ALL\", \"ACTIVE\" (default) or \"INACTIVE\"."
    • addedInput schema / properties / trim / description
      Added value: +"True (default) returns trimmed ad fields."
  8. First observed

TDQS

A4.6/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, openWorldHint=true and destructiveHint=false, so the description's job is to add operational context beyond safety. It does: credit cost implications ('1 extra credit when new creatives get classified'), filtered-scan behavior, the fact that style is inferred from cover frames and unmatched ads are appended as 'unknown', and that date ranges implicitly search all statuses. Some of this restates schema field descriptions, but the cross-field behavior is genuinely additive.

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 single paragraph is front-loaded with the primary use case and the sibling disambiguation before moving into parameter-specific advice, and every sentence maps to a decision the agent must make. It is dense and long, with the style/credit explanation partially duplicating the schema, but there is little filler and no ambiguous hand-waving.

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 16-parameter, open-world search tool with a full output schema, the description covers the selection rationale, the key filter combinations (political, dates, style, media type), the cost model, and the downstream carousel step. Return-value shape is correctly left to the output schema, so nothing an agent needs to invoke it correctly is missing.

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

Parameters4/5

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

Schema description coverage is 100%, so the schema already explains each of the 16 parameters, making 3 the baseline. The description still adds cross-parameter meaning the schema does not: political ad searches should pair ad_type='political_and_issue_ads' with country, and supplying start_date/end_date implies searching all statuses regardless of the status default. It also links style to media_type behavior and limit widening, which is more than field-by-field restatement.

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 ('Searches the full Meta Ad Library') and immediately contrasts scope with a named sibling: 'get_meta_ads only returns ads from the brand's own page.' An agent can distinguish keyword/topic discovery from brand-page lookup and from creator/partnership discovery without reading any schema.

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

Usage Guidelines5/5

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

It gives explicit when-to-use conditions ('discover ads by keyword or topic without knowing a specific brand', 'find partnership/influencer ads a brand is running via creators') plus situational routing: style for UGC vs brand video, ad_type='political_and_issue_ads' + country for elections, date ranges for past periods. It also redirects method-seeking users to get_playbook and display needs to show_ad_carousel, covering both tool selection and follow-on actions.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources