Skip to main content
Glama

delete-user

Remove a WordPress user account and reassign their posts to another user using the WordPress MCP Server tool. Simplify user management with secure programmatic actions.

Instructions

Delete a WordPress user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
passwordYesWordPress application password
reassignIdYesID of the user to reassign posts to
siteUrlYesWordPress site URL
userIdYesUser ID or 'me' for current user
usernameYesWordPress username

Implementation Reference

  • The handler function for the 'delete-user' tool. It performs a DELETE request to the WordPress /wp-json/wp/v2/users/{userId} endpoint with force=true and reassign={reassignId} parameters to delete the user and reassign their content.
    async ({ siteUrl, username, password, userId, reassignId }) => {
      try {
        await makeWPRequest<any>({
          siteUrl,
          endpoint: `users/${userId}`,
          method: "DELETE",
          auth: { username, password },
          params: {
            force: true,
            reassign: reassignId
          }
        });
        
        return {
          content: [
            {
              type: "text",
              text: `Successfully deleted user ${userId}. Posts have been reassigned to user ${reassignId}.`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error deleting user: ${error instanceof Error ? error.message : String(error)}`,
            },
          ],
        };
      }
    }
  • Zod input schema for the 'delete-user' tool defining parameters: siteUrl, username, password, userId (string/number/'me'), reassignId.
    {
      siteUrl: z.string().url().describe("WordPress site URL"),
      username: z.string().describe("WordPress username"),
      password: z.string().describe("WordPress application password"),
      userId: z.union([z.string(), z.number(), z.literal("me")]).describe("User ID or 'me' for current user"),
      reassignId: z.number().describe("ID of the user to reassign posts to"),
    },
  • src/index.ts:522-564 (registration)
    Registration of the 'delete-user' tool via server.tool() with name, description, input schema, and inline handler function.
    server.tool(
      "delete-user",
      "Delete a WordPress user",
      {
        siteUrl: z.string().url().describe("WordPress site URL"),
        username: z.string().describe("WordPress username"),
        password: z.string().describe("WordPress application password"),
        userId: z.union([z.string(), z.number(), z.literal("me")]).describe("User ID or 'me' for current user"),
        reassignId: z.number().describe("ID of the user to reassign posts to"),
      },
      async ({ siteUrl, username, password, userId, reassignId }) => {
        try {
          await makeWPRequest<any>({
            siteUrl,
            endpoint: `users/${userId}`,
            method: "DELETE",
            auth: { username, password },
            params: {
              force: true,
              reassign: reassignId
            }
          });
          
          return {
            content: [
              {
                type: "text",
                text: `Successfully deleted user ${userId}. Posts have been reassigned to user ${reassignId}.`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error deleting user: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Shared utility function makeWPRequest used by the delete-user handler (and other tools) to make authenticated HTTP requests to the WordPress REST API.
    // Helper function for making WordPress API requests
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Delete' implies a destructive mutation, the description doesn't specify whether this action is reversible, what permissions are required, how reassignment works, or what the response looks like. For a high-stakes operation like user deletion with 5 required parameters, this lack of behavioral context is a significant gap.

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, efficient sentence that states the core functionality without unnecessary words. It's appropriately sized for a tool with a clear primary action, though the brevity comes at the cost of missing important contextual information that would be valuable for a destructive operation.

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 required parameters and no annotations or output schema, the description is insufficiently complete. It doesn't address critical context like authentication requirements, irreversible consequences, reassignment implications, or error conditions. The agent would need to infer too much about this high-risk operation from the minimal description.

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 all parameters are documented in the input schema. The description adds no additional parameter information beyond what's already in the schema (e.g., it doesn't explain why 'reassignId' is required or what happens if 'me' is used as userId). With complete schema coverage, the baseline score of 3 is appropriate as the description doesn't enhance parameter understanding.

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 user'), making the purpose immediately understandable. It distinguishes this from sibling tools like 'create-user' or 'update-user' by specifying the destructive action. However, it doesn't explicitly differentiate from other deletion tools like 'delete-category' or 'delete-post' 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 (e.g., authentication requirements), when deletion is appropriate, or what happens to user data. With sibling tools like 'get-user' for checking existence or 'update-user' for modifications, there's no context for choosing deletion over other options.

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