meta-ads-mcp 0.9.3__tar.gz → 0.10.1__tar.gz
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-0.10.1/LICENSE +44 -0
- meta_ads_mcp-0.9.3/README.md → meta_ads_mcp-0.10.1/PKG-INFO +47 -0
- meta_ads_mcp-0.9.3/PKG-INFO → meta_ads_mcp-0.10.1/README.md +22 -25
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/__init__.py +3 -3
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/__init__.py +2 -2
- meta_ads_mcp-0.10.1/meta_ads_mcp/core/targeting.py +332 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/pyproject.toml +4 -4
- meta_ads_mcp-0.10.1/tests/test_estimate_audience_size.py +472 -0
- meta_ads_mcp-0.10.1/tests/test_estimate_audience_size_e2e.py +639 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_targeting.py +7 -7
- meta_ads_mcp-0.9.3/LICENSE +0 -201
- meta_ads_mcp-0.9.3/meta_ads_mcp/core/targeting.py +0 -185
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/.github/workflows/publish.yml +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/.github/workflows/test.yml +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/.gitignore +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/CUSTOM_META_APP.md +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/Dockerfile +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/LOCAL_INSTALLATION.md +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/META_API_NOTES.md +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/RELEASE.md +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/STREAMABLE_HTTP_SETUP.md +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/examples/README.md +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/examples/example_http_client.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/future_improvements.md +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/images/meta-ads-example.png +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_auth.sh +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/__main__.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/accounts.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/ads.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/ads_library.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/adsets.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/api.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/auth.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/authentication.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/budget_schedules.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/callback_server.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/campaigns.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/duplication.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/http_auth_integration.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/insights.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/openai_deep_research.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/pipeboard_auth.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/reports.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/resources.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/server.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/meta_ads_mcp/core/utils.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/requirements.txt +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/setup.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/smithery.yaml +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/README.md +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/README_REGRESSION_TESTS.md +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/__init__.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/conftest.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/e2e_account_info_search_issue.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_account_info_access_fix.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_account_search.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_budget_update.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_budget_update_e2e.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_dsa_beneficiary.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_dsa_integration.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_duplication.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_duplication_regression.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_dynamic_creatives.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_get_account_pages.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_get_ad_creatives_fix.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_get_ad_image_quality_improvements.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_get_ad_image_regression.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_http_transport.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_insights_actions_and_values.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_integration_openai_mcp.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_mobile_app_adset_creation.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_mobile_app_adset_issue.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_openai.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_openai_mcp_deep_research.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_page_discovery.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_page_discovery_integration.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_targeting_search_e2e.py +0 -0
- {meta_ads_mcp-0.9.3 → meta_ads_mcp-0.10.1}/tests/test_update_ad_creative_id.py +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
5
|
+
|
|
6
|
+
Parameters
|
|
7
|
+
|
|
8
|
+
Licensor: ARTELL SOLUÇÕES TECNOLÓGICAS LTDA
|
|
9
|
+
Licensed Work: Meta Ads MCP Server. The Licensed Work is (c) 2025
|
|
10
|
+
Additional Use Grant: You may make production use of the Licensed Work, provided such use does not include offering the Licensed Work to third parties on a hosted or embedded basis which competes with the Licensor's commercial offerings.
|
|
11
|
+
Change Date: January 1, 2029
|
|
12
|
+
Change License: Apache License, Version 2.0
|
|
13
|
+
|
|
14
|
+
Terms
|
|
15
|
+
|
|
16
|
+
The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
|
|
17
|
+
|
|
18
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
|
|
19
|
+
|
|
20
|
+
If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
|
|
21
|
+
|
|
22
|
+
All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
|
|
23
|
+
|
|
24
|
+
You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
|
|
25
|
+
|
|
26
|
+
Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
|
|
27
|
+
|
|
28
|
+
This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License).
|
|
29
|
+
|
|
30
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
|
|
31
|
+
|
|
32
|
+
MariaDB hereby grants you permission to use this License's text to license your works, and to refer to it using the trademark "Business Source License", as long as you comply with the Covenants of Licensor below.
|
|
33
|
+
|
|
34
|
+
Covenants of Licensor
|
|
35
|
+
|
|
36
|
+
In consideration of the right to use this License's text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
|
|
37
|
+
|
|
38
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
|
|
39
|
+
|
|
40
|
+
2. To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None".
|
|
41
|
+
|
|
42
|
+
3. To specify a Change Date.
|
|
43
|
+
|
|
44
|
+
4. Not to modify this License in any other way.
|
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: meta-ads-mcp
|
|
3
|
+
Version: 0.10.1
|
|
4
|
+
Summary: Model Context Protocol (MCP) server for interacting with Meta Ads API
|
|
5
|
+
Project-URL: Homepage, https://github.com/pipeboard-co/meta-ads-mcp
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/pipeboard-co/meta-ads-mcp/issues
|
|
7
|
+
Author-email: Yves Junqueira <yves.junqueira@gmail.com>
|
|
8
|
+
License: BUSL-1.1
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: ads,api,claude,facebook,mcp,meta
|
|
11
|
+
Classifier: License :: Other/Proprietary License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Requires-Dist: httpx>=0.26.0
|
|
16
|
+
Requires-Dist: mcp[cli]<=1.12.2,>=1.10.1
|
|
17
|
+
Requires-Dist: pathlib>=1.0.1
|
|
18
|
+
Requires-Dist: pillow>=10.0.0
|
|
19
|
+
Requires-Dist: pytest-asyncio>=1.0.0
|
|
20
|
+
Requires-Dist: pytest>=8.4.1
|
|
21
|
+
Requires-Dist: python-dateutil>=2.8.2
|
|
22
|
+
Requires-Dist: python-dotenv>=1.1.0
|
|
23
|
+
Requires-Dist: requests>=2.32.3
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
1
26
|
# Meta Ads MCP
|
|
2
27
|
|
|
3
28
|
A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for interacting with Meta Ads API. This tool enables AI models to access, analyze, and manage Meta advertising campaigns through a standardized interface, allowing LLMs to retrieve performance data, visualize ad creatives, and provide strategic insights for Facebook, Instagram, and other Meta platforms.
|
|
@@ -18,6 +43,7 @@ A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for in
|
|
|
18
43
|
- [Features](#features)
|
|
19
44
|
- [Configuration](#configuration)
|
|
20
45
|
- [Available MCP Tools](#available-mcp-tools)
|
|
46
|
+
- [Licensing](#licensing)
|
|
21
47
|
- [Privacy and Security](#privacy-and-security)
|
|
22
48
|
- [Testing](#testing)
|
|
23
49
|
- [Troubleshooting](#troubleshooting)
|
|
@@ -382,6 +408,27 @@ For local installation configuration, authentication options, and advanced techn
|
|
|
382
408
|
- `query`: Search query string (e.g., "Injury Payouts pages", "active campaigns")
|
|
383
409
|
- Returns: List of matching record IDs in ChatGPT-compatible format
|
|
384
410
|
|
|
411
|
+
## Licensing
|
|
412
|
+
|
|
413
|
+
Meta Ads MCP is licensed under the [Business Source License 1.1](LICENSE). This means:
|
|
414
|
+
|
|
415
|
+
### ✅ **What you CAN do:**
|
|
416
|
+
- ✅ **Use for free** - Individual and business use at no cost
|
|
417
|
+
- ✅ **Modify and customize** - Edit the source code for your needs
|
|
418
|
+
- ✅ **Internal commercial use** - Deploy within your organization
|
|
419
|
+
- ✅ **Redistribute** - Share the software with others
|
|
420
|
+
- ✅ **Create derivative works** - Build upon the codebase
|
|
421
|
+
|
|
422
|
+
### ❌ **What you CANNOT do:**
|
|
423
|
+
- ❌ **Offer as competing SaaS** - Cannot offer this as a hosted service that competes with ARTELL SOLUÇÕES TECNOLÓGICAS LTDA's commercial offerings
|
|
424
|
+
|
|
425
|
+
### 🔄 **Future Open Source:**
|
|
426
|
+
- **Change Date**: January 1, 2029
|
|
427
|
+
- **After Change Date**: Automatically converts to Apache License 2.0 (fully open source)
|
|
428
|
+
- **No restrictions**: After the change date, you can use it for any purpose, including competing services
|
|
429
|
+
|
|
430
|
+
This licensing model ensures the software remains accessible while protecting the commercial interests of the original developers. For questions about commercial licensing or use cases, please contact us.
|
|
431
|
+
|
|
385
432
|
## Privacy and Security
|
|
386
433
|
|
|
387
434
|
Meta Ads MCP follows security best practices with secure token management and automatic authentication handling.
|
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: meta-ads-mcp
|
|
3
|
-
Version: 0.9.3
|
|
4
|
-
Summary: Model Context Protocol (MCP) plugin for interacting with Meta Ads API
|
|
5
|
-
Project-URL: Homepage, https://github.com/pipeboard-co/meta-ads-mcp
|
|
6
|
-
Project-URL: Bug Tracker, https://github.com/pipeboard-co/meta-ads-mcp/issues
|
|
7
|
-
Author-email: Yves Junqueira <yves.junqueira@gmail.com>
|
|
8
|
-
License: Apache-2.0
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Keywords: ads,api,claude,facebook,mcp,meta
|
|
11
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
-
Classifier: Operating System :: OS Independent
|
|
13
|
-
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Requires-Python: >=3.10
|
|
15
|
-
Requires-Dist: httpx>=0.26.0
|
|
16
|
-
Requires-Dist: mcp[cli]<=1.12.2,>=1.10.1
|
|
17
|
-
Requires-Dist: pathlib>=1.0.1
|
|
18
|
-
Requires-Dist: pillow>=10.0.0
|
|
19
|
-
Requires-Dist: pytest-asyncio>=1.0.0
|
|
20
|
-
Requires-Dist: pytest>=8.4.1
|
|
21
|
-
Requires-Dist: python-dateutil>=2.8.2
|
|
22
|
-
Requires-Dist: python-dotenv>=1.1.0
|
|
23
|
-
Requires-Dist: requests>=2.32.3
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
|
|
26
1
|
# Meta Ads MCP
|
|
27
2
|
|
|
28
3
|
A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for interacting with Meta Ads API. This tool enables AI models to access, analyze, and manage Meta advertising campaigns through a standardized interface, allowing LLMs to retrieve performance data, visualize ad creatives, and provide strategic insights for Facebook, Instagram, and other Meta platforms.
|
|
@@ -43,6 +18,7 @@ A [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for in
|
|
|
43
18
|
- [Features](#features)
|
|
44
19
|
- [Configuration](#configuration)
|
|
45
20
|
- [Available MCP Tools](#available-mcp-tools)
|
|
21
|
+
- [Licensing](#licensing)
|
|
46
22
|
- [Privacy and Security](#privacy-and-security)
|
|
47
23
|
- [Testing](#testing)
|
|
48
24
|
- [Troubleshooting](#troubleshooting)
|
|
@@ -407,6 +383,27 @@ For local installation configuration, authentication options, and advanced techn
|
|
|
407
383
|
- `query`: Search query string (e.g., "Injury Payouts pages", "active campaigns")
|
|
408
384
|
- Returns: List of matching record IDs in ChatGPT-compatible format
|
|
409
385
|
|
|
386
|
+
## Licensing
|
|
387
|
+
|
|
388
|
+
Meta Ads MCP is licensed under the [Business Source License 1.1](LICENSE). This means:
|
|
389
|
+
|
|
390
|
+
### ✅ **What you CAN do:**
|
|
391
|
+
- ✅ **Use for free** - Individual and business use at no cost
|
|
392
|
+
- ✅ **Modify and customize** - Edit the source code for your needs
|
|
393
|
+
- ✅ **Internal commercial use** - Deploy within your organization
|
|
394
|
+
- ✅ **Redistribute** - Share the software with others
|
|
395
|
+
- ✅ **Create derivative works** - Build upon the codebase
|
|
396
|
+
|
|
397
|
+
### ❌ **What you CANNOT do:**
|
|
398
|
+
- ❌ **Offer as competing SaaS** - Cannot offer this as a hosted service that competes with ARTELL SOLUÇÕES TECNOLÓGICAS LTDA's commercial offerings
|
|
399
|
+
|
|
400
|
+
### 🔄 **Future Open Source:**
|
|
401
|
+
- **Change Date**: January 1, 2029
|
|
402
|
+
- **After Change Date**: Automatically converts to Apache License 2.0 (fully open source)
|
|
403
|
+
- **No restrictions**: After the change date, you can use it for any purpose, including competing services
|
|
404
|
+
|
|
405
|
+
This licensing model ensures the software remains accessible while protecting the commercial interests of the original developers. For questions about commercial licensing or use cases, please contact us.
|
|
406
|
+
|
|
410
407
|
## Privacy and Security
|
|
411
408
|
|
|
412
409
|
Meta Ads MCP follows security best practices with secure token management and automatic authentication handling.
|
|
@@ -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.
|
|
10
|
+
__version__ = "0.10.1"
|
|
11
11
|
|
|
12
12
|
__all__ = [
|
|
13
13
|
'get_ad_accounts',
|
|
@@ -29,7 +29,7 @@ __all__ = [
|
|
|
29
29
|
'main',
|
|
30
30
|
'search_interests',
|
|
31
31
|
'get_interest_suggestions',
|
|
32
|
-
'
|
|
32
|
+
'estimate_audience_size',
|
|
33
33
|
'search_behaviors',
|
|
34
34
|
'search_demographics',
|
|
35
35
|
'search_geo_locations'
|
|
@@ -56,7 +56,7 @@ from .core import (
|
|
|
56
56
|
main,
|
|
57
57
|
search_interests,
|
|
58
58
|
get_interest_suggestions,
|
|
59
|
-
|
|
59
|
+
estimate_audience_size,
|
|
60
60
|
search_behaviors,
|
|
61
61
|
search_demographics,
|
|
62
62
|
search_geo_locations
|
|
@@ -11,7 +11,7 @@ from .server import login_cli, main
|
|
|
11
11
|
from .auth import login
|
|
12
12
|
from . import ads_library # Import module to register conditional tools
|
|
13
13
|
from .budget_schedules import create_budget_schedule
|
|
14
|
-
from .targeting import search_interests, get_interest_suggestions,
|
|
14
|
+
from .targeting import search_interests, get_interest_suggestions, estimate_audience_size, search_behaviors, search_demographics, search_geo_locations
|
|
15
15
|
from . import reports # Import module to register conditional tools
|
|
16
16
|
from . import duplication # Import module to register conditional duplication tools
|
|
17
17
|
from .openai_deep_research import search, fetch # OpenAI MCP Deep Research tools
|
|
@@ -39,7 +39,7 @@ __all__ = [
|
|
|
39
39
|
'create_budget_schedule',
|
|
40
40
|
'search_interests',
|
|
41
41
|
'get_interest_suggestions',
|
|
42
|
-
'
|
|
42
|
+
'estimate_audience_size',
|
|
43
43
|
'search_behaviors',
|
|
44
44
|
'search_demographics',
|
|
45
45
|
'search_geo_locations',
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
"""Targeting search functionality for Meta Ads API."""
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from typing import Optional, List, Dict, Any
|
|
5
|
+
from .api import meta_api_tool, make_api_request
|
|
6
|
+
from .server import mcp_server
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@mcp_server.tool()
|
|
10
|
+
@meta_api_tool
|
|
11
|
+
async def search_interests(access_token: str = None, query: str = None, limit: int = 25) -> str:
|
|
12
|
+
"""
|
|
13
|
+
Search for interest targeting options by keyword.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
access_token: Meta API access token (optional - will use cached token if not provided)
|
|
17
|
+
query: Search term for interests (e.g., "baseball", "cooking", "travel")
|
|
18
|
+
limit: Maximum number of results to return (default: 25)
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
JSON string containing interest data with id, name, audience_size, and path fields
|
|
22
|
+
"""
|
|
23
|
+
if not query:
|
|
24
|
+
return json.dumps({"error": "No search query provided"}, indent=2)
|
|
25
|
+
|
|
26
|
+
endpoint = "search"
|
|
27
|
+
params = {
|
|
28
|
+
"type": "adinterest",
|
|
29
|
+
"q": query,
|
|
30
|
+
"limit": limit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
data = await make_api_request(endpoint, access_token, params)
|
|
34
|
+
|
|
35
|
+
return json.dumps(data, indent=2)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@mcp_server.tool()
|
|
39
|
+
@meta_api_tool
|
|
40
|
+
async def get_interest_suggestions(access_token: str = None, interest_list: List[str] = None, limit: int = 25) -> str:
|
|
41
|
+
"""
|
|
42
|
+
Get interest suggestions based on existing interests.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
access_token: Meta API access token (optional - will use cached token if not provided)
|
|
46
|
+
interest_list: List of interest names to get suggestions for (e.g., ["Basketball", "Soccer"])
|
|
47
|
+
limit: Maximum number of suggestions to return (default: 25)
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
JSON string containing suggested interests with id, name, audience_size, and description fields
|
|
51
|
+
"""
|
|
52
|
+
if not interest_list:
|
|
53
|
+
return json.dumps({"error": "No interest list provided"}, indent=2)
|
|
54
|
+
|
|
55
|
+
endpoint = "search"
|
|
56
|
+
params = {
|
|
57
|
+
"type": "adinterestsuggestion",
|
|
58
|
+
"interest_list": json.dumps(interest_list),
|
|
59
|
+
"limit": limit
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
data = await make_api_request(endpoint, access_token, params)
|
|
63
|
+
|
|
64
|
+
return json.dumps(data, indent=2)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@mcp_server.tool()
|
|
68
|
+
@meta_api_tool
|
|
69
|
+
async def estimate_audience_size(
|
|
70
|
+
access_token: str = None,
|
|
71
|
+
account_id: str = None,
|
|
72
|
+
targeting: Dict[str, Any] = None,
|
|
73
|
+
optimization_goal: str = "REACH",
|
|
74
|
+
# Backwards compatibility for simple interest validation
|
|
75
|
+
interest_list: List[str] = None,
|
|
76
|
+
interest_fbid_list: List[str] = None
|
|
77
|
+
) -> str:
|
|
78
|
+
"""
|
|
79
|
+
Estimate audience size for targeting specifications using Meta's delivery_estimate API.
|
|
80
|
+
|
|
81
|
+
This function provides comprehensive audience estimation for complex targeting combinations
|
|
82
|
+
including demographics, geography, interests, and behaviors. It also maintains backwards
|
|
83
|
+
compatibility for simple interest validation.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
access_token: Meta API access token (optional - will use cached token if not provided)
|
|
87
|
+
account_id: Meta Ads account ID (format: act_XXXXXXXXX) - required for comprehensive estimation
|
|
88
|
+
targeting: Complete targeting specification including demographics, geography, interests, etc.
|
|
89
|
+
Example: {
|
|
90
|
+
"age_min": 25,
|
|
91
|
+
"age_max": 65,
|
|
92
|
+
"geo_locations": {"countries": ["PL"]},
|
|
93
|
+
"flexible_spec": [
|
|
94
|
+
{"interests": [{"id": "6003371567474"}]},
|
|
95
|
+
{"interests": [{"id": "6003462346642"}]}
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
optimization_goal: Optimization goal for estimation (default: "REACH").
|
|
99
|
+
Options: "REACH", "LINK_CLICKS", "IMPRESSIONS", "CONVERSIONS", etc.
|
|
100
|
+
interest_list: [DEPRECATED - for backwards compatibility] List of interest names to validate
|
|
101
|
+
interest_fbid_list: [DEPRECATED - for backwards compatibility] List of interest IDs to validate
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
JSON string with audience estimation results including estimated_audience_size,
|
|
105
|
+
reach_estimate, and targeting validation
|
|
106
|
+
"""
|
|
107
|
+
# Handle backwards compatibility - simple interest validation
|
|
108
|
+
# Check if we're in backwards compatibility mode (interest params provided OR no comprehensive params)
|
|
109
|
+
is_backwards_compatible_call = (interest_list or interest_fbid_list) or (not account_id and not targeting)
|
|
110
|
+
|
|
111
|
+
if is_backwards_compatible_call and not targeting:
|
|
112
|
+
if not interest_list and not interest_fbid_list:
|
|
113
|
+
return json.dumps({"error": "No interest list or FBID list provided"}, indent=2)
|
|
114
|
+
|
|
115
|
+
endpoint = "search"
|
|
116
|
+
params = {
|
|
117
|
+
"type": "adinterestvalid"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if interest_list:
|
|
121
|
+
params["interest_list"] = json.dumps(interest_list)
|
|
122
|
+
|
|
123
|
+
if interest_fbid_list:
|
|
124
|
+
params["interest_fbid_list"] = json.dumps(interest_fbid_list)
|
|
125
|
+
|
|
126
|
+
data = await make_api_request(endpoint, access_token, params)
|
|
127
|
+
|
|
128
|
+
return json.dumps(data, indent=2)
|
|
129
|
+
|
|
130
|
+
# Comprehensive audience estimation using delivery_estimate API
|
|
131
|
+
if not account_id:
|
|
132
|
+
return json.dumps({
|
|
133
|
+
"error": "account_id is required for comprehensive audience estimation",
|
|
134
|
+
"details": "For simple interest validation, use interest_list or interest_fbid_list parameters"
|
|
135
|
+
}, indent=2)
|
|
136
|
+
|
|
137
|
+
if not targeting:
|
|
138
|
+
return json.dumps({
|
|
139
|
+
"error": "targeting specification is required for comprehensive audience estimation",
|
|
140
|
+
"example": {
|
|
141
|
+
"age_min": 25,
|
|
142
|
+
"age_max": 65,
|
|
143
|
+
"geo_locations": {"countries": ["US"]},
|
|
144
|
+
"flexible_spec": [
|
|
145
|
+
{"interests": [{"id": "6003371567474"}]}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
}, indent=2)
|
|
149
|
+
|
|
150
|
+
# Build reach estimate request (using correct Meta API endpoint)
|
|
151
|
+
endpoint = f"{account_id}/reachestimate"
|
|
152
|
+
params = {
|
|
153
|
+
"targeting_spec": targeting
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
# Note: reachestimate endpoint doesn't support optimization_goal or objective parameters
|
|
157
|
+
|
|
158
|
+
try:
|
|
159
|
+
data = await make_api_request(endpoint, access_token, params, method="GET")
|
|
160
|
+
|
|
161
|
+
# Format the response for easier consumption
|
|
162
|
+
if "data" in data and len(data["data"]) > 0:
|
|
163
|
+
estimate_data = data["data"][0]
|
|
164
|
+
formatted_response = {
|
|
165
|
+
"success": True,
|
|
166
|
+
"account_id": account_id,
|
|
167
|
+
"targeting": targeting,
|
|
168
|
+
"optimization_goal": optimization_goal,
|
|
169
|
+
"estimated_audience_size": estimate_data.get("estimate_mau", 0),
|
|
170
|
+
"estimate_details": {
|
|
171
|
+
"monthly_active_users": estimate_data.get("estimate_mau", 0),
|
|
172
|
+
"daily_outcomes_curve": estimate_data.get("estimate_dau", []),
|
|
173
|
+
"bid_estimate": estimate_data.get("bid_estimates", {}),
|
|
174
|
+
"unsupported_targeting": estimate_data.get("unsupported_targeting", [])
|
|
175
|
+
},
|
|
176
|
+
"raw_response": data
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return json.dumps(formatted_response, indent=2)
|
|
180
|
+
else:
|
|
181
|
+
return json.dumps({
|
|
182
|
+
"error": "No estimation data returned from Meta API",
|
|
183
|
+
"raw_response": data,
|
|
184
|
+
"debug_info": {
|
|
185
|
+
"response_keys": list(data.keys()) if isinstance(data, dict) else "not_a_dict",
|
|
186
|
+
"response_type": str(type(data)),
|
|
187
|
+
"endpoint_used": f"{account_id}/reachestimate"
|
|
188
|
+
}
|
|
189
|
+
}, indent=2)
|
|
190
|
+
|
|
191
|
+
except Exception as e:
|
|
192
|
+
# Check if this is the specific Business Manager system user permission error
|
|
193
|
+
error_str = str(e)
|
|
194
|
+
if "100" in error_str and "33" in error_str:
|
|
195
|
+
# Try to provide fallback estimation using individual interests if available
|
|
196
|
+
interests_found = []
|
|
197
|
+
if targeting and "interests" in targeting:
|
|
198
|
+
interests_found.extend([interest.get("id") for interest in targeting["interests"] if interest.get("id")])
|
|
199
|
+
elif targeting and "flexible_spec" in targeting:
|
|
200
|
+
for spec in targeting["flexible_spec"]:
|
|
201
|
+
if "interests" in spec:
|
|
202
|
+
interests_found.extend([interest.get("id") for interest in spec["interests"] if interest.get("id")])
|
|
203
|
+
|
|
204
|
+
if interests_found:
|
|
205
|
+
# Attempt to get individual interest data as fallback
|
|
206
|
+
try:
|
|
207
|
+
fallback_result = await estimate_audience_size(
|
|
208
|
+
access_token=access_token,
|
|
209
|
+
interest_fbid_list=interests_found
|
|
210
|
+
)
|
|
211
|
+
fallback_data = json.loads(fallback_result)
|
|
212
|
+
|
|
213
|
+
return json.dumps({
|
|
214
|
+
"comprehensive_targeting_failed": True,
|
|
215
|
+
"error_code": "100-33",
|
|
216
|
+
"fallback_used": True,
|
|
217
|
+
"details": {
|
|
218
|
+
"issue": "reachestimate endpoint returned error - possibly due to targeting parameters or account limitations",
|
|
219
|
+
"solution": "Individual interest validation used as fallback - comprehensive targeting may have specific requirements",
|
|
220
|
+
"endpoint_used": f"{account_id}/reachestimate"
|
|
221
|
+
},
|
|
222
|
+
"individual_interest_data": fallback_data,
|
|
223
|
+
"note": "Individual interest audience sizes provided as fallback. Comprehensive targeting via reachestimate endpoint failed."
|
|
224
|
+
}, indent=2)
|
|
225
|
+
except:
|
|
226
|
+
pass
|
|
227
|
+
|
|
228
|
+
return json.dumps({
|
|
229
|
+
"error": "reachestimate endpoint returned error (previously was incorrectly using delivery_estimate)",
|
|
230
|
+
"error_code": "100-33",
|
|
231
|
+
"details": {
|
|
232
|
+
"issue": "The endpoint returned an error, possibly due to targeting parameters or account limitations",
|
|
233
|
+
"endpoint_used": f"{account_id}/reachestimate",
|
|
234
|
+
"previous_issue": "Code was previously using non-existent delivery_estimate endpoint - now fixed",
|
|
235
|
+
"available_alternative": "Use interest_list or interest_fbid_list parameters for individual interest validation"
|
|
236
|
+
},
|
|
237
|
+
"raw_error": error_str
|
|
238
|
+
}, indent=2)
|
|
239
|
+
else:
|
|
240
|
+
return json.dumps({
|
|
241
|
+
"error": f"Failed to get audience estimation from reachestimate endpoint: {str(e)}",
|
|
242
|
+
"details": "Check targeting parameters and account permissions",
|
|
243
|
+
"error_type": "general_api_error",
|
|
244
|
+
"endpoint_used": f"{account_id}/reachestimate"
|
|
245
|
+
}, indent=2)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
@mcp_server.tool()
|
|
249
|
+
@meta_api_tool
|
|
250
|
+
async def search_behaviors(access_token: str = None, limit: int = 50) -> str:
|
|
251
|
+
"""
|
|
252
|
+
Get all available behavior targeting options.
|
|
253
|
+
|
|
254
|
+
Args:
|
|
255
|
+
access_token: Meta API access token (optional - will use cached token if not provided)
|
|
256
|
+
limit: Maximum number of results to return (default: 50)
|
|
257
|
+
|
|
258
|
+
Returns:
|
|
259
|
+
JSON string containing behavior targeting options with id, name, audience_size bounds, path, and description
|
|
260
|
+
"""
|
|
261
|
+
endpoint = "search"
|
|
262
|
+
params = {
|
|
263
|
+
"type": "adTargetingCategory",
|
|
264
|
+
"class": "behaviors",
|
|
265
|
+
"limit": limit
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
data = await make_api_request(endpoint, access_token, params)
|
|
269
|
+
|
|
270
|
+
return json.dumps(data, indent=2)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
@mcp_server.tool()
|
|
274
|
+
@meta_api_tool
|
|
275
|
+
async def search_demographics(access_token: str = None, demographic_class: str = "demographics", limit: int = 50) -> str:
|
|
276
|
+
"""
|
|
277
|
+
Get demographic targeting options.
|
|
278
|
+
|
|
279
|
+
Args:
|
|
280
|
+
access_token: Meta API access token (optional - will use cached token if not provided)
|
|
281
|
+
demographic_class: Type of demographics to retrieve. Options: 'demographics', 'life_events',
|
|
282
|
+
'industries', 'income', 'family_statuses', 'user_device', 'user_os' (default: 'demographics')
|
|
283
|
+
limit: Maximum number of results to return (default: 50)
|
|
284
|
+
|
|
285
|
+
Returns:
|
|
286
|
+
JSON string containing demographic targeting options with id, name, audience_size bounds, path, and description
|
|
287
|
+
"""
|
|
288
|
+
endpoint = "search"
|
|
289
|
+
params = {
|
|
290
|
+
"type": "adTargetingCategory",
|
|
291
|
+
"class": demographic_class,
|
|
292
|
+
"limit": limit
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
data = await make_api_request(endpoint, access_token, params)
|
|
296
|
+
|
|
297
|
+
return json.dumps(data, indent=2)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
@mcp_server.tool()
|
|
301
|
+
@meta_api_tool
|
|
302
|
+
async def search_geo_locations(access_token: str = None, query: str = None,
|
|
303
|
+
location_types: List[str] = None, limit: int = 25) -> str:
|
|
304
|
+
"""
|
|
305
|
+
Search for geographic targeting locations.
|
|
306
|
+
|
|
307
|
+
Args:
|
|
308
|
+
access_token: Meta API access token (optional - will use cached token if not provided)
|
|
309
|
+
query: Search term for locations (e.g., "New York", "California", "Japan")
|
|
310
|
+
location_types: Types of locations to search. Options: ['country', 'region', 'city', 'zip',
|
|
311
|
+
'geo_market', 'electoral_district']. If not specified, searches all types.
|
|
312
|
+
limit: Maximum number of results to return (default: 25)
|
|
313
|
+
|
|
314
|
+
Returns:
|
|
315
|
+
JSON string containing location data with key, name, type, and geographic hierarchy information
|
|
316
|
+
"""
|
|
317
|
+
if not query:
|
|
318
|
+
return json.dumps({"error": "No search query provided"}, indent=2)
|
|
319
|
+
|
|
320
|
+
endpoint = "search"
|
|
321
|
+
params = {
|
|
322
|
+
"type": "adgeolocation",
|
|
323
|
+
"q": query,
|
|
324
|
+
"limit": limit
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if location_types:
|
|
328
|
+
params["location_types"] = json.dumps(location_types)
|
|
329
|
+
|
|
330
|
+
data = await make_api_request(endpoint, access_token, params)
|
|
331
|
+
|
|
332
|
+
return json.dumps(data, indent=2)
|
|
@@ -4,18 +4,18 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "meta-ads-mcp"
|
|
7
|
-
version = "0.
|
|
8
|
-
description = "Model Context Protocol (MCP)
|
|
7
|
+
version = "0.10.1"
|
|
8
|
+
description = "Model Context Protocol (MCP) server for interacting with Meta Ads API"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
11
11
|
authors = [
|
|
12
12
|
{name = "Yves Junqueira", email = "yves.junqueira@gmail.com"},
|
|
13
13
|
]
|
|
14
14
|
keywords = ["meta", "facebook", "ads", "api", "mcp", "claude"]
|
|
15
|
-
license = {text = "
|
|
15
|
+
license = {text = "BUSL-1.1"}
|
|
16
16
|
classifiers = [
|
|
17
17
|
"Programming Language :: Python :: 3",
|
|
18
|
-
"License ::
|
|
18
|
+
"License :: Other/Proprietary License",
|
|
19
19
|
"Operating System :: OS Independent",
|
|
20
20
|
]
|
|
21
21
|
dependencies = [
|