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)}`); } }

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