Skip to main content
Glama

update_ad

Modify Meta Ads by updating ad status, bid amount, tracking specs, or creative ID. Use this tool to adjust campaign settings for better performance and alignment with strategic goals.

Instructions

Update an ad with new settings. Args: ad_id: Meta Ads ad ID status: Update ad status (ACTIVE, PAUSED, etc.) bid_amount: Bid amount in account currency (in cents for USD) tracking_specs: Optional tracking specifications (e.g., for pixel events). creative_id: ID of the creative to associate with this ad (changes the ad's image/content) access_token: Meta API access token (optional - will use cached token if not provided)

Input Schema

NameRequiredDescriptionDefault
access_tokenNo
ad_idYes
bid_amountNo
creative_idNo
statusNo
tracking_specsNo

Input Schema (JSON Schema)

{ "properties": { "access_token": { "default": null, "title": "Access Token", "type": "string" }, "ad_id": { "title": "Ad Id", "type": "string" }, "bid_amount": { "default": null, "title": "Bid Amount", "type": "integer" }, "creative_id": { "default": null, "title": "Creative Id", "type": "string" }, "status": { "default": null, "title": "Status", "type": "string" }, "tracking_specs": { "default": null, "title": "tracking_specs", "type": "string" } }, "required": [ "ad_id" ], "title": "update_adArguments", "type": "object" }

Implementation Reference

  • The handler function for the 'update_ad' MCP tool. It updates a Meta ad's status, bid amount, tracking specs, or associates a new creative_id by sending a POST request to the ad's Graph API endpoint. Registered via @mcp_server.tool() decorator.
    @mcp_server.tool() @meta_api_tool async def update_ad( ad_id: str, status: Optional[str] = None, bid_amount: Optional[int] = None, tracking_specs: Optional[List[Dict[str, Any]]] = None, creative_id: Optional[str] = None, access_token: Optional[str] = None ) -> str: """ Update an ad with new settings. Args: ad_id: Meta Ads ad ID status: Update ad status (ACTIVE, PAUSED, etc.) bid_amount: Bid amount in account currency (in cents for USD) tracking_specs: Optional tracking specifications (e.g., for pixel events). creative_id: ID of the creative to associate with this ad (changes the ad's image/content) access_token: Meta API access token (optional - will use cached token if not provided) """ if not ad_id: return json.dumps({"error": "Ad ID is required"}, indent=2) params = {} if status: params["status"] = status if bid_amount is not None: # Ensure bid_amount is sent as a string if it's not null params["bid_amount"] = str(bid_amount) if tracking_specs is not None: # Add tracking_specs to params if provided params["tracking_specs"] = json.dumps(tracking_specs) # Needs to be JSON encoded string if creative_id is not None: # Creative parameter needs to be a JSON object containing creative_id params["creative"] = json.dumps({"creative_id": creative_id}) if not params: return json.dumps({"error": "No update parameters provided (status, bid_amount, tracking_specs, or creative_id)"}, indent=2) endpoint = f"{ad_id}" try: data = await make_api_request(endpoint, access_token, params, method='POST') return json.dumps(data, indent=2) except Exception as e: return json.dumps({"error": f"Failed to update ad: {str(e)}"}, indent=2)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pipeboard-co/meta-ads-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server