Skip to main content
Glama

get_account_info

Retrieve detailed information about a specific Meta Ads account, including account settings and configuration data, using the account ID.

Instructions

Get detailed information about a specific ad account. Args: account_id: Meta Ads account ID (format: act_XXXXXXXXX) access_token: Meta API access token (optional - will use cached token if not provided)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
access_tokenNo

Implementation Reference

  • The core handler function for the 'get_account_info' MCP tool. It fetches detailed ad account information from the Meta Ads API, handles account ID formatting, permission errors with helpful suggestions listing accessible accounts, and adds DSA compliance detection for European accounts.
    @mcp_server.tool() @meta_api_tool async def get_account_info(account_id: str, access_token: Optional[str] = None) -> str: """ Get detailed information about a specific ad account. Args: account_id: Meta Ads account ID (format: act_XXXXXXXXX) access_token: Meta API access token (optional - will use cached token if not provided) """ if not account_id: return { "error": { "message": "Account ID is required", "details": "Please specify an account_id parameter", "example": "Use account_id='act_123456789' or account_id='123456789'" } } # Ensure account_id has the 'act_' prefix for API compatibility if not account_id.startswith("act_"): account_id = f"act_{account_id}" # Try to get the account info directly first endpoint = f"{account_id}" params = { "fields": "id,name,account_id,account_status,amount_spent,balance,currency,age,business_city,business_country_code,timezone_name" } data = await make_api_request(endpoint, access_token, params) # Check if the API request returned an error if "error" in data: # If access was denied, provide helpful error message with accessible accounts if "access" in str(data.get("error", {})).lower() or "permission" in str(data.get("error", {})).lower(): # Get list of accessible accounts for helpful error message accessible_endpoint = "me/adaccounts" accessible_params = { "fields": "id,name,account_id,account_status,amount_spent,balance,currency,age,business_city,business_country_code", "limit": 50 } accessible_accounts_data = await make_api_request(accessible_endpoint, access_token, accessible_params) if "data" in accessible_accounts_data: accessible_accounts = [ {"id": acc["id"], "name": acc["name"]} for acc in accessible_accounts_data["data"][:10] # Show first 10 ] return { "error": { "message": f"Account {account_id} is not accessible to your user account", "details": "This account either doesn't exist or you don't have permission to access it", "accessible_accounts": accessible_accounts, "total_accessible_accounts": len(accessible_accounts_data["data"]), "suggestion": "Try using one of the accessible account IDs listed above" } } # Return the original error for non-permission related issues return data # Add DSA requirement detection if "business_country_code" in data: european_countries = ["DE", "FR", "IT", "ES", "NL", "BE", "AT", "IE", "DK", "SE", "FI", "NO"] if data["business_country_code"] in european_countries: data["dsa_required"] = True data["dsa_compliance_note"] = "This account is subject to European DSA (Digital Services Act) requirements" else: data["dsa_required"] = False data["dsa_compliance_note"] = "This account is not subject to European DSA requirements" return data
  • Imports the accounts module, which triggers the @mcp_server.tool() decorator execution on get_account_info, registering it as an MCP tool.
    from .server import mcp_server from .accounts import get_ad_accounts, get_account_info
  • Package-level import and re-export of get_account_info from core, making it available at the top-level package.
    from .core import ( get_ad_accounts, get_account_info, get_campaigns, get_campaign_details, create_campaign, get_adsets, get_adset_details, update_adset, get_ads, get_ad_details, get_ad_creatives, get_ad_image, update_ad, get_insights, login_cli, main, search_interests, get_interest_suggestions, estimate_audience_size, search_behaviors, search_demographics, search_geo_locations )
  • Creation of the FastMCP server instance 'mcp_server' used by the @mcp_server.tool() decorator to register all tools including get_account_info.
    # Initialize FastMCP server mcp_server = FastMCP("meta-ads")

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