Skip to main content
Glama

WooCommerce: Attach media to product

woocommerce_attach_media_to_product
Destructive

Attach existing media library items to a WooCommerce product as the main image or gallery images; choose append to preserve the gallery or replace to rewrite it.

Instructions

[UNIFIED] Attach existing media library items to a WooCommerce product. Use role='main' for the primary image (gallery index 0) or role='gallery' for extra images. mode='append' preserves the existing gallery; mode='replace' wipes and rewrites it.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "site": "<site>",
      "product_id": "<product_id>",
      "media_ids": "<media_ids>"
    },
    "name": "woocommerce_attach_media_to_product"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNoappend
roleNogallery
siteYes
media_idsYes
product_idYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv3.14.0

TDQS

A4.1/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already flag destructiveHint=true, and the description earns credit by making that concrete: mode='replace' "wipes and rewrites" the gallery, which tells the agent precisely what data is lost. It also states the default-preserving behavior of append, so the agent can reason about reversibility before calling a mutation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, each doing distinct work: what the tool does, how role selects the target slot, and how mode governs preservation. The destructive caveat is stated plainly with no filler or repetition.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive 5-parameter mutation with no output schema, the definition covers the two parameters whose semantics are non-obvious and discloses the destructive path. Minor gaps remain around ordering of media_ids, error behavior for invalid IDs, and what the call returns, but nothing critical to invoking it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% across 5 parameters, so the description carries the burden here. It does explain role and mode with their defaults and effects, but site, product_id, and media_ids are left entirely to inference from their names, including whether media_ids is ordered for gallery placement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

"Attach existing media library items to a WooCommerce product" gives a specific verb and resource, and the word "existing" separates it from the sibling woocommerce_upload_and_attach_to_product, which presumably uploads new files. The sibling is never named explicitly, so the differentiation rests on the adjective rather than a direct contrast.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description tells the agent exactly which parameter values to pick for the two common intents: role='main' for the primary image, role='gallery' for extras, and mode='append' vs 'replace' for gallery preservation. It stops short of stating when to prefer this tool over the upload-and-attach sibling or what preconditions (e.g. media must already exist on the site) are required.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools