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);
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It only states 'Update', which implies mutation, but does not disclose idempotency, side effects, return value, or any behavioral traits beyond the basic action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no extraneous words. It is concise and front-loaded, but could be slightly more informative without sacrificing brevity.

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?

Given the lack of output schema, annotations, and the presence of optional parameters, the description is incomplete. It does not explain partial update behavior, validation rules, or expected outcomes, leaving gaps for an AI agent.

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 coverage is 100% with descriptions for all parameters. The tool description adds no additional meaning beyond what the schema already provides, meeting the baseline of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Update') and identifies the resource as 'experiment (ad study)'. It clearly states the action and object, though it does not differentiate from sibling tools like 'create_experiment' or 'delete_experiment' beyond the verb.

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?

No guidance is provided on when to use this tool versus alternatives (e.g., when to update vs create a new experiment). There is no mention of prerequisites, context, or exclusions.

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