Skip to main content
Glama

Delete media

wp_delete_media
Destructive

Permanently deletes a WordPress media library attachment and its metadata, server file, and image sizes; it also removes the file as a featured image. No trash recovery.

Instructions

Delete one file of the media library (attachment) for good: its entry and metadata are removed, and WordPress deletes the file and its image sizes on the server (a file the server does not let it delete stays, without an error). The media library has no trash here. It is removed as featured image wherever it was one; posts that embed or link it keep its old URL. Needs the right to delete that file. Returns {deleted: true, id}; an id that no longer exists returns a not-found error. Posts and pages are deleted with wp_delete_post.

Input Schema

NameRequiredDescriptionDefault
idYesAttachment id of the file to delete.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv4.7.0

TDQS

A4.7/5.0
Behavior5/5

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

Goes well beyond the destructiveHint annotation: it discloses that metadata and the file plus generated image sizes are removed, that undeletable files fail silently without an error, that featured-image references are cleared while embedded/linked URLs persist, and that a stale id returns not-found. That is exactly the kind of side-effect detail an agent needs before a destructive call.

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?

A single dense paragraph that front-loads the destructive action and its consequence, then layers permissions, return shape, and the alternative tool. Every clause carries distinct information with no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, but the description supplies the return shape ({deleted: true, id}) and the error case, plus the full deletion side-effect profile. Nothing an agent needs to invoke this destructive tool safely is missing.

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%, so the single 'id' parameter is already documented in the schema and the description only echoes it. It does add one behavioral nuance — a nonexistent id yields a not-found error — but no syntax or format guidance beyond that, so the baseline 3 applies.

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?

States a specific verb and resource ('Delete one file of the media library (attachment)') and explicitly scopes itself against the sibling wp_delete_post for posts/pages. The agent can distinguish it from wp_update_media or wp_delete_post without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Covers when to use it (deleting an attachment permanently) and points to wp_delete_post for a different resource, making the boundary explicit. It also flags the prerequisite ('Needs the right to delete that file') and that there is no trash, so the agent knows this is not a recoverable soft delete.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools