shopify-store-mcp 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.
Files changed (88) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +172 -0
  3. package/dist/config.d.ts +10 -0
  4. package/dist/config.js +65 -0
  5. package/dist/db.d.ts +19 -0
  6. package/dist/db.js +161 -0
  7. package/dist/errors.d.ts +36 -0
  8. package/dist/errors.js +93 -0
  9. package/dist/graphql/admin/common/collections.d.ts +8 -0
  10. package/dist/graphql/admin/common/collections.js +44 -0
  11. package/dist/graphql/admin/common/customers.d.ts +13 -0
  12. package/dist/graphql/admin/common/customers.js +112 -0
  13. package/dist/graphql/admin/common/orders.d.ts +13 -0
  14. package/dist/graphql/admin/common/orders.js +142 -0
  15. package/dist/graphql/admin/common/products.d.ts +23 -0
  16. package/dist/graphql/admin/common/products.js +159 -0
  17. package/dist/graphql/admin/common/shop.d.ts +7 -0
  18. package/dist/graphql/admin/common/shop.js +38 -0
  19. package/dist/graphql/admin/index.d.ts +15 -0
  20. package/dist/graphql/admin/index.js +18 -0
  21. package/dist/graphql/admin/specialized/bulk.d.ts +33 -0
  22. package/dist/graphql/admin/specialized/bulk.js +132 -0
  23. package/dist/graphql/admin/specialized/files.d.ts +22 -0
  24. package/dist/graphql/admin/specialized/files.js +170 -0
  25. package/dist/graphql/admin/specialized/inventory.d.ts +13 -0
  26. package/dist/graphql/admin/specialized/inventory.js +78 -0
  27. package/dist/graphql/admin/specialized/metafields.d.ts +22 -0
  28. package/dist/graphql/admin/specialized/metafields.js +100 -0
  29. package/dist/graphql/admin/specialized/metaobjects.d.ts +36 -0
  30. package/dist/graphql/admin/specialized/metaobjects.js +239 -0
  31. package/dist/graphql/admin/specialized/search.d.ts +21 -0
  32. package/dist/graphql/admin/specialized/search.js +100 -0
  33. package/dist/graphql/collections.d.ts +1 -0
  34. package/dist/graphql/collections.js +37 -0
  35. package/dist/graphql/customers.d.ts +2 -0
  36. package/dist/graphql/customers.js +98 -0
  37. package/dist/graphql/inventory.d.ts +2 -0
  38. package/dist/graphql/inventory.js +67 -0
  39. package/dist/graphql/metafields.d.ts +2 -0
  40. package/dist/graphql/metafields.js +43 -0
  41. package/dist/graphql/orders.d.ts +2 -0
  42. package/dist/graphql/orders.js +116 -0
  43. package/dist/graphql/products.d.ts +4 -0
  44. package/dist/graphql/products.js +140 -0
  45. package/dist/graphql/shop.d.ts +1 -0
  46. package/dist/graphql/shop.js +32 -0
  47. package/dist/graphql/storefront/common/cart.d.ts +23 -0
  48. package/dist/graphql/storefront/common/cart.js +210 -0
  49. package/dist/graphql/storefront/common/collections.d.ts +11 -0
  50. package/dist/graphql/storefront/common/collections.js +114 -0
  51. package/dist/graphql/storefront/common/products.d.ts +14 -0
  52. package/dist/graphql/storefront/common/products.js +155 -0
  53. package/dist/graphql/storefront/index.d.ts +7 -0
  54. package/dist/graphql/storefront/index.js +8 -0
  55. package/dist/index.d.ts +2 -0
  56. package/dist/index.js +97 -0
  57. package/dist/logger.d.ts +58 -0
  58. package/dist/logger.js +165 -0
  59. package/dist/prompts/index.d.ts +2 -0
  60. package/dist/prompts/index.js +169 -0
  61. package/dist/queue.d.ts +73 -0
  62. package/dist/queue.js +120 -0
  63. package/dist/resources/index.d.ts +3 -0
  64. package/dist/resources/index.js +180 -0
  65. package/dist/shopify-client.d.ts +16 -0
  66. package/dist/shopify-client.js +39 -0
  67. package/dist/tools/graphql.d.ts +3 -0
  68. package/dist/tools/graphql.js +41 -0
  69. package/dist/tools/index.d.ts +3 -0
  70. package/dist/tools/index.js +23 -0
  71. package/dist/tools/infrastructure.d.ts +6 -0
  72. package/dist/tools/infrastructure.js +215 -0
  73. package/dist/tools/shop.d.ts +3 -0
  74. package/dist/tools/shop.js +28 -0
  75. package/dist/tools/smart-bulk.d.ts +7 -0
  76. package/dist/tools/smart-bulk.js +286 -0
  77. package/dist/tools/smart-files.d.ts +7 -0
  78. package/dist/tools/smart-files.js +169 -0
  79. package/dist/tools/smart-metaobjects.d.ts +7 -0
  80. package/dist/tools/smart-metaobjects.js +186 -0
  81. package/dist/tools/smart-schema.d.ts +7 -0
  82. package/dist/tools/smart-schema.js +138 -0
  83. package/dist/types.d.ts +19 -0
  84. package/dist/types.js +2 -0
  85. package/dist/utils/polling.d.ts +53 -0
  86. package/dist/utils/polling.js +77 -0
  87. package/package.json +83 -0
  88. package/prisma/schema.prisma +82 -0
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Storefront API GraphQL queries and mutations for cart operations
3
+ */
4
+ /**
5
+ * Create a new cart
6
+ */
7
+ export declare const STOREFRONT_CREATE_CART = "#graphql\n mutation StorefrontCreateCart($input: CartInput!) {\n cartCreate(input: $input) {\n cart {\n id\n checkoutUrl\n totalQuantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n subtotalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n edges {\n node {\n id\n quantity\n merchandise {\n ... on ProductVariant {\n id\n title\n product {\n title\n handle\n }\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\n";
8
+ /**
9
+ * Get an existing cart by ID
10
+ */
11
+ export declare const STOREFRONT_GET_CART = "#graphql\n query StorefrontGetCart($cartId: ID!) {\n cart(id: $cartId) {\n id\n checkoutUrl\n totalQuantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n subtotalAmount {\n amount\n currencyCode\n }\n totalTaxAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n edges {\n node {\n id\n quantity\n merchandise {\n ... on ProductVariant {\n id\n title\n product {\n title\n handle\n }\n price {\n amount\n currencyCode\n }\n image {\n url\n altText\n }\n }\n }\n }\n }\n }\n buyerIdentity {\n email\n phone\n countryCode\n }\n }\n }\n";
12
+ /**
13
+ * Add lines to an existing cart
14
+ */
15
+ export declare const STOREFRONT_ADD_CART_LINES = "#graphql\n mutation StorefrontAddCartLines($cartId: ID!, $lines: [CartLineInput!]!) {\n cartLinesAdd(cartId: $cartId, lines: $lines) {\n cart {\n id\n totalQuantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n edges {\n node {\n id\n quantity\n merchandise {\n ... on ProductVariant {\n id\n title\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\n";
16
+ /**
17
+ * Update lines in an existing cart
18
+ */
19
+ export declare const STOREFRONT_UPDATE_CART_LINES = "#graphql\n mutation StorefrontUpdateCartLines($cartId: ID!, $lines: [CartLineUpdateInput!]!) {\n cartLinesUpdate(cartId: $cartId, lines: $lines) {\n cart {\n id\n totalQuantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n }\n lines(first: 100) {\n edges {\n node {\n id\n quantity\n }\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\n";
20
+ /**
21
+ * Remove lines from an existing cart
22
+ */
23
+ export declare const STOREFRONT_REMOVE_CART_LINES = "#graphql\n mutation StorefrontRemoveCartLines($cartId: ID!, $lineIds: [ID!]!) {\n cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {\n cart {\n id\n totalQuantity\n cost {\n totalAmount {\n amount\n currencyCode\n }\n }\n }\n userErrors {\n field\n message\n }\n }\n }\n";
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Storefront API GraphQL queries and mutations for cart operations
3
+ */
4
+ /**
5
+ * Create a new cart
6
+ */
7
+ export const STOREFRONT_CREATE_CART = `#graphql
8
+ mutation StorefrontCreateCart($input: CartInput!) {
9
+ cartCreate(input: $input) {
10
+ cart {
11
+ id
12
+ checkoutUrl
13
+ totalQuantity
14
+ cost {
15
+ totalAmount {
16
+ amount
17
+ currencyCode
18
+ }
19
+ subtotalAmount {
20
+ amount
21
+ currencyCode
22
+ }
23
+ totalTaxAmount {
24
+ amount
25
+ currencyCode
26
+ }
27
+ }
28
+ lines(first: 100) {
29
+ edges {
30
+ node {
31
+ id
32
+ quantity
33
+ merchandise {
34
+ ... on ProductVariant {
35
+ id
36
+ title
37
+ product {
38
+ title
39
+ handle
40
+ }
41
+ price {
42
+ amount
43
+ currencyCode
44
+ }
45
+ image {
46
+ url
47
+ altText
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ userErrors {
56
+ field
57
+ message
58
+ }
59
+ }
60
+ }
61
+ `;
62
+ /**
63
+ * Get an existing cart by ID
64
+ */
65
+ export const STOREFRONT_GET_CART = `#graphql
66
+ query StorefrontGetCart($cartId: ID!) {
67
+ cart(id: $cartId) {
68
+ id
69
+ checkoutUrl
70
+ totalQuantity
71
+ cost {
72
+ totalAmount {
73
+ amount
74
+ currencyCode
75
+ }
76
+ subtotalAmount {
77
+ amount
78
+ currencyCode
79
+ }
80
+ totalTaxAmount {
81
+ amount
82
+ currencyCode
83
+ }
84
+ }
85
+ lines(first: 100) {
86
+ edges {
87
+ node {
88
+ id
89
+ quantity
90
+ merchandise {
91
+ ... on ProductVariant {
92
+ id
93
+ title
94
+ product {
95
+ title
96
+ handle
97
+ }
98
+ price {
99
+ amount
100
+ currencyCode
101
+ }
102
+ image {
103
+ url
104
+ altText
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+ buyerIdentity {
112
+ email
113
+ phone
114
+ countryCode
115
+ }
116
+ }
117
+ }
118
+ `;
119
+ /**
120
+ * Add lines to an existing cart
121
+ */
122
+ export const STOREFRONT_ADD_CART_LINES = `#graphql
123
+ mutation StorefrontAddCartLines($cartId: ID!, $lines: [CartLineInput!]!) {
124
+ cartLinesAdd(cartId: $cartId, lines: $lines) {
125
+ cart {
126
+ id
127
+ totalQuantity
128
+ cost {
129
+ totalAmount {
130
+ amount
131
+ currencyCode
132
+ }
133
+ }
134
+ lines(first: 100) {
135
+ edges {
136
+ node {
137
+ id
138
+ quantity
139
+ merchandise {
140
+ ... on ProductVariant {
141
+ id
142
+ title
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ userErrors {
150
+ field
151
+ message
152
+ }
153
+ }
154
+ }
155
+ `;
156
+ /**
157
+ * Update lines in an existing cart
158
+ */
159
+ export const STOREFRONT_UPDATE_CART_LINES = `#graphql
160
+ mutation StorefrontUpdateCartLines($cartId: ID!, $lines: [CartLineUpdateInput!]!) {
161
+ cartLinesUpdate(cartId: $cartId, lines: $lines) {
162
+ cart {
163
+ id
164
+ totalQuantity
165
+ cost {
166
+ totalAmount {
167
+ amount
168
+ currencyCode
169
+ }
170
+ }
171
+ lines(first: 100) {
172
+ edges {
173
+ node {
174
+ id
175
+ quantity
176
+ }
177
+ }
178
+ }
179
+ }
180
+ userErrors {
181
+ field
182
+ message
183
+ }
184
+ }
185
+ }
186
+ `;
187
+ /**
188
+ * Remove lines from an existing cart
189
+ */
190
+ export const STOREFRONT_REMOVE_CART_LINES = `#graphql
191
+ mutation StorefrontRemoveCartLines($cartId: ID!, $lineIds: [ID!]!) {
192
+ cartLinesRemove(cartId: $cartId, lineIds: $lineIds) {
193
+ cart {
194
+ id
195
+ totalQuantity
196
+ cost {
197
+ totalAmount {
198
+ amount
199
+ currencyCode
200
+ }
201
+ }
202
+ }
203
+ userErrors {
204
+ field
205
+ message
206
+ }
207
+ }
208
+ }
209
+ `;
210
+ //# sourceMappingURL=cart.js.map
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Storefront API GraphQL queries for collection browsing
3
+ */
4
+ /**
5
+ * Get a paginated list of collections for storefront display
6
+ */
7
+ export declare const STOREFRONT_GET_COLLECTIONS = "#graphql\n query StorefrontGetCollections($first: Int!, $after: String) {\n collections(first: $first, after: $after) {\n edges {\n node {\n id\n title\n handle\n description\n image {\n url\n altText\n width\n height\n }\n products(first: 4) {\n edges {\n node {\n id\n title\n handle\n featuredImage {\n url\n altText\n }\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n";
8
+ /**
9
+ * Get a single collection by handle with its products
10
+ */
11
+ export declare const STOREFRONT_GET_COLLECTION_BY_HANDLE = "#graphql\n query StorefrontGetCollectionByHandle($handle: String!, $first: Int!, $after: String) {\n collectionByHandle(handle: $handle) {\n id\n title\n handle\n description\n descriptionHtml\n image {\n url\n altText\n width\n height\n }\n products(first: $first, after: $after) {\n edges {\n node {\n id\n title\n handle\n description\n availableForSale\n featuredImage {\n url\n altText\n width\n height\n }\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n variants(first: 1) {\n edges {\n node {\n id\n price {\n amount\n currencyCode\n }\n }\n }\n }\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n";
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Storefront API GraphQL queries for collection browsing
3
+ */
4
+ /**
5
+ * Get a paginated list of collections for storefront display
6
+ */
7
+ export const STOREFRONT_GET_COLLECTIONS = `#graphql
8
+ query StorefrontGetCollections($first: Int!, $after: String) {
9
+ collections(first: $first, after: $after) {
10
+ edges {
11
+ node {
12
+ id
13
+ title
14
+ handle
15
+ description
16
+ image {
17
+ url
18
+ altText
19
+ width
20
+ height
21
+ }
22
+ products(first: 4) {
23
+ edges {
24
+ node {
25
+ id
26
+ title
27
+ handle
28
+ featuredImage {
29
+ url
30
+ altText
31
+ }
32
+ priceRange {
33
+ minVariantPrice {
34
+ amount
35
+ currencyCode
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ cursor
43
+ }
44
+ pageInfo {
45
+ hasNextPage
46
+ endCursor
47
+ }
48
+ }
49
+ }
50
+ `;
51
+ /**
52
+ * Get a single collection by handle with its products
53
+ */
54
+ export const STOREFRONT_GET_COLLECTION_BY_HANDLE = `#graphql
55
+ query StorefrontGetCollectionByHandle($handle: String!, $first: Int!, $after: String) {
56
+ collectionByHandle(handle: $handle) {
57
+ id
58
+ title
59
+ handle
60
+ description
61
+ descriptionHtml
62
+ image {
63
+ url
64
+ altText
65
+ width
66
+ height
67
+ }
68
+ products(first: $first, after: $after) {
69
+ edges {
70
+ node {
71
+ id
72
+ title
73
+ handle
74
+ description
75
+ availableForSale
76
+ featuredImage {
77
+ url
78
+ altText
79
+ width
80
+ height
81
+ }
82
+ priceRange {
83
+ minVariantPrice {
84
+ amount
85
+ currencyCode
86
+ }
87
+ maxVariantPrice {
88
+ amount
89
+ currencyCode
90
+ }
91
+ }
92
+ variants(first: 1) {
93
+ edges {
94
+ node {
95
+ id
96
+ price {
97
+ amount
98
+ currencyCode
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+ cursor
105
+ }
106
+ pageInfo {
107
+ hasNextPage
108
+ endCursor
109
+ }
110
+ }
111
+ }
112
+ }
113
+ `;
114
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Storefront API GraphQL queries for product browsing
3
+ * These queries are meant for customer-facing operations
4
+ */
5
+ /**
6
+ * Get a paginated list of products for storefront display
7
+ * Includes pricing, images, and availability
8
+ */
9
+ export declare const STOREFRONT_GET_PRODUCTS = "#graphql\n query StorefrontGetProducts($first: Int!, $after: String, $query: String) {\n products(first: $first, after: $after, query: $query) {\n edges {\n node {\n id\n title\n handle\n description\n productType\n vendor\n tags\n availableForSale\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n compareAtPriceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n images(first: 5) {\n edges {\n node {\n url\n altText\n width\n height\n }\n }\n }\n variants(first: 10) {\n edges {\n node {\n id\n title\n availableForSale\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }\n cursor\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n";
10
+ /**
11
+ * Get a single product by handle for storefront display
12
+ * Includes full variant details with inventory availability
13
+ */
14
+ export declare const STOREFRONT_GET_PRODUCT_BY_HANDLE = "#graphql\n query StorefrontGetProductByHandle($handle: String!) {\n productByHandle(handle: $handle) {\n id\n title\n handle\n description\n descriptionHtml\n productType\n vendor\n tags\n availableForSale\n options {\n id\n name\n values\n }\n priceRange {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n images(first: 20) {\n edges {\n node {\n url\n altText\n width\n height\n }\n }\n }\n variants(first: 100) {\n edges {\n node {\n id\n title\n availableForSale\n quantityAvailable\n price {\n amount\n currencyCode\n }\n compareAtPrice {\n amount\n currencyCode\n }\n selectedOptions {\n name\n value\n }\n image {\n url\n altText\n }\n }\n }\n }\n metafields(identifiers: []) {\n key\n namespace\n value\n type\n }\n }\n }\n";
@@ -0,0 +1,155 @@
1
+ /**
2
+ * Storefront API GraphQL queries for product browsing
3
+ * These queries are meant for customer-facing operations
4
+ */
5
+ /**
6
+ * Get a paginated list of products for storefront display
7
+ * Includes pricing, images, and availability
8
+ */
9
+ export const STOREFRONT_GET_PRODUCTS = `#graphql
10
+ query StorefrontGetProducts($first: Int!, $after: String, $query: String) {
11
+ products(first: $first, after: $after, query: $query) {
12
+ edges {
13
+ node {
14
+ id
15
+ title
16
+ handle
17
+ description
18
+ productType
19
+ vendor
20
+ tags
21
+ availableForSale
22
+ priceRange {
23
+ minVariantPrice {
24
+ amount
25
+ currencyCode
26
+ }
27
+ maxVariantPrice {
28
+ amount
29
+ currencyCode
30
+ }
31
+ }
32
+ compareAtPriceRange {
33
+ minVariantPrice {
34
+ amount
35
+ currencyCode
36
+ }
37
+ maxVariantPrice {
38
+ amount
39
+ currencyCode
40
+ }
41
+ }
42
+ images(first: 5) {
43
+ edges {
44
+ node {
45
+ url
46
+ altText
47
+ width
48
+ height
49
+ }
50
+ }
51
+ }
52
+ variants(first: 10) {
53
+ edges {
54
+ node {
55
+ id
56
+ title
57
+ availableForSale
58
+ price {
59
+ amount
60
+ currencyCode
61
+ }
62
+ compareAtPrice {
63
+ amount
64
+ currencyCode
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ cursor
71
+ }
72
+ pageInfo {
73
+ hasNextPage
74
+ endCursor
75
+ }
76
+ }
77
+ }
78
+ `;
79
+ /**
80
+ * Get a single product by handle for storefront display
81
+ * Includes full variant details with inventory availability
82
+ */
83
+ export const STOREFRONT_GET_PRODUCT_BY_HANDLE = `#graphql
84
+ query StorefrontGetProductByHandle($handle: String!) {
85
+ productByHandle(handle: $handle) {
86
+ id
87
+ title
88
+ handle
89
+ description
90
+ descriptionHtml
91
+ productType
92
+ vendor
93
+ tags
94
+ availableForSale
95
+ options {
96
+ id
97
+ name
98
+ values
99
+ }
100
+ priceRange {
101
+ minVariantPrice {
102
+ amount
103
+ currencyCode
104
+ }
105
+ maxVariantPrice {
106
+ amount
107
+ currencyCode
108
+ }
109
+ }
110
+ images(first: 20) {
111
+ edges {
112
+ node {
113
+ url
114
+ altText
115
+ width
116
+ height
117
+ }
118
+ }
119
+ }
120
+ variants(first: 100) {
121
+ edges {
122
+ node {
123
+ id
124
+ title
125
+ availableForSale
126
+ quantityAvailable
127
+ price {
128
+ amount
129
+ currencyCode
130
+ }
131
+ compareAtPrice {
132
+ amount
133
+ currencyCode
134
+ }
135
+ selectedOptions {
136
+ name
137
+ value
138
+ }
139
+ image {
140
+ url
141
+ altText
142
+ }
143
+ }
144
+ }
145
+ }
146
+ metafields(identifiers: []) {
147
+ key
148
+ namespace
149
+ value
150
+ type
151
+ }
152
+ }
153
+ }
154
+ `;
155
+ //# sourceMappingURL=products.js.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Storefront API GraphQL queries and mutations
3
+ * Re-exports all queries organized by domain
4
+ */
5
+ export * from "./common/products.js";
6
+ export * from "./common/collections.js";
7
+ export * from "./common/cart.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Storefront API GraphQL queries and mutations
3
+ * Re-exports all queries organized by domain
4
+ */
5
+ export * from "./common/products.js";
6
+ export * from "./common/collections.js";
7
+ export * from "./common/cart.js";
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env node
2
+ // Set default DATABASE_URL before any imports that use Prisma
3
+ import { fileURLToPath } from "url";
4
+ import { dirname, join } from "path";
5
+ import { existsSync, mkdirSync } from "fs";
6
+ import { homedir } from "os";
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ // Default to a database file in ~/.shopify-mcp/ directory
10
+ if (!process.env.DATABASE_URL) {
11
+ const dbDir = join(homedir(), ".shopify-mcp");
12
+ if (!existsSync(dbDir)) {
13
+ mkdirSync(dbDir, { recursive: true });
14
+ }
15
+ process.env.DATABASE_URL = `file:${join(dbDir, "mcp.db")}`;
16
+ }
17
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
18
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
19
+ import { loadConfig } from "./config.js";
20
+ import { getAdminClient } from "./shopify-client.js";
21
+ import { registerAllTools } from "./tools/index.js";
22
+ import { registerAllPrompts } from "./prompts/index.js";
23
+ import { registerAllResources } from "./resources/index.js";
24
+ // Database and queue
25
+ import prisma, { initializeDatabase, cleanupOldLogs } from "./db.js";
26
+ import { updateQueue, getCurrentTierInfo } from "./queue.js";
27
+ import { getSessionId } from "./logger.js";
28
+ async function main() {
29
+ const config = loadConfig();
30
+ // Initialize database
31
+ await initializeDatabase();
32
+ // Load stored config and set up queue
33
+ const storedConfig = await prisma.storeConfig.findUnique({
34
+ where: { storeDomain: config.storeDomain },
35
+ });
36
+ // Use stored tier, env var, or default to STANDARD
37
+ const tier = storedConfig?.tier ||
38
+ process.env.SHOPIFY_TIER ||
39
+ "STANDARD";
40
+ updateQueue(tier);
41
+ // Clean up old logs if configured
42
+ const retentionDays = parseInt(process.env.MCP_LOG_RETENTION_DAYS || "30", 10);
43
+ if (retentionDays > 0) {
44
+ const deleted = await cleanupOldLogs(retentionDays);
45
+ if (deleted > 0) {
46
+ console.error(`[shopify-store-mcp] Cleaned up ${deleted} old log entries`);
47
+ }
48
+ }
49
+ const adminClient = getAdminClient(config);
50
+ // Verify API connection on startup
51
+ try {
52
+ const healthCheck = await adminClient.request(`query { shop { name } }`);
53
+ if (healthCheck.errors) {
54
+ const errObj = healthCheck.errors;
55
+ if (errObj.networkStatusCode === 401) {
56
+ console.error(`[shopify-store-mcp] ERROR: Invalid access token. Check SHOPIFY_ACCESS_TOKEN.`);
57
+ console.error(`[shopify-store-mcp] Make sure the token belongs to store: ${config.storeDomain}`);
58
+ }
59
+ else if (errObj.networkStatusCode === 403) {
60
+ console.error(`[shopify-store-mcp] ERROR: Token lacks required scopes.`);
61
+ }
62
+ else {
63
+ console.error(`[shopify-store-mcp] ERROR: API connection failed:`, healthCheck.errors);
64
+ }
65
+ process.exit(1);
66
+ }
67
+ const shopName = healthCheck.data?.shop?.name;
68
+ console.error(`[shopify-store-mcp] API connection verified: ${shopName}`);
69
+ }
70
+ catch (error) {
71
+ console.error(`[shopify-store-mcp] ERROR: Failed to connect to Shopify API:`, error);
72
+ process.exit(1);
73
+ }
74
+ const server = new McpServer({
75
+ name: "shopify-store-mcp",
76
+ version: "1.0.0",
77
+ });
78
+ // Register all capabilities
79
+ registerAllTools(server, adminClient, config.storeDomain);
80
+ registerAllPrompts(server);
81
+ registerAllResources(server, config);
82
+ // Connect via stdio transport
83
+ const transport = new StdioServerTransport();
84
+ await server.connect(transport);
85
+ // Log startup info
86
+ const tierInfo = getCurrentTierInfo();
87
+ console.error(`[shopify-store-mcp] Connected to store: ${config.storeDomain}`);
88
+ console.error(`[shopify-store-mcp] API version: ${config.apiVersion}`);
89
+ console.error(`[shopify-store-mcp] Rate limit tier: ${tierInfo.tier} (${tierInfo.config.intervalCap} req/sec)`);
90
+ console.error(`[shopify-store-mcp] Session ID: ${getSessionId()}`);
91
+ console.error(`[shopify-store-mcp] Tools: 10 (run 'schema_discover' to explore store schema)`);
92
+ }
93
+ main().catch((error) => {
94
+ console.error("[shopify-store-mcp] Fatal error:", error);
95
+ process.exit(1);
96
+ });
97
+ //# sourceMappingURL=index.js.map