Delete Theme File


Deletes a theme file in the theme draft; the live theme keeps it until the draft is published. The files a theme cannot work without, such as style.css, are refused.

Property Value
Ability slug mosmcp/theme-file-delete
Wire tool name mosmcp__theme-file-delete
Category Theme: Files (mosmcp-theme-files)
Plan Free

 

Required access

Requirement Value
Capability edit_theme_options
Minimum default role Administrator (Shop manager too when WooCommerce is active)
Annotations readOnly: false · destructive: false · idempotent: true · openWorld: false

 

Input schema

Field Type Required Default Description
path string Yes — Path inside the theme.

 

Output schema

Field Type Required Description
staged boolean Yes
target string
change string
draft object Yes
draft.exists boolean
draft.change_count integer
draft.templates string[]
draft.template_parts string[]
draft.global_styles string
draft.patterns string[]
draft.files string[]
draft.site_identity string[] Pending logo and site icon changes.
draft.custom_css string[] Pending change to the Customizer's Additional CSS. A block theme's Additional CSS is part of global styles.
draft.theme_settings string[] Pending theme (Customizer) settings.
draft.created string
draft.updated string
draft.preview_ready boolean
next_step string
notes string[]

 

Example

Sample prompt
Remove the old assets/css/legacy.css file from my theme.

Example request (json)

{
  "jsonrpc": "2.0",
  "id": 301,
  "method": "tools/call",
  "params": {
    "name": "mosmcp__theme-file-delete",
    "arguments": {
      "input": {
        "path": "assets/css/legacy.css"
      }
    }
  }
}

Example response (json)

{
  "jsonrpc": "2.0",
  "id": 301,
  "result": {
    "isError": false,
    "structuredContent": {
      "staged": true,
      "target": "the theme file \"assets/css/legacy.css\"",
      "change": "deleted",
      "draft": {
        "exists": true,
        "change_count": 1,
        "files": [
          "assets/css/legacy.css (delete)"
        ],
        "created": "2026-09-29 10:25:00 UTC",
        "updated": "2026-09-29 10:25:00 UTC",
        "preview_ready": false
      },
      "next_step": "Nothing has changed on the live site yet. Preview the draft with mosmcp/theme-draft-preview, then publish it with mosmcp/theme-draft-publish.",
      "notes": [
        "If the theme still includes or references this file, the draft health check will catch it before anything is published."
      ]
    }
  }
}

 

Edge cases / errors

  • Protected file (style.css, plus index.php for classic themes or templates/index.html for block themes; only style.css in a child theme) → refused with mosmcp_theme_file_protected.
  • File doesn't exist → mosmcp_theme_file_not_found.
  • Deleting a pattern file a template still uses → a note warns that area will be left empty.
  • The live theme keeps the file until the draft is published.

 


<< Previous Next >>
Update Theme Template Part Edit Theme File

For more information about the Secure MCP Server for WordPress plugin, explore the following resources:

Product Overview | Pricing | Try for Free | Documentation

If you have any questions regarding plugin configuration, pricing plans or licensing, please contact us or mail us at aisupport@xecurify.com.