Skip to main content
Glama

create_rf_prediction

Create a reach and frequency prediction for Meta ad campaigns by providing targeting spec, budget in cents, and scheduling info.

Instructions

Create a new reach & frequency prediction. Provide targeting spec as JSON string, budget in cents, and scheduling info.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
target_specYesJSON string of targeting specification
start_timeYesPrediction start time (ISO 8601 or Unix timestamp)
stop_timeYesPrediction stop time (ISO 8601 or Unix timestamp)
budgetYesBudget in account currency cents
frequency_capYesMaximum frequency cap per user
destination_idYesDestination ID (e.g. Facebook Page ID)

Implementation Reference

  • Handler function for the 'create_rf_prediction' tool. Takes target_spec, start_time, stop_time, budget, frequency_cap, destination_id; sends a POST to /{accountPath}/reachfrequencypredictions on the Meta Ads API.
    async ({ target_spec, start_time, stop_time, budget, frequency_cap, destination_id }) => {
      try {
        const params: Record<string, unknown> = {
          target_spec,
          start_time,
          stop_time,
          budget,
          frequency_cap,
          destination_id,
        };
        const { data, rateLimit } = await client.post(`${client.accountPath}/reachfrequencypredictions`, 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 };
      }
    }
  • Zod schema defining input parameters for create_rf_prediction: target_spec (JSON string), start_time (ISO string), stop_time (ISO string), budget (number cents), frequency_cap (number), destination_id (string).
    {
      target_spec: z.string().describe("JSON string of targeting specification"),
      start_time: z.string().describe("Prediction start time (ISO 8601 or Unix timestamp)"),
      stop_time: z.string().describe("Prediction stop time (ISO 8601 or Unix timestamp)"),
      budget: z.number().describe("Budget in account currency cents"),
      frequency_cap: z.number().describe("Maximum frequency cap per user"),
      destination_id: z.string().describe("Destination ID (e.g. Facebook Page ID)"),
    },
  • Registration of 'create_rf_prediction' as an MCP tool using server.tool() with name 'create_rf_prediction' and description about creating a reach & frequency prediction.
    // ─── create_rf_prediction ─────────────────────────────────────
    server.tool(
      "create_rf_prediction",
      "Create a new reach & frequency prediction. Provide targeting spec as JSON string, budget in cents, and scheduling info.",
      {
        target_spec: z.string().describe("JSON string of targeting specification"),
        start_time: z.string().describe("Prediction start time (ISO 8601 or Unix timestamp)"),
        stop_time: z.string().describe("Prediction stop time (ISO 8601 or Unix timestamp)"),
        budget: z.number().describe("Budget in account currency cents"),
        frequency_cap: z.number().describe("Maximum frequency cap per user"),
        destination_id: z.string().describe("Destination ID (e.g. Facebook Page ID)"),
      },
      async ({ target_spec, start_time, stop_time, budget, frequency_cap, destination_id }) => {
        try {
          const params: Record<string, unknown> = {
            target_spec,
            start_time,
            stop_time,
            budget,
            frequency_cap,
            destination_id,
          };
          const { data, rateLimit } = await client.post(`${client.accountPath}/reachfrequencypredictions`, 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 };
        }
      }
    );
  • src/index.ts:83-83 (registration)
    Registration call linking registerReachFrequencyTools into the main server.
    registerReachFrequencyTools(server, client);
  • The AdsClient.post() method used by the handler to POST data to the Meta Ads API.
    async post(
      path: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.request("POST", path, params);
    }
    
    async delete(
      path: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.request("DELETE", path, params);
    }
    
    // --- Upload (URL-based) ---

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

B3.4/5.0
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It only states the action and input types, but does not mention return values, whether the operation is synchronous, if an ID is created, required permissions, or any side effects. For a mutation tool, this is a significant gap.

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 a single, front-loaded sentence that directly states the purpose and hints at key parameters. Every word earns its place; there is no fluff.

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

Completeness2/5

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

For a complex tool with 6 required parameters and no output schema, the description is too brief. It does not explain what the response contains, how to retrieve the created prediction, error scenarios, or any follow-up steps. Given the low complexity of the input schema, a bit more context is expected.

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?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds minimal value by restating that target_spec is a JSON string and budget is in cents, but does not explain any parameter relationships or expected values 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 action: 'Create a new reach & frequency prediction.' The verb 'Create' is specific and distinguishes it from sibling tools like list_rf_predictions, get_rf_prediction, and delete_rf_prediction.

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?

Usage is implied by the word 'Create' – use when you need a new prediction. However, there is no explicit guidance on when to use it versus alternatives, no prerequisites, or context about how it relates to other rf_prediction tools.

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

Deploy Server

Other Tools