woo-mcp-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 WooCommerce
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,389 @@
1
+ # woo-mcp-server
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org/)
5
+ [![MCP](https://img.shields.io/badge/MCP-STDIO-5b9dff)](https://modelcontextprotocol.io/)
6
+ [![WooCommerce](https://img.shields.io/badge/WooCommerce-REST%20v3-96588a)](https://woocommerce.github.io/woocommerce-rest-api-docs/)
7
+
8
+ **Model Context Protocol (MCP) server for WooCommerce** — so Claude Desktop, GPT-based agents, and any MCP client can manage products, orders, customers, coupons, reports, and more through **typed tools** with **Zod validation**.
9
+
10
+ Built on [`woocommerce-rest-ts-api`](https://www.npmjs.com/package/woocommerce-rest-ts-api) (OAuth 1.0a / HTTPS Basic Auth). This package is a thin orchestration layer — it does **not** reimplement the HTTP stack.
11
+
12
+ ---
13
+
14
+ ## Docs & interactive UI
15
+
16
+ | Resource | How to open | What you get |
17
+ |----------|-------------|----------------|
18
+ | **Developer presentation** (step-by-step + use cases) | `make ui-presentation` | Full slide deck: setup, tools, 6 use-case scenarios, live evidence, repo map |
19
+ | **Tool explorer dashboard** | `make ui` | Searchable catalog, mock tester, architecture, Claude config generator |
20
+ | **This README** | — | Install, env, tool reference, development |
21
+
22
+ ```bash
23
+ # From the monorepo root
24
+ make ui-presentation # http://127.0.0.1:8765/presentation.html
25
+ make ui # http://127.0.0.1:8765/ (tool explorer)
26
+ ```
27
+
28
+ Or open the static files directly:
29
+
30
+ - [`ui/presentation.html`](../../ui/presentation.html) — slide deck (keyboard: `←` `→`, `O` overview, `F` fullscreen)
31
+ - [`ui/index.html`](../../ui/index.html) — interactive tool explorer
32
+
33
+ ---
34
+
35
+ ## Why this exists
36
+
37
+ | Without MCP | With `woo-mcp-server` |
38
+ |-------------|------------------------|
39
+ | Agents invent raw `/wp-json/wc/v3/…` paths | Purpose-built tools: `woo_products_list`, … |
40
+ | OAuth 1.0a easy to get wrong | Library owns signing, retries, limits |
41
+ | One-off scripts per automation | One STDIO binary for any MCP host |
42
+ | Secrets leak into notebooks / prompts | Env-only credentials, fail-fast at startup |
43
+
44
+ ---
45
+
46
+ ## Features
47
+
48
+ - **60+ purpose-built tools** — `woo_{resource}_{action}` naming (no catch-all HTTP free-for-all)
49
+ - **Zod input + output validation** on every tool
50
+ - **Pagination metadata** (`total`, `totalPages`, `currentPage`) on list tools
51
+ - **Search tools** for products and customers; rich order filters
52
+ - **Batch tools** for products and orders (ERP-style sync)
53
+ - **Resources**: `woo://store/info`, `woo://api/schema`
54
+ - **Prompts**: `store-audit`, `order-report`, `inventory-check`
55
+ - **STDIO transport** — Claude Desktop compatible
56
+ - **Rate limiting** via `WC_RATE_LIMIT_PER_SECOND` (default `5`)
57
+ - **Fail-fast config** — missing `WC_URL` / `WC_KEY` / `WC_SECRET` aborts with a clear message
58
+ - **Live-tested** against WooCommerce **10.9.3** (Docker) — see [Live testing](#live-testing)
59
+
60
+ ---
61
+
62
+ ## Quick start
63
+
64
+ ### 1. Install
65
+
66
+ **From npm (recommended for agents / Claude Desktop):**
67
+
68
+ ```bash
69
+ npm install -g woo-mcp-server
70
+ # or one-shot without a global install
71
+ npx -y woo-mcp-server
72
+ ```
73
+
74
+ This pulls [`woocommerce-rest-ts-api`](https://www.npmjs.com/package/woocommerce-rest-ts-api) `^8` automatically.
75
+
76
+ **From this monorepo (development):**
77
+
78
+ ```bash
79
+ git clone https://github.com/Yuri-Lima/woocommerce-rest-api-ts-lib.git
80
+ cd woocommerce-rest-api-ts-lib
81
+ pnpm install
82
+ pnpm run build
83
+ ```
84
+
85
+ ### 2. Configure credentials
86
+
87
+ Create a **Read/Write** key under **WooCommerce → Settings → Advanced → REST API**.
88
+
89
+ ```bash
90
+ export WC_URL=https://mystore.com
91
+ export WC_KEY=ck_xxxxxxxx
92
+ export WC_SECRET=cs_xxxxxxxx
93
+ # Local HTTP Docker stores: leave query-string auth OFF (use OAuth)
94
+ export WC_QUERY_STRING_AUTH=false
95
+ ```
96
+
97
+ | Variable | Required | Default | Description |
98
+ |----------|----------|---------|-------------|
99
+ | `WC_URL` | **yes** | — | Store base URL |
100
+ | `WC_KEY` | **yes** | — | Consumer key (`ck_…`) |
101
+ | `WC_SECRET` | **yes** | — | Consumer secret (`cs_…`) |
102
+ | `WC_VERSION` | no | `wc/v3` | API version prefix |
103
+ | `WC_RATE_LIMIT_PER_SECOND` | no | `5` | Outbound throttle |
104
+ | `WC_QUERY_STRING_AUTH` | no | `false` | `true` on some HTTPS hosts only |
105
+
106
+ ### 3. Run the server
107
+
108
+ ```bash
109
+ npx woo-mcp-server
110
+ # or from monorepo
111
+ pnpm --filter woo-mcp-server start
112
+ ```
113
+
114
+ ### 4. Wire Claude Desktop
115
+
116
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS):
117
+
118
+ ```json
119
+ {
120
+ "mcpServers": {
121
+ "woocommerce": {
122
+ "command": "npx",
123
+ "args": ["woo-mcp-server"],
124
+ "env": {
125
+ "WC_URL": "https://mystore.com",
126
+ "WC_KEY": "ck_xxxxxxxx",
127
+ "WC_SECRET": "cs_xxxxxxxx",
128
+ "WC_RATE_LIMIT_PER_SECOND": "5"
129
+ }
130
+ }
131
+ }
132
+ }
133
+ ```
134
+
135
+ **Local monorepo (dev):**
136
+
137
+ ```json
138
+ {
139
+ "mcpServers": {
140
+ "woocommerce": {
141
+ "command": "node",
142
+ "args": ["/absolute/path/to/packages/mcp-server/dist/cli.js"],
143
+ "env": {
144
+ "WC_URL": "https://mystore.com",
145
+ "WC_KEY": "ck_xxxxxxxx",
146
+ "WC_SECRET": "cs_xxxxxxxx"
147
+ }
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Architecture
156
+
157
+ ```
158
+ AI client (Claude Desktop / custom MCP agent)
159
+ │ MCP over STDIO
160
+
161
+ ┌─────────────────────────────────┐
162
+ │ woo-mcp-server │
163
+ │ • Zod input validation │
164
+ │ • Domain tool handlers │
165
+ │ • Rate limiter │
166
+ │ • Error normalization │
167
+ │ • Zod output validation │
168
+ └───────────────┬─────────────────┘
169
+ │ woocommerce-rest-ts-api
170
+
171
+ WooCommerce REST API (OAuth 1.0a / HTTPS)
172
+ ```
173
+
174
+ The parent library remains the source of truth for HTTP, auth, retries, and types. MCP never rewrites `src/` of the library.
175
+
176
+ ---
177
+
178
+ ## Use-case scenarios
179
+
180
+ Walk through these end-to-end in the [developer presentation](../../ui/presentation.html) (`make ui-presentation`).
181
+
182
+ | # | Scenario | Primary tools / prompts |
183
+ |---|----------|-------------------------|
184
+ | 1 | **Support copilot** — “Where is my order?” | `woo_customers_search` → `woo_orders_list` / `get` → `woo_orders_notes_create` |
185
+ | 2 | **Inventory ops** — weekly low-stock list | prompt `inventory-check` + `woo_products_list` / variations |
186
+ | 3 | **Sales report agent** — monthly narrative | prompt `order-report` + `woo_reports_*` |
187
+ | 4 | **Catalog SEO audit** | prompt `store-audit` (read-only until human approves updates) |
188
+ | 5 | **Bulk import / price sync** | `woo_products_batch` / `woo_orders_batch` |
189
+ | 6 | **Custom agent runtime** | MCP SDK client over STDIO (see presentation slide) |
190
+
191
+ ---
192
+
193
+ ## Tool reference
194
+
195
+ Naming: `woo_{resource}_{action}`. Every tool description is multi-sentence (what + when/why).
196
+
197
+ ### Products
198
+
199
+ | Tool | Description | Required |
200
+ |------|-------------|---------|
201
+ | `woo_products_list` | List products with filters & pagination | — |
202
+ | `woo_products_get` | Get product by ID | `id` |
203
+ | `woo_products_create` | Create product | `name` |
204
+ | `woo_products_update` | Update product fields | `id`, `data` |
205
+ | `woo_products_delete` | Delete product | `id` |
206
+ | `woo_products_search` | Free-text product search | `query` |
207
+ | `woo_products_batch` | Batch create/update/delete | create/update/delete arrays |
208
+
209
+ ### Orders
210
+
211
+ | Tool | Description | Required |
212
+ |------|-------------|---------|
213
+ | `woo_orders_list` | List orders (status, dates, customer) | — |
214
+ | `woo_orders_get` | Get order by ID | `id` |
215
+ | `woo_orders_create` | Create order | — |
216
+ | `woo_orders_update` | Update order | `id`, `data` |
217
+ | `woo_orders_delete` | Delete order | `id` |
218
+ | `woo_orders_notes_list` | List order notes | `order_id` |
219
+ | `woo_orders_notes_create` | Add order note | `order_id`, `note` |
220
+ | `woo_orders_batch` | Batch order operations | create/update/delete arrays |
221
+
222
+ ### Customers
223
+
224
+ | Tool | Description | Required |
225
+ |------|-------------|---------|
226
+ | `woo_customers_list` | List customers | — |
227
+ | `woo_customers_get` | Get customer | `id` |
228
+ | `woo_customers_create` | Create customer | `email` |
229
+ | `woo_customers_update` | Update customer | `id`, `data` |
230
+ | `woo_customers_delete` | Delete customer | `id` |
231
+ | `woo_customers_search` | Search customers | `query` |
232
+
233
+ ### Coupons
234
+
235
+ | Tool | Description | Required |
236
+ |------|-------------|---------|
237
+ | `woo_coupons_list` | List coupons | — |
238
+ | `woo_coupons_get` | Get coupon | `id` |
239
+ | `woo_coupons_create` | Create coupon | `code` |
240
+ | `woo_coupons_update` | Update coupon | `id`, `data` |
241
+ | `woo_coupons_delete` | Delete coupon | `id` |
242
+
243
+ ### Categories & tags
244
+
245
+ | Tool | Description | Required |
246
+ |------|-------------|---------|
247
+ | `woo_categories_list` / `get` / `create` / `update` / `delete` | Product categories CRUD | varies |
248
+ | `woo_tags_list` / `get` / `create` / `update` / `delete` | Product tags CRUD | varies |
249
+
250
+ ### Variations
251
+
252
+ | Tool | Description | Required |
253
+ |------|-------------|---------|
254
+ | `woo_variations_list` | List variations | `product_id` |
255
+ | `woo_variations_get` | Get variation | `product_id`, `id` |
256
+ | `woo_variations_create` | Create variation | `product_id`, `data` |
257
+ | `woo_variations_update` | Update variation | `product_id`, `id`, `data` |
258
+ | `woo_variations_delete` | Delete variation | `product_id`, `id` |
259
+
260
+ ### Shipping
261
+
262
+ | Tool | Description | Required |
263
+ |------|-------------|---------|
264
+ | `woo_shipping_zones_list` / `get` | Shipping zones | — / `id` |
265
+ | `woo_shipping_zone_methods_list` | Methods in a zone | `zone_id` |
266
+ | `woo_shipping_methods_list` | Method types | — |
267
+ | `woo_shipping_classes_list` / `get` | Shipping classes | — / `id` |
268
+
269
+ ### Payments
270
+
271
+ | Tool | Description | Required |
272
+ |------|-------------|---------|
273
+ | `woo_payments_list` | List payment gateways | — |
274
+ | `woo_payments_get` | Get gateway | `id` |
275
+ | `woo_payments_update` | Update gateway settings | `id`, `data` |
276
+
277
+ ### Reports
278
+
279
+ | Tool | Description | Required |
280
+ |------|-------------|---------|
281
+ | `woo_reports_sales` | Sales report | — |
282
+ | `woo_reports_top_sellers` | Top sellers | — |
283
+ | `woo_reports_orders_totals` | Orders by status | — |
284
+ | `woo_reports_customers_totals` | Customer totals | — |
285
+ | `woo_reports_products_totals` | Product type totals | — |
286
+ | `woo_reports_coupons_totals` | Coupon totals | — |
287
+ | `woo_reports_reviews_totals` | Review totals | — |
288
+
289
+ ### Settings · system status · webhooks · tax
290
+
291
+ | Domain | Tools |
292
+ |--------|--------|
293
+ | Settings | `woo_settings_groups_list`, `woo_settings_list`, `woo_settings_get`, `woo_settings_update` |
294
+ | System status | `woo_system_status_get`, `woo_system_status_tools_list`, `woo_system_status_tools_run` |
295
+ | Webhooks | `woo_webhooks_list` / `get` / `create` / `update` / `delete` |
296
+ | Tax | `woo_tax_rates_*`, `woo_tax_classes_list` / `get` |
297
+
298
+ ---
299
+
300
+ ## Resources
301
+
302
+ | URI | Description |
303
+ |-----|-------------|
304
+ | `woo://store/info` | Store name, URL, currency, timezone, WC/WP/PHP versions |
305
+ | `woo://api/schema` | Endpoint map + corresponding MCP tool names |
306
+
307
+ ## Prompts
308
+
309
+ | Name | Description |
310
+ |------|-------------|
311
+ | `store-audit` | Audit products for missing images, descriptions, categories, stock, SEO |
312
+ | `order-report` | Sales summary by status/revenue/top products for a date range |
313
+ | `inventory-check` | Find low-stock products, group by category, suggest reorder qty |
314
+
315
+ ---
316
+
317
+ ## Development
318
+
319
+ ```bash
320
+ # From repo root
321
+ pnpm install
322
+ pnpm run build # library + mcp-server
323
+ pnpm --filter woo-mcp-server test # unit + integration (nock; ≥80% coverage)
324
+ pnpm --filter woo-mcp-server typecheck
325
+ ```
326
+
327
+ ### Package layout
328
+
329
+ ```
330
+ packages/mcp-server/
331
+ src/
332
+ server.ts # MCP bootstrap (STDIO)
333
+ cli.ts # bin entry (woo-mcp-server)
334
+ config.ts # env validation
335
+ client.ts # rate-limited WooCommerce client + cleanParams
336
+ types.ts # shared Zod schemas
337
+ errors.ts # MCP error normalization
338
+ registry.ts # registers all tools/resources/prompts
339
+ tools/ # one file per domain
340
+ resources/
341
+ prompts/
342
+ tests/
343
+ tools/
344
+ integration/ # e2e (in-memory MCP) + live-store (opt-in)
345
+ fixtures/
346
+ ```
347
+
348
+ ### Live testing
349
+
350
+ There is no public shared WooCommerce sandbox with write keys. Use the free local Docker stack:
351
+
352
+ ```bash
353
+ cd scripts/live-wc
354
+ docker compose up -d
355
+ ./bootstrap.sh
356
+ export $(grep -v '^#' .env.live | xargs)
357
+ export WC_QUERY_STRING_AUTH=false
358
+ export LIVE_WC=1
359
+
360
+ pnpm --filter woo-mcp-server test -- tests/integration/live-store.test.ts
361
+ ```
362
+
363
+ See [`scripts/live-wc/README.md`](../../scripts/live-wc/README.md). Proven against **WordPress 7 + WooCommerce 10.9.3** over OAuth on `http://127.0.0.1:8088`.
364
+
365
+ ---
366
+
367
+ ## Library vs MCP — when to use which
368
+
369
+ | Need | Use the library directly | Use `woo-mcp-server` |
370
+ |------|--------------------------|----------------------|
371
+ | Backend service / worker | Yes — typed TS imports | Optional |
372
+ | AI agent / Claude / GPT tools | — | **Yes — designed for this** |
373
+ | Fine-grained control of every request | Yes | — |
374
+ | Shared tool schemas across models | — | Yes (Zod → MCP) |
375
+
376
+ ---
377
+
378
+ ## Security notes
379
+
380
+ - **Never** commit real `ck_` / `cs_` keys.
381
+ - Prefer OAuth over HTTP local stores (`WC_QUERY_STRING_AUTH=false`).
382
+ - Batch `delete` with `force: true` is permanent — dry-run on staging/Docker first.
383
+ - The server only exposes the fixed tool surface; models cannot invent arbitrary endpoints.
384
+
385
+ ---
386
+
387
+ ## License
388
+
389
+ MIT — same as the parent library [`woocommerce-rest-ts-api`](https://github.com/Yuri-Lima/woocommerce-rest-api-ts-lib).