meta-ads-mcp 0.7.2__py3-none-any.whl → 0.7.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
meta_ads_mcp/__init__.py CHANGED
@@ -7,7 +7,7 @@ with the Claude LLM.
7
7
 
8
8
  from meta_ads_mcp.core.server import main
9
9
 
10
- __version__ = "0.7.2"
10
+ __version__ = "0.7.3"
11
11
 
12
12
  __all__ = [
13
13
  'get_ad_accounts',
@@ -1,69 +1,74 @@
1
1
  """Adds Library-related functionality for Meta Ads API."""
2
2
 
3
3
  import json
4
+ import os
4
5
  from typing import Optional, List, Dict, Any
5
6
  from .api import meta_api_tool, make_api_request
6
7
  from .server import mcp_server
7
8
 
8
9
 
9
- @mcp_server.tool()
10
- @meta_api_tool
11
- async def search_ads_archive(
12
- access_token: str = None,
13
- search_terms: str = None,
14
- ad_type: str = "ALL",
15
- ad_reached_countries: List[str] = None,
16
- limit: int = 25, # Default limit, adjust as needed
17
- fields: str = "ad_creation_time,ad_creative_body,ad_creative_link_caption,ad_creative_link_description,ad_creative_link_title,ad_delivery_start_time,ad_delivery_stop_time,ad_snapshot_url,currency,demographic_distribution,funding_entity,impressions,page_id,page_name,publisher_platform,region_distribution,spend"
18
- ) -> str:
19
- """
20
- Search the Facebook Ads Library archive.
10
+ # Only register the search_ads_archive function if the environment variable is NOT set
11
+ DISABLE_ADS_LIBRARY = bool(os.environ.get("META_ADS_DISABLE_ADS_LIBRARY", ""))
21
12
 
22
- Args:
23
- access_token: Meta API access token (optional - will use cached token if not provided).
24
- search_terms: The search query for ads.
25
- ad_type: Type of ads to search for (e.g., POLITICAL_AND_ISSUE_ADS, HOUSING_ADS, ALL).
26
- ad_reached_countries: List of country codes (e.g., ["US", "GB"]).
27
- limit: Maximum number of ads to return.
28
- fields: Comma-separated string of fields to retrieve for each ad.
13
+ if not DISABLE_ADS_LIBRARY:
14
+ @mcp_server.tool()
15
+ @meta_api_tool
16
+ async def search_ads_archive(
17
+ access_token: str = None,
18
+ search_terms: str = None,
19
+ ad_type: str = "ALL",
20
+ ad_reached_countries: List[str] = None,
21
+ limit: int = 25, # Default limit, adjust as needed
22
+ fields: str = "ad_creation_time,ad_creative_body,ad_creative_link_caption,ad_creative_link_description,ad_creative_link_title,ad_delivery_start_time,ad_delivery_stop_time,ad_snapshot_url,currency,demographic_distribution,funding_entity,impressions,page_id,page_name,publisher_platform,region_distribution,spend"
23
+ ) -> str:
24
+ """
25
+ Search the Facebook Ads Library archive.
29
26
 
30
- Example Usage via curl equivalent:
31
- curl -G \\
32
- -d "search_terms='california'" \\
33
- -d "ad_type=POLITICAL_AND_ISSUE_ADS" \\
34
- -d "ad_reached_countries=['US']" \\
35
- -d "fields=ad_snapshot_url,spend" \\
36
- -d "access_token=<ACCESS_TOKEN>" \\
37
- "https://graph.facebook.com/<API_VERSION>/ads_archive"
38
- """
39
- if not access_token:
40
- # Attempt to get token implicitly if not provided - meta_api_tool handles this
41
- pass
27
+ Args:
28
+ access_token: Meta API access token (optional - will use cached token if not provided).
29
+ search_terms: The search query for ads.
30
+ ad_type: Type of ads to search for (e.g., POLITICAL_AND_ISSUE_ADS, HOUSING_ADS, ALL).
31
+ ad_reached_countries: List of country codes (e.g., ["US", "GB"]).
32
+ limit: Maximum number of ads to return.
33
+ fields: Comma-separated string of fields to retrieve for each ad.
42
34
 
43
- if not search_terms:
44
- return json.dumps({"error": "search_terms parameter is required"}, indent=2)
35
+ Example Usage via curl equivalent:
36
+ curl -G \\
37
+ -d "search_terms='california'" \\
38
+ -d "ad_type=POLITICAL_AND_ISSUE_ADS" \\
39
+ -d "ad_reached_countries=['US']" \\
40
+ -d "fields=ad_snapshot_url,spend" \\
41
+ -d "access_token=<ACCESS_TOKEN>" \\
42
+ "https://graph.facebook.com/<API_VERSION>/ads_archive"
43
+ """
44
+ if not access_token:
45
+ # Attempt to get token implicitly if not provided - meta_api_tool handles this
46
+ pass
45
47
 
46
- if not ad_reached_countries:
47
- return json.dumps({"error": "ad_reached_countries parameter is required"}, indent=2)
48
+ if not search_terms:
49
+ return json.dumps({"error": "search_terms parameter is required"}, indent=2)
48
50
 
49
- endpoint = "ads_archive"
50
- params = {
51
- "search_terms": search_terms,
52
- "ad_type": ad_type,
53
- "ad_reached_countries": json.dumps(ad_reached_countries), # API expects a JSON array string
54
- "limit": limit,
55
- "fields": fields,
56
- }
51
+ if not ad_reached_countries:
52
+ return json.dumps({"error": "ad_reached_countries parameter is required"}, indent=2)
57
53
 
58
- try:
59
- data = await make_api_request(endpoint, access_token, params, method="GET")
60
- return json.dumps(data, indent=2)
61
- except Exception as e:
62
- error_msg = str(e)
63
- # Consider logging the full error for debugging
64
- # print(f"Error calling Ads Library API: {error_msg}")
65
- return json.dumps({
66
- "error": "Failed to search ads archive",
67
- "details": error_msg,
68
- "params_sent": {k: v for k, v in params.items() if k != 'access_token'} # Avoid logging token
69
- }, indent=2)
54
+ endpoint = "ads_archive"
55
+ params = {
56
+ "search_terms": search_terms,
57
+ "ad_type": ad_type,
58
+ "ad_reached_countries": json.dumps(ad_reached_countries), # API expects a JSON array string
59
+ "limit": limit,
60
+ "fields": fields,
61
+ }
62
+
63
+ try:
64
+ data = await make_api_request(endpoint, access_token, params, method="GET")
65
+ return json.dumps(data, indent=2)
66
+ except Exception as e:
67
+ error_msg = str(e)
68
+ # Consider logging the full error for debugging
69
+ # print(f"Error calling Ads Library API: {error_msg}")
70
+ return json.dumps({
71
+ "error": "Failed to search ads archive",
72
+ "details": error_msg,
73
+ "params_sent": {k: v for k, v in params.items() if k != 'access_token'} # Avoid logging token
74
+ }, indent=2)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: meta-ads-mcp
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: Model Context Protocol (MCP) plugin for interacting with Meta Ads API
5
5
  Project-URL: Homepage, https://github.com/pipeboard-co/meta-ads-mcp
6
6
  Project-URL: Bug Tracker, https://github.com/pipeboard-co/meta-ads-mcp/issues
@@ -1,9 +1,9 @@
1
- meta_ads_mcp/__init__.py,sha256=KwWEwtUuoU8IdDlVrrrmoG5dF51_f0RcetZ8dUiTwRA,1492
1
+ meta_ads_mcp/__init__.py,sha256=zoHok7v3IrW0q7qRG2A-7SKBUairjLpMXZTtDJsvpxY,1492
2
2
  meta_ads_mcp/__main__.py,sha256=XaQt3iXftG_7f0Zu7Wop9SeFgrD2WBn0EQOaPMc27d8,207
3
3
  meta_ads_mcp/core/__init__.py,sha256=IHBUfLTQW44VLbH_gZDT83nqzGrVWZ0l7FG4P3bp_bU,1706
4
4
  meta_ads_mcp/core/accounts.py,sha256=Nmp7lPxO9wmq25jWV7_H0LIqnEbBhpCVBlLGW2HUaq0,2277
5
5
  meta_ads_mcp/core/ads.py,sha256=aaK70mgfhBJRXr4cdkKag5mjYzvHuHpRttJvTMzPk4Y,36156
6
- meta_ads_mcp/core/ads_library.py,sha256=onStn9UkRqYDC60gOPS-iKDtP1plz6DygUb7hUZ0Jw8,2807
6
+ meta_ads_mcp/core/ads_library.py,sha256=BBGVbtjO5eFV42iiY3XPU-wIV8HupzUKpHgPBrydSvU,3232
7
7
  meta_ads_mcp/core/adsets.py,sha256=k76rm3rkhEebUzvBnM_QaVktrzGTKvTJOtWbBd6s3i8,10399
8
8
  meta_ads_mcp/core/api.py,sha256=aAzM6Q75VQOFXtr5D-mDmBRhxWK4wsiODsJYnR3mpDI,14994
9
9
  meta_ads_mcp/core/auth.py,sha256=H-0s0O2fLo14rmi81Hh5S64pyRl1HS7dm9Q_8UCa3Jg,21622
@@ -21,8 +21,8 @@ meta_ads_mcp/core/resources.py,sha256=-zIIfZulpo76vcKv6jhAlQq91cR2SZ3cjYZt3ek3x0
21
21
  meta_ads_mcp/core/server.py,sha256=WhbAag7xdhbGcp7rnU4sKhqXJ8Slapa_ba3T23Yp_2U,17889
22
22
  meta_ads_mcp/core/targeting.py,sha256=3HW1qirEdwaQurlBZGenbIwawcb5J06ghJKRfgu9ZEs,6318
23
23
  meta_ads_mcp/core/utils.py,sha256=ofKUhyo-5SZoJVuBeTVFPPQCffk0UKpwmDMrd8qQxNc,8715
24
- meta_ads_mcp-0.7.2.dist-info/METADATA,sha256=qE7hnGdcACq3_MRBnFb_kGV-gJzMes_d1AJjPx8u01s,20409
25
- meta_ads_mcp-0.7.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
- meta_ads_mcp-0.7.2.dist-info/entry_points.txt,sha256=Dv2RkoBjRJBqj6CyhwqGIiwPCD-SCL1-7B9-zmVRuv0,57
27
- meta_ads_mcp-0.7.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
- meta_ads_mcp-0.7.2.dist-info/RECORD,,
24
+ meta_ads_mcp-0.7.3.dist-info/METADATA,sha256=VIUGrJrlUcsNKtHH45dK7H0CXn3YuK87_T4BCdM_0UA,20409
25
+ meta_ads_mcp-0.7.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
26
+ meta_ads_mcp-0.7.3.dist-info/entry_points.txt,sha256=Dv2RkoBjRJBqj6CyhwqGIiwPCD-SCL1-7B9-zmVRuv0,57
27
+ meta_ads_mcp-0.7.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ meta_ads_mcp-0.7.3.dist-info/RECORD,,