Skip to main content
Glama

wp_delete_media

Delete media files from WordPress sites by specifying the media ID, with options to permanently remove or move to trash for site cleanup.

Instructions

Deletes a media item.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
idYesThe ID of the media item to delete.
forceNoIf true, permanently delete. If false, move to trash. Defaults to false.

Implementation Reference

  • Tool registration and schema definition for wp_delete_media, including name, description, input parameters (id: number required, force: boolean optional), and handler binding.
    {
      name: "wp_delete_media",
      description: "Deletes a media item.",
      parameters: [
        {
          name: "id",
          type: "number",
          required: true,
          description: "The ID of the media item to delete.",
        },
        {
          name: "force",
          type: "boolean",
          description: "If true, permanently delete. If false, move to trash. Defaults to false.",
        },
      ],
      handler: this.handleDeleteMedia.bind(this),
    },
  • The core handler function that implements wp_delete_media tool logic: extracts id and force params, calls WordPressClient.deleteMedia, handles success response and errors.
    public async handleDeleteMedia(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const { id, force } = params as { id: number; force?: boolean };
      try {
        await client.deleteMedia(id, force);
        const action = force ? "permanently deleted" : "moved to trash";
        return `✅ Media item ${id} has been ${action}`;
      } catch (_error) {
        throw new Error(`Failed to delete media: ${getErrorMessage(_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, what permissions are required, whether deletion is reversible (via trash), rate limits, or what happens to associated files. The 'force' parameter in the schema hints at trash behavior, but the description doesn't explain this.

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.

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 cover behavioral aspects like irreversibility, permissions, or response format. Given the complexity of a delete operation in WordPress (with trash functionality hinted in schema), more context is needed.

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 context beyond what's in the schema (like explaining what a 'media item' ID refers to or site targeting logic). Baseline 3 is appropriate when 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 verb ('Deletes') and resource ('a media item'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like wp_delete_post or wp_delete_comment, which follow the same pattern for different resource types.

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 about when to use this tool versus alternatives. The description doesn't mention prerequisites, when deletion is appropriate, or how it relates to other deletion tools (like wp_delete_post for posts). The agent must infer usage from the tool 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

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/docdyhr/mcp-wordpress'

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