Skip to main content
Glama

update_experiment

Update an existing ad experiment's name and description to maintain accurate study records.

Instructions

Update an existing experiment (ad study).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
experiment_idYesExperiment (ad study) ID
nameNoNew experiment name
descriptionNoNew experiment description

Implementation Reference

  • The 'update_experiment' tool handler. Defined via server.tool() with a schema accepting experiment_id (required), name (optional), and description (optional). The handler destructures experiment_id and passes remaining params to client.post(/${experiment_id}, ...), which sends a POST request to the Facebook Graph API to update the ad study.
    // ─── update_experiment ─────────────────────────────────────
    server.tool(
      "update_experiment",
      "Update an existing experiment (ad study).",
      {
        experiment_id: z.string().describe("Experiment (ad study) ID"),
        name: z.string().optional().describe("New experiment name"),
        description: z.string().optional().describe("New experiment description"),
      },
      async ({ experiment_id, ...params }) => {
        try {
          const { data, rateLimit } = await client.post(`/${experiment_id}`, { ...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 for the 'update_experiment' tool using Zod: experiment_id (string, required), name (string, optional), description (string, optional).
    {
      experiment_id: z.string().describe("Experiment (ad study) ID"),
      name: z.string().optional().describe("New experiment name"),
      description: z.string().optional().describe("New experiment description"),
    },
  • The registerExperimentTools function is the registration point for all experiment-related tools, including 'update_experiment'. It's called from src/index.ts (line 76 and 144) to register tools on the server.
    export function registerExperimentTools(server: McpServer, client: AdsClient): void {
      // ─── list_experiments ──────────────────────────────────────
      server.tool(
        "list_experiments",
        "List A/B test experiments (ad studies) for the ad account.",
        {
          fields: z.string().optional().describe("Comma-separated fields to return"),
          limit: z.number().optional().default(25).describe("Number of results to return"),
          after: z.string().optional().describe("Pagination cursor for next page"),
        },
        async (params) => {
          try {
            const { data, rateLimit } = await client.get(`${client.accountPath}/ad_studies`, { ...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 };
          }
        }
      );
    
      // ─── create_experiment ─────────────────────────────────────
      server.tool(
        "create_experiment",
        "Create a new A/B test experiment (ad study).",
        {
          name: z.string().describe("Experiment name"),
          description: z.string().optional().describe("Experiment description"),
          start_time: z.string().describe("Start time in ISO 8601 or Unix timestamp"),
          end_time: z.string().describe("End time in ISO 8601 or Unix timestamp"),
          type: z.string().optional().describe("Study type"),
          cells: z.string().describe("JSON array of test cells: [{name, campaign_id}]"),
        },
        async (params) => {
          try {
            const { data, rateLimit } = await client.post(`${client.accountPath}/ad_studies`, { ...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 };
          }
        }
      );
    
      // ─── get_experiment ────────────────────────────────────────
      server.tool(
        "get_experiment",
        "Get details of a specific experiment (ad study).",
        {
          experiment_id: z.string().describe("Experiment (ad study) ID"),
          fields: z.string().optional().describe("Comma-separated fields to return"),
        },
        async ({ experiment_id, ...params }) => {
          try {
            const { data, rateLimit } = await client.get(`/${experiment_id}`, { ...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 };
          }
        }
      );
    
      // ─── update_experiment ─────────────────────────────────────
      server.tool(
        "update_experiment",
        "Update an existing experiment (ad study).",
        {
          experiment_id: z.string().describe("Experiment (ad study) ID"),
          name: z.string().optional().describe("New experiment name"),
          description: z.string().optional().describe("New experiment description"),
        },
        async ({ experiment_id, ...params }) => {
          try {
            const { data, rateLimit } = await client.post(`/${experiment_id}`, { ...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 };
          }
        }
      );
    
      // ─── get_experiment_results ────────────────────────────────
      server.tool(
        "get_experiment_results",
        "Get results/cells of an experiment (ad study).",
        {
          experiment_id: z.string().describe("Experiment (ad study) ID"),
          fields: z.string().optional().describe("Comma-separated fields to return"),
        },
        async ({ experiment_id, ...params }) => {
          try {
            const { data, rateLimit } = await client.get(`/${experiment_id}/cells`, { ...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:76-77 (registration)
    Registration call site in the main server initialization. registerExperimentTools(server, client) registers all experiment tools including 'update_experiment'.
    registerExperimentTools(server, client);
  • The client.post() method used by the handler to send the update request to the Meta Ads API (POST to /{experiment_id}).
    async post(
      path: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.request("POST", path, params);
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

A3.5/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the basic action and does not reveal any behavioral traits such as whether the update is partial or full, required permissions, side effects, or return value format. For a mutating 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 sentence with no extraneous words. It is front-loaded with the action and resource, making it highly scannable. Every part of the sentence contributes to the purpose, earning a perfect conciseness score.

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

Completeness3/5

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

The tool is simple (3 parameters, all described in schema), but there is no output schema or annotations. The description is minimal and leaves out important context such as usage guidelines, behavioral details, and what to expect after the update. It is adequate but has clear gaps.

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% coverage for all three parameters, each with a description. The tool description itself adds no additional parameter semantics, but since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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's function: 'Update an existing experiment (ad study).' The verb 'update' is specific, the resource is 'experiment', and the parenthetical clarifies that 'experiment' refers to an ad study, distinguishing it from other experiment-related tools like create_experiment or get_experiment.

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 usage via the word 'existing' (i.e., update an already-created experiment, not create one), but it does not explicitly state when to use it versus alternatives like create_experiment or get_experiment. No exclusions or alternative tools are mentioned.

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