Skip to main content
Glama

facebook_ad_library_search

Search Meta Ad Library by keyword — active/inactive, media type, date range, platforms, cursor, and spend/impressions when Meta publishes them. Each ad has creativeHash + landingDomain; dedupe=true merges repeats. Costs 2 credits. Empty results and failures are never charged. Pass cache=true for a free 24h cache hit (default always fresh).

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": {
      "q": "<q>"
    },
    "name": "facebook_ad_library_search"
  }
}

Input Schema

NameRequiredDescriptionDefault
qYesKeyword, brand, or advertiser to search Meta Ad Library (min 2 characters).
trimNoWhen true, omit cards/images/videos typed arrays (media[] stays). Captapi payloads are already lean vs Meta nested snapshots.
cacheNoSet true to serve from the 24h response cache (0 credits on hit). Default false — always fetch fresh.
limitNoMax items to return (default 20, max 200). Flat 2 credits per call.
cursorNoPagination cursor from a previous nextCursor. Pages through the current Meta HTML result batch.
dedupeNoWhen true, ads with the same creativeHash (same copy, headline and landing domain) collapse into one row, the first in library order, with duplicateIds[] (every ad id in the group) and duplicateCount (group size). Duplicates are merged only among the ads this request fetched (retrievableCount). Ads from another request or from library pages past this batch are not compared, so the same creative can appear again there. Default false: every ad is its own row and no duplicate fields are added. Same price.
fieldsNoOptional comma-separated keys to keep on each result row (or on the object for single-item tools), e.g. id,url,publishedAt,engagement. Pagination keys are always kept. Does not change the price.
statusNoAd delivery status: ACTIVE (default), INACTIVE, or ALL. Use ACTIVE for "what are they running now?".
ad_typeNoall (default) or political_and_issue_ads. Spend/impressions are typically only filled for political/issue ads.
compactNoDefault true here: drop signed media URLs (video, image, avatar links and their expiry stamps) to keep the response small. Ids, permalinks, dates, text and metrics stay. On Threads, Facebook, Meta Ad Library and TikTok Shop tools request timings are dropped too. Pass false for the full body.
countryNoTwo-letter ISO country code (e.g. US, GB, DE), or ALL for every country (Meta's own value). Default US. For inactive ads prefer ALL: a single-country search can list far fewer inactive ads than ALL. Other non-ISO codes are a definitive 400 INVALID_COUNTRY — Meta would otherwise ignore the code and search globally while echoing it back as if the filter worked.
sort_byNoMeta sort mode: total_impressions or relevancy_monthly_grouped.
end_dateNoOnly ads shown (delivered) on or before this date (YYYY-MM-DD).
platformsNoComma-separated publisher platforms to keep: FACEBOOK, INSTAGRAM, MESSENGER, AUDIENCE_NETWORK, THREADS.
media_typeNoCreative filter: ALL (default), IMAGE, VIDEO, MEME, IMAGE_AND_MEME, or NONE.
start_dateNoOnly ads shown (delivered) on or after this date (YYYY-MM-DD). Delivery-date window, not a start-date filter: an ad that started earlier but was still running in the range is included.
search_typeNokeyword_unordered (default) or keyword_exact_phrase.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / dedupe
      Added value: +{
      +  "description": "When true, ads with the same creativeHash (same copy, headline and landing domain) collapse into one row, the first in library order, with duplicateIds[] (every ad id in the group) and duplicateCount (group size). Duplicates are merged only among the ads this request fetched (retrievableCount). Ads from another request or from library pages past this batch are not compared, so the same creative can appear again there. Default false: every ad is its own row and no duplicate fields are added. Same price.",
      +  "type": "boolean"
      +}
  2. Changed1 schema field changed
    • changedInput schema / properties / compact / description
      Previous value: -"Default true here: drop signed media URLs (video, image, avatar links and their expiry stamps) to keep the response small. Ids, permalinks, dates, text and metrics stay. Pass false for the full body."New value: +"Default true here: drop signed media URLs (video, image, avatar links and their expiry stamps) to keep the response small. Ids, permalinks, dates, text and metrics stay. On Threads, Facebook, Meta Ad Library and TikTok Shop tools request timings are dropped too. Pass false for the full body."
  3. Changed2 schema fields changed
    • addedInput schema / properties / compact
      Added value: +{
      +  "default": true,
      +  "description": "Default true here: drop signed media URLs (video, image, avatar links and their expiry stamps) to keep the response small. Ids, permalinks, dates, text and metrics stay. Pass false for the full body.",
      +  "type": "boolean"
      +}
    • addedInput schema / properties / fields
      Added value: +{
      +  "description": "Optional comma-separated keys to keep on each result row (or on the object for single-item tools), e.g. id,url,publishedAt,engagement. Pagination keys are always kept. Does not change the price.",
      +  "type": "string"
      +}
  4. Changed1 schema field changed
    • changedInput schema / properties / country / description
      Previous value: -"Two-letter ISO country code (e.g. US, GB, DE). Default US. Non-ISO codes are a definitive 400 INVALID_COUNTRY — Meta would otherwise ignore the code and search globally while echoing it back as if the filter worked."New value: +"Two-letter ISO country code (e.g. US, GB, DE), or ALL for every country (Meta's own value). Default US. For inactive ads prefer ALL: a single-country search can list far fewer inactive ads than ALL. Other non-ISO codes are a definitive 400 INVALID_COUNTRY — Meta would otherwise ignore the code and search globally while echoing it back as if the filter worked."
  5. Changed2 schema fields changed
    • changedInput schema / properties / end_date / description
      Previous value: -"Only ads with delivery start on/before this date (YYYY-MM-DD)."New value: +"Only ads shown (delivered) on or before this date (YYYY-MM-DD)."
    • changedInput schema / properties / start_date / description
      Previous value: -"Only ads with delivery start on/after this date (YYYY-MM-DD)."New value: +"Only ads shown (delivered) on or after this date (YYYY-MM-DD). Delivery-date window, not a start-date filter: an ad that started earlier but was still running in the range is included."
  6. Changed1 schema field changed
    • changedInput schema / properties / country / description
      Previous value: -"Two-letter ISO country code (e.g. US, GB, DE). Default US."New value: +"Two-letter ISO country code (e.g. US, GB, DE). Default US. Non-ISO codes are a definitive 400 INVALID_COUNTRY — Meta would otherwise ignore the code and search globally while echoing it back as if the filter worked."
  7. Changed1 schema field changed
    • changedInput schema / properties / cache / description
      Previous value: -"Set true to serve from the 24h response cache (0 credits on hit). Default false — always fetch fresh. Envelope includes cached + cachedAt on hits."New value: +"Set true to serve from the 24h response cache (0 credits on hit). Default false — always fetch fresh."
  8. Changed13 schema fields changed
    • changedInput schema / properties / ad_type / description
      Previous value: -"all (default) or political_and_issue_ads."New value: +"all (default) or political_and_issue_ads. Spend/impressions are typically only filled for political/issue ads."
    • changedInput schema / properties / cache / description
      Previous value: -"Set true to serve from the 24h response cache. Default false — always fetch fresh data."New value: +"Set true to serve from the 24h response cache (0 credits on hit). Default false — always fetch fresh. Envelope includes cached + cachedAt on hits."
    • changedInput schema / properties / country / description
      Previous value: -"ISO country code. Default US."New value: +"Two-letter ISO country code (e.g. US, GB, DE). Default US."
    • addedInput schema / properties / cursor
      Added value: +{
      +  "description": "Pagination cursor from a previous nextCursor. Pages through the current Meta HTML result batch.",
      +  "type": "string"
      +}
    • changedInput schema / properties / end_date / description
      Previous value: -"Delivery start on/before YYYY-MM-DD."New value: +"Only ads with delivery start on/before this date (YYYY-MM-DD)."
    • changedInput schema / properties / limit / description
      Previous value: -"Max items to return. Default 20, max 200. Billed per result."New value: +"Max items to return (default 20, max 200). Flat 2 credits per call."
    • changedInput schema / properties / media_type / description
      Previous value: -"ALL (default), IMAGE, VIDEO, MEME, IMAGE_AND_MEME, or NONE."New value: +"Creative filter: ALL (default), IMAGE, VIDEO, MEME, IMAGE_AND_MEME, or NONE."
    • addedInput schema / properties / platforms
      Added value: +{
      +  "description": "Comma-separated publisher platforms to keep: FACEBOOK, INSTAGRAM, MESSENGER, AUDIENCE_NETWORK, THREADS.",
      +  "type": "string"
      +}
    • changedInput schema / properties / q / description
      Previous value: -"Search query or keywords (min 2 chars)."New value: +"Keyword, brand, or advertiser to search Meta Ad Library (min 2 characters)."
    • changedInput schema / properties / sort_by / description
      Previous value: -"total_impressions or relevancy_monthly_grouped."New value: +"Meta sort mode: total_impressions or relevancy_monthly_grouped."
    • changedInput schema / properties / start_date / description
      Previous value: -"Delivery start on/after YYYY-MM-DD."New value: +"Only ads with delivery start on/after this date (YYYY-MM-DD)."
    • changedInput schema / properties / status / description
      Previous value: -"ACTIVE (default), INACTIVE, or ALL."New value: +"Ad delivery status: ACTIVE (default), INACTIVE, or ALL. Use ACTIVE for \"what are they running now?\"."
    • addedInput schema / properties / trim
      Added value: +{
      +  "description": "When true, omit cards/images/videos typed arrays (media[] stays). Captapi payloads are already lean vs Meta nested snapshots.",
      +  "type": "boolean"
      +}
  9. Changed7 schema fields changed
    • addedInput schema / properties / ad_type
      Added value: +{
      +  "description": "all (default) or political_and_issue_ads.",
      +  "type": "string"
      +}
    • addedInput schema / properties / end_date
      Added value: +{
      +  "description": "Delivery start on/before YYYY-MM-DD.",
      +  "type": "string"
      +}
    • addedInput schema / properties / media_type
      Added value: +{
      +  "description": "ALL (default), IMAGE, VIDEO, MEME, IMAGE_AND_MEME, or NONE.",
      +  "type": "string"
      +}
    • addedInput schema / properties / search_type
      Added value: +{
      +  "description": "keyword_unordered (default) or keyword_exact_phrase.",
      +  "type": "string"
      +}
    • addedInput schema / properties / sort_by
      Added value: +{
      +  "description": "total_impressions or relevancy_monthly_grouped.",
      +  "type": "string"
      +}
    • addedInput schema / properties / start_date
      Added value: +{
      +  "description": "Delivery start on/after YYYY-MM-DD.",
      +  "type": "string"
      +}
    • addedInput schema / properties / status
      Added value: +{
      +  "description": "ACTIVE (default), INACTIVE, or ALL.",
      +  "type": "string"
      +}
  10. Changed1 schema field changed
    • changedInput schema / properties / cache / description
      Previous value: -"Responses are cached for 24 hours by default. Set false to bypass the cache and always fetch fresh data (default true)."New value: +"Set true to serve from the 24h response cache. Default false — always fetch fresh data."
  11. Changed1 schema field changed
    • addedInput schema / properties / cache
      Added value: +{
      +  "description": "Responses are cached for 24 hours by default. Set false to bypass the cache and always fetch fresh data (default true).",
      +  "type": "boolean"
      +}
  12. Added

TDQS

A3.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 and does add real behavior: 2 credits per call, empty results and failures are never charged, cache=true gives a free 24h hit while default is always-fresh, and spend/impressions are only present when Meta publishes them. It still omits auth/permission needs and any rate-limit or partial-result failure modes.

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?

Front-loaded with purpose, then pricing and caching — the right order for an agent deciding whether to call. A few clauses duplicate schema content (dedupe merging, cursor), which is mild waste but not bloat.

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?

For a 17-parameter tool with no output schema, the description covers pricing, caching, dedupe scope, and data-availability caveats, which is substantial. It stops short of describing the result envelope or pagination behavior beyond the cursor mention, leaving the agent to infer return shape from the parameter docs.

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

Parameters3/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 defines every parameter in depth; the description only restates dedupe=true merging repeats and cache=true semantics, both of which the schema explains more fully. It adds marginal meaning (the existence of creativeHash/landingDomain as row keys) without compensating beyond the baseline.

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?

Opens with a specific verb+resource: "Search Meta Ad Library by keyword", and enumerates the filter dimensions (status, media type, dates, platforms, cursor, spend/impressions). It does not name any sibling, so an agent cannot directly tell it apart from facebook_ad_library_company_ads or facebook_ad_library_search_companies, but the keyword-search framing makes its role recognizable.

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?

Usage signals are present but indirect: cost is stated (2 credits, free cache hits, no charge on empty/failure), which implies a cheap-first search pattern, yet the description never says when to prefer this tool over company-specific or ad-details siblings. The conditional advice that exists (active vs inactive, spend/impressions only for political ads) lives in the schema, not the prose.

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.