Skip to main content
Glama

get_experiment_results

Retrieve results and cells from a Facebook ad experiment (ad study) using its ID. Specify optional fields to customize the data returned.

Instructions

Get results/cells of an experiment (ad study).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
experiment_idYesExperiment (ad study) ID
fieldsNoComma-separated fields to return

Implementation Reference

  • The handler function for the 'get_experiment_results' tool. It registers a tool with the MCP server that takes 'experiment_id' and optional 'fields', then calls the Meta API endpoint GET /{experiment_id}/cells to retrieve experiment results/cells.
    // ─── 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 };
        }
      }
    );
  • Input schema for 'get_experiment_results' using Zod: 'experiment_id' (string, required) and 'fields' (string, optional).
    {
      experiment_id: z.string().describe("Experiment (ad study) ID"),
      fields: z.string().optional().describe("Comma-separated fields to return"),
    },
  • The 'registerExperimentTools' function wraps all experiment tool registrations. Called from src/index.ts (line 76) with the MCP server and AdsClient instance.
    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 };
          }
        }
      );
    }
  • The AdsClient.get() helper used by the handler to make the GET request to Meta's API.
    async get(
      path: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.request("GET", path, params);
    }
Behavior2/5

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

No annotations; does not disclose behavioral traits such as read-only nature, permissions, or pagination behavior.

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?

Single sentence, no extraneous text, but could be improved by including more context while remaining concise.

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?

Adequate for a simple 2-parameter tool without output schema, but lacks details on return format or pagination.

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 baseline is 3. Description adds no extra meaning beyond schema; does not clarify how 'fields' parameter works.

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 verb 'Get' and resource 'results/cells of an experiment (ad study)', distinguishing it from sibling tool 'get_experiment' which likely retrieves experiment details.

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 on when to use vs. alternatives like get_experiment, or any prerequisites or conditions for use.

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