Skip to main content
Glama

list_business_ad_accounts

List ad accounts owned by your configured business. Filter by fields, set result limit, or paginate with after cursor.

Instructions

List ad accounts owned by the configured business. Requires META_BUSINESS_ID env var.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fieldsNoComma-separated fields to return
limitNoNumber of results (default 25)
afterNoPagination cursor for next page

Implementation Reference

  • The handler function for list_business_ad_accounts tool. Registered via server.tool(), it calls the Meta API endpoint `GET /{businessId}/owned_ad_accounts` using the AdsClient.
    server.tool(
      "list_business_ad_accounts",
      "List ad accounts owned by the configured business. Requires META_BUSINESS_ID env var.",
      {
        fields: z.string().optional().describe("Comma-separated fields to return"),
        limit: z.number().optional().default(25).describe("Number of results (default 25)"),
        after: z.string().optional().describe("Pagination cursor for next page"),
      },
      async ({ fields, limit, after }) => {
        try {
          let businessId: string;
          try {
            businessId = client.businessId;
          } catch {
            return { content: [{ type: "text" as const, text: "META_BUSINESS_ID environment variable is required for this operation. Please set it and restart the server." }], isError: true };
          }
          const params: Record<string, unknown> = {};
          if (fields) params.fields = fields;
          if (limit) params.limit = limit;
          if (after) params.after = after;
          const { data, rateLimit } = await client.get(`/${businessId}/owned_ad_accounts`, params);
          return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );
  • Tool registration via server.tool() call in registerBusinessTools(). The function registerBusinessTools is imported and called in src/index.ts at line 90.
    server.tool(
      "list_business_ad_accounts",
      "List ad accounts owned by the configured business. Requires META_BUSINESS_ID env var.",
      {
        fields: z.string().optional().describe("Comma-separated fields to return"),
        limit: z.number().optional().default(25).describe("Number of results (default 25)"),
        after: z.string().optional().describe("Pagination cursor for next page"),
      },
      async ({ fields, limit, after }) => {
        try {
          let businessId: string;
          try {
            businessId = client.businessId;
          } catch {
            return { content: [{ type: "text" as const, text: "META_BUSINESS_ID environment variable is required for this operation. Please set it and restart the server." }], isError: true };
          }
          const params: Record<string, unknown> = {};
          if (fields) params.fields = fields;
          if (limit) params.limit = limit;
          if (after) params.after = after;
          const { data, rateLimit } = await client.get(`/${businessId}/owned_ad_accounts`, params);
          return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] };
        } catch (error) {
          return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true };
        }
      }
    );
  • Input schema using Zod: fields (optional string), limit (optional number, default 25), after (optional string for pagination).
    {
      fields: z.string().optional().describe("Comma-separated fields to return"),
      limit: z.number().optional().default(25).describe("Number of results (default 25)"),
      after: z.string().optional().describe("Pagination cursor for next page"),
    },
  • The businessId getter on AdsClient reads from config (META_BUSINESS_ID env var) and throws if unset.
    get businessId(): string {
      if (!this.config.businessId) {
        throw new Error(
          "META_BUSINESS_ID is not configured. Set it as an environment variable."
        );
      }
      return this.config.businessId;
    }
Behavior3/5

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

No annotations are provided, so the description carries the burden. It adds the environment variable requirement, which is a behavioral trait not in the schema. However, it does not disclose other behaviors like read-only nature or pagination limits beyond what the schema implies.

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 extremely concise with two sentences, no unnecessary words, and front-loads the core purpose. Every sentence is informative.

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?

Given the tool's simplicity (no required params, no output schema), the description is fairly complete. It covers the key constraint (business ownership) and a prerequisite. Minor omission: could mention pagination behavior, but the schema handles that.

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

Parameters3/5

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

The input schema has 100% description coverage, so the parameters (fields, limit, after) are already well-documented. The description adds no additional meaning beyond the schema, resulting in a baseline score of 3.

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 'List ad accounts owned by the configured business', using a specific verb and resource. The tool name includes 'business' which distinguishes it from the sibling 'list_ad_accounts', indicating a scoped listing.

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 only mentions the prerequisite 'Requires META_BUSINESS_ID env var' but provides no guidance on when to use this tool versus alternatives like 'list_ad_accounts' or when not to use it.

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/mikusnuz/meta-ads-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server