meta-ads-mcp 0.7.0__py3-none-any.whl → 0.7.1__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 +1 -1
- meta_ads_mcp/core/authentication.py +77 -32
- {meta_ads_mcp-0.7.0.dist-info → meta_ads_mcp-0.7.1.dist-info}/METADATA +1 -1
- {meta_ads_mcp-0.7.0.dist-info → meta_ads_mcp-0.7.1.dist-info}/RECORD +7 -7
- {meta_ads_mcp-0.7.0.dist-info → meta_ads_mcp-0.7.1.dist-info}/WHEEL +0 -0
- {meta_ads_mcp-0.7.0.dist-info → meta_ads_mcp-0.7.1.dist-info}/entry_points.txt +0 -0
- {meta_ads_mcp-0.7.0.dist-info → meta_ads_mcp-0.7.1.dist-info}/licenses/LICENSE +0 -0
meta_ads_mcp/__init__.py
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
|
-
"""Authentication-specific functionality for Meta Ads API.
|
|
1
|
+
"""Authentication-specific functionality for Meta Ads API.
|
|
2
|
+
|
|
3
|
+
The Meta Ads MCP server supports three authentication modes:
|
|
4
|
+
|
|
5
|
+
1. **Development/Local Mode** (default)
|
|
6
|
+
- Uses local callback server on localhost:8080+ for OAuth redirect
|
|
7
|
+
- Requires META_ADS_DISABLE_CALLBACK_SERVER to NOT be set
|
|
8
|
+
- Best for local development and testing
|
|
9
|
+
|
|
10
|
+
2. **Production with API Token**
|
|
11
|
+
- Uses PIPEBOARD_API_TOKEN for server-to-server authentication
|
|
12
|
+
- Bypasses OAuth flow entirely
|
|
13
|
+
- Best for server deployments with pre-configured tokens
|
|
14
|
+
|
|
15
|
+
3. **Production OAuth Flow** (NEW)
|
|
16
|
+
- Uses Pipeboard OAuth endpoints for dynamic client registration
|
|
17
|
+
- Triggered when META_ADS_DISABLE_CALLBACK_SERVER is set but no PIPEBOARD_API_TOKEN
|
|
18
|
+
- Supports MCP clients that implement OAuth 2.0 discovery
|
|
19
|
+
|
|
20
|
+
Environment Variables:
|
|
21
|
+
- PIPEBOARD_API_TOKEN: Enables mode 2 (token-based auth)
|
|
22
|
+
- META_ADS_DISABLE_CALLBACK_SERVER: Disables local server, enables mode 3
|
|
23
|
+
- META_ACCESS_TOKEN: Direct Meta token (fallback)
|
|
24
|
+
"""
|
|
2
25
|
|
|
3
26
|
import json
|
|
4
27
|
import asyncio
|
|
@@ -27,41 +50,49 @@ async def get_login_link(access_token: str = None) -> str:
|
|
|
27
50
|
"""
|
|
28
51
|
# Check if we're using pipeboard authentication
|
|
29
52
|
using_pipeboard = bool(os.environ.get("PIPEBOARD_API_TOKEN", ""))
|
|
53
|
+
callback_server_disabled = bool(os.environ.get("META_ADS_DISABLE_CALLBACK_SERVER", ""))
|
|
30
54
|
|
|
31
55
|
if using_pipeboard:
|
|
32
|
-
#
|
|
33
|
-
# Check if we have a cached token
|
|
34
|
-
cached_token = pipeboard_auth_manager.get_access_token()
|
|
35
|
-
token_status = "No token" if not cached_token else "Valid token"
|
|
36
|
-
|
|
37
|
-
# If we already have a valid token and none was provided, just return success
|
|
38
|
-
if cached_token and not access_token:
|
|
39
|
-
logger.info("get_login_link called with existing valid Pipeboard token")
|
|
40
|
-
return json.dumps({
|
|
41
|
-
"message": "Already authenticated with Pipeboard",
|
|
42
|
-
"token_status": token_status,
|
|
43
|
-
"token_preview": cached_token[:10] + "..." if cached_token else None,
|
|
44
|
-
"authentication_method": "pipeboard"
|
|
45
|
-
}, indent=2)
|
|
46
|
-
|
|
47
|
-
# Initiate the auth flow via Pipeboard
|
|
56
|
+
# Pipeboard token-based authentication
|
|
48
57
|
try:
|
|
49
|
-
|
|
50
|
-
login_url = auth_data.get("loginUrl")
|
|
58
|
+
logger.info("Using Pipeboard token-based authentication")
|
|
51
59
|
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
# If an access token was provided, this is likely a test - return success
|
|
61
|
+
if access_token:
|
|
62
|
+
return json.dumps({
|
|
63
|
+
"message": "Manual token provided",
|
|
64
|
+
"token_status": "Provided token",
|
|
65
|
+
"authentication_method": "manual_token"
|
|
66
|
+
}, indent=2)
|
|
67
|
+
|
|
68
|
+
# Check if Pipeboard token is working
|
|
69
|
+
token = pipeboard_auth_manager.get_access_token()
|
|
70
|
+
if token:
|
|
71
|
+
return json.dumps({
|
|
72
|
+
"message": "Already authenticated via Pipeboard",
|
|
73
|
+
"token_status": "Valid Pipeboard token",
|
|
74
|
+
"authentication_method": "pipeboard_token"
|
|
75
|
+
}, indent=2)
|
|
63
76
|
|
|
64
|
-
|
|
77
|
+
# Start Pipeboard auth flow
|
|
78
|
+
auth_data = pipeboard_auth_manager.initiate_auth_flow()
|
|
79
|
+
login_url = auth_data.get('loginUrl')
|
|
80
|
+
|
|
81
|
+
if login_url:
|
|
82
|
+
return json.dumps({
|
|
83
|
+
"login_url": login_url,
|
|
84
|
+
"markdown_link": f"[Click here to authenticate with Meta Ads via Pipeboard]({login_url})",
|
|
85
|
+
"message": "IMPORTANT: Please use the Markdown link format in your response to allow the user to click it.",
|
|
86
|
+
"instructions_for_llm": "You must present this link as clickable Markdown to the user using the markdown_link format provided.",
|
|
87
|
+
"authentication_method": "pipeboard_oauth",
|
|
88
|
+
"note": "After authenticating, the token will be automatically retrieved from Pipeboard."
|
|
89
|
+
}, indent=2)
|
|
90
|
+
else:
|
|
91
|
+
return json.dumps({
|
|
92
|
+
"error": "No login URL received from Pipeboard",
|
|
93
|
+
"authentication_method": "pipeboard_oauth_failed"
|
|
94
|
+
}, indent=2)
|
|
95
|
+
|
|
65
96
|
except Exception as e:
|
|
66
97
|
logger.error(f"Error initiating Pipeboard auth flow: {e}")
|
|
67
98
|
return json.dumps({
|
|
@@ -69,8 +100,22 @@ async def get_login_link(access_token: str = None) -> str:
|
|
|
69
100
|
"message": "Please check your PIPEBOARD_API_TOKEN environment variable.",
|
|
70
101
|
"authentication_method": "pipeboard"
|
|
71
102
|
}, indent=2)
|
|
103
|
+
elif callback_server_disabled:
|
|
104
|
+
# Production OAuth flow - use Pipeboard OAuth endpoints directly
|
|
105
|
+
logger.info("Production OAuth flow - using Pipeboard OAuth endpoints")
|
|
106
|
+
|
|
107
|
+
return json.dumps({
|
|
108
|
+
"authorization_endpoint": "https://pipeboard.co/oauth/authorize",
|
|
109
|
+
"token_endpoint": "https://pipeboard.co/oauth/token",
|
|
110
|
+
"registration_endpoint": "https://pipeboard.co/oauth/register",
|
|
111
|
+
"discovery_endpoint": "/.well-known/oauth-authorization-server",
|
|
112
|
+
"message": "Production OAuth flow - use dynamic client registration",
|
|
113
|
+
"instructions": "MCP clients should use the OAuth discovery endpoint to get authorization URLs",
|
|
114
|
+
"authentication_method": "production_oauth",
|
|
115
|
+
"note": "For manual authentication, clients need to register with Pipeboard OAuth service first"
|
|
116
|
+
}, indent=2)
|
|
72
117
|
else:
|
|
73
|
-
# Original Meta authentication flow
|
|
118
|
+
# Original Meta authentication flow (development/local)
|
|
74
119
|
# Check if we have a cached token
|
|
75
120
|
cached_token = auth_manager.get_access_token()
|
|
76
121
|
token_status = "No token" if not cached_token else "Valid token"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: meta-ads-mcp
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.1
|
|
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,4 +1,4 @@
|
|
|
1
|
-
meta_ads_mcp/__init__.py,sha256=
|
|
1
|
+
meta_ads_mcp/__init__.py,sha256=NX5qdfpot2sNJBbh373KM5xNYIYBL3Wq_rNQz9Dop1M,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
|
|
@@ -7,7 +7,7 @@ meta_ads_mcp/core/ads_library.py,sha256=onStn9UkRqYDC60gOPS-iKDtP1plz6DygUb7hUZ0
|
|
|
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
|
|
10
|
-
meta_ads_mcp/core/authentication.py,sha256=
|
|
10
|
+
meta_ads_mcp/core/authentication.py,sha256=K_LqL1NHtgVlO4aHsnXqHc9zrH9jMmuPpREZBO4KVss,9205
|
|
11
11
|
meta_ads_mcp/core/budget_schedules.py,sha256=UxseExsvKAiPwfDCY9aycT4kys4xqeNytyq-yyDOxrs,2901
|
|
12
12
|
meta_ads_mcp/core/callback_server.py,sha256=LIAJv9DW--83kdZ7VWWZal8xEprYjRZ8iug4rMczYbQ,9372
|
|
13
13
|
meta_ads_mcp/core/campaigns.py,sha256=Fd477GsD1Gx08Ve0uXUCvr4fC-xQCeVHPBwRVaeRQKk,10965
|
|
@@ -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.
|
|
25
|
-
meta_ads_mcp-0.7.
|
|
26
|
-
meta_ads_mcp-0.7.
|
|
27
|
-
meta_ads_mcp-0.7.
|
|
28
|
-
meta_ads_mcp-0.7.
|
|
24
|
+
meta_ads_mcp-0.7.1.dist-info/METADATA,sha256=6H5Wclw8Xg2KH3UYh4VphwFDQGgZVq2pDdXClqannjg,20409
|
|
25
|
+
meta_ads_mcp-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
26
|
+
meta_ads_mcp-0.7.1.dist-info/entry_points.txt,sha256=Dv2RkoBjRJBqj6CyhwqGIiwPCD-SCL1-7B9-zmVRuv0,57
|
|
27
|
+
meta_ads_mcp-0.7.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
28
|
+
meta_ads_mcp-0.7.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|