@01.software/cli 0.7.1 → 0.9.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.
@@ -1,68 +1,30 @@
1
1
  // src/server.ts
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
 
4
- // src/tools/query-collection.ts
5
- import { z } from "zod";
6
-
7
4
  // src/lib/request-context.ts
8
5
  import { AsyncLocalStorage } from "async_hooks";
9
6
  var requestContext = new AsyncLocalStorage();
10
- function headers() {
11
- const ctx = requestContext.getStore();
12
- if (!ctx) return null;
13
- return Object.fromEntries(ctx.headers.entries());
7
+ function tenantAuthContext() {
8
+ return requestContext.getStore()?.auth ?? null;
14
9
  }
15
-
16
- // src/lib/client.ts
17
- import { createServerClient } from "@01.software/sdk";
18
- function getClient() {
19
- let secretKey;
20
- let publishableKey;
21
- try {
22
- const h = headers();
23
- secretKey = h?.["x-api-key"];
24
- publishableKey = h?.["x-publishable-key"] ?? h?.["x-client-key"];
25
- } catch {
26
- }
27
- if (!secretKey) {
28
- secretKey = process.env.SOFTWARE_SECRET_KEY;
29
- }
30
- if (!publishableKey) {
31
- publishableKey = process.env.SOFTWARE_PUBLISHABLE_KEY || process.env.NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY;
32
- }
33
- if (!secretKey) {
34
- throw new Error(
35
- "Authentication required. Provide x-api-key header (HTTP) or SOFTWARE_SECRET_KEY env var (stdio)."
36
- );
37
- }
38
- if (!secretKey.startsWith("sk01_") && !secretKey.startsWith("pat01_")) {
39
- throw new Error("Invalid API key format. Expected sk01_ or pat01_ token.");
40
- }
41
- if (!publishableKey) {
42
- throw new Error(
43
- "publishableKey is required. Provide X-Publishable-Key header (HTTP) or SOFTWARE_PUBLISHABLE_KEY env var (stdio). It is used for rate limiting and monthly quota enforcement via the edge proxy."
44
- );
45
- }
46
- return createServerClient({
47
- publishableKey,
48
- secretKey
49
- });
10
+ function hasRequestContext() {
11
+ return requestContext.getStore() !== void 0;
50
12
  }
51
13
 
52
- // src/tools/query-collection.ts
53
- import { COLLECTIONS } from "@01.software/sdk";
54
-
55
14
  // src/lib/tool-utils.ts
56
15
  function toolSuccess(data) {
57
16
  return JSON.stringify({ success: true, ...data }, null, 2);
58
17
  }
59
18
  function toolError(error) {
60
19
  const base = { success: false };
61
- if (error && typeof error === "object" && "code" in error) {
20
+ const isStructured = !!error && typeof error === "object" && ("code" in error || "reason" in error);
21
+ if (isStructured) {
62
22
  const sdkErr = error;
63
23
  base.error = sdkErr.message || "Unknown error";
64
24
  if (sdkErr.status) base.status = sdkErr.status;
65
25
  if (sdkErr.code) base.code = sdkErr.code;
26
+ if (sdkErr.reason) base.reason = sdkErr.reason;
27
+ if (sdkErr.requestId) base.requestId = sdkErr.requestId;
66
28
  if (sdkErr.suggestion) base.suggestion = sdkErr.suggestion;
67
29
  if (sdkErr.details?.errors) base.errors = sdkErr.details.errors;
68
30
  } else {
@@ -112,7 +74,493 @@ function parseJsonWhere(where) {
112
74
  }
113
75
  }
114
76
 
77
+ // ../../packages/auth-contracts/dist/index.js
78
+ var MCP_RESOURCE_AUDIENCE = "https://mcp.01.software/mcp";
79
+ var MCP_OAUTH_ISSUER = "https://01.software";
80
+ var MCP_PROTECTED_RESOURCE_METADATA_PATH = "/.well-known/oauth-protected-resource/mcp";
81
+ var MCP_TENANT_CLAIM = "tenant_id";
82
+ var MCP_TENANT_ROLE_CLAIM = "tenant_role";
83
+ var MCP_SCOPES = {
84
+ read: "mcp:read",
85
+ write: "mcp:write"
86
+ };
87
+ var MCP_CONSOLE_SERVICE_AUDIENCE = "https://api.01.software/internal/mcp";
88
+ var MCP_CONSOLE_SERVICE_SCOPE = "console:mcp_proxy";
89
+ var MCP_SERVICE_TOKEN_LIFETIME_SECONDS = 60;
90
+
91
+ // src/tool-policy.ts
92
+ var READ_ONLY_ANNOTATION = {
93
+ readOnly: true,
94
+ destructive: false,
95
+ idempotent: true,
96
+ openWorld: false
97
+ };
98
+ var NON_DESTRUCTIVE_MUTATION_ANNOTATION = {
99
+ readOnly: false,
100
+ destructive: false,
101
+ idempotent: false,
102
+ openWorld: false
103
+ };
104
+ var NON_DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION = {
105
+ readOnly: false,
106
+ destructive: false,
107
+ idempotent: true,
108
+ openWorld: false
109
+ };
110
+ var DESTRUCTIVE_NON_IDEMPOTENT_MUTATION_ANNOTATION = {
111
+ readOnly: false,
112
+ destructive: true,
113
+ idempotent: false,
114
+ openWorld: false
115
+ };
116
+ var DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION = {
117
+ readOnly: false,
118
+ destructive: true,
119
+ idempotent: true,
120
+ openWorld: false
121
+ };
122
+ var REASON_IDEMPOTENT_DESTRUCTIVE_UPDATE = "Update operations mutate persisted state but converge to the same end state under repeated identical input.";
123
+ var REASON_CART_EPHEMERAL = "Cart is pre-checkout ephemeral state; reversal is possible by reissuing the prior input. Console enforces tenant scope.";
124
+ var TOOL_POLICY_MANIFEST = {
125
+ // ── Read-only collection / validation (mcp:read, tenant-viewer) ──
126
+ "query-collection": {
127
+ category: "read-only-collection",
128
+ oauthScope: MCP_SCOPES.read,
129
+ consoleRole: "tenant-viewer",
130
+ consoleSurface: "GET /api/{collection}",
131
+ annotationPolicy: READ_ONLY_ANNOTATION
132
+ },
133
+ "get-collection-by-id": {
134
+ category: "read-only-collection",
135
+ oauthScope: MCP_SCOPES.read,
136
+ consoleRole: "tenant-viewer",
137
+ consoleSurface: "GET /api/{collection}/{id}",
138
+ annotationPolicy: READ_ONLY_ANNOTATION
139
+ },
140
+ "get-order": {
141
+ category: "read-only-collection",
142
+ oauthScope: MCP_SCOPES.read,
143
+ consoleRole: "tenant-viewer",
144
+ consoleSurface: "GET /api/orders/{id}",
145
+ annotationPolicy: READ_ONLY_ANNOTATION
146
+ },
147
+ "stock-check": {
148
+ category: "read-only-collection",
149
+ oauthScope: MCP_SCOPES.read,
150
+ consoleRole: "tenant-viewer",
151
+ consoleSurface: "GET /api/products/{id}/stock",
152
+ annotationPolicy: READ_ONLY_ANNOTATION
153
+ },
154
+ "validate-discount": {
155
+ category: "read-only-collection",
156
+ oauthScope: MCP_SCOPES.read,
157
+ consoleRole: "tenant-viewer",
158
+ consoleSurface: "POST /api/discounts/validate",
159
+ annotationPolicy: READ_ONLY_ANNOTATION
160
+ },
161
+ "calculate-shipping": {
162
+ category: "read-only-collection",
163
+ oauthScope: MCP_SCOPES.read,
164
+ consoleRole: "tenant-viewer",
165
+ consoleSurface: "POST /api/shipping/calculate",
166
+ annotationPolicy: READ_ONLY_ANNOTATION
167
+ },
168
+ "get-collection-schema": {
169
+ category: "read-only-collection",
170
+ oauthScope: MCP_SCOPES.read,
171
+ consoleRole: "tenant-viewer",
172
+ consoleSurface: "GET /api/tenants/schema/{collectionSlug}",
173
+ annotationPolicy: READ_ONLY_ANNOTATION
174
+ },
175
+ "list-configurable-fields": {
176
+ category: "read-only-collection",
177
+ oauthScope: MCP_SCOPES.read,
178
+ consoleRole: "tenant-viewer",
179
+ consoleSurface: "GET /api/tenants/field-config",
180
+ annotationPolicy: READ_ONLY_ANNOTATION
181
+ },
182
+ // ── Tenant context (mcp:read, tenant-viewer) ──
183
+ "get-tenant-context": {
184
+ category: "read-only-tenant",
185
+ oauthScope: MCP_SCOPES.read,
186
+ consoleRole: "tenant-viewer",
187
+ consoleSurface: "GET /api/tenants/context",
188
+ annotationPolicy: READ_ONLY_ANNOTATION
189
+ },
190
+ // ── Cart mutations (mcp:write, tenant-editor) ──
191
+ "add-cart-item": {
192
+ category: "mutation-cart",
193
+ oauthScope: MCP_SCOPES.write,
194
+ consoleRole: "tenant-editor",
195
+ consoleSurface: "POST /api/carts/{id}/items",
196
+ annotationPolicy: NON_DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION
197
+ },
198
+ "update-cart-item": {
199
+ category: "mutation-cart",
200
+ oauthScope: MCP_SCOPES.write,
201
+ consoleRole: "tenant-editor",
202
+ consoleSurface: "PATCH /api/carts/{id}/items/{itemId}",
203
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
204
+ exemptionReason: REASON_CART_EPHEMERAL
205
+ },
206
+ "remove-cart-item": {
207
+ category: "mutation-cart",
208
+ oauthScope: MCP_SCOPES.write,
209
+ consoleRole: "tenant-editor",
210
+ consoleSurface: "DELETE /api/carts/{id}/items/{itemId}",
211
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
212
+ exemptionReason: REASON_CART_EPHEMERAL
213
+ },
214
+ "clear-cart": {
215
+ category: "mutation-cart",
216
+ oauthScope: MCP_SCOPES.write,
217
+ consoleRole: "tenant-editor",
218
+ consoleSurface: "POST /api/carts/{id}/clear",
219
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
220
+ exemptionReason: REASON_CART_EPHEMERAL
221
+ },
222
+ "apply-discount": {
223
+ category: "mutation-cart",
224
+ oauthScope: MCP_SCOPES.write,
225
+ consoleRole: "tenant-editor",
226
+ consoleSurface: "POST /api/carts/{id}/discount",
227
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
228
+ exemptionReason: REASON_CART_EPHEMERAL
229
+ },
230
+ "remove-discount": {
231
+ category: "mutation-cart",
232
+ oauthScope: MCP_SCOPES.write,
233
+ consoleRole: "tenant-editor",
234
+ consoleSurface: "DELETE /api/carts/{id}/discount",
235
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
236
+ exemptionReason: REASON_CART_EPHEMERAL
237
+ },
238
+ // ── Order mutations (mcp:write, tenant-admin) ──
239
+ "checkout": {
240
+ category: "mutation-order",
241
+ oauthScope: MCP_SCOPES.write,
242
+ consoleRole: "tenant-admin",
243
+ consoleSurface: "POST /api/checkout",
244
+ annotationPolicy: DESTRUCTIVE_NON_IDEMPOTENT_MUTATION_ANNOTATION
245
+ },
246
+ "create-order": {
247
+ category: "mutation-order",
248
+ oauthScope: MCP_SCOPES.write,
249
+ consoleRole: "tenant-admin",
250
+ consoleSurface: "POST /api/orders",
251
+ annotationPolicy: DESTRUCTIVE_NON_IDEMPOTENT_MUTATION_ANNOTATION
252
+ },
253
+ "update-order": {
254
+ category: "mutation-order",
255
+ oauthScope: MCP_SCOPES.write,
256
+ consoleRole: "tenant-admin",
257
+ consoleSurface: "PATCH /api/orders/{id}",
258
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
259
+ exemptionReason: REASON_IDEMPOTENT_DESTRUCTIVE_UPDATE
260
+ },
261
+ // ── Fulfillment mutations (mcp:write, tenant-admin) ──
262
+ "create-fulfillment": {
263
+ category: "mutation-fulfillment",
264
+ oauthScope: MCP_SCOPES.write,
265
+ consoleRole: "tenant-admin",
266
+ consoleSurface: "POST /api/orders/{id}/fulfillments",
267
+ annotationPolicy: NON_DESTRUCTIVE_MUTATION_ANNOTATION
268
+ },
269
+ "update-fulfillment": {
270
+ category: "mutation-fulfillment",
271
+ oauthScope: MCP_SCOPES.write,
272
+ consoleRole: "tenant-admin",
273
+ consoleSurface: "PATCH /api/fulfillments/{id}",
274
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
275
+ exemptionReason: REASON_IDEMPOTENT_DESTRUCTIVE_UPDATE
276
+ },
277
+ // ── Return mutations (mcp:write, tenant-admin) ──
278
+ "create-return": {
279
+ category: "mutation-return",
280
+ oauthScope: MCP_SCOPES.write,
281
+ consoleRole: "tenant-admin",
282
+ consoleSurface: "POST /api/returns",
283
+ annotationPolicy: DESTRUCTIVE_NON_IDEMPOTENT_MUTATION_ANNOTATION
284
+ },
285
+ "update-return": {
286
+ category: "mutation-return",
287
+ oauthScope: MCP_SCOPES.write,
288
+ consoleRole: "tenant-admin",
289
+ consoleSurface: "PATCH /api/returns/{id}",
290
+ annotationPolicy: DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION,
291
+ exemptionReason: REASON_IDEMPOTENT_DESTRUCTIVE_UPDATE
292
+ },
293
+ "return-with-refund": {
294
+ category: "mutation-return",
295
+ oauthScope: MCP_SCOPES.write,
296
+ consoleRole: "tenant-admin",
297
+ consoleSurface: "POST /api/returns/with-refund",
298
+ annotationPolicy: DESTRUCTIVE_NON_IDEMPOTENT_MUTATION_ANNOTATION
299
+ },
300
+ // ── Transaction mutations (mcp:write, tenant-admin) ──
301
+ "update-transaction": {
302
+ category: "mutation-transaction",
303
+ oauthScope: MCP_SCOPES.write,
304
+ consoleRole: "tenant-admin",
305
+ consoleSurface: "PATCH /api/transactions/{id}",
306
+ annotationPolicy: DESTRUCTIVE_NON_IDEMPOTENT_MUTATION_ANNOTATION
307
+ },
308
+ // ── Field-config mutations (mcp:write, tenant-admin) ──
309
+ "update-field-config": {
310
+ category: "mutation-field-config",
311
+ oauthScope: MCP_SCOPES.write,
312
+ consoleRole: "tenant-admin",
313
+ consoleSurface: "PATCH /api/tenants/field-config",
314
+ annotationPolicy: NON_DESTRUCTIVE_IDEMPOTENT_MUTATION_ANNOTATION
315
+ },
316
+ // ── SDK doc tools (mcp:read, tenant-viewer, sdk-static surface) ──
317
+ "sdk-get-recipe": {
318
+ category: "sdk-doc",
319
+ oauthScope: MCP_SCOPES.read,
320
+ consoleRole: "tenant-viewer",
321
+ consoleSurface: "sdk-static",
322
+ annotationPolicy: READ_ONLY_ANNOTATION
323
+ },
324
+ "sdk-search-docs": {
325
+ category: "sdk-doc",
326
+ oauthScope: MCP_SCOPES.read,
327
+ consoleRole: "tenant-viewer",
328
+ consoleSurface: "sdk-static",
329
+ annotationPolicy: READ_ONLY_ANNOTATION
330
+ },
331
+ "sdk-get-auth-setup": {
332
+ category: "sdk-doc",
333
+ oauthScope: MCP_SCOPES.read,
334
+ consoleRole: "tenant-viewer",
335
+ consoleSurface: "sdk-static",
336
+ annotationPolicy: READ_ONLY_ANNOTATION
337
+ },
338
+ "sdk-get-collection-pattern": {
339
+ category: "sdk-doc",
340
+ oauthScope: MCP_SCOPES.read,
341
+ consoleRole: "tenant-viewer",
342
+ consoleSurface: "sdk-static",
343
+ annotationPolicy: READ_ONLY_ANNOTATION
344
+ }
345
+ };
346
+ function evaluateToolPolicy(toolName, scopes) {
347
+ const entry = TOOL_POLICY_MANIFEST[toolName];
348
+ if (!entry) {
349
+ return {
350
+ allowed: false,
351
+ reason: "tool_policy_missing",
352
+ message: `No tool-policy entry for ${toolName}`
353
+ };
354
+ }
355
+ if (!scopes.includes(entry.oauthScope)) {
356
+ return {
357
+ allowed: false,
358
+ reason: "insufficient_scope",
359
+ message: `Tool ${toolName} requires ${entry.oauthScope}`
360
+ };
361
+ }
362
+ return { allowed: true, entry };
363
+ }
364
+
115
365
  // src/tools/query-collection.ts
366
+ import { z } from "zod";
367
+
368
+ // src/lib/client.ts
369
+ import {
370
+ CollectionClient,
371
+ CommunityClient,
372
+ ModerationApi,
373
+ ServerCommerceClient,
374
+ createServerClient
375
+ } from "@01.software/sdk";
376
+
377
+ // src/service-auth.ts
378
+ import { createPrivateKey, randomUUID, sign as signBytes } from "crypto";
379
+ var KEYSET_ENV = "MCP_SERVICE_KEYSET";
380
+ function assertProductionKeysetUse(source) {
381
+ const vercelEnv = process.env.VERCEL_ENV;
382
+ if (vercelEnv && vercelEnv !== "production") {
383
+ throw new Error(
384
+ `${source} is only allowed in production Vercel deployments; non-production MCP service auth needs environment-specific issuer, audience, JWKS URI, and key material`
385
+ );
386
+ }
387
+ }
388
+ function parsePrivateJwk() {
389
+ const keyset = signingKeyset();
390
+ const jwk = keyset.current;
391
+ const source = keyset.source;
392
+ if (typeof jwk.d !== "string" || jwk.d.length === 0) {
393
+ throw new Error(`${source} current key must be a private JWK`);
394
+ }
395
+ if (typeof jwk.kid !== "string" || jwk.kid.length === 0) {
396
+ throw new Error(`${source} must include kid`);
397
+ }
398
+ return jwk;
399
+ }
400
+ function signingKeyset() {
401
+ const raw = process.env[KEYSET_ENV];
402
+ const source = KEYSET_ENV;
403
+ if (raw) assertProductionKeysetUse(source);
404
+ const parsed = (() => {
405
+ if (!raw) return null;
406
+ try {
407
+ return JSON.parse(raw);
408
+ } catch {
409
+ throw new Error(`${KEYSET_ENV} is invalid JSON`);
410
+ }
411
+ })();
412
+ if (!parsed) throw new Error("MCP service JWT signing key is not configured");
413
+ const keys = Array.isArray(parsed.keys) ? parsed.keys : [parsed];
414
+ if (keys.length === 0 || keys.length > 2) {
415
+ throw new Error(
416
+ `${source} must contain one current key and at most one previous key`
417
+ );
418
+ }
419
+ const currentKid = parsed.current_kid;
420
+ if (typeof currentKid !== "string" && keys.length > 1) {
421
+ throw new Error(
422
+ `${source} must include current_kid when multiple keys are present`
423
+ );
424
+ }
425
+ const current = typeof currentKid === "string" ? keys.find((key) => key.kid === currentKid) : keys[0];
426
+ if (!current) throw new Error(`${source} current_kid is not in keys`);
427
+ return { current, keys, source };
428
+ }
429
+ function algForJwk(jwk) {
430
+ if (jwk.kty === "RSA") return "RS256";
431
+ if (jwk.kty === "EC" && jwk.crv === "P-256") return "ES256";
432
+ throw new Error("MCP service JWT signing key must be RSA or P-256 EC");
433
+ }
434
+ function toPublicJwk(jwk) {
435
+ const {
436
+ d: _d,
437
+ p: _p,
438
+ q: _q,
439
+ dp: _dp,
440
+ dq: _dq,
441
+ qi: _qi,
442
+ oth: _oth,
443
+ ...publicJwk
444
+ } = jwk;
445
+ return {
446
+ ...publicJwk,
447
+ alg: typeof publicJwk.alg === "string" ? publicJwk.alg : algForJwk(jwk),
448
+ use: "sig"
449
+ };
450
+ }
451
+ function base64urlJson(value) {
452
+ return Buffer.from(JSON.stringify(value)).toString("base64url");
453
+ }
454
+ function apiScopesFor(context) {
455
+ return context.scopes.includes("mcp:write") ? ["read", "write"] : ["read"];
456
+ }
457
+ function mcpServicePublicJwks() {
458
+ const keyset = signingKeyset();
459
+ const keys = /* @__PURE__ */ new Map();
460
+ for (const jwk of keyset.keys.map(toPublicJwk)) {
461
+ if (typeof jwk.kid === "string" && jwk.kid.length > 0) {
462
+ keys.set(jwk.kid, jwk);
463
+ }
464
+ }
465
+ return { keys: [...keys.values()] };
466
+ }
467
+ function signMcpServiceToken(context) {
468
+ if (!context.principalId) {
469
+ throw new Error("MCP OAuth principal is required for Console service auth");
470
+ }
471
+ const jwk = parsePrivateJwk();
472
+ const alg = algForJwk(jwk);
473
+ const now = Math.floor(Date.now() / 1e3);
474
+ const payload = {
475
+ iss: MCP_OAUTH_ISSUER,
476
+ aud: MCP_CONSOLE_SERVICE_AUDIENCE,
477
+ iat: now,
478
+ nbf: now,
479
+ exp: now + MCP_SERVICE_TOKEN_LIFETIME_SECONDS,
480
+ jti: randomUUID(),
481
+ sub: context.principalId,
482
+ act: {
483
+ sub: context.principalId,
484
+ tenant_id: context.tenantId
485
+ },
486
+ [MCP_TENANT_CLAIM]: context.tenantId,
487
+ [MCP_TENANT_ROLE_CLAIM]: context.tenantRole,
488
+ scope: MCP_CONSOLE_SERVICE_SCOPE,
489
+ api_scopes: apiScopesFor(context),
490
+ mcp_scopes: context.scopes
491
+ };
492
+ const header = { alg, kid: jwk.kid, typ: "JWT" };
493
+ const encodedHeader = base64urlJson(header);
494
+ const encodedPayload = base64urlJson(payload);
495
+ const signingInput = `${encodedHeader}.${encodedPayload}`;
496
+ const key = createPrivateKey({ key: jwk, format: "jwk" });
497
+ const signature = alg === "RS256" ? signBytes("RSA-SHA256", Buffer.from(signingInput), key) : signBytes("SHA256", Buffer.from(signingInput), {
498
+ key,
499
+ dsaEncoding: "ieee-p1363"
500
+ });
501
+ return `${signingInput}.${signature.toString("base64url")}`;
502
+ }
503
+
504
+ // src/lib/client.ts
505
+ var MISSING_HTTP_AUTH_CONTEXT_ERROR = "MCP HTTP requests require a validated OAuth tenant context before tool execution.";
506
+ function getClient() {
507
+ const oauthContext = tenantAuthContext();
508
+ if (oauthContext) {
509
+ const serviceToken = signMcpServiceToken(oauthContext);
510
+ const client = {
511
+ lastRequestId: null,
512
+ commerce: void 0,
513
+ collections: void 0,
514
+ community: void 0
515
+ };
516
+ const onRequestId = (id) => {
517
+ client.lastRequestId = id;
518
+ };
519
+ client.commerce = new ServerCommerceClient({
520
+ secretKey: serviceToken,
521
+ onRequestId
522
+ });
523
+ client.collections = new CollectionClient(
524
+ "",
525
+ serviceToken,
526
+ void 0,
527
+ void 0,
528
+ onRequestId
529
+ );
530
+ const community = new CommunityClient({ secretKey: serviceToken });
531
+ const moderation = new ModerationApi({ secretKey: serviceToken, onRequestId });
532
+ client.community = Object.assign(community, {
533
+ moderation: {
534
+ banCustomer: moderation.banCustomer.bind(moderation),
535
+ unbanCustomer: moderation.unbanCustomer.bind(moderation)
536
+ }
537
+ });
538
+ return client;
539
+ }
540
+ if (hasRequestContext()) throw new Error(MISSING_HTTP_AUTH_CONTEXT_ERROR);
541
+ const secretKey = process.env.SOFTWARE_SECRET_KEY;
542
+ const publishableKey = process.env.SOFTWARE_PUBLISHABLE_KEY || process.env.NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY;
543
+ if (!secretKey) {
544
+ throw new Error(
545
+ "Authentication required. Set SOFTWARE_SECRET_KEY for stdio transport."
546
+ );
547
+ }
548
+ if (!secretKey.startsWith("sk01_") && !secretKey.startsWith("pat01_")) {
549
+ throw new Error("Invalid SOFTWARE_SECRET_KEY format. Expected sk01_ or pat01_ token.");
550
+ }
551
+ if (!publishableKey) {
552
+ throw new Error(
553
+ "publishableKey is required. Set SOFTWARE_PUBLISHABLE_KEY for stdio transport. It is used for rate limiting and monthly quota enforcement via the edge proxy."
554
+ );
555
+ }
556
+ return createServerClient({
557
+ publishableKey,
558
+ secretKey
559
+ });
560
+ }
561
+
562
+ // src/tools/query-collection.ts
563
+ import { COLLECTIONS } from "@01.software/sdk";
116
564
  var schema = {
117
565
  collection: z.enum(COLLECTIONS).describe("Collection name (required)"),
118
566
  where: z.string().optional().describe(
@@ -203,201 +651,12 @@ async function getCollectionById({
203
651
  }
204
652
  }
205
653
 
206
- // src/tools/create-collection.ts
654
+ // src/tools/get-order.ts
207
655
  import { z as z3 } from "zod";
208
- import { COLLECTIONS as COLLECTIONS3 } from "@01.software/sdk";
209
656
  var schema3 = {
210
- collection: z3.enum(COLLECTIONS3).describe("Collection name (required)"),
211
- data: z3.record(z3.string(), z3.unknown()).describe(
212
- "Data to create (required). Use get-collection-schema first to understand writable fields, hidden fields, and required metadata. Server will validate and reject invalid fields."
213
- )
657
+ orderNumber: z3.string().min(1).describe("Order number to look up (required)")
214
658
  };
215
659
  var metadata3 = {
216
- name: "create-collection",
217
- description: "Create a new collection item",
218
- annotations: {
219
- title: "Create collection item",
220
- readOnlyHint: false,
221
- destructiveHint: false,
222
- idempotentHint: false
223
- }
224
- };
225
- async function createCollection({
226
- collection,
227
- data
228
- }) {
229
- try {
230
- const client = getClient().collections;
231
- const result = await client.from(collection).create(data);
232
- return toolSuccess({ data: result.doc, message: result.message });
233
- } catch (error) {
234
- return toolError(error);
235
- }
236
- }
237
-
238
- // src/tools/update-collection.ts
239
- import { z as z4 } from "zod";
240
- import { COLLECTIONS as COLLECTIONS4 } from "@01.software/sdk";
241
- var schema4 = {
242
- collection: z4.enum(COLLECTIONS4).describe("Collection name (required)"),
243
- id: z4.string().min(1).describe("Item ID (required)"),
244
- data: z4.record(z4.string(), z4.unknown()).describe(
245
- "Data to update (required). Use get-collection-by-id first to check current structure, then get-collection-schema to confirm writable fields and required metadata. Server will validate and reject invalid fields."
246
- )
247
- };
248
- var metadata4 = {
249
- name: "update-collection",
250
- description: "Update an existing collection item",
251
- annotations: {
252
- title: "Update collection item",
253
- readOnlyHint: false,
254
- destructiveHint: true,
255
- idempotentHint: true
256
- }
257
- };
258
- async function updateCollection({
259
- collection,
260
- id,
261
- data
262
- }) {
263
- try {
264
- const client = getClient().collections;
265
- const result = await client.from(collection).update(id, data);
266
- return toolSuccess({ data: result.doc, message: result.message });
267
- } catch (error) {
268
- return toolError(error);
269
- }
270
- }
271
-
272
- // src/tools/delete-collection.ts
273
- import { z as z5 } from "zod";
274
- import { COLLECTIONS as COLLECTIONS5 } from "@01.software/sdk";
275
- var schema5 = {
276
- collection: z5.enum(COLLECTIONS5).describe("Collection name (required)"),
277
- id: z5.string().min(1).describe("Item ID (required)")
278
- };
279
- var metadata5 = {
280
- name: "delete-collection",
281
- description: "Delete a collection item",
282
- annotations: {
283
- title: "Delete collection item",
284
- readOnlyHint: false,
285
- destructiveHint: true,
286
- idempotentHint: true
287
- }
288
- };
289
- async function deleteCollection({
290
- collection,
291
- id
292
- }) {
293
- try {
294
- const client = getClient();
295
- await client.collections.from(collection).remove(id);
296
- return toolSuccess({ message: "Deleted successfully." });
297
- } catch (error) {
298
- return toolError(error);
299
- }
300
- }
301
-
302
- // src/tools/delete-many-collection.ts
303
- import { z as z6 } from "zod";
304
- import { COLLECTIONS as COLLECTIONS6 } from "@01.software/sdk";
305
- var schema6 = {
306
- collection: z6.enum(COLLECTIONS6).describe("Collection name (required)"),
307
- where: z6.string().describe(
308
- `Filter conditions (JSON string, required). Determines which items to delete. Example: '{"status":{"equals":"archived"}}'`
309
- )
310
- };
311
- var metadata6 = {
312
- name: "delete-many-collection",
313
- description: "Bulk delete collection items matching a filter. All matching items will be permanently deleted.",
314
- annotations: {
315
- title: "Bulk delete collection items",
316
- readOnlyHint: false,
317
- destructiveHint: true,
318
- idempotentHint: true
319
- }
320
- };
321
- async function deleteManyCollection({
322
- collection,
323
- where
324
- }) {
325
- try {
326
- const client = getClient().collections;
327
- const parsed = parseJsonWhere(where);
328
- if (!parsed.success) return parsed.error;
329
- if (!parsed.data || typeof parsed.data !== "object" || Object.keys(parsed.data).length === 0) {
330
- return toolError(
331
- new Error(
332
- 'Empty "where" filter is not allowed for bulk deletes. Provide at least one filter condition.'
333
- )
334
- );
335
- }
336
- const result = await client.from(collection).removeMany(parsed.data);
337
- return toolSuccess({
338
- totalDocs: result.totalDocs,
339
- message: `Deleted ${result.totalDocs} item(s).`
340
- });
341
- } catch (error) {
342
- return toolError(error);
343
- }
344
- }
345
-
346
- // src/tools/update-many-collection.ts
347
- import { z as z7 } from "zod";
348
- import { COLLECTIONS as COLLECTIONS7 } from "@01.software/sdk";
349
- var schema7 = {
350
- collection: z7.enum(COLLECTIONS7).describe("Collection name (required)"),
351
- where: z7.string().describe(
352
- `Filter conditions (JSON string, required). Determines which items to update. Example: '{"status":{"equals":"draft"}}'`
353
- ),
354
- data: z7.record(z7.string(), z7.unknown()).describe(
355
- "Data to update (required). Partial updates supported. Server will validate and reject invalid fields."
356
- )
357
- };
358
- var metadata7 = {
359
- name: "update-many-collection",
360
- description: "Bulk update collection items matching a filter. All matching items will be updated with the provided data.",
361
- annotations: {
362
- title: "Bulk update collection items",
363
- readOnlyHint: false,
364
- destructiveHint: true,
365
- idempotentHint: true
366
- }
367
- };
368
- async function updateManyCollection({
369
- collection,
370
- where,
371
- data
372
- }) {
373
- try {
374
- const client = getClient().collections;
375
- const parsed = parseJsonWhere(where);
376
- if (!parsed.success) return parsed.error;
377
- if (!parsed.data || typeof parsed.data !== "object" || Object.keys(parsed.data).length === 0) {
378
- return toolError(
379
- new Error(
380
- 'Empty "where" filter is not allowed for bulk updates. Provide at least one filter condition.'
381
- )
382
- );
383
- }
384
- const result = await client.from(collection).updateMany(parsed.data, data);
385
- return toolSuccess({
386
- data: result.docs,
387
- totalDocs: result.totalDocs,
388
- message: `Updated ${result.totalDocs} item(s).`
389
- });
390
- } catch (error) {
391
- return toolError(error);
392
- }
393
- }
394
-
395
- // src/tools/get-order.ts
396
- import { z as z8 } from "zod";
397
- var schema8 = {
398
- orderNumber: z8.string().min(1).describe("Order number to look up (required)")
399
- };
400
- var metadata8 = {
401
660
  name: "get-order",
402
661
  description: "Get order details by order number. Returns order with related data (depth:1).",
403
662
  annotations: {
@@ -425,26 +684,26 @@ async function getOrder({
425
684
  }
426
685
 
427
686
  // src/tools/create-order.ts
428
- import { z as z9 } from "zod";
429
- var schema9 = {
430
- pgPaymentId: z9.string().optional().describe("PG payment ID (optional \u2014 omit for free orders)"),
431
- orderNumber: z9.string().min(1).describe("Unique order number (required)"),
432
- customerSnapshot: z9.object({
433
- name: z9.string().optional().describe("Customer name"),
434
- email: z9.string().describe("Customer email (required)"),
435
- phone: z9.string().optional().describe("Customer phone")
687
+ import { z as z4 } from "zod";
688
+ var schema4 = {
689
+ pgPaymentId: z4.string().optional().describe("PG payment ID (optional \u2014 omit for free orders)"),
690
+ orderNumber: z4.string().min(1).describe("Unique order number (required)"),
691
+ customerSnapshot: z4.object({
692
+ name: z4.string().optional().describe("Customer name"),
693
+ email: z4.string().describe("Customer email (required)"),
694
+ phone: z4.string().optional().describe("Customer phone")
436
695
  }).describe("Customer snapshot at time of order (required)"),
437
- shippingAddress: z9.record(z9.string(), z9.unknown()).describe(
696
+ shippingAddress: z4.record(z4.string(), z4.unknown()).describe(
438
697
  "Shipping address object (required). Fields: postalCode, address1, address2, deliveryMessage, recipientName, phone"
439
698
  ),
440
- orderItems: z9.array(z9.record(z9.string(), z9.unknown())).describe(
699
+ orderItems: z4.array(z4.record(z4.string(), z4.unknown())).describe(
441
700
  "Array of order item objects (required). Each: { product, variant, option, quantity, unitPrice?, totalPrice? }"
442
701
  ),
443
- totalAmount: z9.number().nonnegative().describe("Total order amount (required, min 0)"),
444
- shippingAmount: z9.number().nonnegative().optional().describe("Shipping amount (optional, default 0)"),
445
- discountCode: z9.string().optional().describe("Discount code to apply (optional)")
702
+ totalAmount: z4.number().nonnegative().describe("Total order amount (required, min 0)"),
703
+ shippingAmount: z4.number().nonnegative().optional().describe("Shipping amount (optional, default 0)"),
704
+ discountCode: z4.string().optional().describe("Discount code to apply (optional)")
446
705
  };
447
- var metadata9 = {
706
+ var metadata4 = {
448
707
  name: "create-order",
449
708
  description: "Create a new order with products and shipping information. Supports idempotency.",
450
709
  annotations: {
@@ -467,10 +726,10 @@ async function createOrder(params) {
467
726
  }
468
727
 
469
728
  // src/tools/update-order.ts
470
- import { z as z10 } from "zod";
471
- var schema10 = {
472
- orderNumber: z10.string().min(1).describe("Order number (required)"),
473
- status: z10.enum([
729
+ import { z as z5 } from "zod";
730
+ var schema5 = {
731
+ orderNumber: z5.string().min(1).describe("Order number (required)"),
732
+ status: z5.enum([
474
733
  "pending",
475
734
  "paid",
476
735
  "failed",
@@ -483,7 +742,7 @@ var schema10 = {
483
742
  "New order status. Return-related statuses (return_requested, return_processing, returned) must be set via Return endpoints."
484
743
  )
485
744
  };
486
- var metadata10 = {
745
+ var metadata5 = {
487
746
  name: "update-order",
488
747
  description: "Update order status. Automatically adjusts stock on status changes (e.g., canceled restores stock).",
489
748
  annotations: {
@@ -507,17 +766,17 @@ async function updateOrder({
507
766
  }
508
767
 
509
768
  // src/tools/checkout.ts
510
- import { z as z11 } from "zod";
511
- var schema11 = {
512
- cartId: z11.string().min(1).describe("Cart ID to convert to order (required)"),
513
- pgPaymentId: z11.string().optional().describe("PG payment ID (optional \u2014 omit for free orders)"),
514
- orderNumber: z11.string().min(1).describe("Unique order number (required)"),
515
- customerSnapshot: z11.record(z11.string(), z11.unknown()).describe(
769
+ import { z as z6 } from "zod";
770
+ var schema6 = {
771
+ cartId: z6.string().min(1).describe("Cart ID to convert to order (required)"),
772
+ pgPaymentId: z6.string().optional().describe("PG payment ID (optional \u2014 omit for free orders)"),
773
+ orderNumber: z6.string().min(1).describe("Unique order number (required)"),
774
+ customerSnapshot: z6.record(z6.string(), z6.unknown()).describe(
516
775
  "Customer snapshot object (required). Fields: { name?, email, phone? }"
517
776
  ),
518
- discountCode: z11.string().optional().describe("Discount code to apply (optional)")
777
+ discountCode: z6.string().optional().describe("Discount code to apply (optional)")
519
778
  };
520
- var metadata11 = {
779
+ var metadata6 = {
521
780
  name: "checkout",
522
781
  description: "Convert a cart to an order. Validates stock, creates order and transaction, marks cart as completed. Supports idempotency.",
523
782
  annotations: {
@@ -540,21 +799,21 @@ async function checkout(params) {
540
799
  }
541
800
 
542
801
  // src/tools/create-fulfillment.ts
543
- import { z as z12 } from "zod";
544
- var schema12 = {
545
- orderNumber: z12.string().min(1).describe("Order number (required)"),
546
- carrier: z12.string().optional().describe("Shipping carrier name (optional)"),
547
- trackingNumber: z12.string().optional().describe(
802
+ import { z as z7 } from "zod";
803
+ var schema7 = {
804
+ orderNumber: z7.string().min(1).describe("Order number (required)"),
805
+ carrier: z7.string().optional().describe("Shipping carrier name (optional)"),
806
+ trackingNumber: z7.string().optional().describe(
548
807
  'Tracking number (optional). Setting carrier + tracking triggers "shipped" status'
549
808
  ),
550
- items: z12.array(
551
- z12.object({
552
- orderItem: z12.string().min(1).describe("Order item ID"),
553
- quantity: z12.number().int().positive().describe("Quantity to fulfill")
809
+ items: z7.array(
810
+ z7.object({
811
+ orderItem: z7.string().min(1).describe("Order item ID"),
812
+ quantity: z7.number().int().positive().describe("Quantity to fulfill")
554
813
  })
555
814
  ).describe("Array of items to fulfill (required)")
556
815
  };
557
- var metadata12 = {
816
+ var metadata7 = {
558
817
  name: "create-fulfillment",
559
818
  description: "Create a shipment/fulfillment for order items. Auto-updates order status (paid \u2192 preparing \u2192 shipped).",
560
819
  annotations: {
@@ -585,20 +844,20 @@ async function createFulfillment({
585
844
  }
586
845
 
587
846
  // src/tools/update-fulfillment.ts
588
- import { z as z13 } from "zod";
589
- var schema13 = {
590
- fulfillmentId: z13.string().min(1).describe("Fulfillment ID (required)"),
591
- status: z13.enum(["packed", "shipped", "delivered", "failed"]).describe(
847
+ import { z as z8 } from "zod";
848
+ var schema8 = {
849
+ fulfillmentId: z8.string().min(1).describe("Fulfillment ID (required)"),
850
+ status: z8.enum(["packed", "shipped", "delivered", "failed"]).describe(
592
851
  "New fulfillment status (required). FSM: pending\u2192packed/shipped/failed, packed\u2192shipped/failed, shipped\u2192delivered/failed"
593
852
  ),
594
- carrier: z13.string().optional().describe(
853
+ carrier: z8.string().optional().describe(
595
854
  "Shipping carrier (optional, changeable only in pending/packed status)"
596
855
  ),
597
- trackingNumber: z13.string().optional().describe(
856
+ trackingNumber: z8.string().optional().describe(
598
857
  "Tracking number (optional, changeable only in pending/packed status)"
599
858
  )
600
859
  };
601
- var metadata13 = {
860
+ var metadata8 = {
602
861
  name: "update-fulfillment",
603
862
  description: "Update fulfillment status, carrier, and tracking number. Auto-updates order status when all fulfillments are delivered.",
604
863
  annotations: {
@@ -628,15 +887,134 @@ async function updateFulfillment({
628
887
  }
629
888
  }
630
889
 
890
+ // ../../packages/contracts/src/tenant/index.ts
891
+ import { z as z9 } from "zod";
892
+ var tenantFieldConfigStateSchema = z9.object({
893
+ hiddenFields: z9.array(z9.string()),
894
+ isHidden: z9.boolean()
895
+ }).strict();
896
+ var tenantContextQuerySchema = z9.object({
897
+ counts: z9.literal("true").optional()
898
+ }).strict();
899
+ var tenantContextToolInputSchema = z9.object({
900
+ includeCounts: z9.boolean().optional().default(false).describe(
901
+ "Include per-collection document counts and config status (bypasses cache, slower)"
902
+ )
903
+ }).strict();
904
+ var tenantContextResponseSchema = z9.object({
905
+ tenant: z9.object({
906
+ id: z9.string(),
907
+ name: z9.string(),
908
+ plan: z9.string(),
909
+ planSource: z9.string().optional(),
910
+ authoritative: z9.boolean().optional(),
911
+ capabilityVersion: z9.string().optional(),
912
+ isDevMode: z9.boolean()
913
+ }).strict(),
914
+ features: z9.array(z9.string()),
915
+ collections: z9.object({
916
+ active: z9.array(z9.string()),
917
+ inactive: z9.array(z9.string())
918
+ }).strict(),
919
+ fieldConfigs: z9.record(z9.string(), tenantFieldConfigStateSchema),
920
+ counts: z9.record(z9.string(), z9.number()).optional(),
921
+ config: z9.object({
922
+ webhookConfigured: z9.boolean()
923
+ }).strict().optional()
924
+ }).strict();
925
+ var COLLECTION_SCHEMA_CONTRACT_VERSION = 1;
926
+ var collectionSchemaEndpointParamsSchema = z9.object({
927
+ collectionSlug: z9.string().min(1, "collectionSlug is required")
928
+ }).strict();
929
+ function createCollectionSchemaToolInputSchema(collections) {
930
+ return z9.object({
931
+ collection: z9.enum(collections).describe("Collection name (required)")
932
+ }).strict();
933
+ }
934
+ var collectionFieldOptionSchema = z9.object({
935
+ label: z9.string(),
936
+ value: z9.string()
937
+ }).strict();
938
+ var collectionFieldSchema = z9.lazy(
939
+ () => z9.object({
940
+ name: z9.string(),
941
+ path: z9.string(),
942
+ type: z9.string(),
943
+ required: z9.literal(true).optional(),
944
+ unique: z9.literal(true).optional(),
945
+ hasMany: z9.literal(true).optional(),
946
+ relationTo: z9.union([z9.string(), z9.array(z9.string())]).optional(),
947
+ options: z9.array(collectionFieldOptionSchema).optional(),
948
+ hidden: z9.literal(true).optional(),
949
+ systemManaged: z9.literal(true).optional(),
950
+ writable: z9.boolean().optional(),
951
+ fields: z9.array(collectionFieldSchema).optional()
952
+ }).strict()
953
+ );
954
+ var collectionSchemaResponseSchema = z9.object({
955
+ contractVersion: z9.literal(COLLECTION_SCHEMA_CONTRACT_VERSION),
956
+ mode: z9.literal("effective"),
957
+ collection: z9.object({
958
+ slug: z9.string(),
959
+ timestamps: z9.boolean(),
960
+ alwaysActive: z9.boolean(),
961
+ feature: z9.string().nullable(),
962
+ systemFields: z9.array(z9.string()),
963
+ visibility: z9.object({
964
+ collectionHidden: z9.boolean(),
965
+ hiddenFields: z9.array(z9.string())
966
+ }).strict(),
967
+ fields: z9.array(collectionFieldSchema)
968
+ }).strict()
969
+ }).strict();
970
+
971
+ // ../../packages/contracts/src/ecommerce/index.ts
972
+ import { z as z10 } from "zod";
973
+ var transactionStatusSchema = z10.enum([
974
+ "pending",
975
+ "paid",
976
+ "failed",
977
+ "canceled"
978
+ ]);
979
+ var updateTransactionSchema = z10.object({
980
+ pgPaymentId: z10.string().min(1, "pgPaymentId is required").describe("PG payment ID (required)"),
981
+ status: transactionStatusSchema.describe(
982
+ "New transaction status (required)"
983
+ ),
984
+ paymentMethod: z10.string().optional().describe("Payment method (optional)"),
985
+ receiptUrl: z10.string().optional().describe("Receipt URL (optional)"),
986
+ paymentKey: z10.string().min(1).optional().describe("Provider payment key for verified paid confirmation"),
987
+ amount: z10.number().int().positive().optional().describe("Provider-confirmed amount for verified paid confirmation")
988
+ }).strict();
989
+ var UpdateTransactionSchema = updateTransactionSchema;
990
+ var returnReasonSchema = z10.enum([
991
+ "change_of_mind",
992
+ "defective",
993
+ "wrong_delivery",
994
+ "damaged",
995
+ "other"
996
+ ]);
997
+ var restockActionSchema = z10.enum(["return_to_stock", "discard"]);
998
+ var returnWithRefundItemSchema = z10.object({
999
+ orderItem: z10.union([z10.string(), z10.number()]).transform(String),
1000
+ quantity: z10.number().int().positive("quantity must be a positive integer"),
1001
+ restockAction: restockActionSchema.default("return_to_stock")
1002
+ }).strict();
1003
+ var returnWithRefundSchema = z10.object({
1004
+ orderNumber: z10.string().min(1, "orderNumber is required").describe("Order number (required)"),
1005
+ reason: returnReasonSchema.optional().describe("Return reason (optional)"),
1006
+ reasonDetail: z10.string().optional().describe("Detailed reason text (optional)"),
1007
+ returnItems: z10.array(returnWithRefundItemSchema).min(1, "At least one return item is required").max(100, "Too many return items").describe("Array of products to return (required)"),
1008
+ refundAmount: z10.number().min(0, "refundAmount must be non-negative").describe("Refund amount (required, min 0)"),
1009
+ pgPaymentId: z10.string().min(1, "pgPaymentId is required").describe("PG payment ID for refund (required)"),
1010
+ paymentKey: z10.string().min(1).optional().describe("Provider payment key for verified refund"),
1011
+ refundReceiptUrl: z10.string().optional().describe("Refund receipt URL (optional)")
1012
+ }).strict();
1013
+ var ReturnWithRefundSchema = returnWithRefundSchema;
1014
+
631
1015
  // src/tools/update-transaction.ts
632
- import { z as z14 } from "zod";
633
- var schema14 = {
634
- pgPaymentId: z14.string().min(1).describe("PG payment ID (required)"),
635
- status: z14.enum(["pending", "paid", "failed", "canceled"]).describe("New transaction status (required)"),
636
- paymentMethod: z14.string().optional().describe("Payment method (optional)"),
637
- receiptUrl: z14.string().optional().describe("Receipt URL (optional)")
638
- };
639
- var metadata14 = {
1016
+ var schema9 = UpdateTransactionSchema.shape;
1017
+ var metadata9 = {
640
1018
  name: "update-transaction",
641
1019
  description: "Update transaction status, payment method, and receipt URL.",
642
1020
  annotations: {
@@ -650,16 +1028,21 @@ async function updateTransaction({
650
1028
  pgPaymentId,
651
1029
  status,
652
1030
  paymentMethod,
653
- receiptUrl
1031
+ receiptUrl,
1032
+ paymentKey,
1033
+ amount
654
1034
  }) {
655
1035
  try {
656
1036
  const client = getClient();
657
- const result = await client.commerce.orders.updateTransaction({
1037
+ const params = {
658
1038
  pgPaymentId,
659
1039
  status,
660
1040
  paymentMethod,
661
- receiptUrl
662
- });
1041
+ receiptUrl,
1042
+ paymentKey,
1043
+ amount
1044
+ };
1045
+ const result = await client.commerce.orders.updateTransaction(params);
663
1046
  return toolSuccess({ data: result });
664
1047
  } catch (error) {
665
1048
  return toolError(error);
@@ -667,20 +1050,20 @@ async function updateTransaction({
667
1050
  }
668
1051
 
669
1052
  // src/tools/create-return.ts
670
- import { z as z15 } from "zod";
671
- var schema15 = {
672
- orderNumber: z15.string().min(1).describe("Order number (required)"),
673
- reason: z15.enum(["change_of_mind", "defective", "wrong_delivery", "damaged", "other"]).optional().describe("Return reason (optional)"),
674
- reasonDetail: z15.string().optional().describe("Detailed reason text (optional)"),
675
- returnItems: z15.array(
676
- z15.object({
677
- orderItem: z15.string().min(1).describe("Order item ID"),
678
- quantity: z15.number().int().positive().describe("Quantity to return")
1053
+ import { z as z11 } from "zod";
1054
+ var schema10 = {
1055
+ orderNumber: z11.string().min(1).describe("Order number (required)"),
1056
+ reason: z11.enum(["change_of_mind", "defective", "wrong_delivery", "damaged", "other"]).optional().describe("Return reason (optional)"),
1057
+ reasonDetail: z11.string().optional().describe("Detailed reason text (optional)"),
1058
+ returnItems: z11.array(
1059
+ z11.object({
1060
+ orderItem: z11.string().min(1).describe("Order item ID"),
1061
+ quantity: z11.number().int().positive().describe("Quantity to return")
679
1062
  })
680
1063
  ).describe("Array of products to return (required)"),
681
- refundAmount: z15.number().nonnegative().describe("Refund amount (required, min 0)")
1064
+ refundAmount: z11.number().nonnegative().describe("Refund amount (required, min 0)")
682
1065
  };
683
- var metadata15 = {
1066
+ var metadata10 = {
684
1067
  name: "create-return",
685
1068
  description: "Create a return request for an order. Only works for delivered/confirmed orders. Updates order status to return_requested.",
686
1069
  annotations: {
@@ -713,14 +1096,14 @@ async function createReturn({
713
1096
  }
714
1097
 
715
1098
  // src/tools/update-return.ts
716
- import { z as z16 } from "zod";
717
- var schema16 = {
718
- returnId: z16.string().min(1).describe("Return ID (required)"),
719
- status: z16.enum(["processing", "approved", "rejected", "completed"]).describe(
1099
+ import { z as z12 } from "zod";
1100
+ var schema11 = {
1101
+ returnId: z12.string().min(1).describe("Return ID (required)"),
1102
+ status: z12.enum(["processing", "approved", "rejected", "completed"]).describe(
720
1103
  "New return status (required). Valid transitions: requested\u2192processing/rejected, processing\u2192approved/rejected, approved\u2192completed"
721
1104
  )
722
1105
  };
723
- var metadata16 = {
1106
+ var metadata11 = {
724
1107
  name: "update-return",
725
1108
  description: "Update return status with FSM validation. Restores inventory on completion, reverts order status on rejection.",
726
1109
  annotations: {
@@ -744,22 +1127,8 @@ async function updateReturn({
744
1127
  }
745
1128
 
746
1129
  // src/tools/return-with-refund.ts
747
- import { z as z17 } from "zod";
748
- var schema17 = {
749
- orderNumber: z17.string().min(1).describe("Order number (required)"),
750
- reason: z17.enum(["change_of_mind", "defective", "wrong_delivery", "damaged", "other"]).optional().describe("Return reason (optional)"),
751
- reasonDetail: z17.string().optional().describe("Detailed reason text (optional)"),
752
- returnItems: z17.array(
753
- z17.object({
754
- orderItem: z17.string().min(1).describe("Order item ID"),
755
- quantity: z17.number().int().positive().describe("Quantity to return")
756
- })
757
- ).describe("Array of products to return (required)"),
758
- refundAmount: z17.number().nonnegative().describe("Refund amount (required, min 0)"),
759
- pgPaymentId: z17.string().min(1).describe("PG payment ID for refund (required)"),
760
- refundReceiptUrl: z17.string().optional().describe("Refund receipt URL (optional)")
761
- };
762
- var metadata17 = {
1130
+ var schema12 = ReturnWithRefundSchema.shape;
1131
+ var metadata12 = {
763
1132
  name: "return-with-refund",
764
1133
  description: "Combined return + refund operation. Creates return, restores stock, cancels transaction, updates order status.",
765
1134
  annotations: {
@@ -776,19 +1145,22 @@ async function returnWithRefund({
776
1145
  returnItems,
777
1146
  refundAmount,
778
1147
  pgPaymentId,
1148
+ paymentKey,
779
1149
  refundReceiptUrl
780
1150
  }) {
781
1151
  try {
782
1152
  const client = getClient();
783
- const result = await client.commerce.orders.returnWithRefund({
1153
+ const params = {
784
1154
  orderNumber,
785
1155
  reason,
786
1156
  reasonDetail,
787
1157
  returnItems,
788
1158
  refundAmount,
789
1159
  pgPaymentId,
1160
+ paymentKey,
790
1161
  refundReceiptUrl
791
- });
1162
+ };
1163
+ const result = await client.commerce.orders.returnWithRefund(params);
792
1164
  return toolSuccess({ data: result });
793
1165
  } catch (error) {
794
1166
  return toolError(error);
@@ -796,15 +1168,15 @@ async function returnWithRefund({
796
1168
  }
797
1169
 
798
1170
  // src/tools/add-cart-item.ts
799
- import { z as z18 } from "zod";
800
- var schema18 = {
801
- cartId: z18.string().min(1).describe("Cart ID (required)"),
802
- product: z18.string().min(1).describe("Product ID (required)"),
803
- variant: z18.string().min(1).describe("Product variant ID (required)"),
804
- option: z18.string().min(1).describe("Product option ID (required)"),
805
- quantity: z18.number().int().positive().describe("Quantity to add (required, positive integer)")
1171
+ import { z as z13 } from "zod";
1172
+ var schema13 = {
1173
+ cartId: z13.string().min(1).describe("Cart ID (required)"),
1174
+ product: z13.string().min(1).describe("Product ID (required)"),
1175
+ variant: z13.string().min(1).describe("Product variant ID (required)"),
1176
+ option: z13.string().min(1).describe("Product option ID (required)"),
1177
+ quantity: z13.number().int().positive().describe("Quantity to add (required, positive integer)")
806
1178
  };
807
- var metadata18 = {
1179
+ var metadata13 = {
808
1180
  name: "add-cart-item",
809
1181
  description: "Add a product to cart. Validates stock, merges quantity if item already exists, recalculates totals.",
810
1182
  annotations: {
@@ -837,12 +1209,12 @@ async function addCartItem({
837
1209
  }
838
1210
 
839
1211
  // src/tools/update-cart-item.ts
840
- import { z as z19 } from "zod";
841
- var schema19 = {
842
- cartItemId: z19.string().min(1).describe("Cart item ID (required)"),
843
- quantity: z19.number().int().positive().describe("New quantity (required, positive integer)")
1212
+ import { z as z14 } from "zod";
1213
+ var schema14 = {
1214
+ cartItemId: z14.string().min(1).describe("Cart item ID (required)"),
1215
+ quantity: z14.number().int().positive().describe("New quantity (required, positive integer)")
844
1216
  };
845
- var metadata19 = {
1217
+ var metadata14 = {
846
1218
  name: "update-cart-item",
847
1219
  description: "Update cart item quantity. Validates stock availability, recalculates cart totals.",
848
1220
  annotations: {
@@ -866,11 +1238,11 @@ async function updateCartItem({
866
1238
  }
867
1239
 
868
1240
  // src/tools/remove-cart-item.ts
869
- import { z as z20 } from "zod";
870
- var schema20 = {
871
- cartItemId: z20.string().min(1).describe("Cart item ID to remove (required)")
1241
+ import { z as z15 } from "zod";
1242
+ var schema15 = {
1243
+ cartItemId: z15.string().min(1).describe("Cart item ID to remove (required)")
872
1244
  };
873
- var metadata20 = {
1245
+ var metadata15 = {
874
1246
  name: "remove-cart-item",
875
1247
  description: "Remove an item from cart. Recalculates cart totals after removal.",
876
1248
  annotations: {
@@ -893,12 +1265,12 @@ async function removeCartItem({
893
1265
  }
894
1266
 
895
1267
  // src/tools/apply-discount.ts
896
- import { z as z21 } from "zod";
897
- var schema21 = {
898
- cartId: z21.string().min(1).describe("Cart ID (required)"),
899
- discountCode: z21.string().describe("Discount code to apply (required)")
1268
+ import { z as z16 } from "zod";
1269
+ var schema16 = {
1270
+ cartId: z16.string().min(1).describe("Cart ID (required)"),
1271
+ discountCode: z16.string().describe("Discount code to apply (required)")
900
1272
  };
901
- var metadata21 = {
1273
+ var metadata16 = {
902
1274
  name: "apply-discount",
903
1275
  description: "Apply a discount code to a cart. Validates the code, updates cart totals, and sets free shipping if applicable.",
904
1276
  annotations: {
@@ -922,11 +1294,11 @@ async function applyDiscount({
922
1294
  }
923
1295
 
924
1296
  // src/tools/remove-discount.ts
925
- import { z as z22 } from "zod";
926
- var schema22 = {
927
- cartId: z22.string().min(1).describe("Cart ID (required)")
1297
+ import { z as z17 } from "zod";
1298
+ var schema17 = {
1299
+ cartId: z17.string().min(1).describe("Cart ID (required)")
928
1300
  };
929
- var metadata22 = {
1301
+ var metadata17 = {
930
1302
  name: "remove-discount",
931
1303
  description: "Remove the applied discount code from a cart and recalculate totals.",
932
1304
  annotations: {
@@ -949,11 +1321,11 @@ async function removeDiscount({
949
1321
  }
950
1322
 
951
1323
  // src/tools/clear-cart.ts
952
- import { z as z23 } from "zod";
953
- var schema23 = {
954
- cartId: z23.string().min(1).describe("Cart ID (required)")
1324
+ import { z as z18 } from "zod";
1325
+ var schema18 = {
1326
+ cartId: z18.string().min(1).describe("Cart ID (required)")
955
1327
  };
956
- var metadata23 = {
1328
+ var metadata18 = {
957
1329
  name: "clear-cart",
958
1330
  description: "Remove all items from a cart, reset discount and amounts. Shipping fee is preserved.",
959
1331
  annotations: {
@@ -976,12 +1348,12 @@ async function clearCart({
976
1348
  }
977
1349
 
978
1350
  // src/tools/validate-discount.ts
979
- import { z as z24 } from "zod";
980
- var schema24 = {
981
- code: z24.string().describe("Discount code to validate (required)"),
982
- orderAmount: z24.number().describe("Order amount for validation (required)")
1351
+ import { z as z19 } from "zod";
1352
+ var schema19 = {
1353
+ code: z19.string().describe("Discount code to validate (required)"),
1354
+ orderAmount: z19.number().describe("Order amount for validation (required)")
983
1355
  };
984
- var metadata24 = {
1356
+ var metadata19 = {
985
1357
  name: "validate-discount",
986
1358
  description: "Validate a discount code. Checks active status, date range, usage limits, minimum order amount, and calculates discount.",
987
1359
  annotations: {
@@ -1008,13 +1380,13 @@ async function validateDiscount({
1008
1380
  }
1009
1381
 
1010
1382
  // src/tools/calculate-shipping.ts
1011
- import { z as z25 } from "zod";
1012
- var schema25 = {
1013
- shippingPolicyId: z25.string().optional().describe("Shipping policy ID (uses default policy if omitted)"),
1014
- orderAmount: z25.number().describe("Order amount for fee calculation (required)"),
1015
- postalCode: z25.string().optional().describe("Postal code for Jeju surcharge detection (63000-63644)")
1383
+ import { z as z20 } from "zod";
1384
+ var schema20 = {
1385
+ shippingPolicyId: z20.string().optional().describe("Shipping policy ID (uses default policy if omitted)"),
1386
+ orderAmount: z20.number().describe("Order amount for fee calculation (required)"),
1387
+ postalCode: z20.string().optional().describe("Postal code for Jeju surcharge detection (63000-63644)")
1016
1388
  };
1017
- var metadata25 = {
1389
+ var metadata20 = {
1018
1390
  name: "calculate-shipping",
1019
1391
  description: "Calculate shipping fee based on order amount and postal code. Supports free shipping threshold and Jeju surcharge.",
1020
1392
  annotations: {
@@ -1043,18 +1415,18 @@ async function calculateShipping({
1043
1415
  }
1044
1416
 
1045
1417
  // src/tools/stock-check.ts
1046
- import { z as z26 } from "zod";
1047
- var schema26 = {
1048
- items: z26.array(
1049
- z26.object({
1050
- variantId: z26.string().describe("Product variant ID"),
1051
- quantity: z26.number().int().positive().describe("Requested quantity")
1418
+ import { z as z21 } from "zod";
1419
+ var schema21 = {
1420
+ items: z21.array(
1421
+ z21.object({
1422
+ variantId: z21.string().describe("Product variant ID"),
1423
+ quantity: z21.number().int().positive().describe("Requested quantity")
1052
1424
  })
1053
1425
  ).describe(
1054
1426
  "Array of items to check stock for (required, max 100). Each: { variantId, quantity }"
1055
1427
  )
1056
1428
  };
1057
- var metadata26 = {
1429
+ var metadata21 = {
1058
1430
  name: "stock-check",
1059
1431
  description: "Batch check product option stock availability. Returns per-item availability and an allAvailable flag.",
1060
1432
  annotations: {
@@ -1077,56 +1449,46 @@ async function stockCheck({
1077
1449
  }
1078
1450
 
1079
1451
  // src/tools/get-collection-schema.ts
1080
- import { z as z27 } from "zod";
1081
- import { COLLECTIONS as COLLECTIONS8 } from "@01.software/sdk";
1452
+ import { COLLECTIONS as COLLECTIONS3 } from "@01.software/sdk";
1082
1453
 
1083
1454
  // src/lib/console-api.ts
1084
1455
  import { createHash } from "crypto";
1085
1456
  var BASE_URL = process.env.SOFTWARE_API_URL || "http://localhost:3000";
1086
1457
  var TIMEOUT_MS = 5e3;
1458
+ var MISSING_HTTP_AUTH_CONTEXT_ERROR2 = "MCP HTTP requests require a validated OAuth tenant context before tool execution.";
1087
1459
  function resolveAuthHeaderContext() {
1088
- let context = {};
1089
- try {
1090
- const h = headers();
1091
- context = {
1092
- apiKey: h?.["x-api-key"],
1093
- publishableKey: h?.["x-publishable-key"] ?? h?.["x-client-key"]
1460
+ const oauthContext = tenantAuthContext();
1461
+ if (oauthContext) {
1462
+ return {
1463
+ apiKey: signMcpServiceToken(oauthContext),
1464
+ mode: "oauth"
1094
1465
  };
1095
- } catch {
1096
1466
  }
1467
+ if (hasRequestContext()) throw new Error(MISSING_HTTP_AUTH_CONTEXT_ERROR2);
1097
1468
  return {
1098
- apiKey: context.apiKey ?? process.env.SOFTWARE_SECRET_KEY,
1099
- publishableKey: context.publishableKey ?? process.env.SOFTWARE_PUBLISHABLE_KEY ?? process.env.NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY
1469
+ apiKey: process.env.SOFTWARE_SECRET_KEY,
1470
+ mode: "stdio",
1471
+ publishableKey: process.env.SOFTWARE_PUBLISHABLE_KEY ?? process.env.NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY
1100
1472
  };
1101
1473
  }
1102
1474
  function resolveApiKey() {
1103
1475
  const { apiKey } = resolveAuthHeaderContext();
1104
1476
  if (!apiKey || typeof apiKey !== "string") {
1105
1477
  throw new Error(
1106
- "Authentication required. Provide x-api-key header (HTTP) or SOFTWARE_SECRET_KEY env var (stdio)."
1478
+ "Authentication required. Set SOFTWARE_SECRET_KEY for stdio transport."
1107
1479
  );
1108
1480
  }
1109
1481
  return apiKey;
1110
1482
  }
1111
- function hashKey(apiKey) {
1112
- return createHash("sha256").update(apiKey).digest("hex");
1113
- }
1114
- function resolveAuthCacheKey(apiKey) {
1115
- const { publishableKey } = resolveAuthHeaderContext();
1116
- return hashKey(
1117
- JSON.stringify({
1118
- apiKey,
1119
- publishableKey: publishableKey ?? ""
1120
- })
1121
- );
1122
- }
1123
1483
  function buildAuthHeaders(apiKey) {
1124
- const { publishableKey } = resolveAuthHeaderContext();
1125
- const headers2 = {
1484
+ const { mode, publishableKey } = resolveAuthHeaderContext();
1485
+ const headers = {
1126
1486
  Authorization: `Bearer ${apiKey}`
1127
1487
  };
1128
- if (publishableKey) headers2["X-Publishable-Key"] = publishableKey;
1129
- return headers2;
1488
+ if (mode === "stdio" && publishableKey) {
1489
+ headers["X-Publishable-Key"] = publishableKey;
1490
+ }
1491
+ return headers;
1130
1492
  }
1131
1493
  function extractErrorMessage(body) {
1132
1494
  if (!body || typeof body !== "object") return void 0;
@@ -1182,17 +1544,16 @@ async function consolePost(path, body, apiKey) {
1182
1544
  // src/lib/collection-schema.ts
1183
1545
  async function getCollectionSchema(collection) {
1184
1546
  const apiKey = resolveApiKey();
1185
- return consoleGet(
1547
+ const data = await consoleGet(
1186
1548
  `/api/tenants/schema/${encodeURIComponent(collection)}`,
1187
1549
  apiKey
1188
1550
  );
1551
+ return collectionSchemaResponseSchema.parse(data);
1189
1552
  }
1190
1553
 
1191
1554
  // src/tools/get-collection-schema.ts
1192
- var schema27 = {
1193
- collection: z27.enum(COLLECTIONS8).describe("Collection name (required)")
1194
- };
1195
- var metadata27 = {
1555
+ var schema22 = createCollectionSchemaToolInputSchema(COLLECTIONS3).shape;
1556
+ var metadata22 = {
1196
1557
  name: "get-collection-schema",
1197
1558
  description: "Get the authoritative tenant-aware collection schema from console. Use this before create/update to understand writable fields, hidden fields, required metadata, and collection-level visibility.",
1198
1559
  annotations: {
@@ -1216,48 +1577,22 @@ async function getCollectionSchemaTool({
1216
1577
  }
1217
1578
  }
1218
1579
 
1219
- // src/tools/get-tenant-context.ts
1220
- import { z as z28 } from "zod";
1221
-
1222
1580
  // src/lib/tenant-context.ts
1223
- var TENANT_CONTEXT_CACHE_TTL_MS = 6e4;
1224
- var cache = /* @__PURE__ */ new Map();
1225
1581
  function getTenantContextPath(includeCounts) {
1226
1582
  return includeCounts ? "/api/tenants/context?counts=true" : "/api/tenants/context";
1227
1583
  }
1228
- function getCachedTenantContext(cacheKey) {
1229
- const cached = cache.get(cacheKey);
1230
- if (!cached || cached.expiry <= Date.now()) return void 0;
1231
- return cached.data;
1232
- }
1233
1584
  async function getTenantContext(includeCounts = false) {
1234
1585
  const apiKey = resolveApiKey();
1235
- const cacheKey = resolveAuthCacheKey(apiKey);
1236
- if (!includeCounts) {
1237
- const cached = getCachedTenantContext(cacheKey);
1238
- if (cached) return cached;
1239
- }
1240
1586
  const data = await consoleGet(
1241
1587
  getTenantContextPath(includeCounts),
1242
1588
  apiKey
1243
1589
  );
1244
- if (!includeCounts) {
1245
- cache.set(cacheKey, {
1246
- data,
1247
- expiry: Date.now() + TENANT_CONTEXT_CACHE_TTL_MS
1248
- });
1249
- }
1250
- return data;
1251
- }
1252
- function invalidateTenantContextCache() {
1253
- cache.clear();
1590
+ return tenantContextResponseSchema.parse(data);
1254
1591
  }
1255
1592
 
1256
1593
  // src/tools/get-tenant-context.ts
1257
- var schema28 = {
1258
- includeCounts: z28.boolean().optional().default(false).describe("Include per-collection document counts and config status (bypasses cache, slower)")
1259
- };
1260
- var metadata28 = {
1594
+ var schema23 = tenantContextToolInputSchema.shape;
1595
+ var metadata23 = {
1261
1596
  name: "get-tenant-context",
1262
1597
  description: "Get current tenant features, active collections, and field visibility. Call this at the start of every session. Use includeCounts=true to also get per-collection document counts for setup diagnostics.",
1263
1598
  annotations: {
@@ -1267,7 +1602,9 @@ var metadata28 = {
1267
1602
  idempotentHint: true
1268
1603
  }
1269
1604
  };
1270
- async function handler({ includeCounts }) {
1605
+ async function handler({
1606
+ includeCounts
1607
+ }) {
1271
1608
  try {
1272
1609
  const ctx = await getTenantContext(includeCounts);
1273
1610
  const lines = [
@@ -1320,11 +1657,10 @@ async function handler({ includeCounts }) {
1320
1657
  }
1321
1658
  }
1322
1659
  if (ctx.config) {
1660
+ lines.push("", "## Config Status");
1323
1661
  lines.push(
1324
- "",
1325
- "## Config Status"
1662
+ `- Webhook configured: ${ctx.config.webhookConfigured ? "Yes" : "No"}`
1326
1663
  );
1327
- lines.push(`- Webhook configured: ${ctx.config.webhookConfigured ? "Yes" : "No"}`);
1328
1664
  }
1329
1665
  return toolSuccess({ context: lines.join("\n") });
1330
1666
  } catch (error) {
@@ -1333,21 +1669,15 @@ async function handler({ includeCounts }) {
1333
1669
  }
1334
1670
 
1335
1671
  // src/tools/list-configurable-fields.ts
1336
- import { z as z29 } from "zod";
1672
+ import { z as z22 } from "zod";
1337
1673
 
1338
1674
  // src/lib/field-config.ts
1339
- var cache2 = /* @__PURE__ */ new Map();
1340
- var CACHE_TTL = 6e4;
1341
1675
  async function fetchFieldConfigs() {
1342
1676
  const apiKey = resolveApiKey();
1343
- const cacheKey = resolveAuthCacheKey(apiKey);
1344
- const cached = cache2.get(cacheKey);
1345
- if (cached && cached.expiry > Date.now()) return cached.data;
1346
1677
  const data = await consoleGet(
1347
1678
  "/api/field-configs/list",
1348
1679
  apiKey
1349
1680
  );
1350
- cache2.set(cacheKey, { data, expiry: Date.now() + CACHE_TTL });
1351
1681
  return data;
1352
1682
  }
1353
1683
  async function saveFieldConfig(body) {
@@ -1359,16 +1689,15 @@ async function saveFieldConfig(body) {
1359
1689
  );
1360
1690
  }
1361
1691
  function invalidateFieldConfigCache() {
1362
- cache2.clear();
1363
1692
  }
1364
1693
 
1365
1694
  // src/tools/list-configurable-fields.ts
1366
- var schema29 = {
1367
- collection: z29.string().optional().describe(
1695
+ var schema24 = {
1696
+ collection: z22.string().optional().describe(
1368
1697
  "Filter by collection slug (optional \u2014 returns all if omitted). Use this filter to reduce response size when you know which collection to check."
1369
1698
  )
1370
1699
  };
1371
- var metadata29 = {
1700
+ var metadata24 = {
1372
1701
  name: "list-configurable-fields",
1373
1702
  description: "List all configurable fields for tenant collections with current visibility state. Shows which fields can be shown/hidden and their current status. Returns all collections including inactive features \u2014 cross-reference with get-tenant-context for active features. Response includes ~300 fields across 47 collections \u2014 use collection filter when possible.",
1374
1703
  annotations: {
@@ -1399,17 +1728,17 @@ async function listConfigurableFields(params) {
1399
1728
  }
1400
1729
 
1401
1730
  // src/tools/update-field-config.ts
1402
- import { z as z30 } from "zod";
1403
- var schema30 = {
1404
- collection: z30.string().min(1).describe("Collection slug (required)"),
1405
- hiddenFields: z30.array(z30.string().min(1).max(200)).max(300).describe(
1731
+ import { z as z23 } from "zod";
1732
+ var schema25 = {
1733
+ collection: z23.string().min(1).describe("Collection slug (required)"),
1734
+ hiddenFields: z23.array(z23.string().min(1).max(200)).max(300).describe(
1406
1735
  "Fields to hide (required). This is a FULL REPLACE \u2014 fields NOT in this list will be shown. Pass [] to show all fields. Use list-configurable-fields first to see available field paths."
1407
1736
  ),
1408
- isHidden: z30.boolean().optional().describe(
1737
+ isHidden: z23.boolean().optional().describe(
1409
1738
  "Hide the entire collection from Admin Panel (optional). When true, individual hiddenFields are irrelevant."
1410
1739
  )
1411
1740
  };
1412
- var metadata30 = {
1741
+ var metadata25 = {
1413
1742
  name: "update-field-config",
1414
1743
  description: "Update field visibility configuration for a tenant collection. Hidden fields are removed from the Admin Panel UI. IMPORTANT: hiddenFields is a full replace, not a merge. Always call list-configurable-fields first to see current state.",
1415
1744
  annotations: {
@@ -1427,7 +1756,6 @@ async function updateFieldConfig(params) {
1427
1756
  isHidden: params.isHidden
1428
1757
  });
1429
1758
  invalidateFieldConfigCache();
1430
- invalidateTenantContextCache();
1431
1759
  return toolSuccess({
1432
1760
  message: `Field config updated for '${params.collection}'`,
1433
1761
  data: result
@@ -1438,7 +1766,7 @@ async function updateFieldConfig(params) {
1438
1766
  }
1439
1767
 
1440
1768
  // src/tools/sdk-get-recipe.ts
1441
- import { z as z31 } from "zod";
1769
+ import { z as z24 } from "zod";
1442
1770
 
1443
1771
  // src/lib/sdk-recipes.ts
1444
1772
  var recipes = {
@@ -1590,7 +1918,7 @@ const result = await client.collections.from('products').create({
1590
1918
  "Returns result.doc (not the document directly)"
1591
1919
  ],
1592
1920
  relatedResources: ["docs://sdk/query-builder"],
1593
- relatedTools: ["create-collection"]
1921
+ relatedTools: ["query-collection", "get-collection-schema"]
1594
1922
  }
1595
1923
  },
1596
1924
  "update-item": {
@@ -1619,7 +1947,7 @@ const result = await client.collections.from('products').update('product-id', {
1619
1947
  "Partial updates are supported \u2014 omitted fields retain their current value"
1620
1948
  ],
1621
1949
  relatedResources: ["docs://sdk/query-builder"],
1622
- relatedTools: ["update-collection"]
1950
+ relatedTools: ["get-collection-by-id", "get-collection-schema"]
1623
1951
  }
1624
1952
  },
1625
1953
  "delete-item": {
@@ -1643,7 +1971,7 @@ console.log('Deleted:', deleted.title)`,
1643
1971
  "Throws if the item does not exist"
1644
1972
  ],
1645
1973
  relatedResources: ["docs://sdk/query-builder"],
1646
- relatedTools: ["delete-collection"]
1974
+ relatedTools: ["get-collection-by-id", "query-collection"]
1647
1975
  }
1648
1976
  },
1649
1977
  "infinite-scroll": {
@@ -1757,18 +2085,13 @@ const client = createClient({
1757
2085
  })
1758
2086
 
1759
2087
  // --- Register ---
1760
- const { customer, verificationRequired } = await client.customer.register({
2088
+ const { customer } = await client.customer.register({
1761
2089
  name: 'Jane Doe',
1762
2090
  email: 'jane@example.com',
1763
2091
  password: 'securePassword123',
1764
2092
  phone: '+821012345678', // optional
1765
2093
  })
1766
2094
 
1767
- if (verificationRequired) {
1768
- // Tenant has requireEmailVerification enabled.
1769
- // Token delivered via webhook \u2014 prompt user to check email.
1770
- }
1771
-
1772
2095
  // --- Login ---
1773
2096
  const { token, customer: loggedIn } = await client.customer.login({
1774
2097
  email: 'jane@example.com',
@@ -1789,9 +2112,9 @@ await client.customer.forgotPassword('jane@example.com') // sends token via webh
1789
2112
  await client.customer.resetPassword(token, 'newPassword123')`,
1790
2113
  cautions: [
1791
2114
  "customer.register/login/me are only available on Client (not ServerClient)",
1792
- "verificationRequired means no token is returned \u2014 user must verify email first",
2115
+ "registration creates a local customer account; add app-level verification if your project requires it",
1793
2116
  "updateProfile only accepts name, phone, and marketingConsent \u2014 not email or password",
1794
- "forgotPassword sends the token via tenant webhook, not directly to the client"
2117
+ "forgotPassword sends the token to configured tenant webhooks; your webhook handler owns email/SMS delivery"
1795
2118
  ],
1796
2119
  relatedResources: ["docs://sdk/customer-auth", "docs://sdk/getting-started"],
1797
2120
  relatedTools: []
@@ -1825,7 +2148,7 @@ const result = await client.collections.from('images').create(formData as unknow
1825
2148
  "Always set alt text for accessibility"
1826
2149
  ],
1827
2150
  relatedResources: ["docs://sdk/query-builder"],
1828
- relatedTools: ["create-collection"]
2151
+ relatedTools: ["query-collection", "get-collection-schema"]
1829
2152
  }
1830
2153
  },
1831
2154
  "bulk-operations": {
@@ -1861,7 +2184,7 @@ const removed = await client.collections.from('products').removeMany(
1861
2184
  "Very broad where clauses (or empty) will affect all documents in the collection"
1862
2185
  ],
1863
2186
  relatedResources: ["docs://sdk/query-builder"],
1864
- relatedTools: ["update-many-collection", "delete-many-collection"]
2187
+ relatedTools: ["query-collection", "get-collection-schema"]
1865
2188
  }
1866
2189
  }
1867
2190
  };
@@ -1875,8 +2198,8 @@ function getRecipe(goal, runtime = "both") {
1875
2198
  }
1876
2199
 
1877
2200
  // src/tools/sdk-get-recipe.ts
1878
- var schema31 = {
1879
- goal: z31.enum([
2201
+ var schema26 = {
2202
+ goal: z24.enum([
1880
2203
  "fetch-list",
1881
2204
  "fetch-by-id",
1882
2205
  "create-item",
@@ -1888,11 +2211,11 @@ var schema31 = {
1888
2211
  "file-upload",
1889
2212
  "bulk-operations"
1890
2213
  ]).describe("What the user wants to accomplish"),
1891
- runtime: z31.enum(["browser", "server", "both"]).default("both").describe("Target runtime environment"),
1892
- collection: z31.string().optional().describe("Specific collection name if applicable"),
1893
- includeExample: z31.boolean().default(true).describe("Whether to include a full code example")
2214
+ runtime: z24.enum(["browser", "server", "both"]).default("both").describe("Target runtime environment"),
2215
+ collection: z24.string().optional().describe("Specific collection name if applicable"),
2216
+ includeExample: z24.boolean().default(true).describe("Whether to include a full code example")
1894
2217
  };
1895
- var metadata31 = {
2218
+ var metadata26 = {
1896
2219
  name: "sdk-get-recipe",
1897
2220
  description: "Get a complete SDK code recipe for a specific task. Returns recommended approach, code example, and related documentation links. Use this FIRST when the user asks how to do something with the SDK.",
1898
2221
  annotations: {
@@ -1935,7 +2258,7 @@ function handler2({
1935
2258
  }
1936
2259
 
1937
2260
  // src/tools/sdk-search-docs.ts
1938
- import { z as z32 } from "zod";
2261
+ import { z as z25 } from "zod";
1939
2262
 
1940
2263
  // src/lib/sdk-doc-index.ts
1941
2264
  var docIndex = [
@@ -2037,8 +2360,8 @@ var docIndex = [
2037
2360
  // Customer Auth
2038
2361
  {
2039
2362
  title: "Customer Auth \u2014 Login and Register",
2040
- keywords: ["customer", "login", "register", "auth", "authentication", "customer auth", "email verification", "verificationRequired"],
2041
- summary: "client.customer.login({ email, password }) and register({ name, email, password }). If tenant requireEmailVerification is on, register returns verificationRequired: true.",
2363
+ keywords: ["customer", "login", "register", "auth", "authentication", "customer auth"],
2364
+ summary: "client.customer.login({ email, password }) and register({ name, email, password }).",
2042
2365
  resourceUri: "docs://sdk/customer-auth"
2043
2366
  },
2044
2367
  {
@@ -2064,7 +2387,7 @@ var docIndex = [
2064
2387
  {
2065
2388
  title: "Webhooks",
2066
2389
  keywords: ["webhook", "hmac", "signature", "WEBHOOK_SECRET", "server-to-server", "event"],
2067
- summary: "Tenant webhooks deliver server-to-server events (e.g. email verification token, password reset token). Signed with HMAC-SHA256 using PAYLOAD_SECRET.",
2390
+ summary: "Tenant webhooks deliver server-to-server events such as password reset tokens. Signed with HMAC-SHA256 using PAYLOAD_SECRET.",
2068
2391
  resourceUri: "docs://sdk/webhook"
2069
2392
  },
2070
2393
  // Order API
@@ -2110,11 +2433,11 @@ function searchDocs(query, limit = 5) {
2110
2433
  }
2111
2434
 
2112
2435
  // src/tools/sdk-search-docs.ts
2113
- var schema32 = {
2114
- query: z32.string().min(2).describe('Search keyword or phrase (e.g. "infinite scroll", "webhook", "customer login")'),
2115
- limit: z32.number().min(1).max(10).default(5).describe("Maximum results to return (1-10, default: 5)")
2436
+ var schema27 = {
2437
+ query: z25.string().min(2).describe('Search keyword or phrase (e.g. "infinite scroll", "webhook", "customer login")'),
2438
+ limit: z25.number().min(1).max(10).default(5).describe("Maximum results to return (1-10, default: 5)")
2116
2439
  };
2117
- var metadata32 = {
2440
+ var metadata27 = {
2118
2441
  name: "sdk-search-docs",
2119
2442
  description: "Search SDK documentation by keyword. Returns matching topics with summaries and resource links. Use when looking for specific SDK features or patterns.",
2120
2443
  annotations: {
@@ -2149,20 +2472,20 @@ function handler3({
2149
2472
  }
2150
2473
 
2151
2474
  // src/tools/sdk-get-auth-setup.ts
2152
- import { z as z33 } from "zod";
2153
- var schema33 = {
2154
- scenario: z33.enum([
2475
+ import { z as z26 } from "zod";
2476
+ var schema28 = {
2477
+ scenario: z26.enum([
2155
2478
  "browser-client",
2156
2479
  "server-client",
2157
2480
  "customer-auth",
2158
2481
  "mcp-connection",
2159
- "api-key-generation",
2482
+ "server-credentials",
2160
2483
  "webhook-verification"
2161
2484
  ]).describe("Authentication scenario")
2162
2485
  };
2163
- var metadata33 = {
2486
+ var metadata28 = {
2164
2487
  name: "sdk-get-auth-setup",
2165
- description: "Get the correct authentication setup for a specific scenario. Returns env var names, code snippets, and security notes.",
2488
+ description: "Get the current authentication setup for a specific scenario. Returns env var names, code snippets, and security notes.",
2166
2489
  annotations: {
2167
2490
  title: "Get Auth Setup",
2168
2491
  readOnlyHint: true,
@@ -2195,15 +2518,14 @@ const { data } = client.query.useQuery({ collection: 'products' })`,
2195
2518
 
2196
2519
  const client = createServerClient({
2197
2520
  publishableKey: process.env.SOFTWARE_PUBLISHABLE_KEY!,
2198
- secretKey: process.env.SOFTWARE_SECRET_KEY! // usually sk01_..., sometimes pat01_...
2521
+ secretKey: process.env.SOFTWARE_SECRET_KEY!
2199
2522
  })
2200
2523
 
2201
2524
  // Full CRUD operations
2202
2525
  const result = await client.collections.from('products').create({ title: 'New Product' })`,
2203
2526
  notes: [
2204
- "ServerClient has full CRUD access \u2014 never expose the API key in browser",
2205
- "SOFTWARE_SECRET_KEY stores an opaque bearer token; backend services should prefer tenant API keys (sk01_...)",
2206
- "Browser-based CLI/init login flows may provision a user-scoped PAT (pat01_...) with a default tenant",
2527
+ "ServerClient has full CRUD access and must run only in trusted server code",
2528
+ "Store server credentials in environment variables and rotate them from the Console",
2207
2529
  "Use in API routes, server actions, or backend services only",
2208
2530
  "React Query hooks available for reads (useQuery, prefetchQuery, etc.) + mutations (useCreate, useUpdate, useRemove)"
2209
2531
  ]
@@ -2235,90 +2557,68 @@ client.customer.isAuthenticated()`,
2235
2557
  notes: [
2236
2558
  "Customer auth uses the browser Client (not ServerClient)",
2237
2559
  "JWT tokens are managed automatically by the SDK",
2238
- "Tenant may require email verification (requireEmailVerification setting)"
2560
+ "Registration creates a local customer account; add application-level verification if needed"
2239
2561
  ]
2240
2562
  },
2241
2563
  "mcp-connection": {
2242
2564
  title: "MCP Server Connection",
2243
- envVars: ["SOFTWARE_PUBLISHABLE_KEY", "SOFTWARE_SECRET_KEY"],
2565
+ envVars: [],
2244
2566
  code: `# Claude Code
2245
- claude mcp add --transport http \\
2246
- --header "x-api-key: $SOFTWARE_SECRET_KEY" \\
2247
- --header "x-publishable-key: $SOFTWARE_PUBLISHABLE_KEY" \\
2248
- 01software https://mcp.01.software/mcp
2567
+ claude mcp add --transport http 01software https://mcp.01.software/mcp
2249
2568
 
2250
- # Codex project-safe .codex/config.toml
2569
+ # Codex .codex/config.toml
2251
2570
  [mcp_servers.01software]
2252
2571
  url = "https://mcp.01.software/mcp"
2253
2572
 
2254
- [mcp_servers.01software.env_http_headers]
2255
- x-api-key = "SOFTWARE_SECRET_KEY"
2256
- x-publishable-key = "SOFTWARE_PUBLISHABLE_KEY"
2257
-
2258
- # Or use .mcp.json
2573
+ # Or use JSON clients that support OAuth discovery
2259
2574
  {
2260
2575
  "mcpServers": {
2261
2576
  "01software": {
2262
2577
  "type": "http",
2263
- "url": "https://mcp.01.software/mcp",
2264
- "headers": {
2265
- "x-api-key": "\${env:SOFTWARE_SECRET_KEY}",
2266
- "x-publishable-key": "\${env:SOFTWARE_PUBLISHABLE_KEY}"
2267
- }
2578
+ "url": "https://mcp.01.software/mcp"
2268
2579
  }
2269
2580
  }
2270
2581
  }`,
2271
2582
  notes: [
2272
- "MCP accepts either a tenant API key (sk01_...) or a personal access token (pat01_...) in x-api-key",
2273
- "HTTP transport also requires x-publishable-key (or legacy x-client-key) for tenant routing, rate limits, and quota enforcement",
2274
- "Codex project scope is appropriate for repo-safe shared configuration, but keep raw sk01_/pat01_ values out of committed files",
2275
- "Use tenant API keys for shared service integrations; PATs are useful for user-scoped local workflows",
2276
- "Never commit raw bearer tokens to repo-local MCP config; prefer environment interpolation, client prompts, OS secret managers, or ignored local files",
2277
- "Avoid passing real tokens directly on shared-machine command lines because shell history and process listings can expose them",
2278
- "stdio transport: use `npx @01.software/cli mcp` with SOFTWARE_PUBLISHABLE_KEY and SOFTWARE_SECRET_KEY env vars"
2583
+ "HTTP MCP uses OAuth discovery and Authorization Code + PKCE",
2584
+ "Clients that cannot complete OAuth discovery are unsupported until a smoke test proves compatibility",
2585
+ "stdio transport remains a local CLI path and is separate from HTTP MCP OAuth discovery"
2279
2586
  ]
2280
2587
  },
2281
- "api-key-generation": {
2282
- title: "API Key Generation",
2588
+ "server-credentials": {
2589
+ title: "Server Credential Management",
2283
2590
  envVars: ["SOFTWARE_PUBLISHABLE_KEY", "SOFTWARE_SECRET_KEY"],
2284
- code: `# API keys are generated from the Console, not in code.
2285
- # Go to Console > Settings > API Keys and click "Create API Key".
2286
- # The generated key has the format: sk01_{40hex}
2287
- # Copy the publishable key from the same tenant.
2591
+ code: `# Server credentials are managed from the Console, not in code.
2592
+ # Copy both values from the same tenant.
2288
2593
 
2289
- # Use them together for MCP, CLI, and server SDK calls:
2290
- export SOFTWARE_PUBLISHABLE_KEY=pk01_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2594
+ # Use them together for CLI and server SDK calls.
2595
+ export SOFTWARE_PUBLISHABLE_KEY=pk_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2291
2596
  export SOFTWARE_SECRET_KEY=sk01_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`,
2292
2597
  notes: [
2293
- "API keys are sk01_{40hex} opaque bearer tokens",
2294
2598
  "The matching SOFTWARE_PUBLISHABLE_KEY is still required for tenant routing, rate limits, and quota enforcement",
2295
- "Browser-based CLI/init login may issue pat01_{40hex} personal access tokens for user-scoped workflows",
2296
- "Used for MCP and REST API authentication via x-api-key header or Authorization: Bearer",
2297
- "Generate keys from Console > Settings > API Keys \u2014 never derive them in code"
2599
+ "Used for REST/SDK authentication in trusted server contexts",
2600
+ "Manage credentials from the Console and rotate them on exposure"
2298
2601
  ]
2299
2602
  },
2300
2603
  "webhook-verification": {
2301
2604
  title: "Webhook Verification",
2302
2605
  envVars: ["WEBHOOK_SECRET"],
2303
- code: `import { handleWebhook } from '@01.software/sdk/webhook'
2606
+ code: `import { handleWebhook, createCustomerAuthWebhookHandler } from '@01.software/sdk/webhook'
2607
+
2608
+ const customerAuthHandler = createCustomerAuthWebhookHandler({
2609
+ passwordReset: sendPasswordResetEmail,
2610
+ })
2304
2611
 
2305
2612
  export async function POST(request: Request) {
2306
- return handleWebhook(request, async (event) => {
2307
- // event.collection, event.operation, event.data
2308
- switch (event.operation) {
2309
- case 'verification':
2310
- await sendVerificationEmail(event.data)
2311
- break
2312
- case 'password-reset':
2313
- await sendPasswordResetEmail(event.data)
2314
- break
2315
- }
2316
- }, { secret: process.env.WEBHOOK_SECRET! })
2613
+ return handleWebhook(request, customerAuthHandler, {
2614
+ secret: process.env.WEBHOOK_SECRET!,
2615
+ })
2317
2616
  }`,
2318
2617
  notes: [
2319
2618
  "handleWebhook() takes (request, handler, options) \u2014 handler receives the parsed event",
2320
2619
  "WEBHOOK_SECRET is set per-tenant in Console > Settings",
2321
- "handleWebhook() verifies HMAC-SHA256 signature automatically before calling handler"
2620
+ "handleWebhook() verifies HMAC-SHA256 signature automatically before calling handler",
2621
+ "createCustomerAuthWebhookHandler() is optional; it just routes auth events to your own email/SMS delivery code"
2322
2622
  ]
2323
2623
  }
2324
2624
  };
@@ -2337,14 +2637,14 @@ function handler4({
2337
2637
  }
2338
2638
 
2339
2639
  // src/tools/sdk-get-collection-pattern.ts
2340
- import { z as z34 } from "zod";
2341
- import { COLLECTIONS as COLLECTIONS9 } from "@01.software/sdk";
2342
- var schema34 = {
2343
- collection: z34.enum(COLLECTIONS9).describe("Collection name"),
2344
- operation: z34.enum(["read", "write", "full-crud"]).default("read").describe("What operations are needed"),
2345
- surface: z34.enum(["query-builder", "react-query", "server-api"]).default("query-builder").describe("Preferred API surface")
2640
+ import { z as z27 } from "zod";
2641
+ import { COLLECTIONS as COLLECTIONS4 } from "@01.software/sdk";
2642
+ var schema29 = {
2643
+ collection: z27.enum(COLLECTIONS4).describe("Collection name"),
2644
+ operation: z27.enum(["read", "write", "full-crud"]).default("read").describe("What operations are needed"),
2645
+ surface: z27.enum(["query-builder", "react-query", "server-api"]).default("query-builder").describe("Preferred API surface")
2346
2646
  };
2347
- var metadata34 = {
2647
+ var metadata29 = {
2348
2648
  name: "sdk-get-collection-pattern",
2349
2649
  description: "Get the recommended CRUD pattern for a specific collection. Returns code examples for the chosen API surface and operation type.",
2350
2650
  annotations: {
@@ -2511,7 +2811,6 @@ function handler5({
2511
2811
  relatedTools: [
2512
2812
  "query-collection",
2513
2813
  "get-collection-by-id",
2514
- ...operation !== "read" ? ["create-collection", "update-collection", "delete-collection"] : [],
2515
2814
  "get-collection-schema"
2516
2815
  ],
2517
2816
  relatedResources: [
@@ -2525,14 +2824,14 @@ function handler5({
2525
2824
  }
2526
2825
 
2527
2826
  // src/prompts/sdk-usage-guide.ts
2528
- import { z as z35 } from "zod";
2529
- var schema35 = {
2530
- goal: z35.string().describe('What the user wants to accomplish (e.g., "query product list", "create order")'),
2531
- runtime: z35.enum(["browser", "server"]).optional().describe("Target runtime: browser (React/Next.js client) or server (Node.js)"),
2532
- surface: z35.enum(["query-builder", "react-query", "customer-api", "server-api"]).optional().describe("Preferred API surface"),
2533
- collection: z35.string().optional().describe("Specific collection if relevant")
2827
+ import { z as z28 } from "zod";
2828
+ var schema30 = {
2829
+ goal: z28.string().describe('What the user wants to accomplish (e.g., "query product list", "create order")'),
2830
+ runtime: z28.enum(["browser", "server"]).optional().describe("Target runtime: browser (React/Next.js client) or server (Node.js)"),
2831
+ surface: z28.enum(["query-builder", "react-query", "customer-api", "server-api"]).optional().describe("Preferred API surface"),
2832
+ collection: z28.string().optional().describe("Specific collection if relevant")
2534
2833
  };
2535
- var metadata35 = {
2834
+ var metadata30 = {
2536
2835
  name: "sdk-usage-guide",
2537
2836
  title: "SDK Usage Guide",
2538
2837
  description: "Provides guidance on how to perform a specific task using the 01.software SDK",
@@ -2629,8 +2928,8 @@ await client.collections.from('products').remove('id')
2629
2928
  const { totalDocs } = await client.collections.from('products').count()
2630
2929
 
2631
2930
  // Metadata - generate Next.js Metadata from collection fields
2632
- // Auto-maps per-collection fields (e.g. posts: description\u2192description, thumbnail\u2192image)
2633
- const postMeta = await client.collections.from('posts').findMetadataById(id, { siteName: 'My Blog' })
2931
+ // Auto-maps per-collection fields (e.g. articles: description\u2192description, thumbnail\u2192image)
2932
+ const articleMeta = await client.collections.from('articles').findMetadataById(id, { siteName: 'My Blog' })
2634
2933
  const productMeta = await client.collections.from('products').findMetadata(
2635
2934
  { where: { slug: { equals: 'my-product' } } },
2636
2935
  { siteName: 'My Store' }
@@ -2669,14 +2968,14 @@ You can perform the "${goal}" task by following the patterns above.`;
2669
2968
  }
2670
2969
 
2671
2970
  // src/prompts/collection-query-help.ts
2672
- import { z as z36 } from "zod";
2673
- import { COLLECTIONS as COLLECTIONS10 } from "@01.software/sdk";
2674
- var schema36 = {
2675
- collection: z36.enum(COLLECTIONS10).describe("Collection name"),
2676
- operation: z36.enum(["find", "create", "update", "delete"]).describe("Operation to perform (find, create, update, delete)"),
2677
- filters: z36.string().optional().describe("Filter conditions (JSON string, optional)")
2971
+ import { z as z29 } from "zod";
2972
+ import { COLLECTIONS as COLLECTIONS5 } from "@01.software/sdk";
2973
+ var schema31 = {
2974
+ collection: z29.enum(COLLECTIONS5).describe("Collection name"),
2975
+ operation: z29.enum(["find", "create", "update", "delete"]).describe("Operation to perform (find, create, update, delete)"),
2976
+ filters: z29.string().optional().describe("Filter conditions (JSON string, optional)")
2678
2977
  };
2679
- var metadata36 = {
2978
+ var metadata31 = {
2680
2979
  name: "collection-query-help",
2681
2980
  title: "Collection Query Help",
2682
2981
  description: "Provides guidance on how to write queries for a specific collection",
@@ -2763,16 +3062,16 @@ ${operation === "find" ? `- Use \`where\` option for filtering (Payload query sy
2763
3062
  }
2764
3063
 
2765
3064
  // src/prompts/order-flow-guide.ts
2766
- import { z as z37 } from "zod";
2767
- var schema37 = {
2768
- scenario: z37.enum([
3065
+ import { z as z30 } from "zod";
3066
+ var schema32 = {
3067
+ scenario: z30.enum([
2769
3068
  "simple-order",
2770
3069
  "cart-checkout",
2771
3070
  "return-refund",
2772
3071
  "fulfillment-tracking"
2773
3072
  ]).describe("Order flow scenario")
2774
3073
  };
2775
- var metadata37 = {
3074
+ var metadata32 = {
2776
3075
  name: "order-flow-guide",
2777
3076
  title: "Order Flow Guide",
2778
3077
  description: "Provides step-by-step guidance for ecommerce order flows including creation, checkout, returns, and fulfillment.",
@@ -2787,8 +3086,8 @@ var SCENARIOS = {
2787
3086
  - Provide: orderNumber, customerSnapshot (email required), shippingAddress, orderItems, totalAmount
2788
3087
  - Optional: pgPaymentId (omit for free orders), shippingAmount, discountCode
2789
3088
 
2790
- 2. **Payment Confirmation** \u2192 \`update-order\` tool
2791
- - Update status to \`paid\` after payment gateway confirms
3089
+ 2. **Payment Confirmation** \u2192 \`update-transaction\` tool
3090
+ - Confirm provider payment with pgPaymentId, paymentKey, and amount
2792
3091
  - Stock is automatically adjusted (stock -= qty, reservedStock += qty)
2793
3092
 
2794
3093
  3. **Fulfillment** \u2192 \`create-fulfillment\` tool
@@ -2815,8 +3114,13 @@ const order = await client.commerce.orders.create({
2815
3114
  pgPaymentId: 'pay_xxx' // omit for free orders
2816
3115
  })
2817
3116
 
2818
- // 2. After payment confirmed
2819
- await client.commerce.orders.update({ orderNumber: 'ORD-240101-001', status: 'paid' })
3117
+ // 2. After payment confirmed by provider
3118
+ await client.commerce.orders.updateTransaction({
3119
+ pgPaymentId: 'pay_xxx',
3120
+ status: 'paid',
3121
+ paymentKey: 'payment_key_xxx',
3122
+ amount: 59800
3123
+ })
2820
3124
 
2821
3125
  // 3. Ship items
2822
3126
  await client.commerce.orders.createFulfillment({
@@ -2834,7 +3138,7 @@ await client.commerce.orders.createFulfillment({
2834
3138
  2. **Apply Discount** (optional) \u2192 \`apply-discount\` tool
2835
3139
  3. **Calculate Shipping** \u2192 \`calculate-shipping\` tool
2836
3140
  4. **Checkout** \u2192 \`checkout\` tool (converts cart to order)
2837
- 5. **Payment** \u2192 \`update-order\` or \`update-transaction\`
3141
+ 5. **Payment** \u2192 \`update-transaction\` for provider-verified paid transitions
2838
3142
 
2839
3143
  ### Key Points
2840
3144
  - Cart has a customer linked \u2014 auto-copied to order on checkout
@@ -2871,7 +3175,7 @@ const order = await client.commerce.orders.checkout({
2871
3175
  1. **Return with Refund** \u2192 \`return-with-refund\` tool
2872
3176
  - Handles return + stock restoration + transaction update in one call
2873
3177
  - Return immediately completed (bypasses FSM)
2874
- - Requires pgPaymentId to identify which transaction to refund
3178
+ - Requires pgPaymentId and paymentKey for provider-verified refund
2875
3179
 
2876
3180
  ### Key Points
2877
3181
  - Full refund: original transaction \u2192 \`canceled\`
@@ -2888,7 +3192,8 @@ await client.commerce.orders.returnWithRefund({
2888
3192
  reasonDetail: 'Product arrived damaged',
2889
3193
  returnItems: [{ orderItem: 'oi-id', quantity: 1 }],
2890
3194
  refundAmount: 29900,
2891
- pgPaymentId: 'pay_xxx'
3195
+ pgPaymentId: 'pay_xxx',
3196
+ paymentKey: 'payment_key_xxx'
2892
3197
  })
2893
3198
  \`\`\``,
2894
3199
  "fulfillment-tracking": `## Fulfillment & Tracking
@@ -2951,12 +3256,12 @@ ${SCENARIOS[scenario] || "Unknown scenario."}
2951
3256
  }
2952
3257
 
2953
3258
  // src/prompts/feature-setup-guide.ts
2954
- import { z as z38 } from "zod";
2955
- var schema38 = {
2956
- feature: z38.enum([
3259
+ import { z as z31 } from "zod";
3260
+ var schema33 = {
3261
+ feature: z31.enum([
2957
3262
  "ecommerce",
2958
3263
  "customers",
2959
- "posts",
3264
+ "articles",
2960
3265
  "documents",
2961
3266
  "playlists",
2962
3267
  "galleries",
@@ -2968,7 +3273,7 @@ var schema38 = {
2968
3273
  "community"
2969
3274
  ]).describe("Feature to get setup guide for")
2970
3275
  };
2971
- var metadata38 = {
3276
+ var metadata33 = {
2972
3277
  name: "feature-setup-guide",
2973
3278
  title: "Feature Setup Guide",
2974
3279
  description: "Setup checklist and remediation guide for a tenant feature. Load before using get-tenant-context to diagnose setup gaps.",
@@ -2981,8 +3286,8 @@ var FEATURES = {
2981
3286
 
2982
3287
  ### Required Collections (count > 0)
2983
3288
 
2984
- 1. **products** \u2014 Use \`create-collection\` with \`collection='products'\`
2985
- - Minimum fields: \`{ title, slug, status: 'active' }\`
3289
+ 1. **products** \u2014 Create via Console UI or SDK \`client.collections.from('products').create({ ... })\`
3290
+ - Minimum fields: \`{ title, slug, status: 'published', _status: 'published' }\`
2986
3291
 
2987
3292
  2. **product-variants** \u2014 At least 1 sellable variant per product
2988
3293
  - Minimum fields: \`{ product, title, price, stock }\`
@@ -3015,26 +3320,26 @@ customer-addresses
3015
3320
 
3016
3321
  ### Optional Collections
3017
3322
 
3018
- customer-groups \u2014 Use \`create-collection\` with \`collection='customer-groups'\`, \`{ title }\`
3323
+ customer-groups \u2014 Create via Console UI or SDK \`client.collections.from('customer-groups').create({ title })\`
3019
3324
 
3020
3325
  ### Config
3021
3326
 
3022
- - \`requireEmailVerification\` can be toggled in tenant settings
3327
+ - Customer registration creates a local account; add app-level verification if needed
3023
3328
  - Customer auth uses custom JWT (separate from Payload auth)`,
3024
- posts: `## Posts Setup Guide
3329
+ articles: `## Articles Setup Guide
3025
3330
 
3026
3331
  ### Required Collections (count > 0)
3027
3332
 
3028
- 1. **posts** \u2014 At least 1 post
3333
+ 1. **articles** \u2014 At least 1 article
3029
3334
  - Minimum fields: \`{ title, slug }\`
3030
3335
 
3031
- 2. **post-authors** \u2014 At least 1 author
3336
+ 2. **article-authors** \u2014 At least 1 author
3032
3337
  - Minimum fields: \`{ title, slug }\`
3033
- - Link authors to posts via the \`authors\` relationship field
3338
+ - Link authors to articles via the \`authors\` relationship field
3034
3339
 
3035
3340
  ### Optional Collections
3036
3341
 
3037
- post-categories, post-tags`,
3342
+ article-categories, article-tags`,
3038
3343
  documents: `## Documents Setup Guide
3039
3344
 
3040
3345
  ### Required Collections (count > 0)
@@ -3054,10 +3359,10 @@ document-categories`,
3054
3359
  ### Required Collections (count > 0)
3055
3360
 
3056
3361
  1. **playlists** \u2014 At least 1 playlist
3057
- - Minimum fields: \`{ title, slug }\`
3362
+ - Minimum fields: \`{ title, slug, status: 'published', _status: 'published' }\`
3058
3363
 
3059
3364
  2. **tracks** \u2014 At least 1 track
3060
- - Minimum fields: \`{ title }\`
3365
+ - Minimum fields: \`{ title, sourceUrl, status: 'published', _status: 'published' }\`
3061
3366
 
3062
3367
  3. **playlists.tracks** \u2014 Link at least 1 track from a playlist
3063
3368
  - Minimum fields: \`{ tracks: [trackId] }\`
@@ -3070,11 +3375,11 @@ playlist-categories, playlist-tags, track-categories, track-tags, track-assets`,
3070
3375
  ### Required Collections (count > 0)
3071
3376
 
3072
3377
  1. **galleries** \u2014 At least 1 gallery
3073
- - Minimum fields: \`{ title, slug }\`
3378
+ - Minimum fields: \`{ title, slug, status: 'published', _status: 'published' }\`
3074
3379
 
3075
3380
  2. **gallery-items** \u2014 At least 1 item per gallery
3076
3381
  - References \`images\` collection (non-upload)
3077
- - Minimum fields: \`{ gallery, image }\`
3382
+ - Minimum fields: \`{ gallery, image, _status: 'published' }\`
3078
3383
 
3079
3384
  ### Optional Collections
3080
3385
 
@@ -3084,7 +3389,7 @@ gallery-categories, gallery-tags`,
3084
3389
  ### Required Collections (count > 0)
3085
3390
 
3086
3391
  1. **links** \u2014 At least 1 link
3087
- - Minimum fields: \`{ title, slug, url }\`
3392
+ - Minimum fields: \`{ title, slug, url, status: 'published', _status: 'published' }\`
3088
3393
 
3089
3394
  ### Optional Collections
3090
3395
 
@@ -3144,7 +3449,7 @@ form-submissions \u2014 Auto-created when forms are submitted by end users`,
3144
3449
 
3145
3450
  ### Required Collections (count > 0)
3146
3451
 
3147
- 1. **threads** \u2014 At least 1 thread
3452
+ 1. **posts** \u2014 At least 1 post
3148
3453
  - Minimum fields: \`{ title, slug }\`
3149
3454
 
3150
3455
  2. **reaction-types** \u2014 At least 1 reaction type defined
@@ -3156,7 +3461,7 @@ comments, reactions, bookmarks, reports, community-bans
3156
3461
 
3157
3462
  ### Optional Collections
3158
3463
 
3159
- thread-categories`
3464
+ post-categories`
3160
3465
  };
3161
3466
  function featureSetupGuide({ feature }) {
3162
3467
  return `# Feature Setup Guide: ${feature}
@@ -3165,12 +3470,12 @@ ${FEATURES[feature] || "Unknown feature."}
3165
3470
 
3166
3471
  ## Related MCP Tools
3167
3472
  - \`get-tenant-context\` \u2014 check current collection counts and feature status
3168
- - \`create-collection\` \u2014 create required collection documents
3169
- - \`query-collection\` \u2014 verify existing documents in a collection`;
3473
+ - \`query-collection\` \u2014 verify existing documents in a collection
3474
+ - \`get-collection-schema\` \u2014 inspect tenant-aware fields before creating data via SDK or Console UI`;
3170
3475
  }
3171
3476
 
3172
3477
  // src/resources/(config)/app.ts
3173
- var metadata39 = {
3478
+ var metadata34 = {
3174
3479
  name: "app-config",
3175
3480
  title: "Application Config",
3176
3481
  description: "01.software SDK and MCP server configuration information"
@@ -3185,35 +3490,20 @@ function handler6() {
3185
3490
 
3186
3491
  ## Authentication
3187
3492
 
3188
- All HTTP requests require a bearer token and publishable key:
3493
+ HTTP MCP uses OAuth discovery and Authorization Code + PKCE.
3189
3494
 
3495
+ \`\`\`toml
3496
+ [mcp_servers.01software]
3497
+ url = "https://mcp.01.software/mcp"
3190
3498
  \`\`\`
3191
- x-api-key: <sk01_... or pat01_...>
3192
- x-publishable-key: <pk01_...>
3193
- \`\`\`
3194
-
3195
- \`x-client-key\` is accepted as a legacy alias for \`x-publishable-key\`.
3196
-
3197
- ### Accepted Token Types
3198
-
3199
- - \`sk01_{40hex}\` \u2014 tenant API key from Console > Settings > API Keys
3200
- - \`pat01_{40hex}\` \u2014 personal access token for user-scoped local workflows
3201
3499
 
3202
- \`\`\`
3203
- SOFTWARE_SECRET_KEY=sk01_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3204
- SOFTWARE_PUBLISHABLE_KEY=pk01_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3205
- \`\`\`
3500
+ ## Available Tools (29)
3206
3501
 
3207
- ## Available Tools (34)
3502
+ > Generic write tools (create/update/delete/update-many/delete-many) are intentionally absent. Use the dedicated workflow tools below or the SDK (\`client.collections.from(slug).create()\` / \`update()\` / \`remove()\` / \`updateMany()\` / \`removeMany()\`) for stateful mutations.
3208
3503
 
3209
- ### Generic CRUD (7)
3504
+ ### Generic Read (2)
3210
3505
  - \`query-collection\` - Query collection with filters, pagination, sorting
3211
3506
  - \`get-collection-by-id\` - Get single item by ID
3212
- - \`create-collection\` - Create new item
3213
- - \`update-collection\` - Update existing item
3214
- - \`delete-collection\` - Delete item (destructive)
3215
- - \`update-many-collection\` - Bulk update items matching filter
3216
- - \`delete-many-collection\` - Bulk delete items matching filter (destructive)
3217
3507
 
3218
3508
  ### Orders (7)
3219
3509
  - \`create-order\` - Create a new order with products and shipping
@@ -3271,70 +3561,86 @@ Rate limits depend on your tenant plan:
3271
3561
  }
3272
3562
 
3273
3563
  // src/resources/(collections)/schema.ts
3274
- import { COLLECTIONS as COLLECTIONS11 } from "@01.software/sdk";
3275
- var metadata40 = {
3564
+ import { COLLECTIONS as COLLECTIONS6 } from "@01.software/sdk";
3565
+ var metadata35 = {
3276
3566
  name: "collections-schema",
3277
3567
  title: "Collection Schema Info",
3278
3568
  description: "Available collections and their schema information"
3279
3569
  };
3570
+ var COLLECTIONS_BY_CATEGORY = {
3571
+ "Tenant Management": ["tenants", "tenant-metadata", "tenant-logos"],
3572
+ Products: [
3573
+ "products",
3574
+ "product-variants",
3575
+ "product-options",
3576
+ "product-option-values",
3577
+ "product-categories",
3578
+ "product-tags",
3579
+ "product-collections"
3580
+ ],
3581
+ Brands: ["brands", "brand-logos"],
3582
+ "Orders & Fulfillment": [
3583
+ "orders",
3584
+ "order-items",
3585
+ "transactions",
3586
+ "fulfillments",
3587
+ "fulfillment-items"
3588
+ ],
3589
+ "Shipping & Returns": ["returns", "return-items", "shipping-policies"],
3590
+ Customers: [
3591
+ "customers",
3592
+ "customer-profiles",
3593
+ "customer-addresses",
3594
+ "customer-groups"
3595
+ ],
3596
+ Carts: ["carts", "cart-items"],
3597
+ "Discounts & Promotions": ["discounts", "promotions"],
3598
+ Documents: ["documents", "document-categories", "document-types"],
3599
+ Articles: ["articles", "article-authors", "article-categories", "article-tags"],
3600
+ Community: [
3601
+ "posts",
3602
+ "comments",
3603
+ "reactions",
3604
+ "reaction-types",
3605
+ "bookmarks",
3606
+ "post-categories",
3607
+ "reports",
3608
+ "community-bans"
3609
+ ],
3610
+ Playlists: [
3611
+ "playlists",
3612
+ "tracks",
3613
+ "playlist-categories",
3614
+ "playlist-tags",
3615
+ "track-categories",
3616
+ "track-tags"
3617
+ ],
3618
+ Galleries: ["galleries", "gallery-items", "gallery-categories", "gallery-tags"],
3619
+ Links: ["links", "link-categories", "link-tags"],
3620
+ Canvas: [
3621
+ "canvases",
3622
+ "canvas-node-types",
3623
+ "canvas-edge-types",
3624
+ "canvas-categories",
3625
+ "canvas-tags",
3626
+ "canvas-nodes",
3627
+ "canvas-edges"
3628
+ ],
3629
+ Videos: ["videos", "video-categories", "video-tags"],
3630
+ "Live Streams": ["live-streams"],
3631
+ Images: ["images"],
3632
+ Forms: ["forms", "form-submissions"],
3633
+ Events: [
3634
+ "event-calendars",
3635
+ "events",
3636
+ "event-categories",
3637
+ "event-occurrences",
3638
+ "event-tags"
3639
+ ]
3640
+ };
3280
3641
  function handler7() {
3281
- const collectionsByCategory = {
3282
- "Tenant Management": ["tenants", "tenant-metadata", "tenant-logos"],
3283
- Products: [
3284
- "products",
3285
- "product-variants",
3286
- "product-options",
3287
- "product-categories",
3288
- "product-tags",
3289
- "product-collections"
3290
- ],
3291
- Brands: ["brands", "brand-logos"],
3292
- "Orders & Fulfillment": [
3293
- "orders",
3294
- "order-items",
3295
- "transactions",
3296
- "fulfillments",
3297
- "fulfillment-items"
3298
- ],
3299
- "Shipping & Returns": [
3300
- "returns",
3301
- "return-items",
3302
- "shipping-policies"
3303
- ],
3304
- Customers: ["customers", "customer-addresses", "customer-groups"],
3305
- Carts: ["carts", "cart-items"],
3306
- Discounts: ["discounts"],
3307
- Documents: ["documents", "document-categories", "document-types"],
3308
- "Posts (Blog)": ["posts", "post-categories", "post-tags"],
3309
- Playlists: [
3310
- "playlists",
3311
- "tracks",
3312
- "track-assets",
3313
- "playlist-categories",
3314
- "playlist-tags",
3315
- "track-categories",
3316
- "track-tags"
3317
- ],
3318
- Galleries: [
3319
- "galleries",
3320
- "gallery-items",
3321
- "gallery-categories",
3322
- "gallery-tags"
3323
- ],
3324
- Canvas: [
3325
- "canvases",
3326
- "canvas-node-types",
3327
- "canvas-edge-types",
3328
- "canvas-categories",
3329
- "canvas-tags"
3330
- ],
3331
- Videos: ["videos", "video-categories", "video-tags"],
3332
- "Live Streams": ["live-streams"],
3333
- Images: ["images"],
3334
- Forms: ["forms", "form-submissions"]
3335
- };
3336
- const categoryDocs = Object.entries(collectionsByCategory).map(([category, collections]) => {
3337
- const collectionList = collections.filter((c) => COLLECTIONS11.includes(c)).map((c) => `- **${c}**`).join("\n");
3642
+ const categoryDocs = Object.entries(COLLECTIONS_BY_CATEGORY).map(([category, collections]) => {
3643
+ const collectionList = collections.filter((c) => COLLECTIONS6.includes(c)).map((c) => `- **${c}**`).join("\n");
3338
3644
  return `## ${category}
3339
3645
  ${collectionList}`;
3340
3646
  }).join("\n\n");
@@ -3355,6 +3661,9 @@ Each collection supports the following operations:
3355
3661
  - \`updateMany(where, data)\` - Bulk update items matching filter
3356
3662
  - \`removeMany(where)\` - Bulk delete items matching filter
3357
3663
 
3664
+ Draft-enabled public collections expose only \`_status: 'published'\` rows to
3665
+ publishable-key reads unless server-side access explicitly includes drafts.
3666
+
3358
3667
  ## Query Examples
3359
3668
 
3360
3669
  ### Filtering
@@ -3376,11 +3685,11 @@ Each collection supports the following operations:
3376
3685
  }
3377
3686
  \`\`\`
3378
3687
 
3379
- Total available collections: ${COLLECTIONS11.length}`;
3688
+ Total available collections: ${COLLECTIONS6.length}`;
3380
3689
  }
3381
3690
 
3382
3691
  // src/resources/(docs)/getting-started.ts
3383
- var metadata41 = {
3692
+ var metadata36 = {
3384
3693
  name: "docs-getting-started",
3385
3694
  title: "Getting Started",
3386
3695
  description: "01.software SDK getting started guide"
@@ -3425,7 +3734,7 @@ const result = await client.collections.from('products').find({
3425
3734
  }
3426
3735
 
3427
3736
  // src/resources/(docs)/guides.ts
3428
- var metadata42 = {
3737
+ var metadata37 = {
3429
3738
  name: "docs-guides",
3430
3739
  title: "Guides",
3431
3740
  description: "01.software SDK usage guides"
@@ -3636,7 +3945,7 @@ For more detailed guides, see the [Guides page](/docs/guides).`;
3636
3945
  }
3637
3946
 
3638
3947
  // src/resources/(docs)/api.ts
3639
- var metadata43 = {
3948
+ var metadata38 = {
3640
3949
  name: "docs-api",
3641
3950
  title: "API Reference",
3642
3951
  description: "01.software SDK API reference documentation"
@@ -3856,7 +4165,7 @@ Customer authentication and profile management. Available on \`Client\` only (\`
3856
4165
  ### Authentication
3857
4166
  \`\`\`typescript
3858
4167
  // Register
3859
- const { customer, verificationRequired? } = await client.customer.register({
4168
+ const { customer } = await client.customer.register({
3860
4169
  name: 'John',
3861
4170
  email: 'john@example.com',
3862
4171
  password: 'password123',
@@ -3891,7 +4200,7 @@ const updated = await client.customer.updateProfile({
3891
4200
 
3892
4201
  ### Password
3893
4202
  \`\`\`typescript
3894
- // Forgot password (sends reset token via webhook)
4203
+ // Forgot password (sends reset token to configured tenant webhooks)
3895
4204
  await client.customer.forgotPassword(email)
3896
4205
 
3897
4206
  // Reset password with token
@@ -3901,11 +4210,6 @@ await client.customer.resetPassword(token, newPassword)
3901
4210
  await client.customer.changePassword(currentPassword, newPassword)
3902
4211
  \`\`\`
3903
4212
 
3904
- ### Email Verification
3905
- \`\`\`typescript
3906
- await client.customer.verifyEmail(token)
3907
- \`\`\`
3908
-
3909
4213
  ### Orders
3910
4214
  \`\`\`typescript
3911
4215
  const orders = await client.commerce.orders.listMine({
@@ -3927,7 +4231,7 @@ For more details, see the [full API documentation](/docs/api).`;
3927
4231
  }
3928
4232
 
3929
4233
  // src/resources/(docs)/query-builder.ts
3930
- var metadata44 = {
4234
+ var metadata39 = {
3931
4235
  name: "docs-query-builder",
3932
4236
  title: "Query Builder",
3933
4237
  description: "01.software SDK Query Builder API reference (client.collections.from)"
@@ -4084,7 +4388,7 @@ if (page1.hasNextPage) {
4084
4388
 
4085
4389
  \`\`\`typescript
4086
4390
  // Descending (newest first)
4087
- const result = await client.collections.from('posts').find({ sort: '-createdAt' })
4391
+ const result = await client.collections.from('articles').find({ sort: '-createdAt' })
4088
4392
 
4089
4393
  // Ascending
4090
4394
  const result2 = await client.collections.from('products').find({ sort: 'price' })
@@ -4121,7 +4425,7 @@ console.log(result.hasNextPage) // true
4121
4425
  }
4122
4426
 
4123
4427
  // src/resources/(docs)/react-query.ts
4124
- var metadata45 = {
4428
+ var metadata40 = {
4125
4429
  name: "docs-react-query",
4126
4430
  title: "React Query Hooks",
4127
4431
  description: "01.software SDK React Query hooks reference (client.query)"
@@ -4369,7 +4673,7 @@ export function ProductList() {
4369
4673
  }
4370
4674
 
4371
4675
  // src/resources/(docs)/server-api.ts
4372
- var metadata46 = {
4676
+ var metadata41 = {
4373
4677
  name: "docs-server-api",
4374
4678
  title: "Server-side API",
4375
4679
  description: "01.software SDK server-side API reference (client.commerce) for orders, fulfillments, returns, carts, and validation"
@@ -4379,19 +4683,19 @@ function handler13() {
4379
4683
 
4380
4684
  Server-side operations are available via \`client.commerce\` on \`ServerClient\`. Use \`createServerClient\` with both \`publishableKey\` and \`secretKey\`.
4381
4685
 
4382
- For backend services, prefer a tenant API key (\`sk01_...\`) in \`SOFTWARE_SECRET_KEY\`.
4383
- Browser-based CLI/init login flows may instead provision a user-scoped PAT (\`pat01_...\`) with a default tenant.
4384
-
4385
4686
  \`\`\`typescript
4386
4687
  import { createServerClient } from '@01.software/sdk'
4387
4688
 
4388
4689
  const client = createServerClient({
4389
4690
  publishableKey: process.env.SOFTWARE_PUBLISHABLE_KEY!,
4390
- secretKey: process.env.SOFTWARE_SECRET_KEY!, // usually sk01_..., sometimes pat01_...
4691
+ secretKey: process.env.SOFTWARE_SECRET_KEY!,
4391
4692
  })
4392
4693
  \`\`\`
4393
4694
 
4394
- > Never expose \`SOFTWARE_SECRET_KEY\` in browser code. Use server components, API routes, or server actions only.
4695
+ Use server components, API routes, or server actions only. Never expose
4696
+ \`SOFTWARE_SECRET_KEY\` to browser code, client bundles, logs, or public
4697
+ repositories. If a secret key leaks, rotate it from the Console before deploying
4698
+ again.
4395
4699
 
4396
4700
  ## Order API
4397
4701
 
@@ -4510,7 +4814,7 @@ const ret = await client.commerce.orders.updateReturn({
4510
4814
  \`\`\`
4511
4815
 
4512
4816
  ### returnWithRefund()
4513
- Create a return and process refund in one atomic operation.
4817
+ Create a return and process a provider-verified refund in one atomic operation.
4514
4818
 
4515
4819
  \`\`\`typescript
4516
4820
  const result = await client.commerce.orders.returnWithRefund({
@@ -4522,6 +4826,7 @@ const result = await client.commerce.orders.returnWithRefund({
4522
4826
  ],
4523
4827
  refundAmount: 29900,
4524
4828
  pgPaymentId: 'toss-payment-id', // required
4829
+ paymentKey: 'toss-payment-key', // required for provider refund
4525
4830
  refundReceiptUrl?: 'https://...',
4526
4831
  })
4527
4832
  \`\`\`
@@ -4529,12 +4834,15 @@ const result = await client.commerce.orders.returnWithRefund({
4529
4834
  ## Transaction API
4530
4835
 
4531
4836
  ### updateTransaction()
4532
- Update a transaction status (after PG callback).
4837
+ Confirm or annotate a transaction. Paid transitions require provider
4838
+ verification; non-financial annotations can still update pending transactions.
4533
4839
 
4534
4840
  \`\`\`typescript
4535
4841
  const tx = await client.commerce.orders.updateTransaction({
4536
4842
  pgPaymentId: 'toss-payment-id',
4537
- status: 'paid', // paid | failed | canceled
4843
+ status: 'paid', // pending | paid | failed | canceled
4844
+ paymentKey: 'toss-payment-key', // required when status is paid
4845
+ amount: 29900, // required when status is paid
4538
4846
  })
4539
4847
  \`\`\`
4540
4848
 
@@ -4627,7 +4935,7 @@ const result = await client.commerce.shipping.calculate({
4627
4935
  }
4628
4936
 
4629
4937
  // src/resources/(docs)/customer-auth.ts
4630
- var metadata47 = {
4938
+ var metadata42 = {
4631
4939
  name: "docs-customer-auth",
4632
4940
  title: "Customer Auth API",
4633
4941
  description: "01.software SDK Customer Auth API reference (client.customer)"
@@ -4660,11 +4968,9 @@ const result = await client.customer.register({
4660
4968
  phone?: '+821012345678',
4661
4969
  })
4662
4970
  // result.customer - created customer object
4663
- // result.token? - JWT token (set if email verification not required)
4664
- // result.verificationRequired? - true if tenant requires email verification
4665
4971
  \`\`\`
4666
4972
 
4667
- When \`verificationRequired\` is true, no token is returned. The tenant's webhook receives a \`verificationToken\` to send to the customer.
4973
+ Registration creates a local customer account. Projects that need additional email verification should enforce it in application code.
4668
4974
 
4669
4975
  ### login()
4670
4976
  Authenticate with email and password.
@@ -4718,12 +5024,12 @@ const updated = await client.customer.updateProfile({
4718
5024
  ## Password
4719
5025
 
4720
5026
  ### forgotPassword()
4721
- Request a password reset. Sends reset token via tenant webhook.
5027
+ Request a password reset. Sends the reset token to configured tenant webhooks; your webhook handler owns delivery.
4722
5028
 
4723
5029
  \`\`\`typescript
4724
5030
  await client.customer.forgotPassword('john@example.com')
4725
5031
  // Rate limited: 5 requests/min per tenant+email
4726
- // Webhook receives: { resetPasswordToken, resetPasswordExpiry }
5032
+ // Webhook receives: { resetPasswordToken, resetPasswordExpiresAt }
4727
5033
  \`\`\`
4728
5034
 
4729
5035
  ### resetPassword()
@@ -4740,15 +5046,6 @@ Change password while authenticated (requires current password).
4740
5046
  await client.customer.changePassword('currentPassword', 'newPassword123')
4741
5047
  \`\`\`
4742
5048
 
4743
- ## Email Verification
4744
-
4745
- ### verifyEmail()
4746
- Verify email address using the token received via webhook.
4747
-
4748
- \`\`\`typescript
4749
- await client.customer.verifyEmail('verification-token')
4750
- \`\`\`
4751
-
4752
5049
  ## Orders
4753
5050
 
4754
5051
  ### listMine()
@@ -4794,12 +5091,7 @@ const client = createClient({
4794
5091
  async function handleRegister(email: string, password: string, name: string) {
4795
5092
  const result = await client.customer.register({ email, password, name })
4796
5093
 
4797
- if (result.verificationRequired) {
4798
- // Redirect to "check your email" page
4799
- return { status: 'verify-email' }
4800
- }
4801
-
4802
- // Token is automatically stored; customer is now logged in
5094
+ // Customer is created as a local account.
4803
5095
  return { status: 'success', customer: result.customer }
4804
5096
  }
4805
5097
 
@@ -4821,7 +5113,7 @@ async function loadProfile() {
4821
5113
  }
4822
5114
 
4823
5115
  // src/resources/(docs)/browser-vs-server.ts
4824
- var metadata48 = {
5116
+ var metadata43 = {
4825
5117
  name: "docs-browser-vs-server",
4826
5118
  title: "Client vs ServerClient",
4827
5119
  description: "When to use Client (createClient) vs ServerClient (createServerClient) in the 01.software SDK"
@@ -4901,7 +5193,11 @@ await client.commerce.orders.checkout({ ... })
4901
5193
 
4902
5194
  **Environment variables**:
4903
5195
  - \`SOFTWARE_PUBLISHABLE_KEY\` \u2014 publishable key (no NEXT_PUBLIC prefix, server-only)
4904
- - \`SOFTWARE_SECRET_KEY\` \u2014 opaque bearer token (server-only, never expose to browser). Backend services usually use \`sk01_...\`; browser-based CLI/init login can provision \`pat01_...\` with a default tenant.
5196
+ - \`SOFTWARE_SECRET_KEY\` \u2014 server credential
5197
+
5198
+ Never expose \`SOFTWARE_SECRET_KEY\` in browser code, client bundles, logs, or
5199
+ public repositories. If a secret key leaks, rotate it from the Console before
5200
+ deploying again.
4905
5201
 
4906
5202
  ## Decision Matrix
4907
5203
 
@@ -4967,15 +5263,16 @@ export function ProductList() {
4967
5263
 
4968
5264
  ## Security Rules
4969
5265
 
4970
- - Never import \`SOFTWARE_SECRET_KEY\` or \`SOFTWARE_PUBLISHABLE_KEY\` in files without a \`'use server'\` directive or that could be bundled for the browser.
5266
+ - Keep server credentials in server-only modules.
4971
5267
  - Only \`NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY\` is safe to use in client components.
4972
- - If you accidentally expose \`SOFTWARE_SECRET_KEY\` in a browser bundle, rotate the key immediately in the 01.software console.
5268
+ - Never import a module that reads \`SOFTWARE_SECRET_KEY\` from a client component.
5269
+ - Rotate any exposed secret key immediately from the Console.
4973
5270
 
4974
5271
  > Ecommerce note: product card pricing lives on \`products.listing.*\`, but authoritative sellable pricing still lives on \`product-variants.price\`.`;
4975
5272
  }
4976
5273
 
4977
5274
  // src/resources/(docs)/file-upload.ts
4978
- var metadata49 = {
5275
+ var metadata44 = {
4979
5276
  name: "docs-file-upload",
4980
5277
  title: "File Upload",
4981
5278
  description: "01.software SDK file upload patterns using the images collection"
@@ -5126,7 +5423,7 @@ The platform stores files in Cloudflare R2 and serves via CDN (\`cdn.01.software
5126
5423
  }
5127
5424
 
5128
5425
  // src/resources/(docs)/webhook.ts
5129
- var metadata50 = {
5426
+ var metadata45 = {
5130
5427
  name: "docs-webhook",
5131
5428
  title: "Webhooks",
5132
5429
  description: "01.software SDK webhook verification and event handling"
@@ -5134,27 +5431,23 @@ var metadata50 = {
5134
5431
  function handler17() {
5135
5432
  return `# Webhooks
5136
5433
 
5137
- The platform dispatches HMAC-SHA256 signed webhook events to your registered URLs for async operations (email verification, password reset, etc.).
5434
+ The platform dispatches HMAC-SHA256 signed webhook events to your registered URLs. Tenant developers own routing inside their webhook handler.
5138
5435
 
5139
5436
  ## Webhook Handling
5140
5437
 
5141
- Use the SDK \`handleWebhook\` helper to verify signatures and route events.
5438
+ Use the SDK \`handleWebhook\` helper to verify signatures. For customer auth events, use \`createCustomerAuthWebhookHandler\` to wire delivery behavior in your app.
5142
5439
 
5143
5440
  \`\`\`typescript
5144
- import { handleWebhook } from '@01.software/sdk/webhook'
5441
+ import { handleWebhook, createCustomerAuthWebhookHandler } from '@01.software/sdk/webhook'
5442
+
5443
+ const handler = createCustomerAuthWebhookHandler({
5444
+ passwordReset: async (data) => {
5445
+ await sendPasswordResetEmail(data)
5446
+ },
5447
+ })
5145
5448
 
5146
5449
  export async function POST(request: Request) {
5147
- return handleWebhook(request, async (event) => {
5148
- // event.collection, event.operation, event.data
5149
- switch (event.operation) {
5150
- case 'verification':
5151
- await sendVerificationEmail(event.data)
5152
- break
5153
- case 'password-reset':
5154
- await sendPasswordResetEmail(event.data)
5155
- break
5156
- }
5157
- }, {
5450
+ return handleWebhook(request, handler, {
5158
5451
  secret: process.env.WEBHOOK_SECRET!,
5159
5452
  })
5160
5453
  }
@@ -5166,19 +5459,17 @@ export async function POST(request: Request) {
5166
5459
 
5167
5460
  \`\`\`typescript
5168
5461
  // app/api/webhooks/route.ts
5169
- import { handleWebhook } from '@01.software/sdk/webhook'
5462
+ import { handleWebhook, createCustomerAuthWebhookHandler } from '@01.software/sdk/webhook'
5463
+
5464
+ const customerAuthHandler = createCustomerAuthWebhookHandler({
5465
+ passwordReset: sendPasswordResetEmail,
5466
+ })
5170
5467
 
5171
5468
  export async function POST(request: Request) {
5172
5469
  return handleWebhook(request, async (event) => {
5173
5470
  console.log('Webhook received:', event.collection, event.operation)
5174
5471
 
5175
- if (event.collection === 'customers') {
5176
- if (event.operation === 'verification') {
5177
- await sendVerificationEmail(event.data)
5178
- } else if (event.operation === 'password-reset') {
5179
- await sendPasswordResetEmail(event.data)
5180
- }
5181
- }
5472
+ await customerAuthHandler(event)
5182
5473
  }, {
5183
5474
  secret: process.env.WEBHOOK_SECRET!,
5184
5475
  })
@@ -5192,49 +5483,13 @@ All webhook events share this envelope:
5192
5483
  \`\`\`typescript
5193
5484
  {
5194
5485
  collection: string, // e.g. 'customers'
5195
- operation: string, // e.g. 'verification' | 'password-reset'
5486
+ operation: string, // e.g. 'password-reset'
5196
5487
  data: object, // event-specific payload
5197
5488
  }
5198
5489
  \`\`\`
5199
5490
 
5200
5491
  ## Event Types
5201
5492
 
5202
- ### Customer Email Verification
5203
-
5204
- Dispatched when a customer registers on a tenant with \`requireEmailVerification: true\`.
5205
-
5206
- \`\`\`typescript
5207
- {
5208
- collection: 'customers',
5209
- operation: 'verification',
5210
- data: {
5211
- customerId: string,
5212
- email: string,
5213
- name: string,
5214
- verificationToken: string, // raw token to include in verification link
5215
- }
5216
- }
5217
- \`\`\`
5218
-
5219
- **Usage**: Send the \`verificationToken\` to the customer's email. The customer calls \`client.customer.verifyEmail(token)\` to complete verification.
5220
-
5221
- \`\`\`typescript
5222
- // Example: send verification email
5223
- async function sendVerificationEmail(data: {
5224
- customerId: string
5225
- email: string
5226
- name: string
5227
- verificationToken: string
5228
- }) {
5229
- const verifyUrl = \`https://yourstore.com/verify-email?token=\${data.verificationToken}\`
5230
- await emailService.send({
5231
- to: data.email,
5232
- subject: 'Verify your email',
5233
- body: \`Click here to verify: \${verifyUrl}\`,
5234
- })
5235
- }
5236
- \`\`\`
5237
-
5238
5493
  ### Customer Password Reset
5239
5494
 
5240
5495
  Dispatched when a customer calls \`client.customer.forgotPassword(email)\`.
@@ -5248,7 +5503,7 @@ Dispatched when a customer calls \`client.customer.forgotPassword(email)\`.
5248
5503
  email: string,
5249
5504
  name: string,
5250
5505
  resetPasswordToken: string, // raw token to include in reset link
5251
- resetPasswordExpiry: string, // ISO 8601 expiry (1 hour from dispatch)
5506
+ resetPasswordExpiresAt: string, // ISO 8601 expiry (1 hour from dispatch)
5252
5507
  }
5253
5508
  }
5254
5509
  \`\`\`
@@ -5261,13 +5516,13 @@ async function sendPasswordResetEmail(data: {
5261
5516
  email: string
5262
5517
  name: string
5263
5518
  resetPasswordToken: string
5264
- resetPasswordExpiry: string
5519
+ resetPasswordExpiresAt: string
5265
5520
  }) {
5266
5521
  const resetUrl = \`https://yourstore.com/reset-password?token=\${data.resetPasswordToken}\`
5267
5522
  await emailService.send({
5268
5523
  to: data.email,
5269
5524
  subject: 'Reset your password',
5270
- body: \`Reset link (expires \${data.resetPasswordExpiry}): \${resetUrl}\`,
5525
+ body: \`Reset link (expires \${data.resetPasswordExpiresAt}): \${resetUrl}\`,
5271
5526
  })
5272
5527
  }
5273
5528
  \`\`\`
@@ -5282,28 +5537,54 @@ Configure webhook URLs in the 01.software console under Tenant Settings > Webhoo
5282
5537
  }
5283
5538
 
5284
5539
  // src/server.ts
5285
- function registerTool(server, schema39, meta, handler18) {
5540
+ var REGISTERED_TOOLS_BY_SERVER = /* @__PURE__ */ new WeakMap();
5541
+ function registerTool(server, schema34, meta, handler18) {
5542
+ let registered = REGISTERED_TOOLS_BY_SERVER.get(server);
5543
+ if (!registered) {
5544
+ registered = /* @__PURE__ */ new Set();
5545
+ REGISTERED_TOOLS_BY_SERVER.set(server, registered);
5546
+ }
5547
+ registered.add(meta.name);
5286
5548
  server.registerTool(
5287
5549
  meta.name,
5288
5550
  {
5289
5551
  description: meta.description,
5290
- inputSchema: schema39,
5552
+ inputSchema: schema34,
5291
5553
  annotations: meta.annotations
5292
5554
  },
5293
5555
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5294
5556
  async (params) => {
5557
+ const ctx = tenantAuthContext();
5558
+ if (ctx) {
5559
+ const decision = evaluateToolPolicy(meta.name, ctx.scopes);
5560
+ if (!decision.allowed) {
5561
+ const status = decision.reason === "insufficient_scope" ? 403 : 500;
5562
+ return {
5563
+ content: [
5564
+ {
5565
+ type: "text",
5566
+ text: toolError({
5567
+ status,
5568
+ reason: decision.reason,
5569
+ message: decision.message
5570
+ })
5571
+ }
5572
+ ]
5573
+ };
5574
+ }
5575
+ }
5295
5576
  const result = await handler18(params);
5296
5577
  return { content: [{ type: "text", text: result }] };
5297
5578
  }
5298
5579
  );
5299
5580
  }
5300
- function registerPrompt(server, schema39, meta, handler18) {
5581
+ function registerPrompt(server, schema34, meta, handler18) {
5301
5582
  server.registerPrompt(
5302
5583
  meta.name,
5303
5584
  {
5304
5585
  title: meta.title,
5305
5586
  description: meta.description,
5306
- argsSchema: schema39
5587
+ argsSchema: schema34
5307
5588
  },
5308
5589
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5309
5590
  (params) => ({
@@ -5330,66 +5611,71 @@ function registerStaticResource(server, uri, meta, handler18) {
5330
5611
  })
5331
5612
  );
5332
5613
  }
5333
- function createServer() {
5614
+ function createServer(options = {}) {
5615
+ const toolSurface = options.toolSurface ?? "full";
5334
5616
  const server = new McpServer({
5335
5617
  name: "01.software MCP Server",
5336
5618
  version: "0.1.0"
5337
5619
  });
5338
- registerTool(server, schema, metadata, queryCollection);
5339
- registerTool(server, schema2, metadata2, getCollectionById);
5340
- registerTool(server, schema3, metadata3, createCollection);
5341
- registerTool(server, schema4, metadata4, updateCollection);
5342
- registerTool(server, schema5, metadata5, deleteCollection);
5343
- registerTool(server, schema6, metadata6, deleteManyCollection);
5344
- registerTool(server, schema7, metadata7, updateManyCollection);
5345
- registerTool(server, schema8, metadata8, getOrder);
5346
- registerTool(server, schema9, metadata9, createOrder);
5347
- registerTool(server, schema10, metadata10, updateOrder);
5348
- registerTool(server, schema11, metadata11, checkout);
5349
- registerTool(server, schema12, metadata12, createFulfillment);
5350
- registerTool(server, schema13, metadata13, updateFulfillment);
5351
- registerTool(server, schema14, metadata14, updateTransaction);
5352
- registerTool(server, schema15, metadata15, createReturn);
5353
- registerTool(server, schema16, metadata16, updateReturn);
5354
- registerTool(server, schema17, metadata17, returnWithRefund);
5355
- registerTool(server, schema18, metadata18, addCartItem);
5356
- registerTool(server, schema19, metadata19, updateCartItem);
5357
- registerTool(server, schema20, metadata20, removeCartItem);
5358
- registerTool(server, schema21, metadata21, applyDiscount);
5359
- registerTool(server, schema22, metadata22, removeDiscount);
5360
- registerTool(server, schema23, metadata23, clearCart);
5361
- registerTool(server, schema24, metadata24, validateDiscount);
5362
- registerTool(server, schema25, metadata25, calculateShipping);
5363
- registerTool(server, schema26, metadata26, stockCheck);
5364
- registerTool(server, schema27, metadata27, getCollectionSchemaTool);
5365
- registerTool(server, schema28, metadata28, handler);
5366
- registerTool(server, schema29, metadata29, listConfigurableFields);
5367
- registerTool(server, schema30, metadata30, updateFieldConfig);
5368
- registerTool(server, schema31, metadata31, handler2);
5369
- registerTool(server, schema32, metadata32, handler3);
5370
- registerTool(server, schema33, metadata33, handler4);
5371
- registerTool(server, schema34, metadata34, handler5);
5372
- registerPrompt(server, schema35, metadata35, sdkUsageGuide);
5373
- registerPrompt(server, schema36, metadata36, collectionQueryHelp);
5374
- registerPrompt(server, schema37, metadata37, orderFlowGuide);
5375
- registerPrompt(server, schema38, metadata38, featureSetupGuide);
5376
- registerStaticResource(server, "config://app", metadata39, handler6);
5377
- registerStaticResource(server, "collections://schema", metadata40, handler7);
5378
- registerStaticResource(server, "docs://sdk/getting-started", metadata41, handler8);
5379
- registerStaticResource(server, "docs://sdk/guides", metadata42, handler9);
5380
- registerStaticResource(server, "docs://sdk/api", metadata43, handler10);
5381
- registerStaticResource(server, "docs://sdk/query-builder", metadata44, handler11);
5382
- registerStaticResource(server, "docs://sdk/react-query", metadata45, handler12);
5383
- registerStaticResource(server, "docs://sdk/server-api", metadata46, handler13);
5384
- registerStaticResource(server, "docs://sdk/customer-auth", metadata47, handler14);
5385
- registerStaticResource(server, "docs://sdk/browser-vs-server", metadata48, handler15);
5386
- registerStaticResource(server, "docs://sdk/file-upload", metadata49, handler16);
5387
- registerStaticResource(server, "docs://sdk/webhook", metadata50, handler17);
5620
+ if (toolSurface === "full") {
5621
+ registerTool(server, schema, metadata, queryCollection);
5622
+ registerTool(server, schema2, metadata2, getCollectionById);
5623
+ registerTool(server, schema3, metadata3, getOrder);
5624
+ registerTool(server, schema4, metadata4, createOrder);
5625
+ registerTool(server, schema5, metadata5, updateOrder);
5626
+ registerTool(server, schema6, metadata6, checkout);
5627
+ registerTool(server, schema7, metadata7, createFulfillment);
5628
+ registerTool(server, schema8, metadata8, updateFulfillment);
5629
+ registerTool(server, schema9, metadata9, updateTransaction);
5630
+ registerTool(server, schema10, metadata10, createReturn);
5631
+ registerTool(server, schema11, metadata11, updateReturn);
5632
+ registerTool(server, schema12, metadata12, returnWithRefund);
5633
+ registerTool(server, schema13, metadata13, addCartItem);
5634
+ registerTool(server, schema14, metadata14, updateCartItem);
5635
+ registerTool(server, schema15, metadata15, removeCartItem);
5636
+ registerTool(server, schema16, metadata16, applyDiscount);
5637
+ registerTool(server, schema17, metadata17, removeDiscount);
5638
+ registerTool(server, schema18, metadata18, clearCart);
5639
+ registerTool(server, schema19, metadata19, validateDiscount);
5640
+ registerTool(server, schema20, metadata20, calculateShipping);
5641
+ registerTool(server, schema21, metadata21, stockCheck);
5642
+ }
5643
+ registerTool(server, schema22, metadata22, getCollectionSchemaTool);
5644
+ registerTool(server, schema23, metadata23, handler);
5645
+ registerTool(server, schema24, metadata24, listConfigurableFields);
5646
+ registerTool(server, schema25, metadata25, updateFieldConfig);
5647
+ registerTool(server, schema26, metadata26, handler2);
5648
+ registerTool(server, schema27, metadata27, handler3);
5649
+ registerTool(server, schema28, metadata28, handler4);
5650
+ registerTool(server, schema29, metadata29, handler5);
5651
+ registerPrompt(server, schema30, metadata30, sdkUsageGuide);
5652
+ registerPrompt(server, schema31, metadata31, collectionQueryHelp);
5653
+ registerPrompt(server, schema32, metadata32, orderFlowGuide);
5654
+ registerPrompt(server, schema33, metadata33, featureSetupGuide);
5655
+ registerStaticResource(server, "config://app", metadata34, handler6);
5656
+ registerStaticResource(server, "collections://schema", metadata35, handler7);
5657
+ registerStaticResource(server, "docs://sdk/getting-started", metadata36, handler8);
5658
+ registerStaticResource(server, "docs://sdk/guides", metadata37, handler9);
5659
+ registerStaticResource(server, "docs://sdk/api", metadata38, handler10);
5660
+ registerStaticResource(server, "docs://sdk/query-builder", metadata39, handler11);
5661
+ registerStaticResource(server, "docs://sdk/react-query", metadata40, handler12);
5662
+ registerStaticResource(server, "docs://sdk/server-api", metadata41, handler13);
5663
+ registerStaticResource(server, "docs://sdk/customer-auth", metadata42, handler14);
5664
+ registerStaticResource(server, "docs://sdk/browser-vs-server", metadata43, handler15);
5665
+ registerStaticResource(server, "docs://sdk/file-upload", metadata44, handler16);
5666
+ registerStaticResource(server, "docs://sdk/webhook", metadata45, handler17);
5388
5667
  return server;
5389
5668
  }
5390
5669
 
5391
5670
  export {
5671
+ MCP_RESOURCE_AUDIENCE,
5672
+ MCP_OAUTH_ISSUER,
5673
+ MCP_PROTECTED_RESOURCE_METADATA_PATH,
5674
+ MCP_TENANT_CLAIM,
5675
+ MCP_TENANT_ROLE_CLAIM,
5676
+ MCP_SCOPES,
5392
5677
  requestContext,
5678
+ mcpServicePublicJwks,
5393
5679
  createServer
5394
5680
  };
5395
- //# sourceMappingURL=chunk-3ZSKJM43.js.map
5681
+ //# sourceMappingURL=chunk-GJOQ4SE2.js.map