@cloudcart/storefront-mcp 0.0.0-stage → 0.2.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) 2026-present CloudCart AD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
11
+ ---
12
+
13
+ Portions of this software are adapted from code under the following licence:
14
+
15
+ Copyright 2023-present, Shopify Inc.
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,119 @@
1
- # Temporary Holding Version
1
+ # @cloudcart/storefront-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An MCP server for the **CloudCart Storefront GraphQL API** — the headless API
4
+ Nitrogen storefronts, the mobile app and other clients are built on.
5
+
6
+ It is a developer's assistant, not a shop's. It runs on your machine, reads the
7
+ schema, and never talks to a store: no access token, no network, nothing that
8
+ could touch live data.
9
+
10
+ Its companion is [`@cloudcart/dev-mcp`](https://www.npmjs.com/package/@cloudcart/dev-mcp), which covers the **Admin**
11
+ API. The two APIs differ in more than scope — the Admin API uses plain numeric
12
+ ids, the Storefront API uses `gid://cloudcart/…` — so keep them apart.
13
+
14
+ ## Tools
15
+
16
+ | Tool | What it is for |
17
+ |---|---|
18
+ | `learn_cloudcart_storefront` | **Call first.** The whole API — catalog, collections, search, content, cart, checkout, customers, orders, returns, analytics — and what the schema cannot tell you: how a signed-in buyer is sent (never an `Authorization` header), that a Nitrogen storefront's checkout is the store's own (`cart.checkoutUrl`), that the server owns every price and money is shown as `formatted`, that facets come back with the products, that a cart is addressed by an unguessable key. |
19
+ | `introspect_graphql_schema` | Look up a type, query or mutation by name. Flags fields that stay empty unless the merchant runs the app behind them. |
20
+ | `validate_graphql_codeblocks` | Check GraphQL before it ships — both against the schema and against the mistakes that validate cleanly and still fail. |
21
+
22
+ There is deliberately no semantic search. The surface is small enough to look
23
+ up by name — `data/storefront.json` holds every type, query and mutation — and
24
+ `learn_cloudcart_storefront` names the operation for each step; an embedding
25
+ index would add size and a cold start to solve a problem this API does not have.
26
+
27
+ ## What the validator notes beyond schema errors
28
+
29
+ Things that pass validation and still go wrong:
30
+
31
+ - a **numeric cart id** — carts are addressed by their key, and a row number
32
+ resolves to nothing
33
+ - reading **delivery before there is an address** — couriers price against a
34
+ destination, so the list is empty
35
+ - reading `paymentMethods` **before delivery is chosen** — the courier decides
36
+ part of what is allowed
37
+ - selecting `amount` **without `formatted`** — fine for logic, but a buyer is
38
+ shown the amount as the store writes money
39
+ - a paged product list or search **without its facets** (`filters`,
40
+ `productFilters`) or **without `totalCount`** — the API already computed them
41
+ - a `metafield` asked for **without its `namespace`** — the store has no
42
+ app-reserved namespace, so a key alone finds nothing
43
+
44
+ It also answers names borrowed from other storefront APIs — `productByHandle`,
45
+ `checkoutCreate`, `cartDeliveryAddressesAdd`, `cartGiftCardCodesUpdate`,
46
+ `customerAccessTokenCreate` — each coming back with the CloudCart equivalent and
47
+ the reason it differs. Most of the
48
+ vocabulary is deliberately familiar; these are the places it is not.
49
+
50
+ ## Install
51
+
52
+ ```bash
53
+ npm install
54
+ npm run build
55
+ ```
56
+
57
+ `data/storefront.json` is part of the package: building needs no schema.
58
+
59
+ ## Regenerate the schema
60
+
61
+ `generate-schema` reads the SDL from the folder in `SF_SCHEMA_DIR`. Give it the
62
+ `sf/schema` files of the commit production runs, never a working copy: a
63
+ developer's queries go to production, and a type that exists only on a branch
64
+ would validate here and fail there. Export them from cc-builder:
65
+
66
+ ```bash
67
+ mkdir -p /tmp/sf-deployed
68
+ git -C /path/to/cc-builder archive <deployed commit> sf/schema | tar -x -C /tmp/sf-deployed
69
+ SF_SCHEMA_DIR=/tmp/sf-deployed/sf/schema npm run generate-schema
70
+ ```
71
+
72
+ The schema is assembled from those files rather than fetched from a running
73
+ store. They are what the server itself builds from — no store, no token, no
74
+ network.
75
+
76
+ ## Use it
77
+
78
+ The CloudCart AI Toolkit plugin registers it. To add it to an MCP host yourself:
79
+
80
+ ```json
81
+ {
82
+ "mcpServers": {
83
+ "cloudcart-storefront-mcp": {
84
+ "command": "npx",
85
+ "args": ["-y", "@cloudcart/storefront-mcp@latest"]
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ From a local build, the command is `node` with `/absolute/path/to/storefront-mcp/dist/index.js`.
92
+
93
+ ## After a schema change is deployed
94
+
95
+ Export the deployed commit's `sf/schema` as above, then:
96
+
97
+ ```bash
98
+ SF_SCHEMA_DIR=/tmp/sf-deployed/sf/schema npm run generate-schema && npm run build
99
+ ```
100
+
101
+ The shipped schema comes from that step, so run it after every deploy that
102
+ changes `sf/schema`.
103
+
104
+ ## Release
105
+
106
+ 1. Regenerate the schema from the deployed commit (above), `npm run build`, and check the three tools.
107
+ 2. Bump `version` in `package.json` (the server reads it from there), commit, push `main`; CI builds and checks the tools on Node 20, 22 and 24.
108
+ 3. `gh release create vX.Y.Z` — the `Publish to npm` workflow checks the tag equals the version and publishes. It needs the repository secret `NPM_TOKEN`.
109
+
110
+ ## Layout
111
+
112
+ ```
113
+ scripts/generate-schema.ts SDL in the repo → data/storefront.json
114
+ src/prompts/storefront.ts what an assistant must know before writing anything
115
+ src/app-resources.ts which fields depend on a merchant's installed apps
116
+ src/tools/ the three tools
117
+ src/schema/loader.ts reads and caches the introspection JSON
118
+ .github/workflows/ CI on every push; the npm release on a GitHub release
119
+ ```