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

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

No annotations are provided, and the description only says 'Delete' without disclosing behavioral traits such as whether deletion is permanent, requires authentication, or has cascading effects. This is insufficient for a mutation tool.

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 concise sentence with no fluff, but it could be 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 no output schema, one parameter, and no annotations, the description fails to provide sufficient context about what happens after deletion or any preconditions. It is incomplete for an agent to use correctly.

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 the parameter 'rule_id' described as 'Rule ID'. The description adds no additional context beyond the schema, so a 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 action (Delete) and the resource (automated rule), distinguishing it from sibling tools like create_rule, update_rule, get_rule, and list_rules.

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 that this tool is used when you want to remove an automated rule, but provides no explicit guidance on when to use it versus alternatives or any prerequisites.

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