Skip to main content
Glama
Mike25app

scaleforge-mcp-meta-ads

get_campaign_insights

Retrieve performance metrics for a single ad campaign, including spend, impressions, clicks, and conversions. Customize date range, breakdown by demographics or placement, and get day-by-day data with time increments.

Instructions

Pull performance metrics for ONE campaign. Default fields: spend, impressions, clicks, cpc, cpm, ctr, reach, frequency, actions, conversions, purchase_roas. Default range: last_7d. Use breakdowns for cuts (age, gender, country, placement). Use time_increment=1 for day-by-day rows.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
campaign_idYes
date_presetNoDefault last_7d
time_rangeNo{since:'YYYY-MM-DD', until:'YYYY-MM-DD'} — overrides date_preset
breakdownsNoe.g. ['age','gender'] or ['country','publisher_platform']
action_breakdownsNoe.g. ['action_type']
time_incrementNo1 = per-day rows, 7 = weekly, 'monthly', etc.
filteringNoMeta filtering spec
fieldsNoOverride default metric list
limitNo
afterNo

Implementation Reference

  • The 'get_campaign_insights' tool definition with its handler. The handler calls metaGet() on the campaign's /insights endpoint with campaign-level params built by insightsParams().
    export const insightsTools: ToolDef[] = [
      {
        name: "get_campaign_insights",
        description:
          "Pull performance metrics for ONE campaign. Default fields: spend, impressions, clicks, " +
          "cpc, cpm, ctr, reach, frequency, actions, conversions, purchase_roas. Default range: " +
          "last_7d. Use `breakdowns` for cuts (age, gender, country, placement). Use `time_increment=1` " +
          "for day-by-day rows.",
        inputSchema: {
          campaign_id: z.string(),
          ...SHARED_INPUT_SCHEMA,
        },
        handler: async (args) =>
          metaGet(`/${String(args.campaign_id)}/insights`, insightsParams(args, "campaign")),
      },
  • Shared input schema (SHARED_INPUT_SCHEMA) used by get_campaign_insights, defining optional fields: date_preset, time_range, breakdowns, action_breakdowns, time_increment, filtering, fields, limit, after. The tool also requires 'campaign_id'.
    const SHARED_INPUT_SCHEMA = {
      date_preset: DATE_PRESET.optional().describe("Default last_7d"),
      time_range: z
        .object({ since: z.string(), until: z.string() })
        .optional()
        .describe("{since:'YYYY-MM-DD', until:'YYYY-MM-DD'} — overrides date_preset"),
      breakdowns: z
        .array(z.string())
        .optional()
        .describe("e.g. ['age','gender'] or ['country','publisher_platform']"),
      action_breakdowns: z
        .array(z.string())
        .optional()
        .describe("e.g. ['action_type']"),
      time_increment: z
        .union([z.number().int(), z.literal("monthly"), z.literal("all_days")])
        .optional()
        .describe("1 = per-day rows, 7 = weekly, 'monthly', etc."),
      filtering: z
        .array(z.record(z.unknown()))
        .optional()
        .describe("Meta filtering spec"),
      fields: z
        .array(z.string())
        .optional()
        .describe("Override default metric list"),
      limit: z.number().int().positive().max(500).optional(),
      after: z.string().optional(),
    };
  • insightsParams() helper function that builds the query parameter bag for all insights calls, setting level, fields, date range, breakdowns, filtering, pagination.
    function insightsParams(args: Record<string, unknown>, level: string): Record<string, unknown> {
      const params: Record<string, unknown> = {
        level,
        fields: (args.fields as string[] | undefined)?.join(",") ?? DEFAULT_INSIGHTS_FIELDS,
      };
      if (args.time_range) params.time_range = args.time_range;
      else params.date_preset = args.date_preset ?? "last_7d";
    
      if (args.breakdowns) params.breakdowns = args.breakdowns;
      if (args.action_breakdowns) params.action_breakdowns = args.action_breakdowns;
      if (args.time_increment !== undefined) params.time_increment = args.time_increment;
      if (args.filtering) params.filtering = args.filtering;
      if (args.limit !== undefined) params.limit = args.limit;
      if (args.after) params.after = args.after;
      return params;
    }
  • Default insights fields string used when no custom fields are provided by the caller.
    const DEFAULT_INSIGHTS_FIELDS =
      "spend,impressions,clicks,cpc,cpm,ctr,reach,frequency,actions,conversions,cost_per_conversion,cost_per_action_type,purchase_roas,video_30_sec_watched_actions,inline_link_clicks";
  • src/index.ts:47-58 (registration)
    Registration of all tools including get_campaign_insights (via insightsTools spread) into the McpServer. The server registers each tool in the loop at lines 65-89.
    const allTools: ToolDef[] = [
      ...accountTools,
      ...campaignTools,
      ...adsetTools,
      ...adTools,
      ...creativeTools,
      ...mediaTools,
      ...insightsTools,
      ...bulkTools,
      ...pageTools,
      ...adsLibraryTools,
    ];
Behavior3/5

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

With no annotations, the description must disclose behavioral traits. It covers default fields, date range, and breakdowns but omits important details like pagination behavior (via limit/after), authentication needs, rate limits, or error handling (e.g., for invalid campaign_id).

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 redundant sentences. It front-loads the main purpose and efficiently lists defaults and options. Every sentence contributes meaning.

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 complexity (10 parameters, nested objects, no output schema), the description covers the main purpose, defaults, and key options. However, it lacks explanation of filtering, action_breakdowns, pagination (limit/after), and the structure of the response. The provided defaults partially compensate.

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?

Schema description coverage is 70%, and the description adds value by explaining defaults (e.g., 'Default range: last_7d') and usage patterns (e.g., 'Use breakdowns for cuts'). It clarifies parameter relationships beyond what the schema provides.

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?

Description clearly states 'Pull performance metrics for ONE campaign,' using a specific verb and resource. It explains default fields, default date range, and available options like breakdowns and time_increment, fully distinguishing the tool's purpose from siblings like get_ad_insights.

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

Usage Guidelines3/5

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

The description implies using this tool for campaign-level insights but does not explicitly state when to use alternatives or when not to use it. No comparison with sibling tools like get_ad_insights or get_adset_insights is provided.

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

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