feat: WooCommerce product variations & attribute management (10 new MCP tools) - #1
Draft
ober37 wants to merge 8 commits into
Draft
feat: WooCommerce product variations & attribute management (10 new MCP tools)#1ober37 wants to merge 8 commits into
ober37 wants to merge 8 commits into
Conversation
… tool consistency - Server.php: protocolVersion 2025-03-26 → 2025-11-25 (Claude Desktop compat) - Server.php: handle_get_stream returns 405 instead of immediate-close SSE to stop mcp-remote retry loop - wp_get_taxonomies: add `slug` field as clearer alias for taxonomy id - wp_get_term_meta: structured response matching update/delete tools Server.php fixes contributed by Brian Ober via PR royalplugins#5. Co-authored-by: Brian Ober <ober37@gmail.com>
…tegration), refresh MCP spec to 2025-11-25, document ForgeCache/Royal Ledger/Royal Links integrations
…h CONTRIBUTING MCP spec link
…es 1 & 2) - wc_get_product_variations, wc_get_variation, wc_create_variation - wc_update_variation, wc_delete_variation, wc_batch_update_variations - wc_get_product_attributes, wc_get_attribute_terms - wc_create_product_attribute, wc_set_product_attributes - Parent price cache synced via WC_Product_Variable::sync() after mutations - Attribute term lookup accepts slug or numeric ID - set_product_attributes warns when existing attributes are overwritten - All Phase 4b bug fixes included (double pa_ prefix, batch loop, wc_create_attribute)
- Phase 4b: pa_ prefix already on attr slug, remove wc_register_attribute_taxonomies(), add existing_attribute_count warning on set_product_attributes - protocolVersion: 2025-03-26 → 2025-11-25 for Claude Desktop compatibility - handle_get_stream: return 405 to prevent mcp-remote SSE reconnection loop - wc_get_product_attributes: use stdClass() for empty properties (valid JSON object) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- wc_update_variation: call WC_Product_Variable::sync() after save so parent product price/stock cache stays fresh - wc_delete_variation: same sync after delete - wc_batch_update_variations (update loop): validate variation belongs to product_id before applying changes — matches single-variation behaviour - wc_batch_update_variations (delete loop): same parent-ownership check - wc_batch_update_variations description: document that deletes are always permanent and operations are scoped to product_id Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ober37
force-pushed
the
pr/wc-variations-upstream
branch
from
May 1, 2026 01:40
cb843c8 to
9fc6dab
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 10 new WooCommerce MCP tools for managing product variations and global attributes, plus two targeted bug fixes to
Server.phpthat affect all users runningmcp-remoteagainst this plugin.New tools (10)
Variation CRUD (6)
wc_get_product_variations— list all variations for a variable productwc_get_variation— get a single variation by ID (validates parent ownership)wc_create_variation— create a new variation with full field supportwc_update_variation— update price, stock, attributes, dimensions, etc.wc_delete_variation— permanently or soft-delete a variationwc_batch_update_variations— create, update, and delete in a single callAttribute management (4)
wc_get_product_attributes— list all registered globalpa_*attribute taxonomieswc_get_attribute_terms— list terms for a global attribute (by ID or taxonomy slug)wc_create_product_attribute— register a new global attribute taxonomywc_set_product_attributes— assign attributes to a variable product (required before creating variations)Files changed
includes/Integrations/WooCommerce.phpincludes/API/REST_Controller.phpincludes/MCP/Server.phpBug fixes in
Server.phpThese fixes affect all users of this plugin with
mcp-remote, not just WooCommerce users.1.
protocolVersion:2025-03-26→2025-11-25The MCP protocol is date-versioned. Current Claude Desktop builds send
protocolVersion: 2025-11-25in theirinitializehandshake. When the server responds with2025-03-26, Claude Desktop silently rejects the entire tool list — no error, no warning, tools simply don't appear. Bumping the server's declared version to2025-11-25restores compatibility with current Claude Desktop builds.2.
handle_get_stream(): return 405 instead of 200+immediate-closeThe existing
handle_get_stream()returns HTTP 200 with SSE headers but immediately closes the stream (as noted in the code comment).mcp-remotetreats an immediately-closed stream as a dropped connection and retries rapidly. After 2–3 retries the server returns 429,mcp-remotegives up, and the entire MCP connection drops — taking all tools with it.Returning
405 Method Not AllowedwithAllow: POST, DELETE, OPTIONSis the correct HTTP signal for "this method is not supported here." It stops the retry loop immediately. The original SSE implementation is preserved (unreachable) so it can be restored if full SSE support is added later.Implementation notes
check_permissioncallbackWC_Product_Variable::sync()called after every variation create, update, and delete to keep parent price/stock cache currentpa_*prefix handling is correct throughout with explanatory commentswc_set_product_attributesemits a warning when replacing pre-existing attributeswc_get_product_attributesusesnew \stdClass()for emptyproperties— PHP[]serializes to JSON array which fails MCP JSON Schema validation and silently breaks all toolsTesting
18 test cases against a live WooCommerce store — 18/18 passing:
tools/listreturns 86 tools, 0 invalid schemas