Skip to main content
Glama

update_rule

Update an existing automated rule by modifying its name, conditions, actions, schedule, or status.

Instructions

Update an existing automated rule.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rule_idYesRule ID
nameNoNew rule name
evaluation_specNoJSON string defining updated rule conditions
execution_specNoJSON string defining updated rule actions
schedule_specNoJSON string defining updated rule schedule
statusNoRule status: ENABLED, DISABLED

Implementation Reference

  • The handler function for the 'update_rule' tool. It destructures rule_id from params, makes a POST request to /{rule_id}, and returns the response or an error message.
      async ({ rule_id, ...params }) => {
        try {
          const { data, rateLimit } = await client.post(`/${rule_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 };
        }
      }
    );
  • Zod schema definitions for the 'update_rule' tool input parameters: rule_id (required), name, evaluation_spec, execution_spec, schedule_spec, and status (all optional).
    {
      rule_id: z.string().describe("Rule ID"),
      name: z.string().optional().describe("New rule name"),
      evaluation_spec: z.string().optional().describe("JSON string defining updated rule conditions"),
      execution_spec: z.string().optional().describe("JSON string defining updated rule actions"),
      schedule_spec: z.string().optional().describe("JSON string defining updated rule schedule"),
      status: z.string().optional().describe("Rule status: ENABLED, DISABLED"),
    },
  • Registration of the 'update_rule' tool via server.tool() with name 'update_rule', description 'Update an existing automated rule.', schema definitions, and handler function.
    server.tool(
      "update_rule",
      "Update an existing automated rule.",
      {
        rule_id: z.string().describe("Rule ID"),
        name: z.string().optional().describe("New rule name"),
        evaluation_spec: z.string().optional().describe("JSON string defining updated rule conditions"),
        execution_spec: z.string().optional().describe("JSON string defining updated rule actions"),
        schedule_spec: z.string().optional().describe("JSON string defining updated rule schedule"),
        status: z.string().optional().describe("Rule status: ENABLED, DISABLED"),
      },
      async ({ rule_id, ...params }) => {
        try {
          const { data, rateLimit } = await client.post(`/${rule_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 };
        }
      }
    );
  • Complete registration of the 'update_rule' tool on the MCP server, including its name, description, input schema, and handler function.
    server.tool(
      "update_rule",
      "Update an existing automated rule.",
      {
        rule_id: z.string().describe("Rule ID"),
        name: z.string().optional().describe("New rule name"),
        evaluation_spec: z.string().optional().describe("JSON string defining updated rule conditions"),
        execution_spec: z.string().optional().describe("JSON string defining updated rule actions"),
        schedule_spec: z.string().optional().describe("JSON string defining updated rule schedule"),
        status: z.string().optional().describe("Rule status: ENABLED, DISABLED"),
      },
      async ({ rule_id, ...params }) => {
        try {
          const { data, rateLimit } = await client.post(`/${rule_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 };
        }
      }
    );
  • The AdsClient.post() helper method used by the update_rule handler to send the POST request 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) ---
    
    async upload(
      path: string,
      fileUrl: string,
      params?: Record<string, unknown>
    ): Promise<ClientResponse> {
      return this.post(path, { ...params, url: fileUrl });
    }
    
    // --- Account helpers ---
    
    get accountPath(): string {
      return `/act_${this.accountId}`;
    }
    
    get accountId(): string {
      if (!this.config.adAccountId) {
        throw new Error(
          "META_AD_ACCOUNT_ID is not configured. Set it as an environment variable."
        );
      }
      return this.config.adAccountId;
    }
Behavior2/5

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

With no annotations, the description carries full burden for behavioral disclosure. It only states 'update' without revealing side effects, idempotency, error handling (e.g., non-existent rule_id), or whether updates are atomic. This is insufficient for an update operation.

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

Conciseness3/5

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

The description is very short at 4 words, which is concise but lacks substance. It fits in a single line, but every sentence should earn its place; here it barely does. A bit more detail would improve without sacrificing conciseness.

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 tool with 6 parameters, no output schema, and no annotations, the description is incomplete. It does not explain the purpose of the JSON specs (evaluation_spec, execution_spec, schedule_spec) or how they interact with the rule. The term 'automated rule' is not defined.

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. The description adds no extra meaning beyond the parameter names and types already in the schema (e.g., 'New rule name' is already in schema). No additional context is provided.

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 'Update an existing automated rule' uses a specific verb (update) and resource (automated rule), clearly indicating the action. However, it does not distinguish this tool from siblings like create_rule or delete_rule, but the verb itself is unambiguous.

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., create_rule for new rules, delete_rule for removal). There is no mention of prerequisites, such as the rule_id must correspond to an existing rule.

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