Skip to main content
Glama

delete-post

Remove unwanted WordPress posts via REST API by specifying site URL, credentials, and post ID. Optionally bypass Trash for permanent deletion.

Instructions

Delete a WordPress post

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
forceNoWhether to bypass Trash and force deletion
passwordYesWordPress application password
postIdYesID of the post to delete
siteUrlYesWordPress site URL
usernameYesWordPress username

Implementation Reference

  • The main handler function for the 'delete-post' tool. It makes a DELETE request to the WordPress REST API endpoint `/wp-json/wp/v2/posts/{postId}` using the provided credentials and optional force parameter to either permanently delete or move the post to trash.
    async ({ siteUrl, username, password, postId, force }) => {
      try {
        await makeWPRequest<any>({
          siteUrl,
          endpoint: `posts/${postId}`,
          method: "DELETE",
          auth: { username, password },
          params: { force }
        });
        
        return {
          content: [
            {
              type: "text",
              text: `Successfully deleted post ${postId}${force ? " (forced deletion)" : " (moved to trash)"}.`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error deleting post: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
  • Zod schema defining the input parameters for the 'delete-post' tool, including site URL, credentials, post ID, and optional force flag.
    {
      siteUrl: z.string().url().describe("WordPress site URL"),
      username: z.string().describe("WordPress username"),
      password: z.string().describe("WordPress application password"),
      postId: z.number().describe("ID of the post to delete"),
      force: z.boolean().optional().default(false).describe("Whether to bypass Trash and force deletion"),
    },
  • src/index.ts:964-1003 (registration)
    The complete registration of the 'delete-post' tool using McpServer.tool(), including name, description, input schema, and handler function.
    server.tool(
      "delete-post",
      "Delete a WordPress post",
      {
        siteUrl: z.string().url().describe("WordPress site URL"),
        username: z.string().describe("WordPress username"),
        password: z.string().describe("WordPress application password"),
        postId: z.number().describe("ID of the post to delete"),
        force: z.boolean().optional().default(false).describe("Whether to bypass Trash and force deletion"),
      },
      async ({ siteUrl, username, password, postId, force }) => {
        try {
          await makeWPRequest<any>({
            siteUrl,
            endpoint: `posts/${postId}`,
            method: "DELETE",
            auth: { username, password },
            params: { force }
          });
          
          return {
            content: [
              {
                type: "text",
                text: `Successfully deleted post ${postId}${force ? " (forced deletion)" : " (moved to trash)"}.`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error deleting post: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Shared helper function makeWPRequest used by the delete-post handler to perform authenticated HTTP requests to the WordPress 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 for behavioral disclosure. 'Delete a WordPress post' implies a destructive mutation but doesn't specify whether deletion is reversible, what permissions are required, whether it affects related content (like comments), or what the response looks like. The description mentions nothing about the 'force' parameter's behavior regarding trash bypass.

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, clear sentence with zero wasted words. It's perfectly front-loaded with the core action and resource. No structural issues exist - every word earns its place in this minimal but complete statement of purpose.

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 mutation tool with 5 parameters, no annotations, and no output schema, the description is inadequate. It doesn't cover authentication requirements, deletion consequences (trash vs permanent), error conditions, or return values. The description should explain more about the behavioral implications of deleting a WordPress post given the complexity of the operation.

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 the schema fully documents all 5 parameters. The description adds no parameter-specific information beyond what's in the schema. It doesn't explain the relationship between parameters (e.g., that siteUrl, username, and password are for authentication) or provide context about postId format. Baseline 3 is appropriate when schema does all the work.

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 verb ('Delete') and resource ('a WordPress post'), making the purpose immediately understandable. It distinguishes from siblings like 'delete-category' and 'delete-user' by specifying 'post', but doesn't mention what type of post or differentiate from similar operations like 'update-post' beyond the obvious action difference.

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), when deletion is appropriate versus updating or archiving, or what happens to deleted posts (trash vs permanent deletion). The sibling tools include 'update-post' and 'get-post' but no comparison is offered.

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