bricks_get_component_usage

UtilityBeginnerRead OnlyComplexity: 2/10
Check where a component is used and instance counts

Overview

Retrieves usage statistics for a Bricks Component, showing which pages, templates, and posts use it along with instance counts. This tool is essential for understanding the impact of modifying or deleting a component.

Use this tool before making breaking changes to a component (updating properties, renaming, or deleting) to understand how many instances exist across the site and where they are located.

Key Features

Page-Level Detail
Returns the specific page IDs and titles where the component is used, with instance counts per page.
Template Coverage
Also checks templates (header, footer, section templates) for component instances, not just regular pages.
Total Count
Provides a total instance count across all pages and templates for quick assessment of component importance.

When to Use

Before deleting a component to verify it is safe to remove
Before making breaking changes to a component to understand the impact
When auditing component usage across the site
When deciding whether to update a component or create a new version
Prerequisites
Component ID must be known (from bricks_get_components or bricks_create_component)

When NOT to Use

When you just need to list all components — use bricks_get_components
When you want to modify the component itself — use bricks_update_component

Parameters

1 Total Parameters1 Required

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 check usage for

Code Examples

Check component usage before deletion

Verifies whether a component is in use and how many instances exist.

JSON
bricks_get_component_usage({
  component_id: "abc123"
})
Response
{
  "total_instances": 12,
  "pages": [
    { "id": 33, "title": "Homepage", "instance_count": 6 },
    { "id": 45, "title": "Services", "instance_count": 4 },
    { "id": 67, "title": "About Us", "instance_count": 2 }
  ],
  "templates": []
}

Common Mistakes

Deleting or modifying a component without checking usage first
Always run bricks_get_component_usage before bricks_delete_component or making breaking changes to bricks_update_component.
Wrong
bricks_delete_component({ component_id: "abc123", force: true })
Correct
bricks_get_component_usage({ component_id: "abc123" })
// Check total_instances > 0 before proceeding
bricks_delete_component({ component_id: "abc123" })

Tips & Warnings

Tips & Warnings

Always check before deleting: This tool is the safety net for component management. Make it a habit to run it before any destructive operation.

High instance counts: If a component has many instances, updating it (rather than deleting) is the safest approach. Updates propagate to all instances automatically.

Return Values

FieldTypeDescription
total_instancesnumberTotal number of component instances across the entire site
pagesarrayArray of page objects where the component is used, each with id, title, and instance_count
templatesarrayArray of template objects where the component is used

Related Tools

Technical Details

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

Changelog

v1.0
Initial release
20250101