get_ad_accounts
Retrieve accessible Meta advertising accounts for a user to manage campaigns on Facebook and Instagram platforms.
Instructions
Get ad accounts accessible by a user.
Args:
access_token: Meta API access token (optional - will use cached token if not provided)
user_id: Meta user ID or "me" for the current user
limit: Maximum number of accounts to return (default: 200)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| access_token | No | ||
| user_id | No | me | |
| limit | No |
Implementation Reference
- meta_ads_mcp/core/accounts.py:9-28 (handler)The primary handler function for the 'get_ad_accounts' MCP tool. It uses the @mcp_server.tool() decorator for registration and @meta_api_tool for API handling. Fetches ad accounts from the Meta API endpoint and returns JSON.@mcp_server.tool() @meta_api_tool async def get_ad_accounts(access_token: Optional[str] = None, user_id: str = "me", limit: int = 200) -> str: """ Get ad accounts accessible by a user. Args: access_token: Meta API access token (optional - will use cached token if not provided) user_id: Meta user ID or "me" for the current user limit: Maximum number of accounts to return (default: 200) """ endpoint = f"{user_id}/adaccounts" params = { "fields": "id,name,account_id,account_status,amount_spent,balance,currency,age,business_city,business_country_code", "limit": limit } data = await make_api_request(endpoint, access_token, params) return json.dumps(data, indent=2)
- meta_ads_mcp/core/__init__.py:4-4 (registration)Import of get_ad_accounts from accounts.py in core/__init__.py, which triggers the tool registration via the decorator when the module is imported.from .accounts import get_ad_accounts, get_account_info
- meta_ads_mcp/__init__.py:39-39 (registration)Export/import of get_ad_accounts in package __init__.py, making it available at the package level.get_ad_accounts,
- meta_ads_mcp/core/accounts.py:11-19 (schema)Input schema defined by function parameters with type hints and documentation describing the arguments for the tool.async def get_ad_accounts(access_token: Optional[str] = None, user_id: str = "me", limit: int = 200) -> str: """ Get ad accounts accessible by a user. Args: access_token: Meta API access token (optional - will use cached token if not provided) user_id: Meta user ID or "me" for the current user limit: Maximum number of accounts to return (default: 200) """