Skip to main content
Glama

delete-category

Remove a WordPress category by specifying its ID and site credentials. Ensures complete deletion without trashing, simplifying category management through programmatic API integration.

Instructions

Delete a WordPress category

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryIdYesID of the category to delete
forceNoRequired to be true, as terms do not support trashing
passwordYesWordPress application password
siteUrlYesWordPress site URL
usernameYesWordPress username

Implementation Reference

  • The handler function for the 'delete-category' tool. It makes a DELETE request to the WordPress REST API endpoint `/wp-json/wp/v2/categories/${categoryId}` using the shared `makeWPRequest` helper, with `force` parameter. Returns success or error message in MCP content format.
      try {
        await makeWPRequest<any>({
          siteUrl,
          endpoint: `categories/${categoryId}`,
          method: "DELETE",
          auth: { username, password },
          params: { force }
        });
        
        return {
          content: [
            {
              type: "text",
              text: `Successfully deleted category ${categoryId}.`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error deleting category: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • Zod schema defining input parameters for the 'delete-category' tool: siteUrl (required URL), username, password (credentials), categoryId (number, required), force (boolean, defaults to true).
      siteUrl: z.string().url().describe("WordPress site URL"),
      username: z.string().describe("WordPress username"),
      password: z.string().describe("WordPress application password"),
      categoryId: z.number().describe("ID of the category to delete"),
      force: z.boolean().optional().default(true).describe("Required to be true, as terms do not support trashing"),
    },
    async ({ siteUrl, username, password, categoryId, force }) => {
  • src/index.ts:2061-2099 (registration)
    Registration of the 'delete-category' tool via `server.tool(name, description, inputSchema, handlerFunction)`. Located in the CATEGORY TOOLS section.
      "delete-category",
      "Delete a WordPress category",
      {
        siteUrl: z.string().url().describe("WordPress site URL"),
        username: z.string().describe("WordPress username"),
        password: z.string().describe("WordPress application password"),
        categoryId: z.number().describe("ID of the category to delete"),
        force: z.boolean().optional().default(true).describe("Required to be true, as terms do not support trashing"),
      },
      async ({ siteUrl, username, password, categoryId, force }) => {
        try {
          await makeWPRequest<any>({
            siteUrl,
            endpoint: `categories/${categoryId}`,
            method: "DELETE",
            auth: { username, password },
            params: { force }
          });
          
          return {
            content: [
              {
                type: "text",
                text: `Successfully deleted category ${categoryId}.`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error deleting category: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Shared helper function `makeWPRequest` used by all WP API tools, including delete-category, to perform authenticated HTTP requests to WP REST API.
    async function makeWPRequest<T>({
      siteUrl, 
      endpoint,
      method = 'GET',
      auth,
      data = null,
      params = null
    }: {
      siteUrl: string;
      endpoint: string;
      method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
      auth: { username: string; password: string };
      data?: any;
      params?: any;
    }): Promise<T> {
      const authString = Buffer.from(`${auth.username}:${auth.password}`).toString('base64');
      
      try {
        const response = await axios({
          method,
          url: `${siteUrl}/wp-json/wp/v2/${endpoint}`,
          headers: {
            'Authorization': `Basic ${authString}`,
            'Content-Type': 'application/json',
          },
          data: data,
          params: params
        });
        
        return response.data as T;
      } catch (error) {
        if (axios.isAxiosError(error) && error.response) {
          throw new Error(`WordPress API error: ${error.response.data?.message || error.message}`);
        }
        throw error;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose that this is a destructive operation (implied but not explicit), authentication requirements, rate limits, error conditions, or what happens to posts in the category. The 'force' parameter description hints at irreversibility, but the main description lacks behavioral context.

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, direct sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately scannable and efficient for an AI agent.

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 destructive tool with no annotations and no output schema, the description is inadequate. It doesn't explain what 'delete' entails (permanent removal vs. trashing), authentication needs, error handling, or return values. Given the complexity and risk of deletion, more context is needed beyond the bare minimum.

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 parameters are fully documented in the schema. The description adds no additional parameter semantics beyond what's in the schema (e.g., it doesn't explain categoryId format or password requirements). Baseline 3 is appropriate since the schema does the heavy lifting.

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 clearly states the action ('Delete') and resource ('WordPress category'), making the purpose immediately understandable. It distinguishes from siblings like 'get-category' or 'update-category' by specifying the destructive operation. However, it doesn't explicitly differentiate from 'delete-post' or 'delete-user' beyond the resource type.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (like needing authentication), consequences of deletion, or when to choose this over similar deletion tools for posts or users. The agent must infer usage from the name alone.

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

Related 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/prathammanocha/wordpress-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server