Skip to main content
Glama

get_ad_accounts

Retrieve ad accounts accessible to a user, returning amount spent and balance in currency units. Specify user ID and limit to control results.

Instructions

Get ad accounts accessible by a user.

amount_spent and balance are returned in currency units (e.g. USD dollars),
not cents.

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main tool handler for 'get_ad_accounts'. This async function is decorated with @mcp_server.tool() and @meta_api_tool. It calls the Meta Graph API endpoint '{user_id}/adaccounts' with fields like id, name, account_id, amount_spent, balance, etc. It normalizes monetary fields (cents to currency units) and returns the result as a JSON string.
    @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.
    
        amount_spent and balance are returned in currency units (e.g. USD dollars),
        not cents.
    
        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)
    
        if "data" in data:
            data["data"] = [_normalize_account_monetary_fields(acc) for acc in data["data"]]
    
        return json.dumps(data, indent=2)
  • Input schema for the tool defined in the docstring/args. Parameters: access_token (optional), user_id (default 'me'), limit (default 200). No Pydantic model - schema is inferred from function signature by FastMCP.
    """
    Get ad accounts accessible by a user.
    
    amount_spent and balance are returned in currency units (e.g. USD dollars),
    not cents.
    
    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)
    """
  • Helper functions: _cents_to_currency converts Meta API monetary values from cents to human-readable currency units. _normalize_account_monetary_fields applies this conversion to amount_spent and balance fields in each account dict.
    def _cents_to_currency(amount, currency: str) -> str:
        """Convert a Meta API monetary value (cents) to a currency-unit string.
    
        Meta returns amount_spent and balance as integers representing the smallest
        currency unit (cents for USD/EUR/GBP, base unit for zero-decimal currencies
        like JPY). This converts to the human-readable decimal amount.
        """
        try:
            amount_int = int(amount)
        except (TypeError, ValueError):
            return str(amount)
        if currency.upper() in _ZERO_DECIMAL_CURRENCIES:
            return str(amount_int)
        return f"{amount_int / 100:.2f}"
    
    
    def _normalize_account_monetary_fields(account: dict) -> dict:
        """Convert amount_spent and balance from cents to currency units in-place."""
        currency = account.get("currency", "USD")
        for field in ("amount_spent", "balance"):
            if field in account:
                account[field] = _cents_to_currency(account[field], currency)
        return account
  • The tool is registered via the @mcp_server.tool() decorator on the function (in accounts.py line 42). It is then re-exported in core/__init__.py where 'get_ad_accounts' is imported from .accounts and added to __all__.
    """Core functionality for Meta Ads API MCP package."""
    
    from .server import mcp_server
    from .accounts import get_ad_accounts, get_account_info
  • The @mcp_server.tool() decorator (from FastMCP) registers 'get_ad_accounts' as an MCP tool on the server instance at module import time.
    @mcp_server.tool()
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses that amount_spent and balance are in currency units (not cents), which is helpful. However, it omits details on authentication failure, rate limits, or pagination behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with no extraneous information. It uses a clear structure with a sentence and bullet-like arg explanations, making it efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description is fairly complete given the presence of an output schema. It explains the currency note and default behaviors. However, it lacks error conditions or prerequisites for using the access token.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must explain parameters. It clearly describes each arg: access_token (optional, cached), user_id ('me' or ID), limit (default 200). This adds significant meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'ad accounts', specifying that they are accessible by a user. This purpose is distinct from sibling tools like 'get_account_info' or 'get_account_pages'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides usage context (args) but does not guide the agent on when to use this tool versus alternatives or when not to use it. No exclusions or prerequisites are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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