Skip to main content
Glama

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
NameRequiredDescriptionDefault
access_tokenNo
user_idNome
limitNo

Implementation Reference

  • 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)
  • 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
  • Export/import of get_ad_accounts in package __init__.py, making it available at the package level.
    get_ad_accounts,
  • 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) """

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