wc_create_product_attribute: create a product attribute
Creates a new global attribute for the shop — a shop-wide structure, not something attached to a single product.
Arguments
| Argument | Required | Meaning |
|---|---|---|
name |
Yes | The display label |
slug |
No | The internal identifier; derived from the name if omitted |
type |
No | How values are chosen; defaults to select |
order_by |
No | How terms are ordered; defaults to menu_order |
has_archives |
No | Whether the attribute gets public archive pages |
dry_run |
No | Report without creating |
The response is attribute_id.
Permissions
Allow WooCommerce catalog writes open, plus manage_woocommerce or edit_products.
Check whether it already exists
Nothing prevents duplicates. "Colour" and "Color", or "Size" created twice, will both exist, each with its own separate term list, and products will split between them.
Unpicking that later means editing every affected product by hand.
List the shop's attributes and tell me whether anything like this already exists. Do not create it yet.
It creates an empty attribute
The attribute is created with no terms, and no MCP tool can add terms. Someone has to open Products → Attributes in the WordPress admin and add the values.
So this tool completes one third of a job:
- Create the attribute — here.
- Add its terms — admin only.
- Attach it to products —
wc_set_product_attributes.
An assistant that creates an attribute and moves straight to variations will build them against an empty term list, and every one of them will be unselectable. Expect to leave the conversation and finish step 2 by hand.
has_archives publishes URLs
Enabling archives gives the attribute public pages — one per term — that search engines can index. That is a decision about the shop's public structure and its SEO, not a detail.
Leave it off unless someone has decided those pages should exist. Turning it on later is easy; retracting indexed URLs is not.
The slug is permanent in practice
It becomes part of the underlying taxonomy name, which variations and stored product data reference. Renaming it afterwards from the admin is possible but disruptive.
Pick it deliberately, and pass it explicitly rather than letting it be derived from a label that might be reworded later.
order_by controls storefront display
It decides how terms are listed in the product's selector — the manual menu_order by default, rather than alphabetically. It affects presentation only, and can be changed at any time.
The dry run
Returns the exact payload it would submit, including the slug it derived and the defaults it filled in. Worth using precisely because those defaults are invisible otherwise:
Dry-run creating a "Material" attribute and show me the slug and type it would use.
If the tool errors immediately
pom_ai_mcp_wc_attribute_api_missing means WooCommerce's attribute API is unavailable in this installation. It is not a permissions problem and not something you can retry around — the attribute has to be created from the admin.
After creating
- List the attributes and confirm the new ID.
- Add its terms in the WordPress admin.
- List the terms to confirm they are visible to MCP.
- Only then attach it to a product.
Common problems
| Symptom | Cause |
|---|---|
| The write is refused | Catalog write gate closed |
pom_ai_mcp_wc_attribute_api_missing |
WooCommerce's attribute API is unavailable |
pom_ai_mcp_wc_forbidden |
Missing shop capability |
| Two similar attributes now exist | Duplicates are not prevented |
| The attribute has no values | Expected; add terms in the admin |
| Unexpected public pages appeared | has_archives was enabled |
Related
wc_get_product_attributes— check for duplicates firstwc_get_attribute_termswc_set_product_attributes