Meta Ads (Facebook/Instagram) MCP server for Claude, ChatGPT, Perplexity & Cursor — the Meta node of Pipeboard’s 5-platform family (+ Google, TikTok, Snap, Reddit). Hosted remote MCP, badged Meta Business Partner, free plan — no self-hosting required.
Python advertisingai-agentschatgptclaudefacebook-adsinstagram-adsmcpmeta-adsmodel-context-protocolpipeboard
Increment version to 0.3.4 and add create_budget_schedule function
Yves Junqueira6d0bda4d7532
diff --git a/meta_ads_mcp/core/__init__.py b/meta_ads_mcp/core/__init__.pyindex 452d654..3e69e9f 100644--- a/meta_ads_mcp/core/__init__.py+++ b/meta_ads_mcp/core/__init__.py@@ -10,6 +10,7 @@ from .authentication import get_login_linkfrom .server import login_cli, mainfrom .auth import loginfrom .ads_library import search_ads_archive+from .budget_schedules import create_budget_schedule__all__ = ['mcp_server',@@ -33,4 +34,5 @@ __all__ = ['login','main','search_ads_archive',+ 'create_budget_schedule',]\ No newline at end of filediff --git a/meta_ads_mcp/core/budget_schedules.py b/meta_ads_mcp/core/budget_schedules.pynew file mode 100644index 0000000..62464eb--- /dev/null+++ b/meta_ads_mcp/core/budget_schedules.py@@ -0,0 +1,71 @@+"""Budget Schedule-related functionality for Meta Ads API."""++import json+from typing import Optional, Dict, Any++from .api import meta_api_tool, make_api_request+from .server import mcp_server+# Assuming no other specific dependencies from adsets.py are needed for this single function.+# If other utilities from adsets.py (like get_ad_accounts) were needed, they'd be imported here.++@mcp_server.tool()+@meta_api_tool+async def create_budget_schedule(+ campaign_id: str,+ budget_value: int,+ budget_value_type: str,+ time_start: int,+ time_end: int,+ access_token: str = None+) -> str:+ """+ Create a budget schedule for a Meta Ads campaign.++ Allows scheduling budget increases based on anticipated high-demand periods.+ The times should be provided as Unix timestamps.++ Args:+ campaign_id: Meta Ads campaign ID.+ budget_value: Amount of budget increase. Interpreted based on budget_value_type.+ budget_value_type: Type of budget value - "ABSOLUTE" or "MULTIPLIER".+ time_start: Unix timestamp for when the high demand period should start.+ time_end: Unix timestamp for when the high demand period should end.+ access_token: Meta API access token (optional - will use cached token if not provided).++ Returns:+ A JSON string containing the ID of the created budget schedule or an error message.+ """+ if not campaign_id:+ return json.dumps({"error": "Campaign ID is required"}, indent=2)+ if budget_value is None: # Check for None explicitly+ return json.dumps({"error": "Budget value is required"}, indent=2)+ if not budget_value_type:+ return json.dumps({"error": "Budget value type is required"}, indent=2)+ if budget_value_type not in ["ABSOLUTE", "MULTIPLIER"]:+ return json.dumps({"error": "Invalid budget_value_type. Must be ABSOLUTE or MULTIPLIER"}, indent=2)+ if time_start is None: # Check for None explicitly to allow 0+ return json.dumps({"error": "Time start is required"}, indent=2)+ if time_end is None: # Check for None explicitly to allow 0+ return json.dumps({"error": "Time end is required"}, indent=2)++ endpoint = f"{campaign_id}/budget_schedules"++ params = {+ "budget_value": budget_value,+ "budget_value_type": budget_value_type,+ "time_start": time_start,+ "time_end": time_end,+ }++ try:+ data = await make_api_request(endpoint, access_token, params, method="POST")+ return json.dumps(data, indent=2)+ except Exception as e:+ error_msg = str(e)+ # Include details about the error and the parameters sent for easier debugging+ return json.dumps({+ "error": "Failed to create budget schedule",+ "details": error_msg,+ "campaign_id": campaign_id,+ "params_sent": params+ }, indent=2)\ No newline at end of filediff --git a/pyproject.toml b/pyproject.tomlindex bf5af7d..b711165 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -4,7 +4,7 @@ build-backend = "hatchling.build"[project]name = "meta-ads-mcp"-version = "0.3.3"+version = "0.3.4"description = "Model Calling Protocol (MCP) plugin for interacting with Meta Ads API"readme = "README.md"requires-python = ">=3.11"diff --git a/uv.lock b/uv.lockindex 19d60d5..eab2ee4 100644--- a/uv.lock+++ b/uv.lock@@ -206,7 +206,7 @@ wheels = [[[package]]name = "meta-ads-mcp"-version = "0.3.2"+version = "0.3.4"source = { editable = "." }dependencies = [{ name = "httpx" },