### Starting the HTTP Server Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Instructions on how to start the Meta Ads MCP HTTP server, with options for specifying host and port. ```APIDOC ## Starting the HTTP Server ### Description Start the Meta Ads MCP server using the `streamable-http` transport mode. You can specify the host and port for the server. ### Command Line Arguments #### `--transport` - **Type**: string - **Description**: Specifies the transport mode. Use `streamable-http` for HTTP transport. - **Default**: `stdio` #### `--host` - **Type**: string - **Description**: The host address for the HTTP server. - **Default**: `localhost` #### `--port` - **Type**: integer - **Description**: The port number for the HTTP server. - **Default**: `8080` ### Examples ```bash # Basic HTTP server (default: localhost:8080) python -m meta_ads_mcp --transport streamable-http # Custom host and port python -m meta_ads_mcp --transport streamable-http --host 0.0.0.0 --port 9000 ``` ``` -------------------------------- ### Authenticate and Execute MCP Requests Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Examples of making authenticated JSON-RPC 2.0 requests to the /mcp endpoint. Demonstrates usage of Bearer tokens and direct Meta access tokens. ```bash curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_pipeboard_token" \ -d '{ "jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": { "name": "get_ad_accounts", "arguments": {"limit": 5} } }' ``` ```bash curl -H "X-META-ACCESS-TOKEN: your_meta_access_token" \ -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}' ``` -------------------------------- ### Start Meta Ads MCP HTTP Server Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Commands to launch the Meta Ads MCP server in streamable-http mode. Supports custom host and port configurations via command-line arguments. ```bash # Basic HTTP server (default: localhost:8080) python -m meta_ads_mcp --transport streamable-http # Custom host and port python -m meta_ads_mcp --transport streamable-http --host 0.0.0.0 --port 9000 ``` -------------------------------- ### List Tools Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Lists available tools that can be called via the API. This is useful for discovering available functionalities. ```APIDOC ## POST /mcp (Health Check / Tool Listing) ### Description Lists the available tools that can be executed via the API. This endpoint can also serve as a health check. ### Method POST ### Endpoint /mcp ### Parameters #### Query Parameters None #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON-RPC version, should be "2.0". - **method** (string) - Required - The method to call, should be "tools/list". - **id** (integer) - Required - A unique identifier for the request. ### Request Example ```json { "jsonrpc": "2.0", "method": "tools/list", "id": 1 } ``` ### Response #### Success Response (200) - **result** (array) - A list of available tool names. - **id** (integer) - The ID of the request. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": [ "get_insights", "get_ad_accounts" ] } ``` ``` -------------------------------- ### Start Streamable HTTP Server for Meta Ads MCP Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Starts the Meta Ads MCP server using the streamable HTTP transport. This command configures the server to listen on all available network interfaces (0.0.0.0) on port 8080, enabling JSON-RPC 2.0 requests to the /mcp endpoint. ```bash # Start the HTTP server python -m meta_ads_mcp --transport streamable-http --host 0.0.0.0 --port 8080 ``` -------------------------------- ### Configure Docker and Environment Variables Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Deployment configuration for running the Meta Ads MCP server in a containerized environment and managing necessary authentication tokens. ```dockerfile FROM python:3.10-slim WORKDIR /app COPY . . RUN pip install -e . EXPOSE 8080 CMD ["python", "-m", "meta_ads_mcp", "--transport", "streamable-http", "--host", "0.0.0.0", "--port", "8080"] ``` ```bash export PIPEBOARD_API_TOKEN=your_pipeboard_token export META_APP_ID=your_app_id export META_APP_SECRET=your_app_secret export META_ACCESS_TOKEN=your_access_token ``` -------------------------------- ### Initialize and Interact with MCP Session Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Standard procedures for initializing an MCP session, listing tools, and calling specific Meta Ads tools using the JSON-RPC 2.0 protocol. ```bash # Initialize Session curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_token" \ -d '{"jsonrpc": "2.0", "method": "initialize", "id": 1, "params": {"protocolVersion": "2024-11-05", "capabilities": {"roots": {"listChanged": true}}, "clientInfo": {"name": "my-app", "version": "1.0.0"}}}' # List Tools curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_token" \ -d '{"jsonrpc": "2.0", "method": "tools/list", "id": 2}' # Call Tool curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your_token" \ -d '{"jsonrpc": "2.0", "method": "tools/call", "id": 3, "params": {"name": "get_ad_accounts", "arguments": {"limit": 10}}}' ``` -------------------------------- ### Authentication Methods Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Details on how to authenticate requests to the Meta Ads MCP HTTP API using Pipeboard tokens or Meta access tokens. ```APIDOC ## Authentication Methods ### Description Authenticate your HTTP requests to the Meta Ads MCP API using either a Pipeboard token or a Meta access token. ### Primary Method: Bearer Token (Recommended) 1. Sign up at [Pipeboard.co](https://pipeboard.co). 2. Generate an API token at [pipeboard.co/api-tokens](https://pipeboard.co/api-tokens). 3. Include the token in the `Authorization` HTTP header as a Bearer token. #### Request Example ```bash curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_pipeboard_token" \ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}' ``` ### Alternative Method: Direct Meta Token If you have a Meta Developer App, you can use a direct access token via the `X-META-ACCESS-TOKEN` header. This is less common. #### Request Example ```bash curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "X-META-ACCESS-TOKEN: your_meta_access_token" \ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}' ``` ### Remote MCP: Token in URL When using the hosted Remote MCP at `https://mcp.pipeboard.co/meta-ads-mcp`, you can alternatively authenticate by including the token as a URL parameter. #### URL Example ``` https://mcp.pipeboard.co/meta-ads-mcp?token=YOUR_PIPEBOARD_TOKEN ``` ``` -------------------------------- ### Execute Meta Ads MCP Tool Calls Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Demonstrates how to invoke MCP tools such as retrieving campaign performance or listing available tools using JSON-RPC 2.0. Requires a valid Bearer token and targets the /mcp endpoint. ```bash curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_token" \ -d '{ "jsonrpc": "2.0", "method": "tools/call", "id": 4, "params": { "name": "get_insights", "arguments": { "object_id": "act_701351919139047", "time_range": "last_30d", "level": "campaign" } } }' ``` ```bash curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_token" \ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}' ``` -------------------------------- ### MCP Protocol Methods Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Details on the available JSON-RPC 2.0 methods supported by the Meta Ads MCP HTTP API, including 'initialize', 'tools/list', and 'tools/call'. ```APIDOC ## MCP Protocol Methods ### Description The Meta Ads MCP server exposes several methods via the `/mcp` endpoint using the JSON-RPC 2.0 protocol. These methods allow you to interact with Meta Ads functionalities. ### Base URL `http://localhost:8080` ### MCP Endpoint `/mcp` ### Available Methods | Method | Description | |--------|-------------| | `initialize` | Initialize MCP session and exchange capabilities. | | `tools/list` | Get a list of all available Meta Ads tools. | | `tools/call` | Execute a specific tool with provided parameters. | ### Request Body Format All requests must follow the JSON-RPC 2.0 specification. ```json { "jsonrpc": "2.0", "method": "[method_name]", "id": 1, // Unique request identifier "params": { ... } // Method-specific parameters } ``` ### Response Format All responses follow JSON-RPC 2.0 format. ```json { "jsonrpc": "2.0", "id": 1, // Matches the request id "result": { ... } // Tool response data or success information } ``` ### Example Usage #### 1. Initialize Session ```bash curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_token" \ -d '{ "jsonrpc": "2.0", "method": "initialize", "id": 1, "params": { "protocolVersion": "2024-11-05", "capabilities": {"roots": {"listChanged": true}}, "clientInfo": {"name": "my-app", "version": "1.0.0"} } }' ``` #### 2. List Available Tools ```bash curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_token" \ -d '{ "jsonrpc": "2.0", "method": "tools/list", "id": 2 }' ``` #### 3. Get Ad Accounts ```bash curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_token" \ -d '{ "jsonrpc": "2.0", "method": "tools/call", "id": 3, "params": { "name": "get_ad_accounts", "arguments": {"limit": 10} } }' ``` ``` -------------------------------- ### HTTP Client for Meta Ads MCP (Python) Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/examples/README.md A Python HTTP client demonstrating interaction with the Meta Ads MCP server. It supports authentication via Pipeboard tokens or Meta access tokens and showcases basic MCP operations like initialization, listing tools, and calling tools. Includes error handling and response formatting. ```python import os import json import requests class MetaAdsMCPClient: def __init__(self, base_url="http://localhost:8080", api_token=None, meta_access_token=None): self.base_url = base_url self.headers = {"Content-Type": "application/json"} if api_token: self.headers["Authorization"] = f"Bearer {api_token}" elif meta_access_token: self.headers["X-Meta-Access-Token"] = meta_access_token def _request(self, method, endpoint, data=None): try: response = requests.request(method, f"{self.base_url}/{endpoint}", headers=self.headers, json=data) response.raise_for_status() # Raise an exception for bad status codes return response.json() except requests.exceptions.RequestException as e: print(f"Error: {e}") return None def initialize(self): return self._request("post", "initialize") def list_tools(self): return self._request("get", "tools") def call_tool(self, tool_name, tool_input): return self._request("post", f"tools/{tool_name}", data=tool_input) if __name__ == "__main__": # --- Authentication --- # Option 1: Pipeboard API Token (from environment variable) pipeboard_token = os.environ.get("PIPEBOARD_API_TOKEN") # Option 2: Meta Access Token (pass directly) # Replace with your actual Meta Access Token if not using Pipeboard token meta_token = None if not pipeboard_token and not meta_token: print("Error: Please set PIPEBOARD_API_TOKEN environment variable or provide meta_access_token.") else: client = MetaAdsMCPClient(api_token=pipeboard_token, meta_access_token=meta_token) # --- Usage Examples --- print("Initializing MCP...") init_response = client.initialize() print(f"Initialization Response: {json.dumps(init_response, indent=2)}") print("\nListing available tools...") tools_response = client.list_tools() print(f"Tools Response: {json.dumps(tools_response, indent=2)}") if tools_response and 'tools' in tools_response and tools_response['tools']: # Example: Call the first available tool first_tool_name = tools_response['tools'][0]['name'] print(f"\nCalling tool: {first_tool_name}...") # Construct a sample input for the tool (this will vary based on the tool) # For demonstration, we'll assume a simple input structure. # You'll need to inspect the tool's schema to provide correct input. sample_tool_input = {"example_param": "example_value"} call_response = client.call_tool(first_tool_name, sample_tool_input) print(f"Tool Call Response: {json.dumps(call_response, indent=2)}") else: print("No tools found to call.") ``` -------------------------------- ### Get Campaign Performance Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Retrieves performance insights for Meta Ads campaigns. This endpoint uses a POST request with a JSON-RPC payload to specify the desired tool and arguments. ```APIDOC ## POST /mcp ### Description Retrieves performance insights for Meta Ads campaigns using the `get_insights` tool. ### Method POST ### Endpoint /mcp ### Parameters #### Query Parameters None #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON-RPC version, should be "2.0". - **method** (string) - Required - The method to call, should be "tools/call". - **id** (integer) - Required - A unique identifier for the request. - **params** (object) - Required - Contains the parameters for the tool call. - **name** (string) - Required - The name of the tool to execute, e.g., "get_insights". - **arguments** (object) - Optional - Arguments for the specified tool. - **object_id** (string) - Required - The ID of the ad account or campaign. - **time_range** (string) - Required - The time period for the insights (e.g., "last_30d"). - **level** (string) - Required - The level of granularity for the insights (e.g., "campaign"). ### Request Example ```json { "jsonrpc": "2.0", "method": "tools/call", "id": 4, "params": { "name": "get_insights", "arguments": { "object_id": "act_701351919139047", "time_range": "last_30d", "level": "campaign" } } } ``` ### Response #### Success Response (200) - **result** (object) - Contains the insights data. - **id** (integer) - The ID of the request. #### Response Example ```json { "jsonrpc": "2.0", "id": 4, "result": { "data": [ { "campaign_id": "12345", "spend": "100.50", "impressions": "10000" } ] } } ``` ``` -------------------------------- ### Get Meta Ads Campaign Details Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Retrieves detailed information for a specific Meta Ads campaign. Requires the campaign ID and can optionally use an access token, defaulting to a cached token if none is provided. ```python def mcp_meta_ads_get_campaign_details(access_token=None, campaign_id): """Get detailed information about a specific campaign. Args: access_token (str, optional): Meta API access token. Defaults to None (uses cached token). campaign_id (str): Meta Ads campaign ID. Returns: dict: Detailed information about the specified campaign. """ pass ``` -------------------------------- ### Get Meta Ads Account Info Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Fetches detailed information for a specific Meta Ads account. Requires the account ID and optionally accepts an access token, falling back to a cached token if not provided. ```python def mcp_meta_ads_get_account_info(access_token=None, account_id): """Get detailed information about a specific ad account. Args: access_token (str, optional): Meta API access token. Defaults to None (uses cached token). account_id (str): Meta Ads account ID (format: act_XXXXXXXXX). Returns: dict: Detailed information about the specified account. """ pass ``` -------------------------------- ### Get Meta Ads Campaigns Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Fetches campaigns for a Meta Ads account, with support for filtering by status. It requires the account ID and allows specifying the maximum number of campaigns to return. An optional access token can be provided. ```python def mcp_meta_ads_get_campaigns(access_token=None, account_id, limit=10, status_filter=None): """Get campaigns for a Meta Ads account with optional filtering. Args: access_token (str, optional): Meta API access token. Defaults to None (uses cached token). account_id (str): Meta Ads account ID (format: act_XXXXXXXXX). limit (int, optional): Maximum number of campaigns to return. Defaults to 10. status_filter (str, optional): Filter by status (e.g., 'ACTIVE', 'PAUSED'). Defaults to None (all statuses). Returns: list: List of campaigns matching the criteria. """ pass ``` -------------------------------- ### Get Meta Ads Ad Set Details Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Fetches detailed information for a specific Meta Ads ad set. Requires the ad set ID and can optionally use an access token, defaulting to a cached token if none is provided. ```python def mcp_meta_ads_get_adset_details(access_token=None, adset_id): """Get detailed information about a specific ad set. Args: access_token (str, optional): Meta API access token. Defaults to None (uses cached token). adset_id (str): Meta Ads ad set ID. Returns: dict: Detailed information about the specified ad set. """ pass ``` -------------------------------- ### Get Meta Ads Account Pages Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Retrieves a list of pages associated with a Meta Ads account. This is useful for ad creation and management. It requires the account ID and can optionally use an access token. ```python def mcp_meta_ads_get_account_pages(access_token=None, account_id='me'): """Get pages associated with a Meta Ads account. Args: access_token (str, optional): Meta API access token. Defaults to None (uses cached token). account_id (str, optional): Meta Ads account ID (format: act_XXXXXXXXX) or 'me' for the current user's pages. Defaults to 'me'. Returns: list: List of pages associated with the account. """ pass ``` -------------------------------- ### Implement Meta Ads MCP Client Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/STREAMABLE_HTTP_SETUP.md Provides reusable client classes for Python and Node.js to simplify JSON-RPC communication with the Meta Ads MCP server. These clients handle header management and payload formatting for tool execution. ```python import requests import json class MetaAdsMCPClient: def __init__(self, base_url="http://localhost:8080", token=None): self.base_url = base_url self.endpoint = f"{base_url}/mcp" self.headers = { "Content-Type": "application/json", "Accept": "application/json, text/event-stream" } if token: self.headers["Authorization"] = f"Bearer {token}" def call_tool(self, tool_name, arguments=None): payload = { "jsonrpc": "2.0", "method": "tools/call", "id": 1, "params": {"name": tool_name} } if arguments: payload["params"]["arguments"] = arguments response = requests.post(self.endpoint, headers=self.headers, json=payload) return response.json() client = MetaAdsMCPClient(token="your_pipeboard_token") result = client.call_tool("get_ad_accounts", {"limit": 5}) print(json.dumps(result, indent=2)) ``` ```javascript const axios = require('axios'); class MetaAdsMCPClient { constructor(baseUrl = 'http://localhost:8080', token = null) { this.baseUrl = baseUrl; this.endpoint = `${baseUrl}/mcp`; this.headers = { 'Content-Type': 'application/json', 'Accept': 'application/json, text/event-stream' }; if (token) { this.headers['Authorization'] = `Bearer ${token}`; } } async callTool(toolName, arguments = null) { const payload = { jsonrpc: '2.0', method: 'tools/call', id: 1, params: { name: toolName } }; if (arguments) { payload.params.arguments = arguments; } try { const response = await axios.post(this.endpoint, payload, { headers: this.headers }); return response.data; } catch (error) { return { error: error.message }; } } } const client = new MetaAdsMCPClient('http://localhost:8080', 'your_pipeboard_token'); client.callTool('get_ad_accounts', { limit: 5 }) .then(result => console.log(JSON.stringify(result, null, 2))); ``` -------------------------------- ### Get Meta Ads Ad Sets Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Retrieves ad sets for a Meta Ads account, with an option to filter by campaign ID. It requires the account ID and allows specifying the maximum number of ad sets to return. An optional access token can be provided. ```python def mcp_meta_ads_get_adsets(access_token=None, account_id, limit=10, campaign_id=None): """Get ad sets for a Meta Ads account with optional filtering by campaign. Args: access_token (str, optional): Meta API access token. Defaults to None (uses cached token). account_id (str): Meta Ads account ID (format: act_XXXXXXXXX). limit (int, optional): Maximum number of ad sets to return. Defaults to 10. campaign_id (str, optional): Optional campaign ID to filter by. Defaults to None. Returns: list: List of ad sets matching the criteria. """ pass ``` -------------------------------- ### Get Meta Ads Ad Accounts Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Retrieves a list of ad accounts accessible by a user. It can optionally use a provided access token or a cached one, and allows specifying the user ID and the maximum number of accounts to return. ```python def mcp_meta_ads_get_ad_accounts(access_token=None, user_id='me', limit=200): """Get ad accounts accessible by a user. Args: access_token (str, optional): Meta API access token. Defaults to None (uses cached token). user_id (str, optional): Meta user ID or 'me' for the current user. Defaults to 'me'. limit (int, optional): Maximum number of accounts to return. Defaults to 200. Returns: list: List of accessible ad accounts with their details. """ pass ``` -------------------------------- ### Meta Ads MCP Python Client Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt A Python client for interacting with the Meta Ads MCP API. It simplifies making calls to various tools like getting ad accounts, campaign insights, and creating campaigns. Requires the 'requests' library. ```python import requests import json class MetaAdsMCPClient: def __init__(self, base_url="http://localhost:8080", token=None): self.base_url = base_url self.endpoint = f"{base_url}/mcp" self.headers = { "Content-Type": "application/json", "Accept": "application/json, text/event-stream" } if token: self.headers["Authorization"] = f"Bearer {token}" self.request_id = 0 def call_tool(self, tool_name, arguments=None): self.request_id += 1 payload = { "jsonrpc": "2.0", "method": "tools/call", "id": self.request_id, "params": {"name": tool_name} } if arguments: payload["params"]["arguments"] = arguments response = requests.post(self.endpoint, headers=self.headers, json=payload) return response.json() # Usage example client = MetaAdsMCPClient(token="your_pipeboard_token") # Get all ad accounts accounts = client.call_tool("get_ad_accounts", {"limit": 10}) print(json.dumps(accounts, indent=2)) # Get campaign insights insights = client.call_tool("get_insights", { "object_id": "act_123456789012345", "time_range": "last_30d", "level": "campaign" }) print(json.dumps(insights, indent=2)) # Create a campaign campaign = client.call_tool("create_campaign", { "account_id": "act_123456789012345", "name": "New Campaign", "objective": "OUTCOME_TRAFFIC", "status": "PAUSED", "daily_budget": 5000 }) print(json.dumps(campaign, indent=2)) ``` -------------------------------- ### Get Campaign Insights (cURL) Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt This cURL command demonstrates how to retrieve campaign insights using the 'get_insights' tool. It requires an object ID, time range, and level. Replace 'your_pipeboard_token' with your actual token. ```shell curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_pipeboard_token" \ -d '{ "jsonrpc": "2.0", "method": "tools/call", "id": 3, "params": { "name": "get_insights", "arguments": { "object_id": "act_123456789012345", "time_range": "last_30d", "level": "campaign" } } }' ``` -------------------------------- ### List Available Tools (cURL) Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt This cURL command demonstrates how to list the available tools within the Meta Ads MCP. It sends a POST request to the /mcp endpoint with the 'tools/list' method. Ensure you replace 'your_pipeboard_token' with your actual token. ```shell curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_pipeboard_token" \ -d '{ "jsonrpc": "2.0", "method": "tools/list", "id": 1 }' ``` -------------------------------- ### Get Ad Image for Analysis Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Retrieves an image associated with a specific ad ID, facilitating visual analysis within an LLM context. ```JSON { "name": "get_ad_image", "arguments": { "ad_id": "23851234567890300" } } ``` -------------------------------- ### Create Meta Ads Campaign Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Creates a new campaign in a Meta Ads account. Requires account ID, name, and objective. Supports setting status, special ad categories, budget, and bid strategy. Legacy objectives are not supported. ```python def mcp_meta_ads_create_campaign(access_token=None, account_id, name, objective, status='PAUSED', special_ad_categories=None, daily_budget=None, lifetime_budget=None, bid_strategy='LOWEST_COST_WITHOUT_CAP'): """Create a new campaign in a Meta Ads account. Args: access_token (str, optional): Meta API access token. Defaults to None (uses cached token). account_id (str): Meta Ads account ID (format: act_XXXXXXXXX). name (str): Campaign name. objective (str): Campaign objective (e.g., 'OUTCOME_AWARENESS', 'OUTCOME_SALES'). status (str, optional): Initial campaign status ('PAUSED' or 'ACTIVE'). Defaults to 'PAUSED'. special_ad_categories (list, optional): List of special ad categories if applicable. Defaults to None. daily_budget (int, optional): Daily budget in account currency (in cents). lifetime_budget (int, optional): Lifetime budget in account currency (in cents). bid_strategy (str, optional): Bid strategy. Defaults to 'LOWEST_COST_WITHOUT_CAP'. Returns: dict: Confirmation with new campaign details. """ pass ``` ```json { "name": "2025 - Bedroom Furniture - Awareness", "account_id": "act_123456789012345", "objective": "OUTCOME_AWARENESS", "special_ad_categories": [], "status": "PAUSED", "buying_type": "AUCTION", "bid_strategy": "LOWEST_COST_WITHOUT_CAP", "daily_budget": 10000 } ``` -------------------------------- ### Create Campaign - Python Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Creates a new advertising campaign using the `create_campaign` MCP tool. Requires `account_id`, `name`, `objective`, `status`, `daily_budget`, and `bid_strategy`. Supports various objectives and can include `special_ad_categories`. ```python # MCP Tool Call - Create a new campaign { "name": "create_campaign", "arguments": { "account_id": "act_123456789012345", "name": "2024 - Product Launch - Awareness", "objective": "OUTCOME_AWARENESS", "status": "PAUSED", "daily_budget": 10000, "bid_strategy": "LOWEST_COST_WITHOUT_CAP", "special_ad_categories": [] } } # Valid objectives: OUTCOME_AWARENESS, OUTCOME_TRAFFIC, OUTCOME_ENGAGEMENT, # OUTCOME_LEADS, OUTCOME_SALES, OUTCOME_APP_PROMOTION # Response { "id": "23851234567890124", "success": true } ``` -------------------------------- ### Create Meta Ads Ad Set Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Creates a new ad set within a Meta Ads account. This function requires the account ID, campaign ID, and the name of the ad set. ```python def mcp_meta_ads_create_adset(account_id, campaign_id, name): """Create a new ad set in a Meta Ads account. Args: account_id (str): Meta Ads account ID (format: act_XXXXXXXXX). campaign_id (str): Meta Ads campaign ID this ad set belongs to. name (str): Ad set name. """ pass ``` -------------------------------- ### mcp_meta_ads_create_ad_set Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Creates a new ad set for a Meta Ads campaign with specified targeting, budget, and optimization goals. ```APIDOC ## POST /api/adsets ### Description Creates a new ad set for a Meta Ads campaign with specified targeting, budget, and optimization goals. ### Method POST ### Endpoint /api/adsets ### Parameters #### Request Body - **status** (string) - Optional - Initial ad set status (default: PAUSED) - **daily_budget** (string) - Optional - Daily budget in account currency (in cents) - **lifetime_budget** (string) - Optional - Lifetime budget in account currency (in cents) - **targeting** (object) - Required - Targeting specifications (e.g., age, location, interests) - **optimization_goal** (string) - Required - Conversion optimization goal (e.g., 'LINK_CLICKS') - **billing_event** (string) - Required - How you're charged (e.g., 'IMPRESSIONS') - **bid_amount** (string) - Optional - Bid amount in cents. Required for LOWEST_COST_WITH_BID_CAP, COST_CAP, TARGET_COST. - **bid_strategy** (string) - Optional - Bid strategy (e.g., 'LOWEST_COST_WITHOUT_CAP', 'LOWEST_COST_WITH_MIN_ROAS') - **bid_constraints** (object) - Optional - Bid constraints dict. Required for LOWEST_COST_WITH_MIN_ROAS (e.g., `{\"roas_average_floor\": 20000}`) - **start_time** (string) - Optional - Start time (ISO 8601) - **end_time** (string) - Optional - End time (ISO 8601) - **access_token** (string) - Optional - Meta API access token ### Response #### Success Response (200) - **confirmation** (object) - Confirmation with new ad set details ``` -------------------------------- ### POST /create_budget_schedule Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Creates a budget schedule for campaigns to automatically adjust budgets during specific timeframes. ```APIDOC ## POST create_budget_schedule ### Description Creates a budget schedule for campaigns to automatically increase budgets during high-demand periods. ### Method POST ### Endpoint create_budget_schedule ### Parameters #### Request Body - **campaign_id** (string) - Required - The ID of the campaign. - **budget_value** (number) - Required - The value for the budget adjustment. - **budget_value_type** (string) - Required - "ABSOLUTE" or "MULTIPLIER". - **time_start** (integer) - Required - Unix timestamp for start. - **time_end** (integer) - Required - Unix timestamp for end. ### Request Example { "campaign_id": "23851234567890123", "budget_value": 200, "budget_value_type": "MULTIPLIER" } ### Response #### Success Response (200) - **id** (string) - The ID of the created schedule. #### Response Example { "id": "23851234567890500" } ``` -------------------------------- ### POST /mcp (List Tools) Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Retrieves the list of available tools supported by the Meta Ads MCP server. ```APIDOC ## POST /mcp ### Description Lists all available tools that can be invoked through the MCP server. ### Method POST ### Endpoint http://localhost:8080/mcp ### Request Body - **jsonrpc** (string) - Required - Must be "2.0" - **method** (string) - Required - Must be "tools/list" - **id** (integer) - Required - Unique request identifier ### Request Example { "jsonrpc": "2.0", "method": "tools/list", "id": 1 } ### Response #### Success Response (200) - **result** (object) - Contains the list of tools and their schemas #### Response Example { "jsonrpc": "2.0", "id": 1, "result": { "tools": [ { "name": "get_ad_accounts", "description": "..." }, { "name": "get_insights", "description": "..." } ] } } ``` -------------------------------- ### Create Ad Set via MCP Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Creates a new ad set with specified targeting, budget, and optimization settings. Requires an account ID and campaign ID. ```json { "name": "create_adset", "arguments": { "account_id": "act_123456789012345", "campaign_id": "23851234567890123", "name": "US Women 25-45 - Interest Targeting", "optimization_goal": "LINK_CLICKS", "billing_event": "IMPRESSIONS", "status": "PAUSED", "daily_budget": 5000, "bid_strategy": "LOWEST_COST_WITHOUT_CAP", "targeting": { "age_min": 25, "age_max": 45, "genders": [2], "geo_locations": {"countries": ["US"]}, "flexible_spec": [ {"interests": [{"id": "6003139266461", "name": "Shopping"}]} ], "targeting_automation": {"advantage_audience": 0} }, "start_time": "2024-07-01T00:00:00-0700" } } ``` -------------------------------- ### Call a Tool (cURL) Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt This cURL command shows how to call a specific tool within the Meta Ads MCP, such as 'get_ad_accounts'. It includes parameters for the tool's arguments. Replace 'your_pipeboard_token' with your actual token. ```shell curl -X POST http://localhost:8080/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "Authorization: Bearer your_pipeboard_token" \ -d '{ "jsonrpc": "2.0", "method": "tools/call", "id": 2, "params": { "name": "get_ad_accounts", "arguments": {"limit": 10} } }' ``` -------------------------------- ### mcp_meta_ads_create_ad_creative Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Creates a new ad creative using an uploaded image hash and specified content. ```APIDOC ## POST /api/creatives ### Description Creates a new ad creative using an uploaded image hash and specified content. ### Method POST ### Endpoint /api/creatives ### Parameters #### Request Body - **account_id** (string) - Required - Meta Ads account ID (format: act_XXXXXXXXX) - **name** (string) - Required - Creative name - **image_hash** (string) - Required - Hash of the uploaded image - **page_id** (string) - Required - Facebook Page ID for the ad - **link_url** (string) - Required - Destination URL - **message** (string) - Required - Ad copy/text - **headline** (string) - Optional - Single headline for simple ads (cannot be used with headlines) - **headlines** (array) - Optional - List of headlines for dynamic creative testing (cannot be used with headline) - **description** (string) - Optional - Single description for simple ads (cannot be used with descriptions) - **descriptions** (array) - Optional - List of descriptions for dynamic creative testing (cannot be used with description) - **dynamic_creative_spec** (object) - Optional - Dynamic creative optimization settings - **call_to_action_type** (string) - Required - CTA button type (e.g., 'LEARN_MORE') - **instagram_actor_id** (string) - Optional - Instagram account ID - **access_token** (string) - Optional - Meta API access token ### Response #### Success Response (200) - **confirmation** (object) - Confirmation with new creative details ``` -------------------------------- ### mcp_meta_ads_create_ad Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Creates a new ad within a specified ad set using an existing creative. ```APIDOC ## POST /api/ads ### Description Creates a new ad within a specified ad set using an existing creative. ### Method POST ### Endpoint /api/ads ### Parameters #### Request Body - **account_id** (string) - Required - Meta Ads account ID (format: act_XXXXXXXXX) - **name** (string) - Required - Ad name - **adset_id** (string) - Required - Ad set ID where this ad will be placed - **creative_id** (string) - Required - ID of an existing creative to use - **status** (string) - Optional - Initial ad status (default: PAUSED) - **bid_amount** (string) - Optional - Optional bid amount (in cents) - **tracking_specs** (object) - Optional - Optional tracking specifications - **access_token** (string) - Optional - Meta API access token ### Response #### Success Response (200) - **confirmation** (object) - Confirmation with new ad details ``` -------------------------------- ### Create Campaign Budget Schedule Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Creates a budget schedule to automatically adjust campaign budgets during specific periods, such as high-demand events like Black Friday. It requires a campaign ID, budget value, budget type (ABSOLUTE or MULTIPLIER), and start/end timestamps. The response returns the ID of the created schedule. ```python # MCP Tool Call - Create a budget schedule for Black Friday { "name": "create_budget_schedule", "arguments": { "campaign_id": "23851234567890123", "budget_value": 200, "budget_value_type": "MULTIPLIER", "time_start": 1732320000, "time_end": 1732492800 } } # budget_value_type options: # - "ABSOLUTE": Set specific budget amount in cents # - "MULTIPLIER": Multiply existing budget (e.g., 200 = 2x) # Response { "id": "23851234567890500" } ``` -------------------------------- ### Search Available Behavior Targeting Options Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Retrieves available behavior targeting options for ad campaigns. This function can be called with a limit parameter to control the number of results returned. The response includes details such as behavior ID, name, audience size bounds, and a descriptive path. ```python # MCP Tool Call - Get behavior targeting options { "name": "search_behaviors", "arguments": { "limit": 50 } } # Response { "data": [ { "id": "6002714895372", "name": "Engaged Shoppers", "audience_size_lower_bound": 100000000, "audience_size_upper_bound": 150000000, "path": ["Behaviors", "Purchase behavior", "Engaged Shoppers"], "description": "People who have clicked on Shop Now buttons in the past week" } ] } ``` -------------------------------- ### Retrieve Account Info - Python Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Fetches detailed information for a specific ad account using the `get_account_info` MCP tool. This includes general account details and DSA compliance requirements for European accounts. The `account_id` is a required argument. ```python # MCP Tool Call - Get account details { "name": "get_account_info", "arguments": { "account_id": "act_123456789012345" } } # Response { "id": "act_123456789012345", "name": "My Business Account", "account_status": 1, "amount_spent": "15420.50", "balance": "5000.00", "currency": "USD", "timezone_name": "America/Los_Angeles", "business_country_code": "US", "dsa_required": false, "dsa_compliance_note": "This account is not subject to European DSA requirements" } ``` -------------------------------- ### POST /get_login_link Source: https://context7.com/pipeboard-co/meta-ads-mcp/llms.txt Generates an authentication URL to link a Meta Ads account to the Pipeboard platform. ```APIDOC ## POST get_login_link ### Description Generates an authentication link for connecting Meta Ads accounts. ### Method POST ### Endpoint get_login_link ### Response #### Success Response (200) - **login_url** (string) - The URL to initiate OAuth. - **markdown_link** (string) - A pre-formatted markdown link for the UI. #### Response Example { "login_url": "https://pipeboard.co/auth/...", "authentication_method": "pipeboard_oauth" } ``` -------------------------------- ### mcp_meta_ads_get_ad_details Source: https://github.com/pipeboard-co/meta-ads-mcp/blob/main/README.md Retrieves detailed information for a specific Meta Ads ad. ```APIDOC ## GET /api/ads/{ad_id} ### Description Retrieves detailed information for a specific Meta Ads ad. ### Method GET ### Endpoint /api/ads/{ad_id} ### Parameters #### Path Parameters - **ad_id** (string) - Required - Meta Ads ad ID #### Query Parameters - **access_token** (string) - Optional - Meta API access token (will use cached token if not provided) ### Response #### Success Response (200) - **ad_details** (object) - Detailed information about the specified ad ```