@burdenoff/mcp-libs 2026.511.1
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/README.md +76 -0
- package/dist/chunk-4GBVJ4OY.js +847 -0
- package/dist/chunk-4GBVJ4OY.js.map +1 -0
- package/dist/chunk-H2OYWLOA.js +919 -0
- package/dist/chunk-H2OYWLOA.js.map +1 -0
- package/dist/chunk-JFEQYSWM.js +174 -0
- package/dist/chunk-JFEQYSWM.js.map +1 -0
- package/dist/chunk-WWFVD7BO.js +273 -0
- package/dist/chunk-WWFVD7BO.js.map +1 -0
- package/dist/context-1jV4NsLv.d.cts +138 -0
- package/dist/context-1jV4NsLv.d.ts +138 -0
- package/dist/core/index.cjs +953 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +59 -0
- package/dist/core/index.d.ts +59 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/http-BP4c721D.d.cts +22 -0
- package/dist/http-DXTeCD5r.d.ts +22 -0
- package/dist/index.cjs +1013 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/module-DBcfA-i3.d.ts +67 -0
- package/dist/module-DFQBZNK6.d.cts +67 -0
- package/dist/modules/auth/index.cjs +533 -0
- package/dist/modules/auth/index.cjs.map +1 -0
- package/dist/modules/auth/index.d.cts +51 -0
- package/dist/modules/auth/index.d.ts +51 -0
- package/dist/modules/auth/index.js +159 -0
- package/dist/modules/auth/index.js.map +1 -0
- package/dist/modules/billing/index.cjs +655 -0
- package/dist/modules/billing/index.cjs.map +1 -0
- package/dist/modules/billing/index.d.cts +8 -0
- package/dist/modules/billing/index.d.ts +8 -0
- package/dist/modules/billing/index.js +606 -0
- package/dist/modules/billing/index.js.map +1 -0
- package/dist/modules/channels/index.cjs +443 -0
- package/dist/modules/channels/index.cjs.map +1 -0
- package/dist/modules/channels/index.d.cts +8 -0
- package/dist/modules/channels/index.d.ts +8 -0
- package/dist/modules/channels/index.js +394 -0
- package/dist/modules/channels/index.js.map +1 -0
- package/dist/modules/conversations/index.cjs +288 -0
- package/dist/modules/conversations/index.cjs.map +1 -0
- package/dist/modules/conversations/index.d.cts +8 -0
- package/dist/modules/conversations/index.d.ts +8 -0
- package/dist/modules/conversations/index.js +239 -0
- package/dist/modules/conversations/index.js.map +1 -0
- package/dist/modules/devportal/index.cjs +796 -0
- package/dist/modules/devportal/index.cjs.map +1 -0
- package/dist/modules/devportal/index.d.cts +8 -0
- package/dist/modules/devportal/index.d.ts +8 -0
- package/dist/modules/devportal/index.js +747 -0
- package/dist/modules/devportal/index.js.map +1 -0
- package/dist/modules/export/index.cjs +333 -0
- package/dist/modules/export/index.cjs.map +1 -0
- package/dist/modules/export/index.d.cts +8 -0
- package/dist/modules/export/index.d.ts +8 -0
- package/dist/modules/export/index.js +284 -0
- package/dist/modules/export/index.js.map +1 -0
- package/dist/modules/files/index.cjs +278 -0
- package/dist/modules/files/index.cjs.map +1 -0
- package/dist/modules/files/index.d.cts +8 -0
- package/dist/modules/files/index.d.ts +8 -0
- package/dist/modules/files/index.js +229 -0
- package/dist/modules/files/index.js.map +1 -0
- package/dist/modules/groups/index.cjs +451 -0
- package/dist/modules/groups/index.cjs.map +1 -0
- package/dist/modules/groups/index.d.cts +8 -0
- package/dist/modules/groups/index.d.ts +8 -0
- package/dist/modules/groups/index.js +402 -0
- package/dist/modules/groups/index.js.map +1 -0
- package/dist/modules/health/index.cjs +159 -0
- package/dist/modules/health/index.cjs.map +1 -0
- package/dist/modules/health/index.d.cts +8 -0
- package/dist/modules/health/index.d.ts +8 -0
- package/dist/modules/health/index.js +36 -0
- package/dist/modules/health/index.js.map +1 -0
- package/dist/modules/integrations/index.cjs +316 -0
- package/dist/modules/integrations/index.cjs.map +1 -0
- package/dist/modules/integrations/index.d.cts +8 -0
- package/dist/modules/integrations/index.d.ts +8 -0
- package/dist/modules/integrations/index.js +267 -0
- package/dist/modules/integrations/index.js.map +1 -0
- package/dist/modules/notifications/index.cjs +222 -0
- package/dist/modules/notifications/index.cjs.map +1 -0
- package/dist/modules/notifications/index.d.cts +8 -0
- package/dist/modules/notifications/index.d.ts +8 -0
- package/dist/modules/notifications/index.js +173 -0
- package/dist/modules/notifications/index.js.map +1 -0
- package/dist/modules/organizations/index.cjs +267 -0
- package/dist/modules/organizations/index.cjs.map +1 -0
- package/dist/modules/organizations/index.d.cts +8 -0
- package/dist/modules/organizations/index.d.ts +8 -0
- package/dist/modules/organizations/index.js +218 -0
- package/dist/modules/organizations/index.js.map +1 -0
- package/dist/modules/products/index.cjs +736 -0
- package/dist/modules/products/index.cjs.map +1 -0
- package/dist/modules/products/index.d.cts +8 -0
- package/dist/modules/products/index.d.ts +8 -0
- package/dist/modules/products/index.js +687 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/rbac/index.cjs +378 -0
- package/dist/modules/rbac/index.cjs.map +1 -0
- package/dist/modules/rbac/index.d.cts +8 -0
- package/dist/modules/rbac/index.d.ts +8 -0
- package/dist/modules/rbac/index.js +329 -0
- package/dist/modules/rbac/index.js.map +1 -0
- package/dist/modules/sandbox/index.cjs +318 -0
- package/dist/modules/sandbox/index.cjs.map +1 -0
- package/dist/modules/sandbox/index.d.cts +8 -0
- package/dist/modules/sandbox/index.d.ts +8 -0
- package/dist/modules/sandbox/index.js +225 -0
- package/dist/modules/sandbox/index.js.map +1 -0
- package/dist/modules/scheduler/index.cjs +267 -0
- package/dist/modules/scheduler/index.cjs.map +1 -0
- package/dist/modules/scheduler/index.d.cts +8 -0
- package/dist/modules/scheduler/index.d.ts +8 -0
- package/dist/modules/scheduler/index.js +218 -0
- package/dist/modules/scheduler/index.js.map +1 -0
- package/dist/modules/security/index.cjs +529 -0
- package/dist/modules/security/index.cjs.map +1 -0
- package/dist/modules/security/index.d.cts +8 -0
- package/dist/modules/security/index.d.ts +8 -0
- package/dist/modules/security/index.js +480 -0
- package/dist/modules/security/index.js.map +1 -0
- package/dist/modules/store/index.cjs +450 -0
- package/dist/modules/store/index.cjs.map +1 -0
- package/dist/modules/store/index.d.cts +8 -0
- package/dist/modules/store/index.d.ts +8 -0
- package/dist/modules/store/index.js +401 -0
- package/dist/modules/store/index.js.map +1 -0
- package/dist/modules/support/index.cjs +285 -0
- package/dist/modules/support/index.cjs.map +1 -0
- package/dist/modules/support/index.d.cts +8 -0
- package/dist/modules/support/index.d.ts +8 -0
- package/dist/modules/support/index.js +236 -0
- package/dist/modules/support/index.js.map +1 -0
- package/dist/modules/tags/index.cjs +421 -0
- package/dist/modules/tags/index.cjs.map +1 -0
- package/dist/modules/tags/index.d.cts +8 -0
- package/dist/modules/tags/index.d.ts +8 -0
- package/dist/modules/tags/index.js +372 -0
- package/dist/modules/tags/index.js.map +1 -0
- package/dist/modules/tours/index.cjs +225 -0
- package/dist/modules/tours/index.cjs.map +1 -0
- package/dist/modules/tours/index.d.cts +8 -0
- package/dist/modules/tours/index.d.ts +8 -0
- package/dist/modules/tours/index.js +176 -0
- package/dist/modules/tours/index.js.map +1 -0
- package/dist/modules/vibecontrols/index.cjs +5551 -0
- package/dist/modules/vibecontrols/index.cjs.map +1 -0
- package/dist/modules/vibecontrols/index.d.cts +8 -0
- package/dist/modules/vibecontrols/index.d.ts +8 -0
- package/dist/modules/vibecontrols/index.js +4380 -0
- package/dist/modules/vibecontrols/index.js.map +1 -0
- package/dist/modules/workspaces/index.cjs +552 -0
- package/dist/modules/workspaces/index.cjs.map +1 -0
- package/dist/modules/workspaces/index.d.cts +8 -0
- package/dist/modules/workspaces/index.d.ts +8 -0
- package/dist/modules/workspaces/index.js +503 -0
- package/dist/modules/workspaces/index.js.map +1 -0
- package/dist/tool-name-CQf_IqAj.d.cts +47 -0
- package/dist/tool-name-DlnrBsZ6.d.ts +47 -0
- package/dist/transports/index.cjs +183 -0
- package/dist/transports/index.cjs.map +1 -0
- package/dist/transports/index.d.cts +13 -0
- package/dist/transports/index.d.ts +13 -0
- package/dist/transports/index.js +3 -0
- package/dist/transports/index.js.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
require('graphql-request');
|
|
5
|
+
require('cross-fetch');
|
|
6
|
+
require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
7
|
+
require('@modelcontextprotocol/sdk/types.js');
|
|
8
|
+
|
|
9
|
+
// src/modules/store/tools.ts
|
|
10
|
+
|
|
11
|
+
// src/core/errors.ts
|
|
12
|
+
var McpInternalError = class extends Error {
|
|
13
|
+
cause;
|
|
14
|
+
constructor(message, cause) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "McpInternalError";
|
|
17
|
+
this.cause = cause;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/core/result.ts
|
|
22
|
+
function jsonResult(data, structured) {
|
|
23
|
+
const result = {
|
|
24
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
25
|
+
};
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
function errorResult(message, hint) {
|
|
29
|
+
const text = hint ? `${message}
|
|
30
|
+
|
|
31
|
+
Hint: ${hint}` : message;
|
|
32
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/core/tool-name.ts
|
|
36
|
+
var MAX_TOOL_NAME_LENGTH = 63;
|
|
37
|
+
function assertSafeName(name, kind) {
|
|
38
|
+
if (name.length > MAX_TOOL_NAME_LENGTH) {
|
|
39
|
+
throw new McpInternalError(
|
|
40
|
+
`Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return name;
|
|
44
|
+
}
|
|
45
|
+
function mcpToolName(productName, ...parts) {
|
|
46
|
+
if (!productName) {
|
|
47
|
+
throw new McpInternalError("mcpToolName: productName is required");
|
|
48
|
+
}
|
|
49
|
+
const name = [productName, ...parts].filter(Boolean).join("_");
|
|
50
|
+
return assertSafeName(name);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/modules/store/operations.ts
|
|
54
|
+
var BROWSE_STORE = `
|
|
55
|
+
query BrowseStore($input: BrowseStoreInput!) {
|
|
56
|
+
browseStore(input: $input) {
|
|
57
|
+
products { id name description price currency type status }
|
|
58
|
+
facets { categories types }
|
|
59
|
+
totalCount hasMore
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
var SEARCH_STORE = `
|
|
64
|
+
query SearchStore($query: String!, $filters: StoreFiltersInput) {
|
|
65
|
+
searchStore(query: $query, filters: $filters) {
|
|
66
|
+
id name price currency type activeInstallCount
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
var GET_STORE_PRODUCT = `
|
|
71
|
+
query GetStoreProduct($id: ID!) {
|
|
72
|
+
getProduct(id: $id) {
|
|
73
|
+
id name description price currency type status
|
|
74
|
+
publisher { name }
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
var MY_CART = `
|
|
79
|
+
query MyCart {
|
|
80
|
+
myCart {
|
|
81
|
+
id currency subtotal total itemCount isEmpty
|
|
82
|
+
items { id productId quantity }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
`;
|
|
86
|
+
var ADD_TO_CART = `
|
|
87
|
+
mutation AddToCart($input: AddToCartInput!) {
|
|
88
|
+
addToCart(input: $input) {
|
|
89
|
+
id itemCount subtotal items { productId quantity }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
var REMOVE_FROM_CART = `
|
|
94
|
+
mutation RemoveFromCart($cartId: ID!, $itemId: ID!) {
|
|
95
|
+
removeFromCart(cartId: $cartId, itemId: $itemId) {
|
|
96
|
+
id itemCount subtotal
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
var CHECKOUT_CART = `
|
|
101
|
+
mutation CheckoutCart($cartId: ID!) {
|
|
102
|
+
checkoutCart(cartId: $cartId) {
|
|
103
|
+
success order { id total status }
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
var GET_ORDERS = `
|
|
108
|
+
query GetOrders($limit: Int, $offset: Int) {
|
|
109
|
+
getOrders(limit: $limit, offset: $offset) {
|
|
110
|
+
id status total currency createdAt
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
var GET_ORDER = `
|
|
115
|
+
query GetOrder($id: ID!) {
|
|
116
|
+
getOrder(id: $id) {
|
|
117
|
+
id status total currency paidAt billingAccountId
|
|
118
|
+
lineItems { productId quantity unitPrice }
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
var GET_INSTALLED_PRODUCTS = `
|
|
123
|
+
query GetInstalledProducts($workspaceId: ID!) {
|
|
124
|
+
getInstalledProducts(workspaceId: $workspaceId) {
|
|
125
|
+
id application { id name } status installedAt lastUsedAt
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
129
|
+
var UNINSTALL_PRODUCT = `
|
|
130
|
+
mutation UninstallProduct($installationId: ID!) {
|
|
131
|
+
uninstallProduct(installationId: $installationId) { success }
|
|
132
|
+
}
|
|
133
|
+
`;
|
|
134
|
+
var GET_LICENSES = `
|
|
135
|
+
query GetLicenses($entitlementId: ID!) {
|
|
136
|
+
getLicenses(entitlementId: $entitlementId) {
|
|
137
|
+
id status validFrom expiresAt
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
|
|
142
|
+
// src/modules/store/tools.ts
|
|
143
|
+
function resolveWorkspaceId(ctx, override) {
|
|
144
|
+
if (override !== void 0 && override !== "") return override;
|
|
145
|
+
const auth = ctx.auth.read();
|
|
146
|
+
if (!auth?.workspaceId) return null;
|
|
147
|
+
return auth.workspaceId;
|
|
148
|
+
}
|
|
149
|
+
function registerStoreTools(server, ctx, track) {
|
|
150
|
+
server.registerTool(
|
|
151
|
+
track(mcpToolName(ctx.productName, "store_search")),
|
|
152
|
+
{
|
|
153
|
+
title: "Search Store",
|
|
154
|
+
description: "Search the marketplace for products by query and optional filters.",
|
|
155
|
+
inputSchema: {
|
|
156
|
+
query: zod.z.string().describe("Search query"),
|
|
157
|
+
type: zod.z.string().optional().describe("Product type filter"),
|
|
158
|
+
category: zod.z.string().optional().describe("Category filter")
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
async ({ query, type, category }) => {
|
|
162
|
+
try {
|
|
163
|
+
const filters = {};
|
|
164
|
+
if (type !== void 0) filters.productType = type.toUpperCase();
|
|
165
|
+
if (category !== void 0) filters.category = category;
|
|
166
|
+
const data = await ctx.gql.global.request(SEARCH_STORE, {
|
|
167
|
+
query,
|
|
168
|
+
filters: Object.keys(filters).length ? filters : void 0
|
|
169
|
+
});
|
|
170
|
+
return jsonResult(data.searchStore);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
ctx.logger.error("store_search failed", { error: String(error) });
|
|
173
|
+
return errorResult(
|
|
174
|
+
`Failed to search store: ${error instanceof Error ? error.message : String(error)}`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
server.registerTool(
|
|
180
|
+
track(mcpToolName(ctx.productName, "store_browse")),
|
|
181
|
+
{
|
|
182
|
+
title: "Browse Store",
|
|
183
|
+
description: "Browse the marketplace with structured input (categories, facets, paging).",
|
|
184
|
+
inputSchema: {
|
|
185
|
+
category: zod.z.string().optional().describe("Category filter"),
|
|
186
|
+
type: zod.z.string().optional().describe("Product type filter"),
|
|
187
|
+
limit: zod.z.number().optional().describe("Page size"),
|
|
188
|
+
offset: zod.z.number().optional().describe("Skip results")
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
async ({ category, type, limit, offset }) => {
|
|
192
|
+
try {
|
|
193
|
+
const input = {};
|
|
194
|
+
if (category !== void 0) input.category = category;
|
|
195
|
+
if (type !== void 0) input.productType = type.toUpperCase();
|
|
196
|
+
if (limit !== void 0) input.limit = limit;
|
|
197
|
+
if (offset !== void 0) input.offset = offset;
|
|
198
|
+
const data = await ctx.gql.global.request(BROWSE_STORE, { input });
|
|
199
|
+
return jsonResult(data.browseStore);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
ctx.logger.error("store_browse failed", { error: String(error) });
|
|
202
|
+
return errorResult(
|
|
203
|
+
`Failed to browse store: ${error instanceof Error ? error.message : String(error)}`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
server.registerTool(
|
|
209
|
+
track(mcpToolName(ctx.productName, "store_get_product")),
|
|
210
|
+
{
|
|
211
|
+
title: "Get Store Product",
|
|
212
|
+
description: "Get a marketplace product by ID.",
|
|
213
|
+
inputSchema: { id: zod.z.string().describe("Product ID") }
|
|
214
|
+
},
|
|
215
|
+
async ({ id }) => {
|
|
216
|
+
try {
|
|
217
|
+
const data = await ctx.gql.global.request(
|
|
218
|
+
GET_STORE_PRODUCT,
|
|
219
|
+
{ id }
|
|
220
|
+
);
|
|
221
|
+
if (!data.getProduct) return errorResult(`Product ${id} not found`);
|
|
222
|
+
return jsonResult(data.getProduct);
|
|
223
|
+
} catch (error) {
|
|
224
|
+
ctx.logger.error("store_get_product failed", { error: String(error) });
|
|
225
|
+
return errorResult(
|
|
226
|
+
`Failed to get product: ${error instanceof Error ? error.message : String(error)}`
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
server.registerTool(
|
|
232
|
+
track(mcpToolName(ctx.productName, "store_cart_list")),
|
|
233
|
+
{
|
|
234
|
+
title: "Show Cart",
|
|
235
|
+
description: "Show the current user's cart.",
|
|
236
|
+
inputSchema: {}
|
|
237
|
+
},
|
|
238
|
+
async () => {
|
|
239
|
+
try {
|
|
240
|
+
const data = await ctx.gql.global.request(MY_CART);
|
|
241
|
+
return jsonResult(data.myCart);
|
|
242
|
+
} catch (error) {
|
|
243
|
+
ctx.logger.error("store_cart_list failed", { error: String(error) });
|
|
244
|
+
return errorResult(
|
|
245
|
+
`Failed to fetch cart: ${error instanceof Error ? error.message : String(error)}`
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
server.registerTool(
|
|
251
|
+
track(mcpToolName(ctx.productName, "store_cart_add")),
|
|
252
|
+
{
|
|
253
|
+
title: "Add to Cart",
|
|
254
|
+
description: "Add a product (and optional variant) to the cart.",
|
|
255
|
+
inputSchema: {
|
|
256
|
+
product: zod.z.string().describe("Product ID"),
|
|
257
|
+
quantity: zod.z.number().optional().describe("Quantity (default 1)"),
|
|
258
|
+
variant: zod.z.string().optional().describe("Variant ID")
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
async ({ product, quantity, variant }) => {
|
|
262
|
+
try {
|
|
263
|
+
const input = { productId: product };
|
|
264
|
+
if (quantity !== void 0) input.quantity = quantity;
|
|
265
|
+
if (variant !== void 0) input.variantId = variant;
|
|
266
|
+
const data = await ctx.gql.global.request(ADD_TO_CART, { input });
|
|
267
|
+
return jsonResult(data.addToCart);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
ctx.logger.error("store_cart_add failed", { error: String(error) });
|
|
270
|
+
return errorResult(
|
|
271
|
+
`Failed to add to cart: ${error instanceof Error ? error.message : String(error)}`
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
server.registerTool(
|
|
277
|
+
track(mcpToolName(ctx.productName, "store_cart_remove")),
|
|
278
|
+
{
|
|
279
|
+
title: "Remove from Cart",
|
|
280
|
+
description: "Remove an item from the cart.",
|
|
281
|
+
inputSchema: {
|
|
282
|
+
cart: zod.z.string().describe("Cart ID"),
|
|
283
|
+
item: zod.z.string().describe("Cart item ID")
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
async ({ cart, item }) => {
|
|
287
|
+
try {
|
|
288
|
+
await ctx.gql.global.request(REMOVE_FROM_CART, { cartId: cart, itemId: item });
|
|
289
|
+
return jsonResult({ status: "success", message: "Item removed from cart", cart, item });
|
|
290
|
+
} catch (error) {
|
|
291
|
+
ctx.logger.error("store_cart_remove failed", { error: String(error) });
|
|
292
|
+
return errorResult(
|
|
293
|
+
`Failed to remove cart item: ${error instanceof Error ? error.message : String(error)}`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
server.registerTool(
|
|
299
|
+
track(mcpToolName(ctx.productName, "store_cart_checkout")),
|
|
300
|
+
{
|
|
301
|
+
title: "Checkout Cart",
|
|
302
|
+
description: "Check out the cart server-side (uses default payment method on the billing account).",
|
|
303
|
+
inputSchema: { cartId: zod.z.string().describe("Cart ID") }
|
|
304
|
+
},
|
|
305
|
+
async ({ cartId }) => {
|
|
306
|
+
try {
|
|
307
|
+
const data = await ctx.gql.global.request(CHECKOUT_CART, { cartId });
|
|
308
|
+
return jsonResult(data.checkoutCart);
|
|
309
|
+
} catch (error) {
|
|
310
|
+
ctx.logger.error("store_cart_checkout failed", { error: String(error) });
|
|
311
|
+
return errorResult(
|
|
312
|
+
`Failed to checkout cart: ${error instanceof Error ? error.message : String(error)}`
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
server.registerTool(
|
|
318
|
+
track(mcpToolName(ctx.productName, "store_orders_list")),
|
|
319
|
+
{
|
|
320
|
+
title: "List Orders",
|
|
321
|
+
description: "List orders for the current user.",
|
|
322
|
+
inputSchema: {
|
|
323
|
+
limit: zod.z.number().optional().describe("Page size (default 50)"),
|
|
324
|
+
offset: zod.z.number().optional().describe("Skip results (default 0)")
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
async ({ limit, offset }) => {
|
|
328
|
+
try {
|
|
329
|
+
const data = await ctx.gql.global.request(GET_ORDERS, {
|
|
330
|
+
limit,
|
|
331
|
+
offset: offset ?? 0
|
|
332
|
+
});
|
|
333
|
+
return jsonResult(data.getOrders);
|
|
334
|
+
} catch (error) {
|
|
335
|
+
ctx.logger.error("store_orders_list failed", { error: String(error) });
|
|
336
|
+
return errorResult(
|
|
337
|
+
`Failed to list orders: ${error instanceof Error ? error.message : String(error)}`
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
);
|
|
342
|
+
server.registerTool(
|
|
343
|
+
track(mcpToolName(ctx.productName, "store_orders_get")),
|
|
344
|
+
{
|
|
345
|
+
title: "Get Order",
|
|
346
|
+
description: "Get an order by ID.",
|
|
347
|
+
inputSchema: { id: zod.z.string().describe("Order ID") }
|
|
348
|
+
},
|
|
349
|
+
async ({ id }) => {
|
|
350
|
+
try {
|
|
351
|
+
const data = await ctx.gql.global.request(GET_ORDER, { id });
|
|
352
|
+
if (!data.getOrder) return errorResult(`Order ${id} not found`);
|
|
353
|
+
return jsonResult(data.getOrder);
|
|
354
|
+
} catch (error) {
|
|
355
|
+
ctx.logger.error("store_orders_get failed", { error: String(error) });
|
|
356
|
+
return errorResult(
|
|
357
|
+
`Failed to get order: ${error instanceof Error ? error.message : String(error)}`
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
);
|
|
362
|
+
server.registerTool(
|
|
363
|
+
track(mcpToolName(ctx.productName, "store_installed_list")),
|
|
364
|
+
{
|
|
365
|
+
title: "List Installed Products",
|
|
366
|
+
description: "List installed products in the current (or specified) workspace.",
|
|
367
|
+
inputSchema: {
|
|
368
|
+
workspace: zod.z.string().optional().describe("Workspace ID (defaults to current)")
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
async ({ workspace }) => {
|
|
372
|
+
try {
|
|
373
|
+
const wid = resolveWorkspaceId(ctx, workspace);
|
|
374
|
+
if (!wid) {
|
|
375
|
+
return errorResult(
|
|
376
|
+
"No active workspace. Bind a workspace via the auth login flow first."
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
const data = await ctx.gql.global.request(GET_INSTALLED_PRODUCTS, { workspaceId: wid });
|
|
380
|
+
return jsonResult(data.getInstalledProducts);
|
|
381
|
+
} catch (error) {
|
|
382
|
+
ctx.logger.error("store_installed_list failed", { error: String(error) });
|
|
383
|
+
return errorResult(
|
|
384
|
+
`Failed to list installed products: ${error instanceof Error ? error.message : String(error)}`
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
);
|
|
389
|
+
server.registerTool(
|
|
390
|
+
track(mcpToolName(ctx.productName, "store_installed_uninstall")),
|
|
391
|
+
{
|
|
392
|
+
title: "Uninstall Product",
|
|
393
|
+
description: "Uninstall a product by installation ID.",
|
|
394
|
+
inputSchema: { installationId: zod.z.string().describe("Installation ID") }
|
|
395
|
+
},
|
|
396
|
+
async ({ installationId }) => {
|
|
397
|
+
try {
|
|
398
|
+
await ctx.gql.global.request(UNINSTALL_PRODUCT, { installationId });
|
|
399
|
+
return jsonResult({ status: "success", message: "Product uninstalled", installationId });
|
|
400
|
+
} catch (error) {
|
|
401
|
+
ctx.logger.error("store_installed_uninstall failed", { error: String(error) });
|
|
402
|
+
return errorResult(
|
|
403
|
+
`Failed to uninstall product: ${error instanceof Error ? error.message : String(error)}`
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
server.registerTool(
|
|
409
|
+
track(mcpToolName(ctx.productName, "store_licenses_list")),
|
|
410
|
+
{
|
|
411
|
+
title: "List Licenses",
|
|
412
|
+
description: "List licenses for an entitlement.",
|
|
413
|
+
inputSchema: { entitlement: zod.z.string().describe("Entitlement ID") }
|
|
414
|
+
},
|
|
415
|
+
async ({ entitlement }) => {
|
|
416
|
+
try {
|
|
417
|
+
const data = await ctx.gql.global.request(GET_LICENSES, { entitlementId: entitlement });
|
|
418
|
+
return jsonResult(data.getLicenses);
|
|
419
|
+
} catch (error) {
|
|
420
|
+
ctx.logger.error("store_licenses_list failed", { error: String(error) });
|
|
421
|
+
return errorResult(
|
|
422
|
+
`Failed to list licenses: ${error instanceof Error ? error.message : String(error)}`
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// src/modules/store/index.ts
|
|
430
|
+
var storeModule = {
|
|
431
|
+
id: "store",
|
|
432
|
+
version: "0.0.1",
|
|
433
|
+
displayName: "Store",
|
|
434
|
+
dependsOn: ["auth"],
|
|
435
|
+
capabilities: { tools: {} },
|
|
436
|
+
register(server, ctx) {
|
|
437
|
+
const tools = [];
|
|
438
|
+
const track = (n) => {
|
|
439
|
+
tools.push(n);
|
|
440
|
+
return n;
|
|
441
|
+
};
|
|
442
|
+
registerStoreTools(server, ctx, track);
|
|
443
|
+
return { tools, resources: [], prompts: [] };
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
var store_default = storeModule;
|
|
447
|
+
|
|
448
|
+
module.exports = store_default;
|
|
449
|
+
//# sourceMappingURL=index.cjs.map
|
|
450
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/core/errors.ts","../../../src/core/result.ts","../../../src/core/tool-name.ts","../../../src/modules/store/operations.ts","../../../src/modules/store/tools.ts","../../../src/modules/store/index.ts"],"names":["z"],"mappings":";;;;;;;;;;;AA8BO,IAAM,gBAAA,GAAN,cAA+B,KAAA,CAAM;AAAA,EACjB,KAAA;AAAA,EAEzB,WAAA,CAAY,SAAiB,KAAA,EAAiB;AAC5C,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,kBAAA;AACZ,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AAAA,EACf;AACF,CAAA;;;ACCO,SAAS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AA,EAAY,KAAM;AACzB,MAAA,IAAI;AACF,QAAA,MAAM,IAAA,GAAO,MAAM,GAAA,CAAI,GAAA,CAAI,MAAA,CAAO,QAE/B,YAAA,EAAc,EAAE,aAAA,EAAe,WAAA,EAAa,CAAA;AAC/C,QAAA,OAAO,UAAA,CAAW,KAAK,WAAW,CAAA;AAAA,MACpC,SAAS,KAAA,EAAO;AACd,QAAA,GAAA,CAAI,MAAA,CAAO,MAAM,4BAAA,EAA8B,EAAE,OAAO,MAAA,CAAO,KAAK,GAAG,CAAA;AACvE,QAAA,OAAO,WAAA;AAAA,UACL,4BAA4B,KAAA,YAAiB,KAAA,GAAQ,MAAM,OAAA,GAAU,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,SACpF;AAAA,MACF;AAAA,IACF;AAAA,GACF;AACF;;;ACjXA,IAAM,WAAA,GAAyB;AAAA,EAC7B,EAAA,EAAI,OAAA;AAAA,EACJ,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,OAAA;AAAA,EACb,SAAA,EAAW,CAAC,MAAM,CAAA;AAAA,EAClB,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,EAAE;AAAA,EAE1B,QAAA,CAAS,QAAmB,GAAA,EAAqC;AAC/D,IAAA,MAAM,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,kBAAA,CAAmB,MAAA,EAAQ,KAAK,KAAK,CAAA;AAErC,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,aAAA,GAAQ","file":"index.cjs","sourcesContent":["/**\n * Error classes for MCP SDK.\n *\n * Modules MUST throw these instead of throwing raw Errors. The registerTool\n * wrapper in result.ts catches and maps them to MCP-protocol-compliant\n * `{ isError: true, content: [...] }` responses.\n *\n * Throwing past the wrapper to the protocol surfaces as JSON-RPC -32603 to\n * the client and is a protocol bug.\n */\n\nexport class McpUserError extends Error {\n public readonly hint: string | undefined;\n\n constructor(message: string, opts?: { hint?: string }) {\n super(message);\n this.name = 'McpUserError';\n this.hint = opts?.hint;\n }\n}\n\nexport class McpAuthError extends McpUserError {\n constructor(message: string, opts?: { hint?: string }) {\n super(message, {\n hint: opts?.hint ?? 'Run the auth_login tool to authenticate.',\n });\n this.name = 'McpAuthError';\n }\n}\n\nexport class McpInternalError extends Error {\n public override readonly cause: unknown;\n\n constructor(message: string, cause?: unknown) {\n super(message);\n this.name = 'McpInternalError';\n this.cause = cause;\n }\n}\n","/**\n * MCP tool result helpers + central handler.\n *\n * Modules NEVER call server.registerTool directly — they use registerTool()\n * from this module so the central try/catch wraps the handler and:\n * - maps thrown McpUserError / McpAuthError / McpInternalError to\n * MCP-protocol-compliant `{ isError: true, content: [...] }` shapes\n * - threads `_meta.progressToken` into ctx.progress for long ops\n * - emits a structured log line on every error\n * - never leaks `cause` from McpInternalError to the client\n *\n * This is the analog of cli-sdk's createProgram() central error handler.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { ZodRawShape } from 'zod';\nimport type { McpContext } from './context.js';\nimport { McpAuthError, McpInternalError, McpUserError } from './errors.js';\n\nexport interface ToolTextContent {\n type: 'text';\n text: string;\n [k: string]: unknown;\n}\n\nexport interface ToolResult {\n content: ToolTextContent[];\n isError?: boolean;\n structuredContent?: Record<string, unknown>;\n [k: string]: unknown;\n}\n\nexport interface ToolMeta {\n progressToken?: string | number;\n}\n\n/**\n * Build a successful tool result with JSON content (pretty-printed).\n */\nexport function jsonResult(data: unknown, structured?: Record<string, unknown>): ToolResult {\n const result: ToolResult = {\n content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],\n };\n if (structured !== undefined) {\n result.structuredContent = structured;\n }\n return result;\n}\n\n/**\n * Build a successful tool result with plain text content.\n */\nexport function textResult(text: string): ToolResult {\n return { content: [{ type: 'text', text }] };\n}\n\n/**\n * Build an error tool result. Honors MCP's `{ isError: true, content }` shape.\n * Optional hint is appended on a new line so the LLM can react.\n */\nexport function errorResult(message: string, hint?: string): ToolResult {\n const text = hint ? `${message}\\n\\nHint: ${hint}` : message;\n return { content: [{ type: 'text', text }], isError: true };\n}\n\nexport interface ToolMetadata {\n title: string;\n description: string;\n inputSchema?: ZodRawShape;\n}\n\nexport type ToolHandler<TArgs = Record<string, unknown>> = (\n args: TArgs,\n ctx: McpContext,\n meta: ToolMeta,\n) => Promise<unknown>;\n\n/**\n * Register a tool with the central error wrapper.\n *\n * The handler returns a plain value or void. The wrapper:\n * - wraps non-undefined returns in jsonResult()\n * - if the value already looks like a ToolResult (has `content`), passes through\n * - catches McpAuthError / McpUserError / McpInternalError / generic Error\n * - logs every error via ctx.logger.error\n */\nexport function registerTool<TArgs extends Record<string, unknown>>(\n server: McpServer,\n ctx: McpContext,\n name: string,\n metadata: ToolMetadata,\n handler: ToolHandler<TArgs>,\n): void {\n const sdkConfig = {\n title: metadata.title,\n description: metadata.description,\n ...(metadata.inputSchema ? { inputSchema: metadata.inputSchema } : {}),\n };\n\n // The MCP SDK's registerTool signature is `(name, config, handler)`. The\n // handler arity depends on whether inputSchema is present (1-arg without,\n // 2-arg with). We accept a unified handler shape and dispatch at runtime.\n // The SDK's typing is strict and conditional on the inputSchema generic;\n // bypass with a cast since runtime acceptance is unconditional.\n const wrapped = async (...callbackArgs: unknown[]): Promise<ToolResult> => {\n const hasArgs = callbackArgs.length === 2;\n const args = (hasArgs ? callbackArgs[0] : {}) as TArgs;\n const extra = (hasArgs ? callbackArgs[1] : callbackArgs[0]) as\n | { _meta?: { progressToken?: string | number } }\n | undefined;\n\n const progressToken = extra?._meta?.progressToken;\n const meta: ToolMeta = progressToken !== undefined ? { progressToken } : {};\n\n try {\n const result = await handler(args, ctx, meta);\n if (isToolResult(result)) return result;\n if (result === undefined) return textResult('OK');\n return jsonResult(result);\n } catch (error) {\n return mapErrorToResult(error, ctx, name);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (server as any).registerTool(name, sdkConfig, wrapped);\n}\n\nfunction isToolResult(value: unknown): value is ToolResult {\n return (\n !!value &&\n typeof value === 'object' &&\n 'content' in value &&\n Array.isArray((value as ToolResult).content)\n );\n}\n\nfunction mapErrorToResult(error: unknown, ctx: McpContext, toolName: string): ToolResult {\n if (error instanceof McpAuthError) {\n ctx.logger.warn(`${toolName}: auth required`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpUserError) {\n ctx.logger.info(`${toolName}: user error`, { message: error.message });\n return errorResult(error.message, error.hint);\n }\n if (error instanceof McpInternalError) {\n ctx.logger.error(`${toolName}: internal error`, {\n message: error.message,\n cause: stringifyCause(error.cause),\n });\n return errorResult(`Internal error in ${toolName}.`);\n }\n const message = error instanceof Error ? error.message : String(error);\n ctx.logger.error(`${toolName}: unhandled error`, { message });\n return errorResult(`${toolName}: ${message}`);\n}\n\nfunction stringifyCause(cause: unknown): string | undefined {\n if (cause === undefined || cause === null) return undefined;\n if (cause instanceof Error) return cause.message;\n try {\n return JSON.stringify(cause);\n } catch {\n return String(cause);\n }\n}\n","/**\n * Tool / resource / prompt naming helpers.\n *\n * Mandatory product prefix avoids collisions when Claude Desktop runs\n * multiple MCP servers concurrently (typical setup is ~6).\n *\n * Tool names are capped at 63 characters — Claude Desktop pre-1.x\n * truncated at 64 in some versions.\n */\n\nimport { McpInternalError } from './errors.js';\n\nconst MAX_TOOL_NAME_LENGTH = 63;\n\nfunction assertSafeName(name: string, kind: 'tool' | 'resource' | 'prompt'): string {\n if (kind === 'tool' && name.length > MAX_TOOL_NAME_LENGTH) {\n throw new McpInternalError(\n `Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`,\n );\n }\n return name;\n}\n\n/**\n * Build a tool name. Format: `<productName>_<...parts>` (snake_case).\n * Example: mcpToolName('vibecontrols', 'vibes', 'list') -> 'vibecontrols_vibes_list'\n */\nexport function mcpToolName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpToolName: productName is required');\n }\n const name = [productName, ...parts].filter(Boolean).join('_');\n return assertSafeName(name, 'tool');\n}\n\n/**\n * Build a resource URI. Format: `<productName>://<...parts>`.\n * Example: mcpResourceUri('vibecontrols', 'schema') -> 'vibecontrols://schema'\n */\nexport function mcpResourceUri(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpResourceUri: productName is required');\n }\n return `${productName}://${parts.filter(Boolean).join('/')}`;\n}\n\n/**\n * Build a prompt name. Format: `<productName>-<...parts>` (kebab-case).\n * Example: mcpPromptName('vibecontrols', 'setup') -> 'vibecontrols-setup'\n */\nexport function mcpPromptName(productName: string, ...parts: string[]): string {\n if (!productName) {\n throw new McpInternalError('mcpPromptName: productName is required');\n }\n return [productName, ...parts].filter(Boolean).join('-');\n}\n\nexport const TOOL_NAME_LIMIT = MAX_TOOL_NAME_LENGTH;\n","export const BROWSE_STORE = `\n query BrowseStore($input: BrowseStoreInput!) {\n browseStore(input: $input) {\n products { id name description price currency type status }\n facets { categories types }\n totalCount hasMore\n }\n }\n`;\n\nexport const SEARCH_STORE = `\n query SearchStore($query: String!, $filters: StoreFiltersInput) {\n searchStore(query: $query, filters: $filters) {\n id name price currency type activeInstallCount\n }\n }\n`;\n\nexport const GET_STORE_PRODUCT = `\n query GetStoreProduct($id: ID!) {\n getProduct(id: $id) {\n id name description price currency type status\n publisher { name }\n }\n }\n`;\n\nexport const MY_CART = `\n query MyCart {\n myCart {\n id currency subtotal total itemCount isEmpty\n items { id productId quantity }\n }\n }\n`;\n\nexport const ADD_TO_CART = `\n mutation AddToCart($input: AddToCartInput!) {\n addToCart(input: $input) {\n id itemCount subtotal items { productId quantity }\n }\n }\n`;\n\nexport const REMOVE_FROM_CART = `\n mutation RemoveFromCart($cartId: ID!, $itemId: ID!) {\n removeFromCart(cartId: $cartId, itemId: $itemId) {\n id itemCount subtotal\n }\n }\n`;\n\nexport const CHECKOUT_CART = `\n mutation CheckoutCart($cartId: ID!) {\n checkoutCart(cartId: $cartId) {\n success order { id total status }\n }\n }\n`;\n\nexport const GET_ORDERS = `\n query GetOrders($limit: Int, $offset: Int) {\n getOrders(limit: $limit, offset: $offset) {\n id status total currency createdAt\n }\n }\n`;\n\nexport const GET_ORDER = `\n query GetOrder($id: ID!) {\n getOrder(id: $id) {\n id status total currency paidAt billingAccountId\n lineItems { productId quantity unitPrice }\n }\n }\n`;\n\nexport const GET_INSTALLED_PRODUCTS = `\n query GetInstalledProducts($workspaceId: ID!) {\n getInstalledProducts(workspaceId: $workspaceId) {\n id application { id name } status installedAt lastUsedAt\n }\n }\n`;\n\nexport const UNINSTALL_PRODUCT = `\n mutation UninstallProduct($installationId: ID!) {\n uninstallProduct(installationId: $installationId) { success }\n }\n`;\n\nexport const GET_LICENSES = `\n query GetLicenses($entitlementId: ID!) {\n getLicenses(entitlementId: $entitlementId) {\n id status validFrom expiresAt\n }\n }\n`;\n","/**\n * Store module tools — marketplace search, cart, orders, installed apps,\n * licenses. Backend: ~/products/global/store/global-store-svc/.\n * Ported from cli-sdk/src/modules/store/.\n *\n * Note: store_cart_checkout completes the cart server-side (no browser\n * redirect). Provider-bound payment capture (Stripe checkout pages) is not\n * exposed in cli-sdk and is omitted here.\n */\n\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport {\n BROWSE_STORE,\n SEARCH_STORE,\n GET_STORE_PRODUCT,\n MY_CART,\n ADD_TO_CART,\n REMOVE_FROM_CART,\n CHECKOUT_CART,\n GET_ORDERS,\n GET_ORDER,\n GET_INSTALLED_PRODUCTS,\n UNINSTALL_PRODUCT,\n GET_LICENSES,\n} from './operations.js';\n\ninterface StoreProduct {\n id: string;\n name: string;\n price?: number;\n currency?: string;\n type?: string;\n status?: string;\n}\n\ninterface CartRow {\n id: string;\n itemCount?: number;\n subtotal?: number;\n total?: number;\n currency?: string;\n isEmpty?: boolean;\n items?: Array<{ id: string; productId: string; quantity: number }>;\n}\n\ninterface OrderRow {\n id: string;\n status?: string;\n total?: number;\n currency?: string;\n createdAt?: string;\n}\n\nfunction resolveWorkspaceId(ctx: McpContext, override: string | undefined): string | null {\n if (override !== undefined && override !== '') return override;\n const auth = ctx.auth.read();\n if (!auth?.workspaceId) return null;\n return auth.workspaceId;\n}\n\nexport function registerStoreTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Search / browse / get ──────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_search')),\n {\n title: 'Search Store',\n description: 'Search the marketplace for products by query and optional filters.',\n inputSchema: {\n query: z.string().describe('Search query'),\n type: z.string().optional().describe('Product type filter'),\n category: z.string().optional().describe('Category filter'),\n },\n },\n async ({ query, type, category }) => {\n try {\n const filters: Record<string, unknown> = {};\n if (type !== undefined) filters.productType = type.toUpperCase();\n if (category !== undefined) filters.category = category;\n const data = await ctx.gql.global.request<{ searchStore: StoreProduct[] }>(SEARCH_STORE, {\n query,\n filters: Object.keys(filters).length ? filters : undefined,\n });\n return jsonResult(data.searchStore);\n } catch (error) {\n ctx.logger.error('store_search failed', { error: String(error) });\n return errorResult(\n `Failed to search store: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_browse')),\n {\n title: 'Browse Store',\n description: 'Browse the marketplace with structured input (categories, facets, paging).',\n inputSchema: {\n category: z.string().optional().describe('Category filter'),\n type: z.string().optional().describe('Product type filter'),\n limit: z.number().optional().describe('Page size'),\n offset: z.number().optional().describe('Skip results'),\n },\n },\n async ({ category, type, limit, offset }) => {\n try {\n const input: Record<string, unknown> = {};\n if (category !== undefined) input.category = category;\n if (type !== undefined) input.productType = type.toUpperCase();\n if (limit !== undefined) input.limit = limit;\n if (offset !== undefined) input.offset = offset;\n const data = await ctx.gql.global.request<{\n browseStore: {\n products: StoreProduct[];\n facets: { categories: string[]; types: string[] };\n totalCount: number;\n hasMore: boolean;\n };\n }>(BROWSE_STORE, { input });\n return jsonResult(data.browseStore);\n } catch (error) {\n ctx.logger.error('store_browse failed', { error: String(error) });\n return errorResult(\n `Failed to browse store: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_get_product')),\n {\n title: 'Get Store Product',\n description: 'Get a marketplace product by ID.',\n inputSchema: { id: z.string().describe('Product ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ getProduct: StoreProduct | null }>(\n GET_STORE_PRODUCT,\n { id },\n );\n if (!data.getProduct) return errorResult(`Product ${id} not found`);\n return jsonResult(data.getProduct);\n } catch (error) {\n ctx.logger.error('store_get_product failed', { error: String(error) });\n return errorResult(\n `Failed to get product: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Cart ───────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_cart_list')),\n {\n title: 'Show Cart',\n description: \"Show the current user's cart.\",\n inputSchema: {},\n },\n async () => {\n try {\n const data = await ctx.gql.global.request<{ myCart: CartRow }>(MY_CART);\n return jsonResult(data.myCart);\n } catch (error) {\n ctx.logger.error('store_cart_list failed', { error: String(error) });\n return errorResult(\n `Failed to fetch cart: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_cart_add')),\n {\n title: 'Add to Cart',\n description: 'Add a product (and optional variant) to the cart.',\n inputSchema: {\n product: z.string().describe('Product ID'),\n quantity: z.number().optional().describe('Quantity (default 1)'),\n variant: z.string().optional().describe('Variant ID'),\n },\n },\n async ({ product, quantity, variant }) => {\n try {\n const input: Record<string, unknown> = { productId: product };\n if (quantity !== undefined) input.quantity = quantity;\n if (variant !== undefined) input.variantId = variant;\n const data = await ctx.gql.global.request<{ addToCart: CartRow }>(ADD_TO_CART, { input });\n return jsonResult(data.addToCart);\n } catch (error) {\n ctx.logger.error('store_cart_add failed', { error: String(error) });\n return errorResult(\n `Failed to add to cart: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_cart_remove')),\n {\n title: 'Remove from Cart',\n description: 'Remove an item from the cart.',\n inputSchema: {\n cart: z.string().describe('Cart ID'),\n item: z.string().describe('Cart item ID'),\n },\n },\n async ({ cart, item }) => {\n try {\n await ctx.gql.global.request(REMOVE_FROM_CART, { cartId: cart, itemId: item });\n return jsonResult({ status: 'success', message: 'Item removed from cart', cart, item });\n } catch (error) {\n ctx.logger.error('store_cart_remove failed', { error: String(error) });\n return errorResult(\n `Failed to remove cart item: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_cart_checkout')),\n {\n title: 'Checkout Cart',\n description:\n 'Check out the cart server-side (uses default payment method on the billing account).',\n inputSchema: { cartId: z.string().describe('Cart ID') },\n },\n async ({ cartId }) => {\n try {\n const data = await ctx.gql.global.request<{\n checkoutCart: { success: boolean; order?: OrderRow };\n }>(CHECKOUT_CART, { cartId });\n return jsonResult(data.checkoutCart);\n } catch (error) {\n ctx.logger.error('store_cart_checkout failed', { error: String(error) });\n return errorResult(\n `Failed to checkout cart: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Orders ─────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_orders_list')),\n {\n title: 'List Orders',\n description: 'List orders for the current user.',\n inputSchema: {\n limit: z.number().optional().describe('Page size (default 50)'),\n offset: z.number().optional().describe('Skip results (default 0)'),\n },\n },\n async ({ limit, offset }) => {\n try {\n const data = await ctx.gql.global.request<{ getOrders: OrderRow[] }>(GET_ORDERS, {\n limit,\n offset: offset ?? 0,\n });\n return jsonResult(data.getOrders);\n } catch (error) {\n ctx.logger.error('store_orders_list failed', { error: String(error) });\n return errorResult(\n `Failed to list orders: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_orders_get')),\n {\n title: 'Get Order',\n description: 'Get an order by ID.',\n inputSchema: { id: z.string().describe('Order ID') },\n },\n async ({ id }) => {\n try {\n const data = await ctx.gql.global.request<{ getOrder: OrderRow | null }>(GET_ORDER, { id });\n if (!data.getOrder) return errorResult(`Order ${id} not found`);\n return jsonResult(data.getOrder);\n } catch (error) {\n ctx.logger.error('store_orders_get failed', { error: String(error) });\n return errorResult(\n `Failed to get order: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Installed ──────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_installed_list')),\n {\n title: 'List Installed Products',\n description: 'List installed products in the current (or specified) workspace.',\n inputSchema: {\n workspace: z.string().optional().describe('Workspace ID (defaults to current)'),\n },\n },\n async ({ workspace }) => {\n try {\n const wid = resolveWorkspaceId(ctx, workspace);\n if (!wid) {\n return errorResult(\n 'No active workspace. Bind a workspace via the auth login flow first.',\n );\n }\n const data = await ctx.gql.global.request<{\n getInstalledProducts: Array<{\n id: string;\n application: { id: string; name: string };\n status: string;\n installedAt: string;\n }>;\n }>(GET_INSTALLED_PRODUCTS, { workspaceId: wid });\n return jsonResult(data.getInstalledProducts);\n } catch (error) {\n ctx.logger.error('store_installed_list failed', { error: String(error) });\n return errorResult(\n `Failed to list installed products: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_installed_uninstall')),\n {\n title: 'Uninstall Product',\n description: 'Uninstall a product by installation ID.',\n inputSchema: { installationId: z.string().describe('Installation ID') },\n },\n async ({ installationId }) => {\n try {\n await ctx.gql.global.request(UNINSTALL_PRODUCT, { installationId });\n return jsonResult({ status: 'success', message: 'Product uninstalled', installationId });\n } catch (error) {\n ctx.logger.error('store_installed_uninstall failed', { error: String(error) });\n return errorResult(\n `Failed to uninstall product: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Licenses ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'store_licenses_list')),\n {\n title: 'List Licenses',\n description: 'List licenses for an entitlement.',\n inputSchema: { entitlement: z.string().describe('Entitlement ID') },\n },\n async ({ entitlement }) => {\n try {\n const data = await ctx.gql.global.request<{\n getLicenses: Array<{ id: string; status: string; validFrom: string; expiresAt: string }>;\n }>(GET_LICENSES, { entitlementId: entitlement });\n return jsonResult(data.getLicenses);\n } catch (error) {\n ctx.logger.error('store_licenses_list failed', { error: String(error) });\n return errorResult(\n `Failed to list licenses: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Store module — marketplace search/browse, cart, orders, installed apps,\n * licenses. Backend: ~/products/global/store/global-store-svc/.\n * Ported from cli-sdk/src/modules/store/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerStoreTools } from './tools.js';\n\nconst storeModule: McpModule = {\n id: 'store',\n version: '0.0.1',\n displayName: 'Store',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerStoreTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default storeModule;\n"]}
|