bricks_delete_component

UtilityIntermediateDestructiveComplexity: 4/10
Delete a component with usage check

Overview

Deletes a Bricks Component from the site. By default, the tool checks whether the component is currently used on any pages and returns a warning with usage details if instances are found. Use force=true to bypass this safety check and delete the component regardless of usage.

Deleting a component that is in use will cause existing instances on pages to break or render empty. Always check usage first with bricks_get_component_usage before deleting.

Key Features

Usage Safety Check
By default, checks if the component is used on any pages and returns a warning with details. Prevents accidental deletion of active components.
Force Delete
Set force=true to delete the component even if it has active instances. Use with caution — existing instances will break.

When to Use

When removing an unused component that is no longer needed
When cleaning up test or draft components during development
When replacing a component with a better version (delete old after migrating instances)
Prerequisites
Component ID must be known (from bricks_get_components)
Recommended: Run bricks_get_component_usage to verify no active instances exist
If instances exist, update them to use a different component or inline the elements first

When NOT to Use

When the component is actively used on pages — migrate instances first
When you want to update a component — use bricks_update_component instead
When unsure if the component is in use — run bricks_get_component_usage first

Parameters

2 Total Parameters1 Required1 Optional

Warning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
component_idstringREQUIRED
ID of the component to delete

Warning: Undefined array key "param_enum_values" in /var/www/vhosts/mcpbricksbuilder.wecode.swiss/httpdocs/wp-content/themes/bricks/includes/elements/code.php(236) : eval()'d code on line 28
forcebooleanoptional
Force delete even if the component is in use on pages. Defaults to false.
Default: false

Code Examples

Safe delete with usage check

Attempts to delete a component. If it is in use, returns a warning instead of deleting.

JSON
bricks_delete_component({
  component_id: "abc123",
  force: false
})
Response
// If unused:
{ "success": true, "message": "Component deleted successfully" }

// If in use:
{ "success": false, "message": "Component is in use on 3 pages. Use force=true to delete anyway.", "usage": { "pages": [33, 45, 67], "instance_count": 8 } }

Common Mistakes

Force-deleting a component without checking usage first
Always run bricks_get_component_usage before deleting. Migrate instances to a new component or inline the elements before deletion.
Wrong
bricks_delete_component({ component_id: "abc123", force: true })
Correct
// Step 1: Check usage
bricks_get_component_usage({ component_id: "abc123" })
// Step 2: Migrate instances if needed
// Step 3: Then delete safely
bricks_delete_component({ component_id: "abc123" })

Tips & Warnings

Tips & Warnings

Destructive operation: Deleting a component that is in use will cause existing instances to render empty or break. Always check usage first.

No undo: Component deletion cannot be undone. If you need a backup, use bricks_get_components({ include_elements: true }) to export the component definition before deleting.

Return Values

FieldTypeDescription
successbooleanWhether the component was deleted successfully
messagestringConfirmation message or warning if component is in use
usageobjectUsage details if deletion was blocked (pages and instance counts)

Related Tools

Technical Details

Tool ID
bricks_delete_component
API Endpoint
/bricks-mcp/v1/components/{component_id}
HTTP Method
DELETE
Namespace
components
Source File
components/components.ts
Version
1.0
Min Bricks Version
1.9
Requires Auth
Yes

Changelog

v1.0
Initial release
20250101