Skip to main content
Glama
andrealufino

aapl-ads-mcp

list_ad_groups

List ad groups in an Apple Search Ads campaign. Provide campaign ID to retrieve ad group metadata including name, status, default bid, and automated keyword opt-in. Supports pagination with limit (default 20, max 1000) and offset.

Instructions

List ad groups within a specific Apple Search Ads campaign. Requires ASA authentication; read-only. Returns ad group metadata (id, name, status, default bid, automated keyword opt-in) but not performance metrics — use get_ad_group_report for metrics. Supports pagination via limit/offset; default limit 20, max 1000.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaignIdYesID of the campaign whose ad groups to list. Obtain from list_campaigns.
limitNoMax ad groups to return (1–1000). Defaults to 20.
offsetNoZero-based page offset for pagination. Defaults to 0.

Implementation Reference

  • Registers the 'list_ad_groups' tool on the MCP server via server.tool('list_ad_groups', ...). Also defines the handler function that executes the tool logic.
    export function registerAdGroupsTools(server: McpServer, client: AsaClient): void {
      server.tool(
        "list_ad_groups",
        "List ad groups within a specific Apple Search Ads campaign. Requires ASA authentication; read-only. Returns ad group metadata (id, name, status, default bid, automated keyword opt-in) but not performance metrics — use get_ad_group_report for metrics. Supports pagination via limit/offset; default limit 20, max 1000.",
        {
          campaignId: z
            .number()
            .int()
            .positive()
            .describe("ID of the campaign whose ad groups to list. Obtain from list_campaigns."),
          limit: z
            .number()
            .int()
            .min(1)
            .max(1000)
            .optional()
            .describe("Max ad groups to return (1–1000). Defaults to 20."),
          offset: z
            .number()
            .int()
            .min(0)
            .optional()
            .describe("Zero-based page offset for pagination. Defaults to 0."),
        },
        async (args) => {
          const { campaignId, limit, offset } = ListAdGroupsInputSchema.parse(args);
    
          const response = await client.getPaginated<AdGroup[]>(`/campaigns/${campaignId}/adgroups`, {
            limit,
            offset,
          });
          const adGroups = Array.isArray(response.data) ? response.data : [];
    
          const result = {
            pagination: response.pagination,
            adGroups: adGroups.map((ag) => AdGroupOutputSchema.parse(ag)),
          };
    
          return {
            content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }],
          };
        }
      );
    }
  • The async handler for 'list_ad_groups': parses input via ListAdGroupsInputSchema, calls client.getPaginated on /campaigns/{campaignId}/adgroups, validates each ad group with AdGroupOutputSchema, and returns paginated results as JSON.
    async (args) => {
      const { campaignId, limit, offset } = ListAdGroupsInputSchema.parse(args);
    
      const response = await client.getPaginated<AdGroup[]>(`/campaigns/${campaignId}/adgroups`, {
        limit,
        offset,
      });
      const adGroups = Array.isArray(response.data) ? response.data : [];
    
      const result = {
        pagination: response.pagination,
        adGroups: adGroups.map((ag) => AdGroupOutputSchema.parse(ag)),
      };
    
      return {
        content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }],
      };
    }
  • ListAdGroupsInputSchema: validates input with Zod (campaignId required, limit default 20/max 1000, offset default 0).
    export const ListAdGroupsInputSchema = z.object({
      campaignId: z.number().int().positive().describe("Campaign ID to list ad groups for"),
      limit: z
        .number()
        .int()
        .min(1)
        .max(1000)
        .optional()
        .default(20)
        .describe("Max results to return (1–1000)"),
      offset: z
        .number()
        .int()
        .min(0)
        .optional()
        .default(0)
        .describe("Zero-based offset for pagination"),
    });
  • AdGroupOutputSchema: defines the shape of each returned ad group (id, campaignId, name, status, servingStatus, defaultBidAmount, etc.).
    export const AdGroupOutputSchema = z.object({
      id: z.number(),
      campaignId: z.number(),
      orgId: z.number(),
      name: z.string(),
      status: z.enum(["ENABLED", "PAUSED", "DELETED"]),
      servingStatus: z.string().nullable(),
      defaultBidAmount: MoneySchema,
      automatedKeywordsOptIn: z.boolean(),
      startTime: z.string(),
      endTime: z.string().nullable().optional(),
      creationTime: z.string(),
      modificationTime: z.string(),
    });
  • src/server.ts:26-26 (registration)
    Calls registerAdGroupsTools(server, client) to wire the tool into the MCP server during initialization.
    registerAdGroupsTools(server, client);
Behavior5/5

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

Discloses read-only nature, describes return content (metadata fields) and what is not returned (performance metrics), providing full behavioral context without annotations.

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?

Three concise sentences, front-loaded with purpose, no redundant information, efficient use of text.

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

Completeness5/5

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

Despite lacking output schema, the description covers authentication, return content, limitations, pagination, and alternative tools, making it fully contextual for a list operation.

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

Parameters4/5

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

Since schema covers 100% of parameters with descriptions, the description adds useful context like obtaining campaignId from list_campaigns, slightly exceeding the baseline 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 the tool lists ad groups within a specific Apple Search Ads campaign, distinguishing it from siblings like get_ad_group_report for performance metrics.

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

Usage Guidelines4/5

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

Specifies read-only operation, pagination details (limit/offset defaults and max), and directs to get_ad_group_report for performance metrics, but does not explicitly exclude other sibling tools.

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/andrealufino/aapl-ads-mcp'

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