Skip to main content
Glama

get_account_info

Retrieve detailed information about a Meta Ads account using an access token and account ID. Enables access to account-specific data for campaign analysis and management.

Instructions

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

Input Schema

NameRequiredDescriptionDefault
access_tokenNo
account_idNo

Input Schema (JSON Schema)

{ "properties": { "access_token": { "default": null, "title": "Access Token", "type": "string" }, "account_id": { "default": null, "title": "Account Id", "type": "string" } }, "title": "get_account_infoArguments", "type": "object" }

Implementation Reference

  • The primary handler function for the get_account_info MCP tool. Decorated with @mcp_server.tool() for automatic MCP registration. Handles account ID normalization, direct API calls to retrieve account details, permission error handling with suggestions of accessible accounts, and adds DSA compliance indicators for European business 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
  • Import statement in core/__init__.py that loads the get_account_info function, triggering its decorator-based MCP tool registration.
    from .accounts import get_ad_accounts, get_account_info
  • Import statements in server.py that ensure all tool modules (including accounts.py containing get_account_info) are loaded and their @mcp_server.tool() decorators executed for MCP server registration, particularly for HTTP transport.
    logger.info("Ensuring all tools are registered for HTTP transport") from . import accounts, campaigns, adsets, ads, insights, authentication

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