Skip to main content
Glama

delete_rule

Delete an automated rule by providing its rule ID. Remove rules no longer needed for ad campaign management.

Instructions

Delete an automated rule.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rule_idYesRule ID

Implementation Reference

  • Registration of the 'delete_rule' tool on the MCP server via server.tool()
    server.tool(
      "delete_rule",
      "Delete an automated rule.",
      {
        rule_id: z.string().describe("Rule ID"),
      },
      async ({ rule_id }) => {
        try {
          const { data, rateLimit } = await client.delete(`/${rule_id}`);
          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 };
        }
      }
    );
  • Handler function that executes DELETE request via AdsClient to delete a rule by rule_id
    async ({ rule_id }) => {
      try {
        const { data, rateLimit } = await client.delete(`/${rule_id}`);
        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 defining the required 'rule_id' parameter as a string
    {
      rule_id: z.string().describe("Rule ID"),
    },
  • Parent function registerRuleTools that registers all rule-related tools on the server
    export function registerRuleTools(server: McpServer, client: AdsClient): void {
      // ─── list_rules ────────────────────────────────────────────
      server.tool(
        "list_rules",
        "List automated rules 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}/adrules_library`, { ...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_rule ──────────────────────────────────────────────
      server.tool(
        "get_rule",
        "Get details of a specific automated rule.",
        {
          rule_id: z.string().describe("Rule ID"),
          fields: z.string().optional().describe("Comma-separated fields to return"),
        },
        async ({ rule_id, ...params }) => {
          try {
            const { data, rateLimit } = await client.get(`/${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 };
          }
        }
      );
    
      // ─── create_rule ───────────────────────────────────────────
      server.tool(
        "create_rule",
        "Create a new automated rule for the ad account.",
        {
          name: z.string().describe("Rule name"),
          evaluation_spec: z.string().describe("JSON string defining rule conditions"),
          execution_spec: z.string().describe("JSON string defining rule actions"),
          schedule_spec: z.string().optional().describe("JSON string defining rule schedule"),
        },
        async (params) => {
          try {
            const { data, rateLimit } = await client.post(`${client.accountPath}/adrules_library`, { ...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_rule ───────────────────────────────────────────
      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 };
          }
        }
      );
    
      // ─── delete_rule ───────────────────────────────────────────
      server.tool(
        "delete_rule",
        "Delete an automated rule.",
        {
          rule_id: z.string().describe("Rule ID"),
        },
        async ({ rule_id }) => {
          try {
            const { data, rateLimit } = await client.delete(`/${rule_id}`);
            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 };
          }
        }
      );
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

B3.3/5.0
Behavior2/5

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

There are no annotations, so the description must carry the full burden of behavioral disclosure. It states only the destructive action ('Delete') without mentioning irreversibility, side effects, authorization requirements, or consequences. This is minimal and largely restates the obvious.

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 with no wasted words. For a simple delete operation, this level of conciseness is appropriate and easy to parse.

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?

For a one-parameter, simple delete tool, the core action is communicated adequately. However, the lack of any indication about permanence, response behavior, or failure conditions leaves some contextual gaps, especially given the complete absence of annotations.

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% for the single parameter rule_id, so the schema already documents it. The description adds no extra meaning beyond confirming the target of deletion, matching the baseline of 3.

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 uses a specific verb ('Delete') and resource ('automated rule'), clearly distinguishing it from siblings like create_rule, update_rule, get_rule, and list_rules. It states exactly what the tool does with no ambiguity.

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, nor any prerequisites or exclusions. The usage context is only implied by the tool name and description, not explicitly stated.

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