@dynamoi/mcp 0.7.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CAPABILITY_PARITY.md +57 -59
  2. package/CHANGELOG.md +160 -0
  3. package/README.md +241 -132
  4. package/dist/auth/protected-resource.d.ts +5 -18
  5. package/dist/auth/protected-resource.d.ts.map +1 -1
  6. package/dist/auth/protected-resource.js +8 -12
  7. package/dist/auth/protected-resource.js.map +1 -1
  8. package/dist/{chunk-2jm8hjsz.js → chunk-3htwe57a.js} +19 -30
  9. package/dist/chunk-3htwe57a.js.map +10 -0
  10. package/dist/chunk-n5xmtwjj.js +9 -0
  11. package/dist/chunk-n5xmtwjj.js.map +10 -0
  12. package/dist/consent.d.ts +3 -3
  13. package/dist/consent.d.ts.map +1 -1
  14. package/dist/consent.js +8 -8
  15. package/dist/consent.js.map +1 -1
  16. package/dist/flow-types.d.ts +3 -3
  17. package/dist/flow-types.d.ts.map +1 -1
  18. package/dist/index.d.ts +6 -5
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1192 -577
  21. package/dist/index.js.map +18 -17
  22. package/dist/server/about.d.ts +74 -0
  23. package/dist/server/about.d.ts.map +1 -0
  24. package/dist/server/create-server.d.ts +18 -12
  25. package/dist/server/create-server.d.ts.map +1 -1
  26. package/dist/server/distribution-tools.d.ts +53 -3
  27. package/dist/server/distribution-tools.d.ts.map +1 -1
  28. package/dist/server/instructions.d.ts.map +1 -1
  29. package/dist/server/onboarding-tool-definitions.d.ts +50 -0
  30. package/dist/server/onboarding-tool-definitions.d.ts.map +1 -1
  31. package/dist/server/openai-tools.d.ts +50 -0
  32. package/dist/server/openai-tools.d.ts.map +1 -1
  33. package/dist/server/output-schemas.d.ts +233 -0
  34. package/dist/server/output-schemas.d.ts.map +1 -1
  35. package/dist/server/playbook-resources.d.ts +1 -1
  36. package/dist/server/playbook-resources.d.ts.map +1 -1
  37. package/dist/server/prompts.d.ts +1 -1
  38. package/dist/server/prompts.d.ts.map +1 -1
  39. package/dist/server/resources.d.ts +1 -1
  40. package/dist/server/resources.d.ts.map +1 -1
  41. package/dist/server/shop-tools.d.ts +335 -0
  42. package/dist/server/shop-tools.d.ts.map +1 -0
  43. package/dist/server/smart-link-theme-preview.d.ts +26 -1
  44. package/dist/server/smart-link-theme-preview.d.ts.map +1 -1
  45. package/dist/server/smart-link-tools.d.ts +126 -2
  46. package/dist/server/smart-link-tools.d.ts.map +1 -1
  47. package/dist/server/tools.d.ts +402 -13
  48. package/dist/server/tools.d.ts.map +1 -1
  49. package/dist/server/workflow-tools.d.ts +62 -1
  50. package/dist/server/workflow-tools.d.ts.map +1 -1
  51. package/dist/transport/http.d.ts +7 -1
  52. package/dist/transport/http.d.ts.map +1 -1
  53. package/dist/types.d.ts +14 -2
  54. package/dist/types.d.ts.map +1 -1
  55. package/package.json +5 -5
  56. package/server.json +1 -12
  57. package/dist/auth/verify-token.d.ts +0 -21
  58. package/dist/auth/verify-token.d.ts.map +0 -1
  59. package/dist/chunk-2jm8hjsz.js.map +0 -10
  60. package/dist/chunk-kb3xpcrb.js +0 -9
  61. package/dist/chunk-kb3xpcrb.js.map +0 -10
package/dist/index.js CHANGED
@@ -1,21 +1,76 @@
1
1
  import {
2
- DYNAMOI_BETTER_AUTH_MCP_SCOPES,
3
- DYNAMOI_MCP_SCOPES,
4
- DYNAMOI_MCP_TOOL_SCOPES,
5
- buildProtectedResourceMetadata,
6
- buildWwwAuthenticateHeader
7
- } from "./chunk-2jm8hjsz.js";
2
+ DYNAMOI_BETTER_AUTH_MCP_SCOPES2,
3
+ DYNAMOI_MCP_TOOL_SCOPES2,
4
+ buildWwwAuthenticateHeader2
5
+ } from "./chunk-3htwe57a.js";
8
6
  import {
9
- PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY,
10
- PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH,
11
- PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION
12
- } from "./chunk-kb3xpcrb.js";
13
-
14
- // src/server/distribution-tools.ts
7
+ PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION2,
8
+ PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY2,
9
+ PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH2
10
+ } from "./chunk-n5xmtwjj.js";
11
+ // src/server/about.ts
15
12
  import * as z2 from "zod/v4";
16
13
 
17
14
  // src/server/output-schemas.ts
18
15
  import * as z from "zod/v4";
16
+ var ResultErrorCodeSchema = z.enum([
17
+ "ACCOUNT_READ_ONLY",
18
+ "INVALID_SPOTIFY_SOURCE",
19
+ "CAPABILITY_REQUIRED",
20
+ "INSUFFICIENT_SCOPE",
21
+ "STATE_CONFLICT",
22
+ "QUOTE_CHANGED",
23
+ "RATE_LIMITED",
24
+ "OUTPUT_INVALID",
25
+ "UNKNOWN_EFFECT"
26
+ ]);
27
+ var ResultNextActionSchema = z.object({
28
+ field: z.string().trim().min(1).max(120).optional(),
29
+ kind: z.enum(["provide_input", "read_status", "reconnect", "handoff"]),
30
+ reason: z.string().trim().min(1).max(240).optional()
31
+ }).strict();
32
+ var ResultErrorRecoverySchema = z.object({
33
+ code: ResultErrorCodeSchema.optional(),
34
+ field: z.string().trim().min(1).max(120).optional(),
35
+ nextAction: ResultNextActionSchema.optional(),
36
+ prerequisite: z.string().trim().min(1).max(240).optional(),
37
+ retryAfterSeconds: z.number().int().min(0).max(86400).optional(),
38
+ retryable: z.boolean().optional()
39
+ }).strict();
40
+ function addRecoverySafetyIssues(value, context) {
41
+ if (value.retryAfterSeconds !== undefined && value.retryable !== true) {
42
+ context.addIssue({
43
+ code: "custom",
44
+ message: "Retry timing requires retryable=true.",
45
+ path: ["retryAfterSeconds"]
46
+ });
47
+ }
48
+ if (value.retryable !== true) {
49
+ return;
50
+ }
51
+ if (value.code !== "RATE_LIMITED") {
52
+ context.addIssue({
53
+ code: "custom",
54
+ message: "Only RATE_LIMITED results may be retryable.",
55
+ path: ["retryable"]
56
+ });
57
+ }
58
+ if (value.retryAfterSeconds === undefined || value.retryAfterSeconds <= 0) {
59
+ context.addIssue({
60
+ code: "custom",
61
+ message: "Retryable results require a positive retryAfterSeconds value.",
62
+ path: ["retryAfterSeconds"]
63
+ });
64
+ }
65
+ }
66
+ var RESULT_ERROR_RECOVERY_FIELDS = [
67
+ "code",
68
+ "field",
69
+ "nextAction",
70
+ "prerequisite",
71
+ "retryable",
72
+ "retryAfterSeconds"
73
+ ];
19
74
  var MoneyDisplayOutputSchema = z.object({
20
75
  amountUsd: z.number(),
21
76
  formatted: z.string()
@@ -26,6 +81,7 @@ function createOutputEnvelopeSchema(dataSchema, options) {
26
81
  data: dataSchema.optional(),
27
82
  kind: z.enum(["validation", "business", "platform", "unknown"]).optional(),
28
83
  message: z.string().optional(),
84
+ ...ResultErrorRecoverySchema.shape,
29
85
  status: z.enum(statuses)
30
86
  }).strict().superRefine((value, context) => {
31
87
  if (value.status === "error" && !value.message) {
@@ -42,6 +98,20 @@ function createOutputEnvelopeSchema(dataSchema, options) {
42
98
  path: ["data"]
43
99
  });
44
100
  }
101
+ const valueRecord = value;
102
+ if (value.status !== "error") {
103
+ for (const field of RESULT_ERROR_RECOVERY_FIELDS) {
104
+ if (valueRecord[field] !== undefined) {
105
+ context.addIssue({
106
+ code: "custom",
107
+ message: "Recovery metadata is only valid on error results.",
108
+ path: [field]
109
+ });
110
+ }
111
+ }
112
+ return;
113
+ }
114
+ addRecoverySafetyIssues(value, context);
45
115
  });
46
116
  }
47
117
  var AnyToolDataOutputSchema = z.object({}).passthrough();
@@ -73,7 +143,6 @@ var SmartLinkStatusSchemas = {
73
143
  "approved_by_ops",
74
144
  "rejected"
75
145
  ]),
76
- odesliStatus: z.enum(["pending", "resolved", "failed"]),
77
146
  publishState: z.enum(["published", "unpublished"]),
78
147
  renderState: z.enum(["queued", "rendering", "rendered", "failed"]),
79
148
  takedownStatus: z.enum(["none", "active", "resolved"]),
@@ -88,7 +157,6 @@ var SmartLinkSummaryOutputSchema = z.object({
88
157
  id: z.string(),
89
158
  isPublic: z.boolean(),
90
159
  localizedPublicUrls: z.array(z.string()).optional(),
91
- odesliStatus: SmartLinkStatusSchemas.odesliStatus,
92
160
  publicUrl: z.string(),
93
161
  publishState: SmartLinkStatusSchemas.publishState,
94
162
  releaseSlug: z.string(),
@@ -208,22 +276,123 @@ var CreateSmartLinkFromSpotifyOutputEnvelopeSchema = createOutputEnvelopeSchema(
208
276
  var CreateSmartLinksFromSpotifyArtistOutputEnvelopeSchema = createOutputEnvelopeSchema(CreateSmartLinksFromSpotifyArtistDataOutputSchema);
209
277
  var ListSmartLinksOutputEnvelopeSchema = createOutputEnvelopeSchema(z.union([ListSmartLinksDataOutputSchema, ListSmartLinksSummaryOutputSchema]));
210
278
 
279
+ // src/server/about.ts
280
+ var DYNAMOI_ABOUT_INTRO = "Dynamoi is a music marketing platform founded in 2021 by Trevor Loucks. It runs managed Meta and YouTube ad campaigns, music distribution, and royalty analytics for independent artists, labels, managers, and YouTube creators, alongside free Smart Links and analytics. An artist can go from a Spotify URL to a shareable release page, a running campaign, or a distribution application in one place: Dynamoi brings the whole artist lifecycle (distribution, campaigns, and royalties) into one system.";
281
+ var DYNAMOI_ABOUT_COMPANY = `## Company
282
+
283
+ - **Founded** — 2021, by Trevor Loucks (Founder & CEO).
284
+ - **Headquarters** — Sioux Falls, South Dakota, United States.
285
+ - **Operating model** — Dynamoi is operated by humans, assisted by AI. People make the decisions and are accountable for every campaign and support reply; AI assists with ad creative, campaign monitoring, reporting, and routine tasks.
286
+ - **Support** — email support@dynamoi.com. The Dynamoi team replies within 24 hours.`;
287
+ var DYNAMOI_ABOUT_CAMPAIGN_NOTE = "Campaigns run on Dynamoi's own managed Meta and Google ad infrastructure, so artists do not need their own Business Manager, pixels, or ad accounts. They reach real people through official ad networks, never bots, fake streams, click farms, or paid playlist placement. Results vary by campaign and are never guaranteed.";
288
+ var DYNAMOI_ABOUT_SMART_LINKS_BULLET = "- **Free Smart Links** — create and manage Smart Links and artist hubs from Spotify artist, album, or track URLs at no cost. Link analytics, custom themes, validated pixel IDs, and team seats are included. High-popularity or unverifiable artist links may stay unpublished in verification hold until Dynamoi can verify the client relationship.";
289
+ var DYNAMOI_ABOUT_YOUTUBE_BULLET = "- **YouTube campaigns** — managed Google Ads campaigns for YouTube channel growth. Dynamoi optimizes ad spend against AdSense revenue per country, so delivery favors audiences that actually monetize.";
290
+ var DYNAMOI_ABOUT_DISTRIBUTION_GATE = "Dynamoi scores five requirements before an application can be submitted — including an established audience (at least 10,000 monthly Spotify listeners) and identity verification — and approval is not guaranteed.";
291
+ var DYNAMOI_ABOUT_GETTING_STARTED = `## How to get started
292
+
293
+ 1. Sign in at https://dynamoi.com.
294
+ 2. Connect your Spotify artist profile.
295
+ 3. Create a free Smart Link for a release.`;
296
+ var DYNAMOI_ABOUT_MARKDOWN = `# About Dynamoi
297
+
298
+ ${DYNAMOI_ABOUT_INTRO}
299
+
300
+ ## What Dynamoi offers
301
+
302
+ ${DYNAMOI_ABOUT_SMART_LINKS_BULLET}
303
+ - **Managed Smart Campaigns** — Dynamoi runs Meta ad campaigns that promote Spotify tracks, albums, and playlists.
304
+ ${DYNAMOI_ABOUT_YOUTUBE_BULLET}
305
+ - **Music distribution** — an opt-in product that delivers releases to 100+ stores including Spotify, Apple Music, Amazon Music, YouTube Music, TikTok, Deezer, and Tidal. The artist keeps 90% of Net Receipts (Dynamoi keeps 10%), there are no upfront release fees, and Content ID is included. Optional publishing administration is available to distribution clients for 10% of Net Receipts. ${DYNAMOI_ABOUT_DISTRIBUTION_GATE}
306
+ - **YouTube promotion Shop** — one-off YouTube promotion purchases without a subscription, for users who do not want managed advertising.
307
+
308
+ ${DYNAMOI_ABOUT_CAMPAIGN_NOTE}
309
+
310
+ ${DYNAMOI_ABOUT_COMPANY}
311
+
312
+ ${DYNAMOI_ABOUT_GETTING_STARTED}
313
+
314
+ ## Pricing
315
+
316
+ Smart Links are free. Starter is $25/month with a $50 launch campaign credit, and campaign budgets start at $10/day. There are no contracts: pause between releases or cancel anytime and keep your free tools. Managed advertising and distribution are paid products — see current plans and pricing at https://dynamoi.com/pricing.`;
317
+ var DYNAMOI_ABOUT_DIRECTORY_MARKDOWN = `# About Dynamoi
318
+
319
+ ${DYNAMOI_ABOUT_INTRO}
320
+
321
+ ## What Dynamoi offers
322
+
323
+ ${DYNAMOI_ABOUT_SMART_LINKS_BULLET}
324
+ - **Managed Smart Campaigns** — Dynamoi runs Meta ad campaigns that promote Spotify tracks, albums, and playlists.
325
+ ${DYNAMOI_ABOUT_YOUTUBE_BULLET}
326
+ - **Music distribution** — an opt-in product that delivers releases to 100+ stores including Spotify, Apple Music, Amazon Music, YouTube Music, TikTok, Deezer, and Tidal. ${DYNAMOI_ABOUT_DISTRIBUTION_GATE}
327
+
328
+ ${DYNAMOI_ABOUT_CAMPAIGN_NOTE}
329
+
330
+ ${DYNAMOI_ABOUT_COMPANY}
331
+
332
+ ${DYNAMOI_ABOUT_GETTING_STARTED}`;
333
+ var DYNAMOI_ABOUT_SUMMARY = "Dynamoi is a music marketing platform founded in 2021 by Trevor Loucks and based in Sioux Falls, South Dakota: free Smart Links and analytics, managed Meta Smart Campaigns and YouTube campaigns, a YouTube promotion Shop, and opt-in distribution to 100+ stores. Operated by humans, assisted by AI. Starter is $25/month with a $50 launch campaign credit, and campaign budgets start at $10/day. Sign in at dynamoi.com, connect Spotify, and create a free Smart Link to start. Pricing: https://dynamoi.com/pricing. Support: support@dynamoi.com (replies within 24 hours).";
334
+ var DYNAMOI_ABOUT_DIRECTORY_SUMMARY = "Dynamoi is a music marketing platform founded in 2021 by Trevor Loucks and based in Sioux Falls, South Dakota: free Smart Links and analytics, managed Meta Smart Campaigns and YouTube campaigns, and opt-in distribution to 100+ stores. Operated by humans, assisted by AI. Sign in at dynamoi.com, connect Spotify, and create a free Smart Link to start. Support: support@dynamoi.com (replies within 24 hours).";
335
+ var DYNAMOI_ABOUT_RESOURCE = {
336
+ description: "Canonical About Dynamoi overview: what Dynamoi is, who it is for, free Smart Links, managed Smart Campaigns, YouTube campaigns, distribution, company facts, support, and how to get started.",
337
+ mimeType: "text/markdown",
338
+ name: "dynamoi_about",
339
+ title: "About Dynamoi",
340
+ uri: "dynamoi://about"
341
+ };
342
+ var DYNAMOI_ABOUT_TOOL_DEFINITION = {
343
+ description: "Use this when the user asks what Dynamoi is, who it is for, or what it offers — including before sign-in or before choosing a tool. Returns the canonical About Dynamoi text plus a short structured summary covering free Smart Links, managed Smart Campaigns, YouTube campaigns, distribution, company facts, support, and getting started. This is read-only product information, not account data.",
344
+ destructiveHint: false,
345
+ idempotentHint: true,
346
+ name: "dynamoi_about",
347
+ openWorldHint: false,
348
+ outputSchema: AnyOutputEnvelopeSchema,
349
+ readOnlyHint: true,
350
+ schema: z2.object({}).strict(),
351
+ title: "About Dynamoi"
352
+ };
353
+ function getDynamoiAbout(options) {
354
+ const isFull = options?.toolProfile === "full";
355
+ return {
356
+ data: {
357
+ links: {
358
+ dashboard: "https://dynamoi.com/dashboard",
359
+ ...isFull ? { pricing: "https://dynamoi.com/pricing" } : {},
360
+ signIn: "https://dynamoi.com",
361
+ support: "mailto:support@dynamoi.com"
362
+ },
363
+ markdown: isFull ? DYNAMOI_ABOUT_MARKDOWN : DYNAMOI_ABOUT_DIRECTORY_MARKDOWN,
364
+ summary: isFull ? DYNAMOI_ABOUT_SUMMARY : DYNAMOI_ABOUT_DIRECTORY_SUMMARY
365
+ },
366
+ status: "success"
367
+ };
368
+ }
369
+ // src/server/create-server.ts
370
+ import {
371
+ McpServer
372
+ } from "@modelcontextprotocol/server";
373
+ import * as z12 from "zod/v4";
374
+
375
+ // src/version.ts
376
+ var BUNDLED_DYNAMOI_MCP_VERSION = "1.0.0";
377
+ var DYNAMOI_MCP_VERSION = BUNDLED_DYNAMOI_MCP_VERSION.length > 0 && !BUNDLED_DYNAMOI_MCP_VERSION.includes("__") ? BUNDLED_DYNAMOI_MCP_VERSION : "1.0.0";
378
+
211
379
  // src/server/distribution-tools.ts
212
- var DynamoiGetDistributionApplicationInputSchema = z2.object({
213
- artistId: z2.string().uuid()
380
+ import * as z3 from "zod/v4";
381
+ var DynamoiGetDistributionApplicationInputSchema = z3.object({
382
+ artistId: z3.string().uuid()
214
383
  }).strict();
215
- var DynamoiApplyForDistributionInputSchema = z2.object({
216
- adultSignerAttestation: z2.literal(true),
217
- applicantCountry: z2.string().trim().length(2),
218
- artistId: z2.string().uuid(),
219
- confirmApplicationSubmission: z2.literal(true),
220
- payoutCountry: z2.string().trim().length(2),
221
- taxResidencyCountry: z2.string().trim().length(2),
222
- userIntentSummary: z2.string().trim().min(1).max(500)
384
+ var DynamoiApplyForDistributionInputSchema = z3.object({
385
+ adultSignerAttestation: z3.literal(true),
386
+ applicantCountry: z3.string().trim().length(2),
387
+ artistId: z3.string().uuid(),
388
+ confirmApplicationSubmission: z3.literal(true),
389
+ payoutCountry: z3.string().trim().length(2),
390
+ taxResidencyCountry: z3.string().trim().length(2),
391
+ userIntentSummary: z3.string().trim().min(1).max(500)
223
392
  }).strict();
224
393
  var DISTRIBUTION_TOOL_DEFINITIONS = [
225
394
  {
226
- description: "Use this when the user asks whether an artist qualifies for Dynamoi music distribution, wants the five application requirements, or wants the status of an existing distribution application. It checks Spotify connection, at least 1,000 Spotify followers, at least 10,000 verified Soundcharts monthly listeners, connected Facebook Page plus Instagram professional identity, and a connected YouTube channel. Meeting all five requirements permits an application but never guarantees approval. When the connection tools are available, use purpose=distribution_identity for missing Meta or YouTube identity; otherwise send the user to the distribution application in Dynamoi. Identity connections do not require advertising billing.",
395
+ description: "Use this when the user asks whether an artist qualifies for Dynamoi music distribution, wants the five application requirements, or wants the status of an existing distribution application. It checks Spotify connection, at least 1,000 Spotify followers, at least 10,000 verified Soundcharts monthly listeners, connected Facebook Page plus Instagram professional identity, and a connected YouTube channel. Meeting all five requirements permits an application but never guarantees approval. When the connection tools are available, use purpose=distribution_identity for missing Meta or YouTube identity; otherwise tell the user: 'You can do this in the Dynamoi dashboard at https://dynamoi.com/dashboard.' Identity connections do not require advertising billing.",
227
396
  destructiveHint: false,
228
397
  name: "dynamoi_get_distribution_application",
229
398
  openWorldHint: false,
@@ -233,105 +402,31 @@ var DISTRIBUTION_TOOL_DEFINITIONS = [
233
402
  title: "Check Distribution Application"
234
403
  },
235
404
  {
236
- description: "Submit an artist's application for Dynamoi music distribution after the user explicitly asks to apply and all five eligibility requirements are met. This records an application for manual review; it does not approve distribution, accept an agreement, submit a release, transfer rights, configure splits or tax forms, or deliver music to stores. All three two-letter country codes, an adult signer attestation, confirmApplicationSubmission=true, and a concise userIntentSummary are required. Repeated submission is idempotent for an active application.",
405
+ description: "Submit an artist's application for Dynamoi music distribution after the user explicitly asks to apply and all five eligibility requirements are met. This records an application for manual review; it does not approve distribution, accept an agreement, submit a release, transfer rights, configure splits or tax forms, or deliver music to stores. All three valid ISO 3166-1 alpha-2 country or territory codes, an adult signer attestation, confirmApplicationSubmission=true, and a concise userIntentSummary are required. Country, tax, payout, sanctions, and provider-delivery checks remain manual progression gates after intake; a valid code does not imply approval. Repeated submission is idempotent for an active application.",
237
406
  destructiveHint: false,
238
407
  idempotentHint: true,
239
408
  name: "dynamoi_apply_for_distribution",
240
- openWorldHint: false,
409
+ openWorldHint: true,
241
410
  outputSchema: AnyOutputEnvelopeSchema,
242
411
  readOnlyHint: false,
243
412
  schema: DynamoiApplyForDistributionInputSchema,
244
413
  title: "Apply for Music Distribution"
245
414
  }
246
415
  ];
247
- // src/auth/verify-token.ts
248
- import { createRemoteJWKSet, jwtVerify } from "jose";
249
- var jwksByUrl = new Map;
250
- function getRemoteJwks(jwksUrl) {
251
- const existing = jwksByUrl.get(jwksUrl);
252
- if (existing) {
253
- return existing;
254
- }
255
- const created = createRemoteJWKSet(new URL(jwksUrl));
256
- jwksByUrl.set(jwksUrl, created);
257
- return created;
258
- }
259
- function extractClientId(payload) {
260
- const direct = payload["client_id"];
261
- if (typeof direct === "string" && direct.trim().length > 0) {
262
- return direct;
263
- }
264
- const azp = payload["azp"];
265
- if (typeof azp === "string" && azp.trim().length > 0) {
266
- return azp;
267
- }
268
- return null;
269
- }
270
- function extractScopes(payload) {
271
- const scope = payload["scope"];
272
- if (typeof scope === "string") {
273
- return scope.split(/\s+/).map((part) => part.trim()).filter((part) => part.length > 0);
274
- }
275
- const scopes = payload["scopes"];
276
- if (Array.isArray(scopes)) {
277
- return scopes.filter((scopeValue) => typeof scopeValue === "string" && scopeValue.trim().length > 0);
278
- }
279
- return [];
280
- }
281
- async function verifyAccessToken(options) {
282
- const jwks = getRemoteJwks(options.jwksUrl);
283
- const verifyOptions = {
284
- algorithms: options.algorithms ?? ["ES256", "RS256"],
285
- audience: options.audienceAllowlist,
286
- issuer: options.issuer
287
- };
288
- const { payload } = await jwtVerify(options.token, jwks, verifyOptions);
289
- const sub = typeof payload.sub === "string" ? payload.sub : null;
290
- if (!sub) {
291
- throw new Error("JWT missing sub");
292
- }
293
- const iss = typeof payload.iss === "string" ? payload.iss : null;
294
- if (!iss) {
295
- throw new Error("JWT missing iss");
296
- }
297
- const exp = typeof payload.exp === "number" ? payload.exp : null;
298
- if (!exp) {
299
- throw new Error("JWT missing exp");
300
- }
301
- const aud = payload.aud;
302
- return {
303
- aud,
304
- clientId: extractClientId(payload),
305
- exp,
306
- grantId: typeof payload["gid"] === "string" ? payload["gid"] : null,
307
- iss,
308
- jti: typeof payload.jti === "string" ? payload.jti : null,
309
- scopes: extractScopes(payload),
310
- sessionId: typeof payload.sid === "string" ? payload.sid : null,
311
- sub
312
- };
313
- }
314
- // src/server/create-server.ts
315
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
316
- import * as z10 from "zod/v4";
317
-
318
- // src/version.ts
319
- var BUNDLED_DYNAMOI_MCP_VERSION = "0.7.1";
320
- var DYNAMOI_MCP_VERSION = BUNDLED_DYNAMOI_MCP_VERSION.length > 0 && !BUNDLED_DYNAMOI_MCP_VERSION.includes("__") ? BUNDLED_DYNAMOI_MCP_VERSION : "0.7.1";
321
416
 
322
417
  // src/server/instructions.ts
323
418
  var DYNAMOI_MCP_INSTRUCTIONS = `
324
- You are operating Dynamoi's tools on behalf of the authenticated user. Dynamoi helps
325
- artists and labels create music-promotion campaigns, build Smart Links, review analytics,
326
- and apply for music distribution. YouTube creators can grow channels through managed
327
- Google ad campaigns. Smart Links are free to create and manage. High-popularity
328
- or unverifiable artist links may stay unpublished in verification hold until Dynamoi
329
- can verify the client relationship. Managed advertising and ad budgets are separate
330
- paid campaign services.
419
+ Dynamoi is a music marketing platform for independent artists, labels, managers, and YouTube creators. It combines free Smart Links and analytics with managed Meta Smart Campaigns, managed YouTube campaigns, a one-off YouTube promotion Shop, and opt-in music distribution to 100+ stores. Call dynamoi_about or read dynamoi://about for the canonical product and pricing overview.
420
+
421
+ You are operating Dynamoi's tools on behalf of the authenticated user. Smart Links
422
+ are free to create and manage. High-popularity or unverifiable artist links may
423
+ stay unpublished in verification hold until Dynamoi can verify the client
424
+ relationship. Managed advertising and ad budgets are separate paid campaign
425
+ services.
331
426
 
332
427
  === Session Start Routine ===
333
428
 
334
- When the user's first message in a Dynamoi session is account-relevant (artists, campaigns, smart links, analytics, distribution, billing, connections, launches, or "what should I do here"), call dynamoi_get_account_overview first to learn the user's state. The response includes a recommendedNextActions array and a state object — treat that array as authoritative guidance for what to ask or do next.
429
+ Use dynamoi_get_account_overview for an explicit account overview, uncertain account context, or onboarding guidance. When the request already identifies the relevant artist, campaign, or Smart Link, use the targeted tool directly. Resolve ambiguous identities before acting. Treat recommendedNextActions as suggestions within the user's request and current permissions, not authorization for additional writes.
335
430
 
336
431
  Route by state from dynamoi_get_account_overview:
337
432
 
@@ -344,13 +439,13 @@ Route by state from dynamoi_get_account_overview:
344
439
 
345
440
  - state.hasAnyArtist === true && state.hasAnyActiveCampaign === false: Offer dynamoi_get_campaign_readiness to validate launch inputs without creating anything.
346
441
 
347
- - state.hasAnyArtist === true && billing blocks a launch: tell the user managed-advertising billing setup must happen in the Dynamoi dashboard, not through a ChatGPT checkout link. After they start or restore billing there, poll dynamoi_get_billing for the target artist to confirm billing is active.
442
+ - state.hasAnyArtist === true && billing blocks a launch: managed-advertising billing setup is not available through this MCP surface. Tell the user: "You can do this in the Dynamoi dashboard at https://dynamoi.com/dashboard." After they start or restore billing there, poll dynamoi_get_billing for the target artist to confirm billing is active.
348
443
 
349
444
  - state.hasAnyArtist === true && state.hasAnyConnectedMeta === false and the user wants Spotify Smart Campaigns: only offer dynamoi_start_meta_connection after billing is active. If the tool returns billing_required, route the user to dashboard billing first. If it returns billing_check_unavailable, retry shortly instead of treating the user as unpaid. After Meta browser return, poll dynamoi_get_platform_status for the target artist with the returned onboardingAttemptId and onboardingFlow=meta. Treat platforms.meta.status as complete when it is oauth_complete, partnership_pending, or partnership_active.
350
445
 
351
446
  - state.hasAnyArtist === true && state.hasAnyConnectedYoutube === false and the user wants YouTube growth: offer dynamoi_start_youtube_channel_link, then poll dynamoi_get_platform_status for the target artist with the returned onboardingAttemptId and onboardingFlow=youtube after the browser return page sends them back to chat. Treat the connection as complete when platforms.youtube.connected is true.
352
447
 
353
- Do NOT call dynamoi_list_artists or dynamoi_search as a first step for brand-new users — both will return empty for them and the conversation stalls. Always go through dynamoi_get_account_overview first.
448
+ For a known empty account, use account overview to explain supported onboarding. Otherwise, use roster or search when it resolves missing identity. Apply the state-based suggestions only when setup is needed or the user asks for guidance; do not force an unrelated onboarding detour.
354
449
 
355
450
  === End Session Start Routine ===
356
451
 
@@ -359,9 +454,9 @@ Principles:
359
454
  - Answer general knowledge or advice questions directly without Dynamoi tools unless the user is asking about their Dynamoi account, artists, campaigns, billing, connections, or launches.
360
455
  - Do not call Dynamoi tools just to "check context" before answering generic advice questions. If the question is about Instagram growth, lyrics, songwriting, promotion strategy, or general marketing education and does not require the user's account data, answer natively and do not mention inspecting Dynamoi.
361
456
  - Even when Dynamoi is attached, generic advice stays native. If the user asks something like "How do I get more followers on Instagram organically without running any ads?", answer directly with no Dynamoi tool calls.
362
- - \`dynamoi_get_account_overview\` is the first call for account-relevant session starts and explicit account-overview questions. Do not use it as a zero-context scout before answering unrelated prompts.
363
- - Never claim you changed something unless the tool returned status "success" or
364
- "partial_success".
457
+ - Use \`dynamoi_get_account_overview\` when account orientation is needed, not as a prerequisite for every account-related task. Do not use it before unrelated advice; each targeted operation still enforces resource access.
458
+ - When a requested action is not available through this MCP surface — billing or subscription setup, plan changes, payment, or other dashboard-only steps — tell the user: "You can do this in the Dynamoi dashboard at https://dynamoi.com/dashboard."
459
+ - Never claim you changed something unless the tool returned an actual mutation result.
365
460
  - Prefer read tools first before write tools. For writes, confirm intent and restate
366
461
  what will change.
367
462
  - After a successful write tool call, answer directly from the returned record instead of chaining more tools just to restate the result.
@@ -374,49 +469,66 @@ Principles:
374
469
  - Smart Link pixel tools accept validated pixel IDs only. Do not ask for arbitrary JavaScript, tag-manager snippets, or script code.
375
470
  - When the user asks about music distribution, call dynamoi_get_distribution_application before making eligibility claims. Treat its five scored requirements as authoritative. Applicant country, tax-residency country, payout country, and the adult signer attestation are required submission fields, but they are not additional eligibility-score requirements.
376
471
  - For missing Meta or YouTube distribution identity, use purpose=distribution_identity on the relevant connection tool when that tool is available. These least-privilege identity flows do not require advertising billing. Never substitute the advertising flow.
377
- - Call dynamoi_apply_for_distribution only after the user explicitly asks to submit, confirms the application, provides all required country fields, and attests that the signer is an adult. Submission starts manual review; it never implies approval, agreement acceptance, release submission, rights clearance, store delivery, royalty setup, or payout readiness.
472
+ - Call dynamoi_apply_for_distribution only after the user explicitly asks to submit, confirms the application, provides valid ISO country or territory fields, and attests that the signer is an adult. Submission starts manual review; country, tax, payout, sanctions, and provider-delivery gates still decide progression. It never implies approval, agreement acceptance, release submission, rights clearance, store delivery, royalty setup, or payout readiness.
378
473
  - Money values are shown in USD as presented in Dynamoi.
379
474
  - Budget minimums: $10/day (daily), $50 total (Smart Campaign), $50 total (YouTube).
475
+ - Shop tools are a separate one-off purchase surface for YouTube promotion, independent of managed-advertising billing. Use dynamoi_shop_get_quote for a read-only Shop estimate. Use dynamoi_shop_create_checkout only after explicit user intent to create an unpaid Stripe Checkout Session. Re-quote when the tool reports a changed amount. Never describe Checkout creation as payment, an order, or campaign launch.
380
476
  - Product and pricing details are available as MCP resources. Keep runtime answers
381
477
  focused on the user's account data and requested action.
382
478
 
383
479
  Common workflows:
384
- - Discovery: dynamoi_list_artists → dynamoi_list_campaigns → dynamoi_get_campaign →
385
- dynamoi_get_campaign with includeAnalytics=true when needed
480
+ - Discovery: use dynamoi_get_account_overview for an explicit overview or uncertain
481
+ account context. When the artist or campaign is already identified, call its
482
+ targeted read directly. Use dynamoi_list_artists, dynamoi_search, or
483
+ dynamoi_list_campaigns to resolve missing or ambiguous identity, then read the
484
+ resolved resource.
386
485
  - Artist performance summary: dynamoi_get_artist_analytics with granularity=DAILY when requested. If that response already includes the strongest campaign, do not call more analytics tools.
387
486
  - Diagnose stuck campaign: dynamoi_get_campaign → dynamoi_get_platform_status →
388
487
  propose next steps
389
- - Pause/resume: dynamoi_get_campaign (confirm) → dynamoi_update_campaign with action=pause or action=resume
488
+ - Pause/resume: dynamoi_get_campaign (confirm) → dynamoi_update_campaign with action=pause or action=resume; a resume that needs card funding also requires the funding-consent fields (see the tool description).
390
489
  - Budget update: dynamoi_get_campaign (confirm) → dynamoi_update_campaign with action=update_budget
391
- - Launch: dynamoi_list_media_assets → dynamoi_launch_campaign
490
+ - Launch: dynamoi_list_media_assets → dynamoi_launch_campaign. DAILY budgets require the
491
+ user's funding consent (authorizeAutomaticDailyFunding plus the exact consent fields);
492
+ TOTAL budgets use existing credit.
392
493
  - Free Smart Link artist catalog creation: dynamoi_create_smart_links_from_spotify_artist; omit artistId for a brand-new user with no Dynamoi artist yet
393
- - Free Smart Link single-release creation: dynamoi_list_artists → dynamoi_create_smart_link_from_spotify
394
- - Smart Link analytics/settings: dynamoi_list_smart_links → dynamoi_get_smart_link with includeAnalytics=true or includeArtistSettings=true
494
+ - Free Smart Link single-release creation: call dynamoi_create_smart_link_from_spotify
495
+ directly when the artist and release are identified; resolve missing artist
496
+ access first when needed.
497
+ - Smart Link analytics/settings: call dynamoi_get_smart_link directly when the
498
+ Smart Link is identified; use dynamoi_list_smart_links only to resolve a
499
+ missing or ambiguous link, then set includeAnalytics=true or
500
+ includeArtistSettings=true as requested.
395
501
  - Distribution: dynamoi_get_distribution_application → satisfy missing identity requirements with purpose=distribution_identity when available → collect required country fields and adult attestation → explicit confirmation → dynamoi_apply_for_distribution
396
502
  - Post-launch answer: if dynamoi_launch_campaign succeeds, answer from that result directly. Only call dynamoi_get_campaign when the user explicitly needs more detail than the launch result already returned, and prefer format=summary for that follow-up.
397
- - Review/demo Smart Campaign launch: if the user already gave artist, content title, budget, countries, and reusable media assets, you may call dynamoi_launch_campaign without spotifyUrl/endDate because Dynamoi can infer reviewer-safe defaults. Do not invent placeholder values for omitted fields; omit those keys entirely.
503
+ - Shop one-off promotion: dynamoi_shop_get_quote → explicit user confirmation → dynamoi_shop_create_checkout. The returned URL is an unpaid handoff; the user completes payment outside MCP and no Shop order exists until Dynamoi verifies settlement.
398
504
  `.trim();
399
505
  var DYNAMOI_CHATGPT_APP_INSTRUCTIONS = `
400
- You are operating Dynamoi's ChatGPT app tools on behalf of the authenticated user.
401
- Dynamoi helps artists and labels create music-promotion assets, review campaign and
402
- Smart Link analytics, and check or submit music-distribution applications from ChatGPT.
506
+ Dynamoi is a music marketing platform for independent artists, labels, managers, and YouTube creators. It combines free Smart Links and analytics with managed Meta Smart Campaigns, managed YouTube campaigns, and opt-in music distribution to 100+ stores. Call dynamoi_about for the canonical product overview.
403
507
 
404
- This ChatGPT app surface is review-safe and does not start billing, external OAuth
405
- connections, campaign launches, campaign budget changes, or direct purchase flows.
406
- When the user asks to buy, subscribe, launch a paid campaign, connect Meta or YouTube,
407
- or change a live campaign, explain that those steps happen in the Dynamoi dashboard.
408
- Use the available read tools afterward to check existing status, analytics, and setup
409
- state.
508
+ You are operating Dynamoi's tools on behalf of the authenticated user. This
509
+ surface is review-safe: it does not expose billing, subscription or plan setup,
510
+ campaign launch or budget tools, external OAuth connection starters, Shop
511
+ checkout, or any purchase flow. When the user asks to buy, subscribe, launch a
512
+ paid campaign, connect Meta or YouTube, or change a live campaign, explain that
513
+ the action is not available through this surface and tell them: "You can do this
514
+ in the Dynamoi dashboard at https://dynamoi.com/dashboard." Do not create or
515
+ surface a purchase or checkout URL. Use the available read tools afterward to
516
+ check existing status, analytics, and setup state.
410
517
 
411
518
  Principles:
412
519
  - Answer general marketing, songwriting, lyrics, or social-media advice natively
413
520
  unless the user explicitly asks about their Dynamoi account, artists, campaigns,
414
521
  analytics, or Smart Links.
415
522
  - Do not call Dynamoi tools just to "check context" for generic advice.
416
- - For account questions, use dynamoi_get_account_overview first.
523
+ - For an explicit account overview or uncertain account context, use
524
+ dynamoi_get_account_overview. If the request identifies the artist, campaign,
525
+ or Smart Link, use its targeted read directly; resolve missing or ambiguous
526
+ identity with the relevant roster or search tool first.
417
527
  - For artist rosters, use dynamoi_list_artists.
418
- - For existing campaigns, use dynamoi_list_campaigns, dynamoi_get_campaign, and
419
- dynamoi_get_artist_analytics. These tools are read-only.
528
+ - For an identified campaign, call dynamoi_get_campaign directly. Use
529
+ dynamoi_list_campaigns to resolve a missing or ambiguous campaign, and use
530
+ dynamoi_get_artist_analytics when the user asks for artist performance.
531
+ These tools are read-only.
420
532
  - For music distribution, use dynamoi_get_distribution_application to explain the exact
421
533
  five requirements and current application status. Use dynamoi_apply_for_distribution
422
534
  only after explicit user confirmation and complete country/adult-attestation fields.
@@ -428,8 +540,7 @@ Principles:
428
540
  includeArtistSettings=true for artist-level theme or pixel settings.
429
541
  - Smart Link pixel tools accept validated pixel IDs only. Do not ask for arbitrary
430
542
  JavaScript, tag-manager snippets, or script code.
431
- - Never claim you changed something unless the tool returned status "success" or
432
- "partial_success".
543
+ - Never claim you changed something unless the tool returned an actual mutation result.
433
544
  - For writes, confirm intent and restate what will change.
434
545
  - After a successful write tool call, answer directly from the returned record instead
435
546
  of chaining more tools just to restate the result.
@@ -440,7 +551,7 @@ Principles:
440
551
  `.trim();
441
552
 
442
553
  // src/server/prompts.ts
443
- import * as z3 from "zod/v4";
554
+ import * as z4 from "zod/v4";
444
555
  function asTextPrompt(text) {
445
556
  return {
446
557
  messages: [
@@ -453,10 +564,10 @@ function asTextPrompt(text) {
453
564
  }
454
565
  function registerDynamoiPrompts(server) {
455
566
  server.registerPrompt("dynamoi_find_smart_link_url", {
456
- argsSchema: {
457
- artistId: z3.string().uuid().optional(),
458
- query: z3.string().trim().optional()
459
- },
567
+ argsSchema: z4.object({
568
+ artistId: z4.string().uuid().optional(),
569
+ query: z4.string().trim().optional()
570
+ }),
460
571
  description: "Find a user's free Smart Link URL and answer with public URLs, titles, and statuses.",
461
572
  title: "Find Smart Link URL"
462
573
  }, (args) => asTextPrompt([
@@ -469,7 +580,7 @@ function registerDynamoiPrompts(server) {
469
580
  ].filter(Boolean).join(`
470
581
  `)));
471
582
  server.registerPrompt("dynamoi_explain_free_smart_links", {
472
- argsSchema: {},
583
+ argsSchema: z4.object({}),
473
584
  description: "Explain Dynamoi free Smart Links and how they differ from paid managed advertising.",
474
585
  title: "Explain Free Smart Links"
475
586
  }, () => asTextPrompt([
@@ -480,10 +591,10 @@ function registerDynamoiPrompts(server) {
480
591
  ].join(`
481
592
  `)));
482
593
  server.registerPrompt("dynamoi_create_free_smart_link", {
483
- argsSchema: {
484
- artistId: z3.string().uuid().optional(),
485
- spotifyUrl: z3.string().trim().optional()
486
- },
594
+ argsSchema: z4.object({
595
+ artistId: z4.string().uuid().optional(),
596
+ spotifyUrl: z4.string().trim().optional()
597
+ }),
487
598
  description: "Create free Smart Links from a Spotify artist, album, or track URL.",
488
599
  title: "Create Free Smart Link"
489
600
  }, (args) => asTextPrompt([
@@ -496,9 +607,9 @@ function registerDynamoiPrompts(server) {
496
607
  ].join(`
497
608
  `)));
498
609
  server.registerPrompt("dynamoi_audit_campaigns", {
499
- argsSchema: {
500
- artistId: z3.string().uuid().optional()
501
- },
610
+ argsSchema: z4.object({
611
+ artistId: z4.string().uuid().optional()
612
+ }),
502
613
  description: "Audit an artist's campaigns and summarize what is working and what to fix next.",
503
614
  title: "Audit Campaigns"
504
615
  }, (args) => asTextPrompt([
@@ -512,11 +623,11 @@ function registerDynamoiPrompts(server) {
512
623
  ].join(`
513
624
  `)));
514
625
  server.registerPrompt("dynamoi_release_launch_plan", {
515
- argsSchema: {
516
- artistId: z3.string().uuid().optional(),
517
- contentTitle: z3.string().trim().optional(),
518
- contentType: z3.enum(["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]).optional()
519
- },
626
+ argsSchema: z4.object({
627
+ artistId: z4.string().uuid().optional(),
628
+ contentTitle: z4.string().trim().optional(),
629
+ contentType: z4.enum(["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]).optional()
630
+ }),
520
631
  description: "Create a pragmatic release launch plan and propose a Dynamoi campaign setup.",
521
632
  title: "Release Launch Plan"
522
633
  }, (args) => asTextPrompt([
@@ -526,10 +637,8 @@ function registerDynamoiPrompts(server) {
526
637
  args.contentTitle ? `Title: ${args.contentTitle}` : "",
527
638
  "",
528
639
  "Ask any missing questions first (links, creative, budget, countries, dates).",
529
- "For review/demo Smart Campaign launches that already specify the artist, content title, budget, countries, and reusable media assets, you may proceed without asking for spotifyUrl or endDate.",
530
- "When those review/demo fields are omitted, do not invent placeholder spotifyUrl or endDate values; omit them and let Dynamoi infer them.",
531
640
  "Then propose the simplest campaign plan that fits today’s supported platforms:",
532
- "- Smart Campaign (Meta) for Spotify/Apple Music releases",
641
+ "- Smart Campaign (Meta) for Spotify releases",
533
642
  "- YouTube campaign for videos",
534
643
  "",
535
644
  "If we proceed to launch:",
@@ -538,9 +647,9 @@ function registerDynamoiPrompts(server) {
538
647
  ].filter(Boolean).join(`
539
648
  `)));
540
649
  server.registerPrompt("dynamoi_why_campaign_blocked", {
541
- argsSchema: {
542
- campaignId: z3.string().uuid()
543
- },
650
+ argsSchema: z4.object({
651
+ campaignId: z4.string().uuid()
652
+ }),
544
653
  description: "Diagnose why a campaign is blocked/stuck and recommend the next fix.",
545
654
  title: "Why Is My Campaign Blocked?"
546
655
  }, (args) => asTextPrompt([
@@ -556,10 +665,8 @@ function registerDynamoiPrompts(server) {
556
665
  }
557
666
 
558
667
  // src/server/resources.ts
559
- import {
560
- ResourceTemplate
561
- } from "@modelcontextprotocol/sdk/server/mcp.js";
562
- import * as z4 from "zod/v4";
668
+ import { ResourceTemplate } from "@modelcontextprotocol/server";
669
+ import * as z5 from "zod/v4";
563
670
 
564
671
  // src/server/playbook-resources.ts
565
672
  function registerPlaybookResources(server) {
@@ -574,7 +681,6 @@ function registerPlaybookResources(server) {
574
681
  text: JSON.stringify({
575
682
  fastestPath: "Ask the user for their Spotify artist URL, then call dynamoi_create_smart_links_from_spotify_artist with that URL. Return the artist hub URL plus the starter Smart Link URL. Catalog import continues in the background.",
576
683
  freePlanReminder: "Free Smart Links have no per-link fee for creation or management. High-popularity or unverifiable artist links may stay unpublished in verification hold until Dynamoi can verify the client relationship. Creating a Smart Link does not create a paid campaign or spend ad budget.",
577
- marginCopyGuard: "Never describe Dynamoi's pricing in terms that imply pass-through or zero overhead. Do not quote plan prices, campaign credits, daily campaign-spend billing, or checkout details in ChatGPT; billing setup belongs in the Dynamoi dashboard. The internal media-spend margin is not part of any client-facing copy.",
578
684
  persona: "Independent musician or small artist with at least one Spotify release. Goal: increase Spotify streams.",
579
685
  sampleScript: "Drop your Spotify artist link and I'll set up your free Dynamoi hub in about 30 seconds. We'll get all your releases on one shareable page, then we can talk about whether you want to promote any of them.",
580
686
  talkingPoints: {
@@ -583,7 +689,7 @@ function registerPlaybookResources(server) {
583
689
  trigger: "User asks how Dynamoi differs from link-in-bio or Smart Link products."
584
690
  },
585
691
  hesitationReassurance: {
586
- claim: "Managed advertising billing is completed in the Dynamoi dashboard. In ChatGPT, keep the flow focused on Smart Links, readiness, platform connections, and campaign management after billing setup is complete.",
692
+ claim: "Managed advertising billing is completed in the Dynamoi dashboard. On surfaces without billing or launch tools, keep the flow focused on Smart Links, readiness, platform connections, and campaign management after billing setup is complete.",
587
693
  trigger: "User hesitates about price, commitment, or whether the first month is enough to test."
588
694
  },
589
695
  postLaunchExpectations: {
@@ -599,7 +705,7 @@ function registerPlaybookResources(server) {
599
705
  trigger: "User mentions Instagram, social media growth, or followers while discussing Spotify promotion."
600
706
  }
601
707
  },
602
- upsellAfterStarter: "Once they have a hub URL, the natural next ask is 'would you like to promote this release on Meta Ads?' which routes to dynamoi_get_campaign_readiness, dynamoi_start_meta_connection if Meta is missing, then dynamoi_launch_campaign for a Smart Campaign."
708
+ upsellAfterStarter: "Once they have a hub URL, the natural next ask is 'would you like to promote this release on Meta Ads?' which routes to dynamoi_get_campaign_readiness, dynamoi_start_meta_connection if Meta is missing, then dynamoi_launch_campaign for a Smart Campaign — when those tools are available to this client."
603
709
  }),
604
710
  uri: uri.href
605
711
  }
@@ -614,18 +720,18 @@ function registerPlaybookResources(server) {
614
720
  {
615
721
  mimeType: "application/json",
616
722
  text: JSON.stringify({
617
- channelLinkingPath: "Call dynamoi_start_youtube_channel_link for the target artist, give the user the returned Google authorization URL, then poll dynamoi_get_platform_status for that artist with the returned onboardingAttemptId and onboardingFlow=youtube after the return page sends them back to chat. The completion field is platforms.youtube.connected.",
618
- differentiator: "Dynamoi is the only ad platform that optimizes YouTube ad spend against AdSense revenue per country. Most ad tools optimize for views; Dynamoi optimizes for views that make money. The system explores small bids in new markets, scales countries where viewer revenue is strong, and pauses countries that cannot cover their costs.",
723
+ channelLinkingPath: "When connection tools are available to this client, call dynamoi_start_youtube_channel_link for the target artist, give the user the returned Google authorization URL, then poll dynamoi_get_platform_status for that artist with the returned onboardingAttemptId and onboardingFlow=youtube after the return page sends them back to chat. The completion field is platforms.youtube.connected. On surfaces without connection tools, direct the user: 'You can do this in the Dynamoi dashboard at https://dynamoi.com/dashboard.'",
724
+ differentiator: "Dynamoi optimizes YouTube ad spend against AdSense revenue per country. Most ad tools optimize for views; Dynamoi optimizes for views that make money. The system explores small bids in new markets, scales countries where viewer revenue is strong, and pauses countries that cannot cover their costs.",
619
725
  persona: "Channel owner of any niche (music, education, gaming, vlog, podcast, tutorial, product reviews) who wants subscriber growth that pays back via AdSense.",
620
- postLinkingFlow: "After channel link, call dynamoi_get_campaign_readiness for a YouTube growth campaign. Mention that ad copy is internationalized per market for lower cost and that campaigns require playlists so each paid view drives sustained organic views downstream.",
621
- sampleScript: "Most YouTube ad systems optimize for raw views. Dynamoi merges your AdSense revenue with ad cost data to optimize bids per country based on real viewer revenue, so you grow toward viewers who actually monetize. I can start the YouTube channel link from here, then we can plan your first campaign.",
726
+ postLinkingFlow: "After channel link, call dynamoi_get_campaign_readiness for a YouTube growth campaign when that tool is available to this client; otherwise direct campaign setup to the Dynamoi dashboard. Mention that ad copy is internationalized per market for lower cost and that campaigns require playlists so each paid view drives sustained organic views downstream.",
727
+ sampleScript: "Most YouTube ad systems optimize for raw views. Dynamoi merges your AdSense revenue with ad cost data to optimize bids per country based on real viewer revenue, so you grow toward viewers who actually monetize. I can help you link your YouTube channel, then we can plan your first campaign.",
622
728
  talkingPoints: {
623
729
  differentiatorComparison: {
624
730
  claim: "Most creator ad tools optimize for views or subscribers. Dynamoi compares ad cost with AdSense revenue by country so delivery can favor viewers who are more likely to pay back over time.",
625
731
  trigger: "User asks how YouTube campaigns differ from normal Google Ads or creator-growth services."
626
732
  },
627
733
  hesitationReassurance: {
628
- claim: "Managed advertising billing is completed in the Dynamoi dashboard. In ChatGPT, keep the flow focused on channel linking, readiness, and campaign management after billing setup is complete.",
734
+ claim: "Managed advertising billing is completed in the Dynamoi dashboard. On surfaces without billing or launch tools, keep the flow focused on channel linking, readiness, and campaign management after billing setup is complete.",
629
735
  trigger: "User expresses pricing concern or asks whether they can test without a long commitment."
630
736
  },
631
737
  playlistWaterfall: {
@@ -652,12 +758,12 @@ function registerPlaybookResources(server) {
652
758
  mimeType: "application/json",
653
759
  text: JSON.stringify({
654
760
  billingNote: "Consolidated billing across all artists in the organization. No per-seat charge, no per-artist fee.",
655
- persona: "Label owner, manager, or distributor handling more than one artist. Goal: oversee promotion across a roster from one account.",
761
+ persona: "Label owner or manager handling more than one artist. Goal: oversee promotion across a roster from one account.",
656
762
  rolesNote: "Dynamoi supports admin, editor, and viewer roles at organization and artist level. Editors can mutate everything except admin management; viewers are read-only.",
657
763
  sampleScript: "Dynamoi handles rosters: organizations with admin/editor/viewer roles, consolidated billing, and per-artist permissions. To start, create your first artist with a Spotify URL, then invite your team. We can layer in more artists from the same organization once you have one running.",
658
764
  setupSequence: [
659
765
  "If they have one artist ready: route to dynamoi://playbooks/spotify-artist for that first artist.",
660
- "After the first artist is set up, mention team invites are managed in the dashboard at /dashboard/settings/organization (no MCP tool yet).",
766
+ "After the first artist is set up, mention team invites are managed in organization settings — not available through MCP. 'You can do this in the Dynamoi dashboard at https://dynamoi.com/dashboard.'",
661
767
  "Cross-artist analytics are available via dynamoi_get_artist_analytics per artist; a roster-wide rollup is dashboard-only."
662
768
  ],
663
769
  talkingPoints: {
@@ -670,7 +776,7 @@ function registerPlaybookResources(server) {
670
776
  trigger: "User compares Dynamoi to Linkfire, Feature.fm, Hypeddit, or a label marketing stack."
671
777
  },
672
778
  hesitationReassurance: {
673
- claim: "Managed advertising billing is completed in the Dynamoi dashboard. In ChatGPT, keep the flow focused on roster setup, readiness checks, and campaign management after billing setup is complete.",
779
+ claim: "Managed advertising billing is completed in the Dynamoi dashboard. On surfaces without billing or launch tools, keep the flow focused on roster setup, readiness checks, and campaign management after billing setup is complete.",
674
780
  trigger: "User asks whether billing scales per seat or wants to test with one artist first."
675
781
  }
676
782
  }
@@ -712,19 +818,19 @@ function registerPlaybookResources(server) {
712
818
  if: "state.hasAnyArtist === true && state.hasAnySmartLink === false"
713
819
  },
714
820
  {
715
- do: "Offer dynamoi_get_campaign_readiness to validate launch inputs before creating anything.",
821
+ do: "Offer dynamoi_get_campaign_readiness to validate launch inputs before creating anything, when that tool is available to this client.",
716
822
  if: "state.hasAnyArtist === true && state.hasAnyActiveCampaign === false"
717
823
  },
718
824
  {
719
- do: "Tell the user managed-advertising billing setup must happen in the Dynamoi dashboard, not through a ChatGPT checkout link. After they start or restore billing there, poll dynamoi_get_billing for that artist to confirm billing is active.",
825
+ do: "Managed-advertising billing setup is not available through this MCP surface; tell the user: 'You can do this in the Dynamoi dashboard at https://dynamoi.com/dashboard.' After they start or restore billing there, poll dynamoi_get_billing for that artist to confirm billing is active.",
720
826
  if: "state.hasAnyArtist === true && billing is the launch blocker"
721
827
  },
722
828
  {
723
- do: "Offer dynamoi_start_meta_connection for the target artist, then poll dynamoi_get_platform_status for that artist with the returned onboardingAttemptId and onboardingFlow=meta after Meta returns them to chat. The completion field is platforms.meta.status.",
829
+ do: "When connection tools are available to this client, offer dynamoi_start_meta_connection for the target artist, then poll dynamoi_get_platform_status for that artist with the returned onboardingAttemptId and onboardingFlow=meta after Meta returns them to chat. The completion field is platforms.meta.status. On surfaces without connection tools, direct the user: 'You can do this in the Dynamoi dashboard at https://dynamoi.com/dashboard.'",
724
830
  if: "state.hasAnyArtist === true && user wants Spotify Smart Campaigns && state.hasAnyConnectedMeta === false"
725
831
  },
726
832
  {
727
- do: "Offer dynamoi_start_youtube_channel_link for the target artist, then poll dynamoi_get_platform_status for that artist with the returned onboardingAttemptId and onboardingFlow=youtube after Google returns them to chat. The completion field is platforms.youtube.connected.",
833
+ do: "When connection tools are available to this client, offer dynamoi_start_youtube_channel_link for the target artist, then poll dynamoi_get_platform_status for that artist with the returned onboardingAttemptId and onboardingFlow=youtube after Google returns them to chat. The completion field is platforms.youtube.connected. On surfaces without connection tools, direct the user: 'You can do this in the Dynamoi dashboard at https://dynamoi.com/dashboard.'",
728
834
  if: "state.hasAnyArtist === true && user wants YouTube growth && state.hasAnyConnectedYoutube === false"
729
835
  },
730
836
  {
@@ -777,9 +883,9 @@ function registerDynamoiResources(server, adapter) {
777
883
  totalUsd: 50
778
884
  }
779
885
  },
780
- includes: "Free Smart Links, unlimited team seats, unlimited artists, white-glove support, and campaign landing-page support where available",
886
+ includes: "Free Smart Links, Smart Link analytics, custom themes, validated pixel IDs, team seats, and campaign landing pages where available",
781
887
  managedAdvertising: {
782
- description: "Managed advertising subscription and payment setup happen in the Dynamoi dashboard, outside ChatGPT. This MCP server can check billing readiness after setup, but does not create checkout links or collect payment.",
888
+ description: "Managed advertising subscription and payment setup happen in the Dynamoi dashboard. This MCP server can check billing readiness after setup; it does not start subscriptions or collect payment for managed advertising.",
783
889
  paymentSetupLocation: "Dynamoi dashboard"
784
890
  },
785
891
  noContracts: true
@@ -903,7 +1009,7 @@ function registerDynamoiResources(server, adapter) {
903
1009
  },
904
1010
  managedAdvertising: {
905
1011
  paid: true,
906
- pricing: "Billing and payment setup happen in the Dynamoi dashboard, outside ChatGPT.",
1012
+ pricing: "Billing and payment setup happen in the Dynamoi dashboard.",
907
1013
  useFor: "Managed Meta and Google ad campaigns for Spotify promotion and YouTube channel growth."
908
1014
  }
909
1015
  }),
@@ -949,7 +1055,7 @@ function registerDynamoiResources(server, adapter) {
949
1055
  {
950
1056
  mimeType: "application/json",
951
1057
  text: JSON.stringify({
952
- emptyStateRule: "Always call dynamoi_get_account_overview first for routing. If list_artists, list_campaigns, list_smart_links, or search return empty for a brand-new user, do not respond 'no records found' as a terminal answer; consult dynamoi_get_account_overview.recommendedNextActions or dynamoi://playbooks/onboarding-tree.",
1058
+ emptyStateRule: "If the request identifies an artist, campaign, or Smart Link, use the targeted read directly. For missing or ambiguous identity, use the relevant roster or search tool first, then read the resolved resource. For a known empty account, use dynamoi_get_account_overview.recommendedNextActions or dynamoi://playbooks/onboarding-tree to explain supported onboarding; do not treat empty lists as a terminal answer.",
953
1059
  genericAdvice: "Answer generic music marketing questions directly unless the user asks about their Dynamoi account or asks Dynamoi to take an action.",
954
1060
  stopRule: "If a read tool already returns the requested fact in summary form, answer the user instead of chaining more read tools.",
955
1061
  userFacingFields: "Prefer names, public URLs, statuses, money display values, and next actions over internal IDs.",
@@ -1010,7 +1116,7 @@ function registerDynamoiResources(server, adapter) {
1010
1116
  list: async () => ({ resources: [] })
1011
1117
  }), { mimeType: "application/json", title: "Artist" }, async (uri, variables) => {
1012
1118
  const artistId = variables["artistId"];
1013
- const parsed = z4.string().uuid().safeParse(artistId);
1119
+ const parsed = z5.string().uuid().safeParse(artistId);
1014
1120
  if (!parsed.success) {
1015
1121
  return {
1016
1122
  contents: [
@@ -1042,7 +1148,7 @@ function registerDynamoiResources(server, adapter) {
1042
1148
  list: async () => ({ resources: [] })
1043
1149
  }), { mimeType: "application/json", title: "Campaign" }, async (uri, variables) => {
1044
1150
  const campaignId = variables["campaignId"];
1045
- const parsed = z4.string().uuid().safeParse(campaignId);
1151
+ const parsed = z5.string().uuid().safeParse(campaignId);
1046
1152
  if (!parsed.success) {
1047
1153
  return {
1048
1154
  contents: [
@@ -1074,7 +1180,7 @@ function registerDynamoiResources(server, adapter) {
1074
1180
  list: async () => ({ resources: [] })
1075
1181
  }), { mimeType: "application/json", title: "Smart Link" }, async (uri, variables) => {
1076
1182
  const playLinkId = variables["playLinkId"];
1077
- const parsed = z4.string().uuid().safeParse(playLinkId);
1183
+ const parsed = z5.string().uuid().safeParse(playLinkId);
1078
1184
  if (!parsed.success) {
1079
1185
  return {
1080
1186
  contents: [
@@ -1106,7 +1212,7 @@ function registerDynamoiResources(server, adapter) {
1106
1212
  list: async () => ({ resources: [] })
1107
1213
  }), { mimeType: "application/json", title: "Smart Link Artist Settings" }, async (uri, variables) => {
1108
1214
  const artistId = variables["artistId"];
1109
- const parsed = z4.string().uuid().safeParse(artistId);
1215
+ const parsed = z5.string().uuid().safeParse(artistId);
1110
1216
  if (!parsed.success) {
1111
1217
  return {
1112
1218
  contents: [
@@ -1136,11 +1242,148 @@ function registerDynamoiResources(server, adapter) {
1136
1242
  });
1137
1243
  }
1138
1244
 
1245
+ // src/server/shop-tools.ts
1246
+ import * as z6 from "zod/v4";
1247
+ var DYNAMOI_SHOP_FULL_SCOPE = "dynamoi:mcp.full";
1248
+ var DYNAMOI_SHOP_MAX_TARGET_COUNTRY_CODES = 50;
1249
+ var DYNAMOI_SHOP_CUSTOM_MIN_TARGET_VIEWS = 25000;
1250
+ var DYNAMOI_SHOP_CUSTOM_MAX_TARGET_VIEWS = 1e6;
1251
+ var DYNAMOI_SHOP_CUSTOM_MIN_DURATION_DAYS = 7;
1252
+ var DYNAMOI_SHOP_CUSTOM_MAX_DURATION_DAYS = 30;
1253
+ var ShopPackageSelectionInputSchema = z6.object({
1254
+ kind: z6.literal("package"),
1255
+ tier: z6.enum(["starter", "standard", "premium"])
1256
+ }).strict();
1257
+ var ShopCustomSelectionInputSchema = z6.object({
1258
+ campaignDurationDays: z6.number().int().min(DYNAMOI_SHOP_CUSTOM_MIN_DURATION_DAYS).max(DYNAMOI_SHOP_CUSTOM_MAX_DURATION_DAYS),
1259
+ kind: z6.literal("custom"),
1260
+ targetViews: z6.number().int().min(DYNAMOI_SHOP_CUSTOM_MIN_TARGET_VIEWS).max(DYNAMOI_SHOP_CUSTOM_MAX_TARGET_VIEWS)
1261
+ }).strict();
1262
+ var DynamoiShopSelectionInputSchema = z6.discriminatedUnion("kind", [
1263
+ ShopPackageSelectionInputSchema,
1264
+ ShopCustomSelectionInputSchema
1265
+ ]);
1266
+ var ShopGlobalTargetingInputSchema = z6.object({ mode: z6.literal("GLOBAL") }).strict();
1267
+ var ShopIncludedTargetingInputSchema = z6.object({
1268
+ countryCodes: z6.array(z6.string().regex(/^[A-Z]{2}$/)).min(1).max(DYNAMOI_SHOP_MAX_TARGET_COUNTRY_CODES),
1269
+ mode: z6.literal("INCLUDE")
1270
+ }).strict();
1271
+ var DynamoiShopTargetingInputSchema = z6.discriminatedUnion("mode", [
1272
+ ShopGlobalTargetingInputSchema,
1273
+ ShopIncludedTargetingInputSchema
1274
+ ]);
1275
+ var DynamoiShopGetQuoteInputSchema = z6.object({
1276
+ marketLocale: z6.string().trim().min(2).max(35),
1277
+ selection: DynamoiShopSelectionInputSchema,
1278
+ storefrontSlug: z6.string().trim().min(1).max(160).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),
1279
+ targeting: DynamoiShopTargetingInputSchema,
1280
+ youtubeUrl: z6.string().trim().url().max(500)
1281
+ }).strict();
1282
+ var DynamoiShopCreateCheckoutInputSchema = z6.object({
1283
+ expectedTotal: z6.object({
1284
+ amountMinor: z6.number().int().positive(),
1285
+ currency: z6.string().regex(/^[A-Z]{3}$/)
1286
+ }).strict(),
1287
+ promotion: DynamoiShopGetQuoteInputSchema,
1288
+ requestId: z6.string().uuid()
1289
+ }).strict();
1290
+ var ShopSelectionOutputSchema = DynamoiShopSelectionInputSchema;
1291
+ var ShopTargetingOutputSchema = z6.discriminatedUnion("mode", [
1292
+ ShopGlobalTargetingInputSchema,
1293
+ z6.object({
1294
+ countryCodes: z6.array(z6.string().regex(/^[A-Z]{2}$/)).min(1),
1295
+ mode: z6.literal("INCLUDE")
1296
+ }).strict()
1297
+ ]);
1298
+ var ShopMoneyOutputSchema = z6.object({
1299
+ amountMinor: z6.number().int().positive(),
1300
+ currency: z6.string().regex(/^[A-Z]{3}$/),
1301
+ formatted: z6.string().min(1).max(80)
1302
+ }).strict();
1303
+ var DynamoiShopQuoteDataSchema = z6.object({
1304
+ campaignDurationDays: z6.number().int().positive().nullable(),
1305
+ estimatedViews: z6.object({
1306
+ basis: z6.literal("rolling_30_day_cpv"),
1307
+ max: z6.number().int().nonnegative(),
1308
+ min: z6.number().int().nonnegative(),
1309
+ notGuaranteed: z6.literal(true)
1310
+ }).strict().nullable(),
1311
+ kind: z6.literal("shop_quote"),
1312
+ reviewRequired: z6.boolean(),
1313
+ selection: ShopSelectionOutputSchema,
1314
+ storefront: z6.object({
1315
+ currency: z6.string().regex(/^[A-Z]{3}$/),
1316
+ marketLocale: z6.string(),
1317
+ slug: z6.string()
1318
+ }).strict(),
1319
+ targeting: ShopTargetingOutputSchema,
1320
+ total: ShopMoneyOutputSchema,
1321
+ video: z6.object({
1322
+ normalizedUrl: z6.string().url(),
1323
+ videoId: z6.string().regex(/^[A-Za-z0-9_-]{11}$/)
1324
+ }).strict()
1325
+ }).strict();
1326
+ var DynamoiShopCheckoutDataSchema = z6.object({
1327
+ checkoutUrl: z6.string().url(),
1328
+ expiresAt: z6.string().datetime({ offset: true }),
1329
+ kind: z6.literal("shop_checkout"),
1330
+ orderCreated: z6.literal(false),
1331
+ paymentCompleted: z6.literal(false),
1332
+ status: z6.literal("checkout_required"),
1333
+ total: ShopMoneyOutputSchema
1334
+ }).strict();
1335
+ var ToolErrorEnvelopeSchema = z6.object({
1336
+ kind: z6.enum(["validation", "business", "platform", "unknown"]),
1337
+ message: z6.string().min(1),
1338
+ ...ResultErrorRecoverySchema.shape,
1339
+ status: z6.literal("error")
1340
+ }).strict().superRefine((value, context) => {
1341
+ addRecoverySafetyIssues(value, context);
1342
+ });
1343
+ var DynamoiShopQuoteOutputEnvelopeSchema = z6.union([
1344
+ z6.object({
1345
+ data: DynamoiShopQuoteDataSchema,
1346
+ status: z6.literal("success")
1347
+ }).strict(),
1348
+ ToolErrorEnvelopeSchema
1349
+ ]);
1350
+ var DynamoiShopCheckoutOutputEnvelopeSchema = z6.union([
1351
+ z6.object({
1352
+ data: DynamoiShopCheckoutDataSchema,
1353
+ status: z6.literal("success")
1354
+ }).strict(),
1355
+ ToolErrorEnvelopeSchema
1356
+ ]);
1357
+ var SHOP_TOOL_DEFINITIONS = [
1358
+ {
1359
+ description: "Calculate a read-only Dynamoi Shop estimate for a one-off YouTube video promotion. The server derives storefront price, currency, targeting, and estimated views. This does not reserve a price, create checkout, collect payment, create an order, or launch a campaign.",
1360
+ destructiveHint: false,
1361
+ idempotentHint: true,
1362
+ name: "dynamoi_shop_get_quote",
1363
+ openWorldHint: false,
1364
+ outputSchema: DynamoiShopQuoteOutputEnvelopeSchema,
1365
+ readOnlyHint: true,
1366
+ schema: DynamoiShopGetQuoteInputSchema,
1367
+ title: "Get Shop Promotion Estimate"
1368
+ },
1369
+ {
1370
+ description: "After explicit user intent, revalidate and re-quote a one-off Dynamoi Shop YouTube promotion and create an unpaid Stripe Checkout Session. The expected total is a compare-and-reject guard, never a price instruction. This does not charge the user, create an order, or launch a campaign; the user must open and complete Stripe Checkout.",
1371
+ destructiveHint: false,
1372
+ idempotentHint: true,
1373
+ name: "dynamoi_shop_create_checkout",
1374
+ openWorldHint: true,
1375
+ outputSchema: DynamoiShopCheckoutOutputEnvelopeSchema,
1376
+ readOnlyHint: false,
1377
+ schema: DynamoiShopCreateCheckoutInputSchema,
1378
+ title: "Create Unpaid Shop Checkout"
1379
+ }
1380
+ ];
1381
+
1139
1382
  // src/server/smart-link-theme-preview.ts
1140
- import * as z5 from "zod/v4";
1383
+ import * as z7 from "zod/v4";
1141
1384
  var SMART_LINK_THEME_PREVIEW_RESOURCE_URI = "ui://dynamoi/smart-link-theme-preview-v1.html";
1142
- var SampleTextSchema = z5.string().trim().min(1).max(80);
1143
- var DynamoiPreviewSmartLinkThemesInputSchema = z5.object({
1385
+ var SampleTextSchema = z7.string().trim().min(1).max(80);
1386
+ var DynamoiPreviewSmartLinkThemesInputSchema = z7.object({
1144
1387
  artistName: SampleTextSchema.optional(),
1145
1388
  releaseTitle: SampleTextSchema.optional()
1146
1389
  }).strict();
@@ -1399,15 +1642,15 @@ function registerSmartLinkThemePreviewResource(server) {
1399
1642
  }
1400
1643
 
1401
1644
  // src/server/smart-link-tools.ts
1402
- import * as z7 from "zod/v4";
1645
+ import * as z9 from "zod/v4";
1403
1646
 
1404
1647
  // src/server/shared-schemas.ts
1405
- import * as z6 from "zod/v4";
1406
- var ToolFormatSchema = z6.enum(["json", "summary"]);
1407
- var IsoDateSchema = z6.string().regex(/^\d{4}-\d{2}-\d{2}$/);
1408
- var UserIntentSummarySchema = z6.string().trim().max(500).optional();
1409
- var ClientRequestIdSchema = z6.string().uuid().optional();
1410
- var RequiredClientRequestIdSchema = z6.string().uuid();
1648
+ import * as z8 from "zod/v4";
1649
+ var ToolFormatSchema = z8.enum(["json", "summary"]);
1650
+ var IsoDateSchema = z8.string().regex(/^\d{4}-\d{2}-\d{2}$/);
1651
+ var UserIntentSummarySchema = z8.string().trim().max(500).optional();
1652
+ var ClientRequestIdSchema = z8.string().uuid().optional();
1653
+ var RequiredClientRequestIdSchema = z8.string().uuid();
1411
1654
  function isValidCalendarDate(value) {
1412
1655
  const date = new Date(`${value}T00:00:00.000Z`);
1413
1656
  return Number.isFinite(date.getTime()) && date.toISOString().slice(0, 10) === value;
@@ -1415,7 +1658,7 @@ function isValidCalendarDate(value) {
1415
1658
  var IsoCalendarDateSchema = IsoDateSchema.refine(isValidCalendarDate, {
1416
1659
  message: "must be a valid calendar date"
1417
1660
  });
1418
- var DateRangeSchema = z6.object({
1661
+ var DateRangeSchema = z8.object({
1419
1662
  end: IsoDateSchema,
1420
1663
  start: IsoDateSchema
1421
1664
  }).strict().superRefine((data, ctx) => {
@@ -1444,77 +1687,55 @@ var DateRangeSchema = z6.object({
1444
1687
 
1445
1688
  // src/server/smart-link-tools.ts
1446
1689
  var SmartLinkStatusFiltersSchema = {
1447
- claimStatus: z7.enum([
1690
+ claimStatus: z9.enum([
1448
1691
  "auto_approved",
1449
1692
  "pending_ops_review",
1450
1693
  "verification_deferred",
1451
1694
  "approved_by_ops",
1452
1695
  "rejected"
1453
1696
  ]).optional(),
1454
- publishState: z7.enum(["published", "unpublished"]).optional(),
1455
- renderState: z7.enum(["queued", "rendering", "rendered", "failed"]).optional()
1697
+ publishState: z9.enum(["published", "unpublished"]).optional(),
1698
+ renderState: z9.enum(["queued", "rendering", "rendered", "failed"]).optional()
1456
1699
  };
1457
- var SmartLinkThemeSchema = z7.enum([
1700
+ var SmartLinkThemeSchema = z9.enum([
1458
1701
  "classic",
1459
1702
  "brutalist",
1460
1703
  "aurora",
1461
1704
  "cinematic"
1462
1705
  ]);
1463
- var LegacySmartLinkIncludeSchema = z7.array(z7.enum(["analytics", "artist_settings"]));
1464
- function normalizeLegacySmartLinkInclude(rawInput) {
1465
- if (!rawInput || typeof rawInput !== "object" || Array.isArray(rawInput)) {
1466
- return rawInput;
1467
- }
1468
- const input = rawInput;
1469
- if (!Object.hasOwn(input, "include")) {
1470
- return rawInput;
1471
- }
1472
- const legacyInclude = LegacySmartLinkIncludeSchema.safeParse(input["include"]);
1473
- if (!legacyInclude.success) {
1474
- return rawInput;
1475
- }
1476
- const { include: _include, ...normalized } = input;
1477
- if (normalized["includeAnalytics"] === undefined && legacyInclude.data.includes("analytics")) {
1478
- normalized["includeAnalytics"] = true;
1479
- }
1480
- if (normalized["includeArtistSettings"] === undefined && legacyInclude.data.includes("artist_settings")) {
1481
- normalized["includeArtistSettings"] = true;
1482
- }
1483
- return normalized;
1484
- }
1485
- var DynamoiCreateSmartLinkFromSpotifyInputSchema = z7.object({
1486
- artistId: z7.string().uuid(),
1706
+ var DynamoiCreateSmartLinkFromSpotifyInputSchema = z9.object({
1707
+ artistId: z9.string().uuid(),
1487
1708
  clientRequestId: RequiredClientRequestIdSchema.optional(),
1488
- customDescription: z7.string().trim().max(500).optional(),
1709
+ customDescription: z9.string().trim().max(500).optional(),
1489
1710
  format: ToolFormatSchema.optional(),
1490
- spotifyUrl: z7.string().trim().min(1).max(500),
1711
+ spotifyUrl: z9.string().trim().min(1).max(500),
1491
1712
  userIntentSummary: UserIntentSummarySchema
1492
1713
  }).strict();
1493
- var DynamoiCreateSmartLinksFromSpotifyArtistInputSchema = z7.object({
1494
- artistId: z7.string().uuid().optional(),
1714
+ var DynamoiCreateSmartLinksFromSpotifyArtistInputSchema = z9.object({
1715
+ artistId: z9.string().uuid().optional(),
1495
1716
  clientRequestId: RequiredClientRequestIdSchema.optional(),
1496
1717
  format: ToolFormatSchema.optional(),
1497
- spotifyArtistUrl: z7.string().trim().min(1).max(500),
1718
+ spotifyArtistUrl: z9.string().trim().min(1).max(500),
1498
1719
  userIntentSummary: UserIntentSummarySchema
1499
1720
  }).strict();
1500
- var DynamoiListSmartLinksInputSchema = z7.object({
1501
- artistId: z7.string().uuid(),
1502
- cursor: z7.string().optional(),
1721
+ var DynamoiListSmartLinksInputSchema = z9.object({
1722
+ artistId: z9.string().uuid(),
1723
+ cursor: z9.string().optional(),
1503
1724
  format: ToolFormatSchema.optional(),
1504
- limit: z7.number().int().min(1).max(50).optional(),
1505
- query: z7.string().trim().max(120).optional(),
1725
+ limit: z9.number().int().min(1).max(50).optional(),
1726
+ query: z9.string().trim().max(120).optional(),
1506
1727
  ...SmartLinkStatusFiltersSchema
1507
1728
  }).strict();
1508
1729
  var DynamoiGetSmartLinkInputShape = {
1509
- artistId: z7.string().uuid().optional(),
1730
+ artistId: z9.string().uuid().optional(),
1510
1731
  dateRange: DateRangeSchema.optional(),
1511
1732
  format: ToolFormatSchema.optional(),
1512
- granularity: z7.enum(["TOTAL", "DAILY"]).optional(),
1513
- includeAnalytics: z7.boolean().optional(),
1514
- includeArtistSettings: z7.boolean().optional(),
1515
- includeBreakdowns: z7.boolean().optional(),
1516
- playLinkId: z7.string().uuid().optional(),
1517
- spotifyUrl: z7.string().trim().min(1).max(500).optional()
1733
+ granularity: z9.enum(["TOTAL", "DAILY"]).optional(),
1734
+ includeAnalytics: z9.boolean().optional(),
1735
+ includeArtistSettings: z9.boolean().optional(),
1736
+ includeBreakdowns: z9.boolean().optional(),
1737
+ playLinkId: z9.string().uuid().optional(),
1738
+ spotifyUrl: z9.string().trim().min(1).max(500).optional()
1518
1739
  };
1519
1740
  function validateDynamoiGetSmartLinkInput(data, ctx) {
1520
1741
  const settingsOnly = data.includeArtistSettings === true && !data.playLinkId && !data.spotifyUrl && Boolean(data.artistId);
@@ -1533,33 +1754,33 @@ function validateDynamoiGetSmartLinkInput(data, ctx) {
1533
1754
  });
1534
1755
  }
1535
1756
  }
1536
- var StrictDynamoiGetSmartLinkInputSchema = z7.object(DynamoiGetSmartLinkInputShape).strict().superRefine(validateDynamoiGetSmartLinkInput);
1757
+ var StrictDynamoiGetSmartLinkInputSchema = z9.object(DynamoiGetSmartLinkInputShape).strict().superRefine(validateDynamoiGetSmartLinkInput);
1537
1758
  var DynamoiGetSmartLinkInputSchema = StrictDynamoiGetSmartLinkInputSchema;
1538
1759
  function parseDynamoiGetSmartLinkInput(rawInput) {
1539
- return StrictDynamoiGetSmartLinkInputSchema.parse(normalizeLegacySmartLinkInclude(rawInput));
1760
+ return StrictDynamoiGetSmartLinkInputSchema.parse(rawInput);
1540
1761
  }
1541
- var DynamoiGetSmartLinkAnalyticsInputSchema = z7.object({
1762
+ var DynamoiGetSmartLinkAnalyticsInputSchema = z9.object({
1542
1763
  dateRange: DateRangeSchema.optional(),
1543
1764
  format: ToolFormatSchema.optional(),
1544
- granularity: z7.enum(["TOTAL", "DAILY"]).optional(),
1545
- includeBreakdowns: z7.boolean().optional(),
1546
- playLinkId: z7.string().uuid()
1765
+ granularity: z9.enum(["TOTAL", "DAILY"]).optional(),
1766
+ includeBreakdowns: z9.boolean().optional(),
1767
+ playLinkId: z9.string().uuid()
1547
1768
  }).strict();
1548
- var DynamoiGetSmartLinkArtistSettingsInputSchema = z7.object({
1549
- artistId: z7.string().uuid(),
1769
+ var DynamoiGetSmartLinkArtistSettingsInputSchema = z9.object({
1770
+ artistId: z9.string().uuid(),
1550
1771
  format: ToolFormatSchema.optional()
1551
1772
  }).strict();
1552
- var DynamoiUpdateSmartLinkInputSchema = z7.object({
1553
- action: z7.enum(["update_description", "update_artist_settings"]),
1554
- artistId: z7.string().uuid().optional(),
1773
+ var DynamoiUpdateSmartLinkInputSchema = z9.object({
1774
+ action: z9.enum(["update_description", "update_artist_settings"]),
1775
+ artistId: z9.string().uuid().optional(),
1555
1776
  clientRequestId: ClientRequestIdSchema,
1556
- customDescription: z7.string().max(500).nullable().optional(),
1557
- expectedUpdatedAt: z7.string().datetime().optional(),
1558
- googleAdsConversionId: z7.string().trim().max(32).nullable().optional(),
1559
- metaPixelId: z7.string().trim().max(32).nullable().optional(),
1560
- playLinkId: z7.string().uuid().optional(),
1777
+ customDescription: z9.string().max(500).nullable().optional(),
1778
+ expectedUpdatedAt: z9.string().datetime().optional(),
1779
+ googleAdsConversionId: z9.string().trim().max(32).nullable().optional(),
1780
+ metaPixelId: z9.string().trim().max(32).nullable().optional(),
1781
+ playLinkId: z9.string().uuid().optional(),
1561
1782
  theme: SmartLinkThemeSchema.optional(),
1562
- tiktokPixelId: z7.string().trim().max(32).nullable().optional(),
1783
+ tiktokPixelId: z9.string().trim().max(32).nullable().optional(),
1563
1784
  userIntentSummary: UserIntentSummarySchema
1564
1785
  }).strict().superRefine((data, ctx) => {
1565
1786
  if (data.action === "update_description" && data.customDescription === undefined) {
@@ -1610,13 +1831,13 @@ var DynamoiUpdateSmartLinkInputSchema = z7.object({
1610
1831
  }
1611
1832
  }
1612
1833
  });
1613
- var DynamoiUpdateSmartLinkArtistSettingsInputSchema = z7.object({
1614
- artistId: z7.string().uuid(),
1834
+ var DynamoiUpdateSmartLinkArtistSettingsInputSchema = z9.object({
1835
+ artistId: z9.string().uuid(),
1615
1836
  clientRequestId: ClientRequestIdSchema,
1616
- googleAdsConversionId: z7.string().trim().max(32).nullable().optional(),
1617
- metaPixelId: z7.string().trim().max(32).nullable().optional(),
1837
+ googleAdsConversionId: z9.string().trim().max(32).nullable().optional(),
1838
+ metaPixelId: z9.string().trim().max(32).nullable().optional(),
1618
1839
  theme: SmartLinkThemeSchema.optional(),
1619
- tiktokPixelId: z7.string().trim().max(32).nullable().optional(),
1840
+ tiktokPixelId: z9.string().trim().max(32).nullable().optional(),
1620
1841
  userIntentSummary: UserIntentSummarySchema
1621
1842
  }).strict().superRefine((data, ctx) => {
1622
1843
  if (data.theme === undefined && data.metaPixelId === undefined && data.tiktokPixelId === undefined && data.googleAdsConversionId === undefined) {
@@ -1641,7 +1862,7 @@ var PHASE_4_TOOL_DEFINITIONS = [
1641
1862
  },
1642
1863
  {
1643
1864
  description: "Use this when the user gives a Spotify artist URL and wants Dynamoi to create, import, or refresh free Smart Links for the artist catalog and return the artist hub. If the signed-in user has no Dynamoi artist yet, omit artistId so Dynamoi can create the first artist from the Spotify artist profile. This starts the background catalog import so the user does not need to open the dashboard. Smart Links are free to create and manage. High-popularity or unverifiable artist catalog links may stay unpublished in verification hold until Dynamoi can verify the client relationship. This does not create a paid ad campaign. In the final answer, lead with the artist hub URL and current public Smart Link URLs; do not expose internal IDs unless asked.",
1644
- destructiveHint: true,
1865
+ destructiveHint: false,
1645
1866
  idempotentHint: true,
1646
1867
  name: "dynamoi_create_smart_links_from_spotify_artist",
1647
1868
  openWorldHint: true,
@@ -1684,7 +1905,7 @@ var PHASE_4_TOOL_DEFINITIONS = [
1684
1905
  ];
1685
1906
 
1686
1907
  // src/server/tools.ts
1687
- import * as z9 from "zod/v4";
1908
+ import * as z11 from "zod/v4";
1688
1909
 
1689
1910
  // src/server/onboarding-tool-definitions.ts
1690
1911
  function createPhaseOnboardingToolDefinitions(schemas) {
@@ -1715,12 +1936,12 @@ function createPhaseOnboardingToolDefinitions(schemas) {
1715
1936
  }
1716
1937
 
1717
1938
  // src/server/openai-tools.ts
1718
- import * as z8 from "zod/v4";
1719
- var DynamoiOpenAiSearchInputSchema = z8.object({
1720
- query: z8.string().trim().min(1).max(500)
1939
+ import * as z10 from "zod/v4";
1940
+ var DynamoiOpenAiSearchInputSchema = z10.object({
1941
+ query: z10.string().trim().min(1).max(500)
1721
1942
  }).strict();
1722
- var DynamoiOpenAiFetchInputSchema = z8.object({
1723
- id: z8.string().trim().min(1).max(200)
1943
+ var DynamoiOpenAiFetchInputSchema = z10.object({
1944
+ id: z10.string().trim().min(1).max(200)
1724
1945
  }).strict();
1725
1946
  var OPENAI_TOOL_DEFINITIONS = [
1726
1947
  {
@@ -1748,8 +1969,8 @@ var OPENAI_TOOL_DEFINITIONS = [
1748
1969
  // src/server/tools.ts
1749
1970
  var DateRangeSchema2 = DateRangeSchema;
1750
1971
  var ToolFormatSchema2 = ToolFormatSchema;
1751
- var OnboardingAttemptIdSchema = z9.string().trim().min(1).max(120).optional();
1752
- var ExpectedCampaignStatusEnum = z9.enum([
1972
+ var OnboardingAttemptIdSchema = z11.string().trim().min(1).max(120).optional();
1973
+ var ExpectedCampaignStatusEnum = z11.enum([
1753
1974
  "AWAITING_SMART_LINK",
1754
1975
  "ACTIVE",
1755
1976
  "ARCHIVED",
@@ -1765,20 +1986,20 @@ var ExpectedCampaignStatusSchema = ExpectedCampaignStatusEnum.optional();
1765
1986
  var CampaignStatusFilterSchema = ExpectedCampaignStatusEnum.exclude([
1766
1987
  "ENDED"
1767
1988
  ]).optional();
1768
- var DynamoiListArtistsInputSchema = z9.object({
1769
- artistId: z9.string().uuid().optional(),
1770
- cursor: z9.string().optional(),
1989
+ var DynamoiListArtistsInputSchema = z11.object({
1990
+ artistId: z11.string().uuid().optional(),
1991
+ cursor: z11.string().optional(),
1771
1992
  format: ToolFormatSchema2.optional(),
1772
- limit: z9.number().int().min(1).max(50).optional()
1993
+ limit: z11.number().int().min(1).max(50).optional()
1773
1994
  }).strict();
1774
- var DynamoiSearchInputSchema = z9.object({
1775
- artistId: z9.string().uuid().optional(),
1776
- cursor: z9.string().optional(),
1995
+ var DynamoiSearchInputSchema = z11.object({
1996
+ artistId: z11.string().uuid().optional(),
1997
+ cursor: z11.string().optional(),
1777
1998
  format: ToolFormatSchema2.optional(),
1778
- includeArchived: z9.boolean().optional(),
1779
- limit: z9.number().int().min(1).max(50).optional(),
1780
- query: z9.string().trim().max(120).optional(),
1781
- type: z9.enum(["artist", "campaign", "smartlink"]).optional()
1999
+ includeArchived: z11.boolean().optional(),
2000
+ limit: z11.number().int().min(1).max(50).optional(),
2001
+ query: z11.string().trim().max(120).optional(),
2002
+ type: z11.enum(["artist", "campaign", "smartlink"]).optional()
1782
2003
  }).strict().superRefine((data, ctx) => {
1783
2004
  if (!(data.type || data.query)) {
1784
2005
  ctx.addIssue({
@@ -1788,125 +2009,136 @@ var DynamoiSearchInputSchema = z9.object({
1788
2009
  });
1789
2010
  }
1790
2011
  });
1791
- var DynamoiGetCurrentUserIntentSchema = z9.enum([
2012
+ var DynamoiGetCurrentUserIntentSchema = z11.enum([
1792
2013
  "account_overview",
1793
2014
  "artist_access_check",
1794
2015
  "organization_access_check",
1795
2016
  "platform_connection_check"
1796
2017
  ]);
1797
- var DynamoiGetCurrentUserInputSchema = z9.object({
2018
+ var DynamoiGetCurrentUserInputSchema = z11.object({
1798
2019
  format: ToolFormatSchema2.optional(),
1799
- intent: DynamoiGetCurrentUserIntentSchema
2020
+ intent: DynamoiGetCurrentUserIntentSchema.default("account_overview")
1800
2021
  }).strict();
1801
- var DynamoiGetArtistInputSchema = z9.object({
1802
- artistId: z9.string().uuid(),
2022
+ var DynamoiGetArtistInputSchema = z11.object({
2023
+ artistId: z11.string().uuid(),
1803
2024
  format: ToolFormatSchema2.optional()
1804
2025
  }).strict();
1805
- var DynamoiListCampaignsInputSchema = z9.object({
1806
- artistId: z9.string().uuid(),
1807
- campaignType: z9.enum(["SMART_CAMPAIGN", "YOUTUBE"]).optional(),
1808
- cursor: z9.string().optional(),
2026
+ var DynamoiListCampaignsInputSchema = z11.object({
2027
+ artistId: z11.string().uuid(),
2028
+ campaignType: z11.enum(["SMART_CAMPAIGN", "YOUTUBE"]).optional(),
2029
+ cursor: z11.string().optional(),
1809
2030
  format: ToolFormatSchema2.optional(),
1810
- limit: z9.number().int().min(1).max(50).optional(),
2031
+ limit: z11.number().int().min(1).max(50).optional(),
1811
2032
  status: CampaignStatusFilterSchema
1812
2033
  }).strict();
1813
- var DynamoiGetCampaignInputSchema = z9.object({
2034
+ var DynamoiGetCampaignInputSchema = z11.object({
1814
2035
  analyticsDateRange: DateRangeSchema2.optional(),
1815
- analyticsGranularity: z9.enum(["TOTAL", "DAILY"]).optional(),
1816
- campaignId: z9.string().uuid(),
2036
+ analyticsGranularity: z11.enum(["TOTAL", "DAILY"]).optional(),
2037
+ campaignId: z11.string().uuid(),
1817
2038
  format: ToolFormatSchema2.optional(),
1818
- includeAnalytics: z9.boolean().optional(),
1819
- includeCountries: z9.boolean().optional(),
1820
- includeDeploymentStatus: z9.boolean().optional()
2039
+ includeAnalytics: z11.boolean().optional(),
2040
+ includeCountries: z11.boolean().optional(),
2041
+ includeDeploymentStatus: z11.boolean().optional()
1821
2042
  }).strict();
1822
- var DynamoiGetCampaignAnalyticsInputSchema = z9.object({
1823
- campaignId: z9.string().uuid(),
2043
+ var DynamoiGetCampaignAnalyticsInputSchema = z11.object({
2044
+ campaignId: z11.string().uuid(),
1824
2045
  dateRange: DateRangeSchema2.optional(),
1825
2046
  format: ToolFormatSchema2.optional(),
1826
- granularity: z9.enum(["TOTAL", "DAILY"]).optional()
2047
+ granularity: z11.enum(["TOTAL", "DAILY"]).optional()
1827
2048
  }).strict();
1828
- var DynamoiGetArtistAnalyticsInputSchema = z9.object({
1829
- artistId: z9.string().uuid(),
2049
+ var DynamoiGetArtistAnalyticsInputSchema = z11.object({
2050
+ artistId: z11.string().uuid(),
1830
2051
  dateRange: DateRangeSchema2.optional(),
1831
2052
  format: ToolFormatSchema2.optional(),
1832
- granularity: z9.enum(["TOTAL", "DAILY"]).optional()
2053
+ granularity: z11.enum(["TOTAL", "DAILY"]).optional()
1833
2054
  }).strict();
1834
- var DynamoiGetBillingInputSchema = z9.object({
1835
- artistId: z9.string().uuid(),
2055
+ var DynamoiGetBillingInputSchema = z11.object({
2056
+ artistId: z11.string().uuid(),
1836
2057
  format: ToolFormatSchema2.optional(),
1837
2058
  onboardingAttemptId: OnboardingAttemptIdSchema
1838
2059
  }).strict();
1839
- var LocationTargetSchema = z9.object({
1840
- code: z9.string().trim().min(1).max(8),
1841
- name: z9.string().trim().min(1).max(120)
2060
+ var LocationTargetSchema = z11.object({
2061
+ code: z11.string().trim().min(1).max(8),
2062
+ name: z11.string().trim().min(1).max(120)
1842
2063
  }).strict();
1843
- var DynamoiGetPlatformStatusInputSchema = z9.object({
1844
- artistId: z9.string().uuid(),
2064
+ var DynamoiGetPlatformStatusInputSchema = z11.object({
2065
+ artistId: z11.string().uuid(),
1845
2066
  format: ToolFormatSchema2.optional(),
1846
2067
  onboardingAttemptId: OnboardingAttemptIdSchema,
1847
- onboardingFlow: z9.enum(["meta", "youtube"]).optional()
2068
+ onboardingFlow: z11.enum(["meta", "youtube"]).optional()
1848
2069
  }).strict();
1849
- var DynamoiStartYoutubeChannelLinkInputSchema = z9.object({
1850
- artistId: z9.string().uuid(),
2070
+ var DynamoiStartYoutubeChannelLinkInputSchema = z11.object({
2071
+ artistId: z11.string().uuid(),
1851
2072
  format: ToolFormatSchema2.optional(),
1852
- purpose: z9.enum(["advertising", "distribution_identity"]).optional(),
2073
+ purpose: z11.enum(["advertising", "distribution_identity"]).optional(),
1853
2074
  userIntentSummary: UserIntentSummarySchema
1854
2075
  }).strict();
1855
- var DynamoiStartMetaConnectionInputSchema = z9.object({
1856
- artistId: z9.string().uuid(),
2076
+ var DynamoiStartMetaConnectionInputSchema = z11.object({
2077
+ artistId: z11.string().uuid(),
1857
2078
  format: ToolFormatSchema2.optional(),
1858
- purpose: z9.enum(["advertising", "distribution_identity"]).optional(),
2079
+ purpose: z11.enum(["advertising", "distribution_identity"]).optional(),
1859
2080
  userIntentSummary: UserIntentSummarySchema
1860
2081
  }).strict();
1861
- var DynamoiListAvailableCountriesInputSchema = z9.object({
1862
- campaignType: z9.enum(["SMART_CAMPAIGN", "YOUTUBE"]),
1863
- cursor: z9.string().optional(),
2082
+ var DynamoiListAvailableCountriesInputSchema = z11.object({
2083
+ campaignType: z11.enum(["SMART_CAMPAIGN", "YOUTUBE"]),
2084
+ cursor: z11.string().optional(),
1864
2085
  format: ToolFormatSchema2.optional(),
1865
- limit: z9.number().int().min(1).max(100).optional(),
1866
- query: z9.string().trim().max(120).optional()
2086
+ limit: z11.number().int().min(1).max(100).optional(),
2087
+ query: z11.string().trim().max(120).optional()
1867
2088
  }).strict();
1868
- var DynamoiGetOnboardingStatusInputSchema = z9.object({
1869
- artistId: z9.string().uuid(),
2089
+ var DynamoiGetOnboardingStatusInputSchema = z11.object({
2090
+ artistId: z11.string().uuid(),
1870
2091
  format: ToolFormatSchema2.optional()
1871
2092
  }).strict();
1872
- var DynamoiGetCampaignReadinessInputSchema = z9.object({
1873
- artistId: z9.string().uuid(),
1874
- budgetAmount: z9.number().finite().positive().optional(),
1875
- budgetType: z9.enum(["DAILY", "TOTAL"]).optional(),
1876
- campaignType: z9.enum(["SMART_CAMPAIGN", "YOUTUBE"]),
1877
- contentType: z9.enum(["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]).optional(),
2093
+ var DynamoiGetCampaignReadinessInputSchema = z11.object({
2094
+ artistId: z11.string().uuid(),
2095
+ budgetAmount: z11.number().finite().positive().optional(),
2096
+ budgetType: z11.enum(["DAILY", "TOTAL"]).optional(),
2097
+ campaignType: z11.enum(["SMART_CAMPAIGN", "YOUTUBE"]),
2098
+ contentType: z11.enum(["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]).optional(),
1878
2099
  endDate: IsoCalendarDateSchema.optional(),
1879
2100
  format: ToolFormatSchema2.optional(),
1880
- locationTargets: z9.array(LocationTargetSchema).optional(),
1881
- mediaAssetIds: z9.array(z9.string().uuid()).optional(),
1882
- spotifyUrl: z9.string().trim().min(1).max(500).optional(),
1883
- youtubeVideoId: z9.string().trim().min(1).max(128).optional()
2101
+ locationTargets: z11.array(LocationTargetSchema).optional(),
2102
+ mediaAssetIds: z11.array(z11.string().uuid()).optional(),
2103
+ spotifyUrl: z11.string().trim().min(1).max(500).optional(),
2104
+ youtubeVideoId: z11.string().trim().min(1).max(128).optional()
1884
2105
  }).strict();
1885
- var DynamoiGetCampaignDeploymentStatusInputSchema = z9.object({
1886
- campaignId: z9.string().uuid(),
2106
+ var DynamoiGetCampaignDeploymentStatusInputSchema = z11.object({
2107
+ campaignId: z11.string().uuid(),
1887
2108
  format: ToolFormatSchema2.optional()
1888
2109
  }).strict();
1889
- var DynamoiPauseCampaignInputSchema = z9.object({
1890
- campaignId: z9.string().uuid(),
2110
+ var DynamoiPauseCampaignInputSchema = z11.object({
2111
+ campaignId: z11.string().uuid(),
1891
2112
  clientRequestId: ClientRequestIdSchema,
1892
2113
  expectedCurrentStatus: ExpectedCampaignStatusSchema,
1893
2114
  userIntentSummary: UserIntentSummarySchema
1894
2115
  }).strict();
1895
- var DynamoiResumeCampaignInputSchema = z9.object({
1896
- campaignId: z9.string().uuid(),
2116
+ var DynamoiResumeCampaignInputSchema = z11.object({
2117
+ acceptedConsentCopyHash: z11.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH2).optional(),
2118
+ acceptedConsentVersion: z11.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION2).optional(),
2119
+ authorizeAutomaticDailyFunding: z11.literal(true).optional(),
2120
+ campaignId: z11.string().uuid(),
1897
2121
  clientRequestId: ClientRequestIdSchema,
1898
2122
  expectedCurrentStatus: ExpectedCampaignStatusSchema,
1899
2123
  userIntentSummary: UserIntentSummarySchema
1900
- }).strict();
1901
- var DynamoiUpdateBudgetInputSchema = z9.object({
1902
- acceptedConsentCopyHash: z9.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH).optional(),
1903
- acceptedConsentVersion: z9.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION).optional(),
1904
- authorizeAutomaticDailyFunding: z9.literal(true).describe(`Set only after the client explicitly accepts: “${PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY}”`).optional(),
1905
- budgetAmount: z9.number().finite().positive(),
1906
- campaignId: z9.string().uuid(),
2124
+ }).strict().superRefine((data, ctx) => {
2125
+ if (data.authorizeAutomaticDailyFunding && !(data.acceptedConsentCopyHash && data.acceptedConsentVersion && data.clientRequestId)) {
2126
+ ctx.addIssue({
2127
+ code: "custom",
2128
+ message: "acceptedConsentCopyHash, acceptedConsentVersion, and clientRequestId are required with automatic daily funding authorization",
2129
+ path: ["authorizeAutomaticDailyFunding"]
2130
+ });
2131
+ }
2132
+ });
2133
+ var DynamoiUpdateBudgetInputSchema = z11.object({
2134
+ acceptedConsentCopyHash: z11.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH2).optional(),
2135
+ acceptedConsentVersion: z11.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION2).optional(),
2136
+ authorizeAutomaticDailyFunding: z11.literal(true).describe(`Set only after the client explicitly accepts: “${PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY2}”`).optional(),
2137
+ budgetAmount: z11.number().finite().positive(),
2138
+ campaignId: z11.string().uuid(),
1907
2139
  clientRequestId: ClientRequestIdSchema,
1908
2140
  endDate: IsoCalendarDateSchema.optional(),
1909
- expectedCurrentBudgetAmount: z9.number().finite().positive().optional(),
2141
+ expectedCurrentBudgetAmount: z11.number().finite().positive().optional(),
1910
2142
  expectedCurrentEndDate: IsoCalendarDateSchema.optional(),
1911
2143
  userIntentSummary: UserIntentSummarySchema
1912
2144
  }).strict().superRefine((data, ctx) => {
@@ -1918,16 +2150,16 @@ var DynamoiUpdateBudgetInputSchema = z9.object({
1918
2150
  });
1919
2151
  }
1920
2152
  });
1921
- var DynamoiUpdateCampaignInputSchema = z9.object({
1922
- action: z9.enum(["pause", "resume", "update_budget"]),
1923
- acceptedConsentCopyHash: z9.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH).optional(),
1924
- acceptedConsentVersion: z9.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION).optional(),
1925
- authorizeAutomaticDailyFunding: z9.literal(true).describe(`Set only after the client explicitly accepts: “${PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY}”`).optional(),
1926
- budgetAmount: z9.number().finite().positive().optional(),
1927
- campaignId: z9.string().uuid(),
2153
+ var DynamoiUpdateCampaignInputSchema = z11.object({
2154
+ acceptedConsentCopyHash: z11.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH2).optional(),
2155
+ acceptedConsentVersion: z11.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION2).optional(),
2156
+ action: z11.enum(["pause", "resume", "update_budget"]),
2157
+ authorizeAutomaticDailyFunding: z11.literal(true).describe(`Set only after the client explicitly accepts: “${PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY2}”`).optional(),
2158
+ budgetAmount: z11.number().finite().positive().optional(),
2159
+ campaignId: z11.string().uuid(),
1928
2160
  clientRequestId: ClientRequestIdSchema,
1929
2161
  endDate: IsoCalendarDateSchema.optional(),
1930
- expectedCurrentBudgetAmount: z9.number().finite().positive().optional(),
2162
+ expectedCurrentBudgetAmount: z11.number().finite().positive().optional(),
1931
2163
  expectedCurrentEndDate: IsoCalendarDateSchema.optional(),
1932
2164
  expectedCurrentStatus: ExpectedCampaignStatusSchema,
1933
2165
  userIntentSummary: UserIntentSummarySchema
@@ -1941,10 +2173,7 @@ var DynamoiUpdateCampaignInputSchema = z9.object({
1941
2173
  }
1942
2174
  if (data.action !== "update_budget") {
1943
2175
  for (const field of [
1944
- "acceptedConsentCopyHash",
1945
- "acceptedConsentVersion",
1946
2176
  "budgetAmount",
1947
- "authorizeAutomaticDailyFunding",
1948
2177
  "endDate",
1949
2178
  "expectedCurrentBudgetAmount",
1950
2179
  "expectedCurrentEndDate"
@@ -1958,6 +2187,21 @@ var DynamoiUpdateCampaignInputSchema = z9.object({
1958
2187
  }
1959
2188
  }
1960
2189
  }
2190
+ if (data.action === "pause") {
2191
+ for (const field of [
2192
+ "acceptedConsentCopyHash",
2193
+ "acceptedConsentVersion",
2194
+ "authorizeAutomaticDailyFunding"
2195
+ ]) {
2196
+ if (data[field] !== undefined) {
2197
+ ctx.addIssue({
2198
+ code: "custom",
2199
+ message: `${field} is only valid when action is update_budget or resume`,
2200
+ path: [field]
2201
+ });
2202
+ }
2203
+ }
2204
+ }
1961
2205
  if (data.authorizeAutomaticDailyFunding && !(data.acceptedConsentCopyHash && data.acceptedConsentVersion && data.clientRequestId)) {
1962
2206
  ctx.addIssue({
1963
2207
  code: "custom",
@@ -1966,32 +2210,50 @@ var DynamoiUpdateCampaignInputSchema = z9.object({
1966
2210
  });
1967
2211
  }
1968
2212
  });
1969
- var DynamoiListMediaAssetsInputSchema = z9.object({
1970
- artistId: z9.string().uuid(),
1971
- cursor: z9.string().optional(),
2213
+ var DynamoiListMediaAssetsInputSchema = z11.object({
2214
+ artistId: z11.string().uuid(),
2215
+ cursor: z11.string().optional(),
1972
2216
  format: ToolFormatSchema2.optional(),
1973
- includeUrls: z9.boolean().optional(),
1974
- limit: z9.number().int().min(1).max(50).optional()
2217
+ includeUrls: z11.boolean().optional(),
2218
+ limit: z11.number().int().min(1).max(50).optional()
1975
2219
  }).strict();
1976
- var DynamoiLaunchCampaignInputSchema = z9.object({
1977
- adCopy: z9.string().trim().max(500).optional(),
1978
- appleMusicUrl: z9.string().trim().min(1).max(500).optional(),
1979
- artistId: z9.string().uuid(),
1980
- budgetAmount: z9.number().finite().positive(),
1981
- budgetSplits: z9.record(z9.enum(["META", "GOOGLE"]), z9.number().int().min(0).max(100)),
1982
- budgetType: z9.enum(["DAILY", "TOTAL"]),
1983
- campaignType: z9.enum(["SMART_CAMPAIGN", "YOUTUBE"]),
1984
- clientRequestId: z9.string().uuid(),
1985
- contentTitle: z9.string().trim().min(1).max(160),
1986
- contentType: z9.enum(["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]),
2220
+ var DynamoiLaunchCampaignInputSchema = z11.object({
2221
+ acceptedConsentCopyHash: z11.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH2).optional(),
2222
+ acceptedConsentVersion: z11.literal(PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION2).optional(),
2223
+ adCopy: z11.string().trim().max(500).optional(),
2224
+ appleMusicUrl: z11.string().trim().min(1).max(500).optional(),
2225
+ artistId: z11.string().uuid(),
2226
+ authorizeAutomaticDailyFunding: z11.literal(true).describe(`Required for DAILY budgets. Set only after the client explicitly accepts: “${PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY2}”`).optional(),
2227
+ budgetAmount: z11.number().finite().positive(),
2228
+ budgetSplits: z11.record(z11.enum(["META", "GOOGLE"]), z11.number().int().min(0).max(100)),
2229
+ budgetType: z11.enum(["DAILY", "TOTAL"]),
2230
+ campaignType: z11.enum(["SMART_CAMPAIGN", "YOUTUBE"]),
2231
+ clientRequestId: z11.string().uuid(),
2232
+ contentTitle: z11.string().trim().min(1).max(160),
2233
+ contentType: z11.enum(["TRACK", "ALBUM", "PLAYLIST", "VIDEO"]),
1987
2234
  endDate: IsoCalendarDateSchema.optional(),
1988
- locationTargets: z9.array(LocationTargetSchema).optional(),
1989
- mediaAssetIds: z9.array(z9.string().uuid()).optional(),
1990
- spotifyUrl: z9.string().trim().min(1).max(500).optional(),
1991
- useAiGeneratedCopy: z9.boolean().optional(),
2235
+ locationTargets: z11.array(LocationTargetSchema).optional(),
2236
+ mediaAssetIds: z11.array(z11.string().uuid()).optional(),
2237
+ spotifyUrl: z11.string().trim().min(1).max(500).optional(),
2238
+ useAiGeneratedCopy: z11.boolean().optional(),
1992
2239
  userIntentSummary: UserIntentSummarySchema,
1993
- youtubeVideoId: z9.string().trim().min(1).max(128).optional()
2240
+ youtubePlaylistId: z11.string().trim().min(1).max(128).optional(),
2241
+ youtubeStrategy: z11.enum([
2242
+ "CHEAPEST_VIEWS",
2243
+ "ORGANIC_VIEWS",
2244
+ "SUBSCRIBERS",
2245
+ "ORGANIC_VIEWS_AND_SUBSCRIBERS",
2246
+ "ADSENSE_ROI"
2247
+ ]).optional(),
2248
+ youtubeVideoId: z11.string().trim().min(1).max(128).optional()
1994
2249
  }).strict().superRefine((data, ctx) => {
2250
+ if (data.budgetType === "DAILY" && !(data.authorizeAutomaticDailyFunding && data.acceptedConsentCopyHash && data.acceptedConsentVersion)) {
2251
+ ctx.addIssue({
2252
+ code: "custom",
2253
+ message: "DAILY budgets require authorizeAutomaticDailyFunding with acceptedConsentCopyHash and acceptedConsentVersion",
2254
+ path: ["authorizeAutomaticDailyFunding"]
2255
+ });
2256
+ }
1995
2257
  const sum = Object.values(data.budgetSplits ?? {}).reduce((acc, v) => acc + (Number.isFinite(v) ? v : 0), 0);
1996
2258
  if (!(sum > 0)) {
1997
2259
  ctx.addIssue({
@@ -2038,6 +2300,20 @@ var DynamoiLaunchCampaignInputSchema = z9.object({
2038
2300
  path: ["youtubeVideoId"]
2039
2301
  });
2040
2302
  }
2303
+ if (!data.youtubeStrategy) {
2304
+ ctx.addIssue({
2305
+ code: "custom",
2306
+ message: "youtubeStrategy is required for YOUTUBE",
2307
+ path: ["youtubeStrategy"]
2308
+ });
2309
+ }
2310
+ if (data.youtubeStrategy && data.youtubeStrategy !== "CHEAPEST_VIEWS" && !data.youtubePlaylistId) {
2311
+ ctx.addIssue({
2312
+ code: "custom",
2313
+ message: "youtubePlaylistId is required for YOUTUBE unless youtubeStrategy is CHEAPEST_VIEWS",
2314
+ path: ["youtubePlaylistId"]
2315
+ });
2316
+ }
2041
2317
  if (data.contentType !== "VIDEO") {
2042
2318
  ctx.addIssue({
2043
2319
  code: "custom",
@@ -2063,7 +2339,7 @@ var DynamoiLaunchCampaignInputSchema = z9.object({
2063
2339
  });
2064
2340
  var PHASE_1_TOOL_DEFINITIONS = [
2065
2341
  {
2066
- description: "Use this when the user explicitly asks about the signed-in Dynamoi account itself, such as who is logged in, how many organizations or artists it can access, or whether account-level platform connections exist. Always pass intent to match that explicit account question. Do not use this to confirm a specific Meta or YouTube onboarding attempt because this account-level state can span multiple artists; use dynamoi_get_platform_status for the target artist instead. Do not use this to enumerate artists one by one; use dynamoi_list_artists for that. Never use this to 'check context' before answering generic Instagram, lyrics, songwriting, or marketing-advice questions, even if Dynamoi is attached.",
2342
+ description: "Use this when the user explicitly asks about the signed-in Dynamoi account itself, such as who is logged in, how many organizations or artists it can access, or whether account-level platform connections exist. Pass intent to match that explicit account question; it defaults to account_overview. Do not use this to confirm a specific Meta or YouTube onboarding attempt because this account-level state can span multiple artists; use dynamoi_get_platform_status for the target artist instead. Do not use this to enumerate artists one by one; use dynamoi_list_artists for that. Never use this to 'check context' before answering generic Instagram, lyrics, songwriting, or marketing-advice questions, even if Dynamoi is attached.",
2067
2343
  destructiveHint: false,
2068
2344
  name: "dynamoi_get_account_overview",
2069
2345
  openWorldHint: false,
@@ -2124,7 +2400,7 @@ var PHASE_1_TOOL_DEFINITIONS = [
2124
2400
  title: "Get Artist Analytics"
2125
2401
  },
2126
2402
  {
2127
- description: "Use this when the user asks about billing state, credit balance, promo limits, subscription status, or whether billing blocks launches for one artist. This is a read-only status check; it does not create checkout links or collect payment. If billing blocks a launch, direct the user to start or restore managed advertising in the Dynamoi dashboard, then call this tool again to confirm the status. Do not use this for campaign analytics or platform connection troubleshooting.",
2403
+ description: "Use this when the user asks about billing state, credit balance, promo limits, subscription status, or whether billing blocks launches for one artist. This is a read-only status check; it does not create checkout links or collect payment. If billing blocks a launch, starting or restoring managed advertising is not available through this MCP surface; tell the user: 'You can do this in the Dynamoi dashboard at https://dynamoi.com/dashboard.' Then call this tool again to confirm the status. Do not use this for campaign analytics or platform connection troubleshooting.",
2128
2404
  destructiveHint: false,
2129
2405
  name: "dynamoi_get_billing",
2130
2406
  openWorldHint: false,
@@ -2170,7 +2446,7 @@ var PHASE_ONBOARDING_TOOL_DEFINITIONS = createPhaseOnboardingToolDefinitions({
2170
2446
  });
2171
2447
  var PHASE_2_TOOL_DEFINITIONS = [
2172
2448
  {
2173
- description: "Use this when the user explicitly wants to pause, resume, or update the budget/end date for an existing campaign. Set action to pause, resume, or update_budget. Do not use this for inspection-only questions; this changes live campaign workflow state or external campaign settings.",
2449
+ description: `Use this when the user explicitly wants to pause, resume, or update the budget/end date for an existing campaign. Set action to pause, resume, or update_budget. Pause takes effect immediately. For resume or update_budget on a campaign that needs automatic daily card funding, first show the user this exact consent copy: "${PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY2}" — then pass authorizeAutomaticDailyFunding=true with the exact acceptedConsentVersion ("${PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION2}") and acceptedConsentCopyHash ("${PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH2}") plus the request's clientRequestId. Without them, a resume that needs card funding is refused with: "Review and accept the daily funding authorization to resume this campaign." When retrying the same resume, reuse the same clientRequestId. Do not use this for inspection-only questions; this changes live campaign workflow state or external campaign settings.`,
2174
2450
  destructiveHint: true,
2175
2451
  idempotentHint: true,
2176
2452
  name: "dynamoi_update_campaign",
@@ -2195,7 +2471,7 @@ var PHASE_3_TOOL_DEFINITIONS = [
2195
2471
  title: "List Media Assets"
2196
2472
  },
2197
2473
  {
2198
- description: "Use this when the user explicitly wants to create a new Smart Campaign or YouTube Campaign and start the launch workflow with provided details. Ads are not necessarily live until the returned delivery state is ACTIVE. For review or demo Smart Campaign launches that already specify the artist, content title, budget, countries, and reusable media assets, you may omit spotifyUrl and endDate because Dynamoi can infer reviewer-safe defaults. Do not invent placeholder spotifyUrl or endDate values for those review/demo launches; omit them and let Dynamoi infer them. After a successful launch, answer from the returned campaign details directly instead of chaining more tools unless the user explicitly asked for more. Do not use this for recommendations or previews; this creates a real campaign workflow or demo-safe simulated campaign.",
2474
+ description: `Use this when the user explicitly wants to create a new Smart Campaign or YouTube Campaign and start the launch workflow with provided details. Ads are not necessarily live until the returned delivery state is ACTIVE. DAILY budgets require authorizeAutomaticDailyFunding=true plus the exact acceptedConsentVersion ("${PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION2}") and acceptedConsentCopyHash ("${PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH2}"); first show the user this exact consent copy: "${PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY2}". TOTAL budgets use existing credit and need no consent. YOUTUBE campaigns require youtubeVideoId and youtubeStrategy, plus youtubePlaylistId unless the strategy is CHEAPEST_VIEWS. After a successful launch, answer from the returned campaign details directly instead of chaining more tools unless the user explicitly asked for more.`,
2199
2475
  destructiveHint: true,
2200
2476
  idempotentHint: true,
2201
2477
  name: "dynamoi_launch_campaign",
@@ -2209,106 +2485,104 @@ var PHASE_3_TOOL_DEFINITIONS = [
2209
2485
 
2210
2486
  // src/server/create-server.ts
2211
2487
  function buildDynamoiToolSecuritySchemes(scopes) {
2212
- return [{ scopes: [...scopes], type: "oauth2" }];
2488
+ return scopes.length === 0 ? [{ type: "noauth" }] : [{ scopes: [...scopes], type: "oauth2" }];
2213
2489
  }
2214
- var DescriptiveEntitySchema = z10.object({
2215
- id: z10.string().optional(),
2216
- name: z10.string().optional(),
2217
- publicUrl: z10.string().optional(),
2218
- summary: z10.string().optional()
2490
+ var DescriptiveEntitySchema = z12.object({
2491
+ id: z12.string().optional(),
2492
+ name: z12.string().optional(),
2493
+ publicUrl: z12.string().optional(),
2494
+ summary: z12.string().optional()
2219
2495
  }).passthrough();
2220
- var CHATGPT_DESCRIPTIVE_DATA_SCHEMAS = {
2221
- dynamoi_get_account_overview: z10.object({
2222
- artistCount: z10.number().optional(),
2223
- artists: z10.object({
2224
- count: z10.number(),
2225
- summaries: z10.array(DescriptiveEntitySchema)
2496
+ var DIRECTORY_DESCRIPTIVE_DATA_SCHEMAS = {
2497
+ dynamoi_get_account_overview: z12.object({
2498
+ artistCount: z12.number().optional(),
2499
+ artists: z12.object({
2500
+ count: z12.number(),
2501
+ summaries: z12.array(DescriptiveEntitySchema)
2226
2502
  }).optional(),
2227
- organizationCount: z10.number().optional(),
2228
- recommendedNextActions: z10.array(z10.string()).optional(),
2229
- state: z10.object({}).passthrough().optional(),
2230
- summary: z10.string().optional(),
2231
- user: z10.object({ name: z10.string().optional() }).optional()
2503
+ organizationCount: z12.number().optional(),
2504
+ recommendedNextActions: z12.array(z12.string()).optional(),
2505
+ state: z12.object({}).passthrough().optional(),
2506
+ summary: z12.string().optional(),
2507
+ user: z12.object({ name: z12.string().optional() }).optional()
2232
2508
  }).passthrough(),
2233
- dynamoi_get_artist_analytics: z10.object({
2234
- artistId: z10.string().optional(),
2235
- artistName: z10.string().optional(),
2236
- dateRange: z10.object({ end: z10.string(), start: z10.string() }).optional(),
2237
- summary: z10.string().optional()
2509
+ dynamoi_get_artist_analytics: z12.object({
2510
+ artistId: z12.string().optional(),
2511
+ artistName: z12.string().optional(),
2512
+ dateRange: z12.object({ end: z12.string(), start: z12.string() }).optional(),
2513
+ summary: z12.string().optional()
2238
2514
  }).passthrough(),
2239
2515
  dynamoi_get_campaign: DescriptiveEntitySchema.extend({
2240
- artistId: z10.string().optional(),
2241
- contentTitle: z10.string().optional(),
2242
- nextActions: z10.array(z10.string()).optional(),
2243
- status: z10.string().optional()
2516
+ artistId: z12.string().optional(),
2517
+ contentTitle: z12.string().optional(),
2518
+ nextActions: z12.array(z12.string()).optional(),
2519
+ status: z12.string().optional()
2244
2520
  }).passthrough(),
2245
- dynamoi_get_platform_status: z10.object({
2246
- artistId: z10.string().optional(),
2247
- artistName: z10.string().optional(),
2248
- platforms: z10.object({}).passthrough().optional(),
2249
- summary: z10.string().optional()
2521
+ dynamoi_get_platform_status: z12.object({
2522
+ artistId: z12.string().optional(),
2523
+ artistName: z12.string().optional(),
2524
+ platforms: z12.object({}).passthrough().optional(),
2525
+ summary: z12.string().optional()
2250
2526
  }).passthrough(),
2251
2527
  dynamoi_get_smart_link: DescriptiveEntitySchema.extend({
2252
- artistId: z10.string().optional(),
2253
- artistName: z10.string().optional(),
2254
- nextActions: z10.array(z10.string()).optional(),
2255
- publishState: z10.string().optional(),
2256
- releaseTitle: z10.string().optional(),
2257
- theme: z10.string().optional()
2528
+ artistId: z12.string().optional(),
2529
+ artistName: z12.string().optional(),
2530
+ nextActions: z12.array(z12.string()).optional(),
2531
+ publishState: z12.string().optional(),
2532
+ releaseTitle: z12.string().optional(),
2533
+ theme: z12.string().optional()
2258
2534
  }).passthrough(),
2259
- dynamoi_list_artists: z10.object({
2260
- artists: z10.array(DescriptiveEntitySchema).optional(),
2261
- nextCursor: z10.string().optional(),
2262
- summary: z10.string().optional(),
2263
- totalCount: z10.number().optional()
2535
+ dynamoi_list_artists: z12.object({
2536
+ artists: z12.array(DescriptiveEntitySchema).optional(),
2537
+ nextCursor: z12.string().optional(),
2538
+ summary: z12.string().optional(),
2539
+ totalCount: z12.number().optional()
2264
2540
  }).passthrough(),
2265
- dynamoi_list_campaigns: z10.object({
2266
- campaigns: z10.array(DescriptiveEntitySchema).optional(),
2267
- nextCursor: z10.string().optional(),
2268
- summary: z10.string().optional(),
2269
- totalCount: z10.number().optional()
2541
+ dynamoi_list_campaigns: z12.object({
2542
+ campaigns: z12.array(DescriptiveEntitySchema).optional(),
2543
+ nextCursor: z12.string().optional(),
2544
+ summary: z12.string().optional(),
2545
+ totalCount: z12.number().optional()
2270
2546
  }).passthrough(),
2271
- dynamoi_preview_smart_link_themes: z10.object({
2272
- artistName: z10.string(),
2273
- releaseTitle: z10.string(),
2274
- themes: z10.array(DescriptiveEntitySchema)
2547
+ dynamoi_preview_smart_link_themes: z12.object({
2548
+ artistName: z12.string(),
2549
+ releaseTitle: z12.string(),
2550
+ themes: z12.array(DescriptiveEntitySchema)
2275
2551
  }).passthrough(),
2276
- dynamoi_search: z10.object({
2277
- nextCursor: z10.string().optional(),
2278
- results: z10.array(DescriptiveEntitySchema).optional(),
2279
- summary: z10.string().optional(),
2280
- totalCount: z10.number().optional()
2552
+ dynamoi_search: z12.object({
2553
+ nextCursor: z12.string().optional(),
2554
+ results: z12.array(DescriptiveEntitySchema).optional(),
2555
+ summary: z12.string().optional(),
2556
+ totalCount: z12.number().optional()
2281
2557
  }).passthrough(),
2282
2558
  dynamoi_update_smart_link: DescriptiveEntitySchema.extend({
2283
- artistId: z10.string().optional(),
2284
- artistName: z10.string().optional(),
2285
- defaultTheme: z10.string().optional(),
2286
- renderQueuedCount: z10.number().optional(),
2287
- renderWarning: z10.string().nullable().optional()
2559
+ artistId: z12.string().optional(),
2560
+ artistName: z12.string().optional(),
2561
+ defaultTheme: z12.string().optional(),
2562
+ renderQueuedCount: z12.number().optional(),
2563
+ renderWarning: z12.string().nullable().optional()
2288
2564
  }).passthrough(),
2289
2565
  fetch: DescriptiveEntitySchema,
2290
- search: z10.object({ results: z10.array(DescriptiveEntitySchema).optional() }).passthrough()
2566
+ search: z12.object({ results: z12.array(DescriptiveEntitySchema).optional() }).passthrough()
2291
2567
  };
2292
2568
  function getAdvertisedToolOutputSchema(options) {
2293
- if (options.toolProfile !== "chatgpt-app") {
2569
+ if (options.toolProfile !== "directory") {
2294
2570
  return options.canonical;
2295
2571
  }
2296
- const dataSchema = CHATGPT_DESCRIPTIVE_DATA_SCHEMAS[options.toolName];
2572
+ const dataSchema = DIRECTORY_DESCRIPTIVE_DATA_SCHEMAS[options.toolName];
2297
2573
  if (!dataSchema) {
2298
2574
  return options.canonical;
2299
2575
  }
2300
- return z10.object({
2576
+ return z12.object({
2301
2577
  data: dataSchema.optional(),
2302
- kind: z10.string().optional(),
2303
- message: z10.string().optional(),
2304
- status: z10.enum(["success", "partial_success", "error"])
2578
+ kind: z12.string().optional(),
2579
+ message: z12.string().optional(),
2580
+ ...ResultErrorRecoverySchema.shape,
2581
+ status: z12.enum(["success", "partial_success", "error"])
2305
2582
  }).passthrough();
2306
2583
  }
2307
2584
  function getDynamoiToolOAuthScopes(toolName, providerScopes) {
2308
- const requiredScopes = DYNAMOI_MCP_TOOL_SCOPES[toolName];
2309
- if (!providerScopes.some((scope) => scope.startsWith("dynamoi:"))) {
2310
- return providerScopes;
2311
- }
2585
+ const requiredScopes = DYNAMOI_MCP_TOOL_SCOPES2[toolName];
2312
2586
  const missingScopes = requiredScopes.filter((scope) => !providerScopes.includes(scope));
2313
2587
  if (missingScopes.length > 0) {
2314
2588
  throw new Error(`MCP provider does not support ${toolName} scopes: ${missingScopes.join(", ")}`);
@@ -2316,15 +2590,20 @@ function getDynamoiToolOAuthScopes(toolName, providerScopes) {
2316
2590
  return requiredScopes;
2317
2591
  }
2318
2592
  var DYNAMOI_TOOL_DEFINITIONS = [
2593
+ DYNAMOI_ABOUT_TOOL_DEFINITION,
2319
2594
  ...PHASE_1_TOOL_DEFINITIONS,
2320
2595
  ...PHASE_ONBOARDING_TOOL_DEFINITIONS,
2321
2596
  ...PHASE_2_TOOL_DEFINITIONS,
2322
2597
  ...PHASE_3_TOOL_DEFINITIONS,
2323
2598
  ...DISTRIBUTION_TOOL_DEFINITIONS,
2599
+ ...SHOP_TOOL_DEFINITIONS,
2324
2600
  SMART_LINK_THEME_PREVIEW_TOOL_DEFINITION,
2325
2601
  ...PHASE_4_TOOL_DEFINITIONS
2326
2602
  ];
2327
- var CHATGPT_APP_EXCLUDED_TOOL_NAMES = new Set([
2603
+ var MUTATING_TOOL_NAMES = new Set(DYNAMOI_TOOL_DEFINITIONS.filter((definition) => !definition.readOnlyHint).map((definition) => definition.name));
2604
+ var DIRECTORY_EXCLUDED_TOOL_NAMES = new Set([
2605
+ "dynamoi_shop_create_checkout",
2606
+ "dynamoi_shop_get_quote",
2328
2607
  "dynamoi_get_billing",
2329
2608
  "dynamoi_get_campaign_readiness",
2330
2609
  "dynamoi_launch_campaign",
@@ -2336,12 +2615,163 @@ var CHATGPT_APP_EXCLUDED_TOOL_NAMES = new Set([
2336
2615
  ]);
2337
2616
  function getDynamoiToolDefinitions(options) {
2338
2617
  const definitions = [...DYNAMOI_TOOL_DEFINITIONS];
2339
- if ((options?.toolProfile ?? "full") !== "chatgpt-app") {
2618
+ if (options?.toolProfile === "full") {
2340
2619
  return definitions;
2341
2620
  }
2342
- return definitions.filter((definition) => !CHATGPT_APP_EXCLUDED_TOOL_NAMES.has(definition.name));
2621
+ return definitions.filter((definition) => !DIRECTORY_EXCLUDED_TOOL_NAMES.has(definition.name));
2622
+ }
2623
+ var RECOVERY_METADATA_FIELDS = [
2624
+ "code",
2625
+ "field",
2626
+ "nextAction",
2627
+ "prerequisite",
2628
+ "retryable",
2629
+ "retryAfterSeconds"
2630
+ ];
2631
+ var SPOTIFY_SOURCE_ERROR_MESSAGES = new Set([
2632
+ "Paste a valid Spotify artist, album, or track URL.",
2633
+ "Paste a Spotify artist, album, or track URL.",
2634
+ "Open the Spotify artist profile, then copy the Spotify link.",
2635
+ "Spotify URL is missing a valid Spotify ID.",
2636
+ "Paste the public Spotify artist link, not the Spotify for Artists dashboard page.",
2637
+ "Spotify link did not resolve to a Spotify artist, album, or track URL.",
2638
+ "Spotify link redirected too many times.",
2639
+ "Spotify link could not be opened. Paste the full Spotify URL instead."
2640
+ ]);
2641
+ var SPOTIFY_ARTIST_CATALOG_ERROR_MESSAGES = new Set([
2642
+ "Use a Spotify artist URL for full-catalog Smart Link import. For album or track URLs, use dynamoi_create_smart_link_from_spotify."
2643
+ ]);
2644
+ var REVIEWER_WRITE_TOOL_NAMES = new Set([
2645
+ "dynamoi_apply_for_distribution",
2646
+ "dynamoi_create_smart_link_from_spotify",
2647
+ "dynamoi_create_smart_links_from_spotify_artist",
2648
+ "dynamoi_launch_campaign",
2649
+ "dynamoi_start_meta_connection",
2650
+ "dynamoi_start_youtube_channel_link",
2651
+ "dynamoi_update_campaign",
2652
+ "dynamoi_update_smart_link"
2653
+ ]);
2654
+ var SHOP_RATE_LIMIT_RETRY_AFTER_SECONDS = {
2655
+ checkout: 10 * 60,
2656
+ quote: 60
2657
+ };
2658
+ var SHOP_RATE_LIMIT_ERROR_PATTERNS = {
2659
+ checkout: /^Too many Shop checkout requests\. Try again in ([1-9]\d*) seconds\.$/,
2660
+ quote: /^Too many Shop quote requests\. Try again in ([1-9]\d*) seconds\.$/
2661
+ };
2662
+ function mapShopRateLimitRecovery(toolName, message) {
2663
+ const kind = toolName === "dynamoi_shop_get_quote" ? "quote" : toolName === "dynamoi_shop_create_checkout" ? "checkout" : undefined;
2664
+ if (!kind) {
2665
+ return;
2666
+ }
2667
+ const match = SHOP_RATE_LIMIT_ERROR_PATTERNS[kind].exec(message);
2668
+ if (!match || match[0] !== message) {
2669
+ return;
2670
+ }
2671
+ const retryAfterSeconds = Number(match[1]);
2672
+ if (!Number.isSafeInteger(retryAfterSeconds) || retryAfterSeconds < 1 || retryAfterSeconds > SHOP_RATE_LIMIT_RETRY_AFTER_SECONDS[kind]) {
2673
+ return;
2674
+ }
2675
+ return {
2676
+ code: "RATE_LIMITED",
2677
+ retryAfterSeconds,
2678
+ retryable: true
2679
+ };
2680
+ }
2681
+ function mapKnownErrorRecovery(toolName, kind, message) {
2682
+ if (kind === "unknown" && MUTATING_TOOL_NAMES.has(toolName)) {
2683
+ return {
2684
+ code: "UNKNOWN_EFFECT",
2685
+ nextAction: {
2686
+ kind: "read_status",
2687
+ reason: "Inspect the existing operation or resource identity before retrying."
2688
+ },
2689
+ prerequisite: "The existing operation or resource identity must be inspected before replaying.",
2690
+ retryable: false
2691
+ };
2692
+ }
2693
+ if (kind !== "business") {
2694
+ return;
2695
+ }
2696
+ const shopRateLimitRecovery = mapShopRateLimitRecovery(toolName, message);
2697
+ if (shopRateLimitRecovery) {
2698
+ return shopRateLimitRecovery;
2699
+ }
2700
+ if (REVIEWER_WRITE_TOOL_NAMES.has(toolName) && message === "Reviewer accounts are read-only in MCP.") {
2701
+ return {
2702
+ code: "ACCOUNT_READ_ONLY",
2703
+ nextAction: {
2704
+ kind: "handoff",
2705
+ reason: "Use an authorized non-reviewer account for this write."
2706
+ },
2707
+ prerequisite: "A non-reviewer account with write access is required.",
2708
+ retryable: false
2709
+ };
2710
+ }
2711
+ const isSingleReleaseSpotifyTool = toolName === "dynamoi_create_smart_link_from_spotify";
2712
+ const isArtistCatalogSpotifyTool = toolName === "dynamoi_create_smart_links_from_spotify_artist";
2713
+ if ((isSingleReleaseSpotifyTool || isArtistCatalogSpotifyTool) && (SPOTIFY_SOURCE_ERROR_MESSAGES.has(message) || isArtistCatalogSpotifyTool && SPOTIFY_ARTIST_CATALOG_ERROR_MESSAGES.has(message))) {
2714
+ const field = isArtistCatalogSpotifyTool ? "spotifyArtistUrl" : "spotifyUrl";
2715
+ const expectedInput = isArtistCatalogSpotifyTool ? "Provide a public Spotify artist URL." : "Provide a public Spotify artist, album, or track URL.";
2716
+ return {
2717
+ code: "INVALID_SPOTIFY_SOURCE",
2718
+ field,
2719
+ nextAction: {
2720
+ field,
2721
+ kind: "provide_input",
2722
+ reason: expectedInput
2723
+ },
2724
+ prerequisite: expectedInput,
2725
+ retryable: false
2726
+ };
2727
+ }
2728
+ if (toolName === "dynamoi_update_smart_link" && message === "Smart Link changed since it was last read. Read it again before updating.") {
2729
+ return {
2730
+ code: "STATE_CONFLICT",
2731
+ field: "expectedUpdatedAt",
2732
+ nextAction: {
2733
+ kind: "read_status",
2734
+ reason: "Read the existing Smart Link again, then resubmit only with its current state."
2735
+ },
2736
+ prerequisite: "Read the Smart Link before updating it.",
2737
+ retryable: false
2738
+ };
2739
+ }
2740
+ if (toolName === "dynamoi_shop_create_checkout" && message === "The Shop quote changed. Get a new quote before creating checkout.") {
2741
+ return {
2742
+ code: "QUOTE_CHANGED",
2743
+ field: "expectedTotal",
2744
+ nextAction: {
2745
+ field: "expectedTotal",
2746
+ kind: "provide_input",
2747
+ reason: "Get a fresh quote, ask the user to confirm its total, then submit with that total and the same requestId."
2748
+ },
2749
+ prerequisite: "Get a fresh Shop quote and obtain renewed user confirmation for its total before creating checkout.",
2750
+ retryable: false
2751
+ };
2752
+ }
2753
+ return;
2754
+ }
2755
+ function normalizeKnownErrorRecovery(envelope, toolName) {
2756
+ if (envelope === null || envelope === undefined || typeof envelope === "string" || typeof envelope === "number" || typeof envelope === "boolean") {
2757
+ return envelope;
2758
+ }
2759
+ if (typeof envelope !== "object" || Array.isArray(envelope)) {
2760
+ return typeof envelope === "object" ? envelope : null;
2761
+ }
2762
+ const record = envelope;
2763
+ if (record["status"] !== "error") {
2764
+ return record;
2765
+ }
2766
+ const message = record["message"];
2767
+ if (RECOVERY_METADATA_FIELDS.some((field) => record[field] !== undefined) || typeof message !== "string") {
2768
+ return record;
2769
+ }
2770
+ const recovery = mapKnownErrorRecovery(toolName, record["kind"], message);
2771
+ return recovery ? { ...record, ...recovery } : envelope;
2343
2772
  }
2344
2773
  var DYNAMOI_TOOL_DISPATCHERS = {
2774
+ dynamoi_about: (_adapter, _input, toolProfile) => Promise.resolve(getDynamoiAbout({ toolProfile })),
2345
2775
  dynamoi_apply_for_distribution: (adapter, input) => adapter.applyForDistribution(input),
2346
2776
  dynamoi_create_smart_link_from_spotify: (adapter, input) => adapter.createSmartLinkFromSpotify(input),
2347
2777
  dynamoi_create_smart_links_from_spotify_artist: (adapter, input) => adapter.createSmartLinksFromSpotifyArtist(input),
@@ -2361,6 +2791,8 @@ var DYNAMOI_TOOL_DISPATCHERS = {
2361
2791
  dynamoi_list_smart_links: (adapter, input) => adapter.listSmartLinks(input),
2362
2792
  dynamoi_preview_smart_link_themes: (_adapter, input) => Promise.resolve(previewSmartLinkThemes(input)),
2363
2793
  dynamoi_search: (adapter, input) => adapter.search(input),
2794
+ dynamoi_shop_create_checkout: (adapter, input) => adapter.shopCreateCheckout(input),
2795
+ dynamoi_shop_get_quote: (adapter, input) => adapter.shopGetQuote(input),
2364
2796
  dynamoi_start_meta_connection: (adapter, input) => adapter.startMetaConnection(input),
2365
2797
  dynamoi_start_youtube_channel_link: (adapter, input) => adapter.startYoutubeChannelLink(input),
2366
2798
  dynamoi_update_campaign: (adapter, input) => adapter.updateCampaign(input),
@@ -2368,6 +2800,43 @@ var DYNAMOI_TOOL_DISPATCHERS = {
2368
2800
  fetch: (adapter, input) => adapter.openAiFetch(input),
2369
2801
  search: (adapter, input) => adapter.openAiSearch(input)
2370
2802
  };
2803
+ function snapshotForObserver(value) {
2804
+ try {
2805
+ return structuredClone(value);
2806
+ } catch {
2807
+ if (value === null || typeof value !== "object" && typeof value !== "function") {
2808
+ return value;
2809
+ }
2810
+ try {
2811
+ if (value instanceof Error) {
2812
+ const snapshot = new Error("The thrown error could not be cloned for observation.");
2813
+ try {
2814
+ const name = value.name;
2815
+ if (typeof name === "string") {
2816
+ snapshot.name = name;
2817
+ }
2818
+ } catch {}
2819
+ try {
2820
+ const message = value.message;
2821
+ if (typeof message === "string") {
2822
+ snapshot.message = message;
2823
+ }
2824
+ } catch {}
2825
+ try {
2826
+ const stack = value.stack;
2827
+ if (typeof stack === "string") {
2828
+ snapshot.stack = stack;
2829
+ }
2830
+ } catch {}
2831
+ return snapshot;
2832
+ }
2833
+ } catch {}
2834
+ return {
2835
+ kind: "unknown",
2836
+ message: "The thrown value could not be cloned for observation."
2837
+ };
2838
+ }
2839
+ }
2371
2840
  function asTextResult(envelope) {
2372
2841
  const isToolError = Boolean(envelope) && typeof envelope === "object" && envelope.status === "error";
2373
2842
  const plainText = (() => {
@@ -2398,35 +2867,85 @@ function asTextResult(envelope) {
2398
2867
  return result;
2399
2868
  }
2400
2869
  function asValidatedTextResult(options) {
2401
- const parsed = options.outputSchema.safeParse(options.envelope);
2870
+ const envelope = normalizeKnownErrorRecovery(options.envelope, options.toolName);
2871
+ const parsed = options.outputSchema.safeParse(envelope);
2402
2872
  if (!parsed.success) {
2403
2873
  return asTextResult({
2874
+ code: "OUTPUT_INVALID",
2404
2875
  kind: "validation",
2405
2876
  message: `Tool ${options.toolName} returned an invalid result shape.`,
2877
+ nextAction: {
2878
+ kind: "read_status",
2879
+ reason: "Inspect the existing operation identity before retrying."
2880
+ },
2881
+ prerequisite: "The existing operation or resource identity must be inspected before replaying.",
2882
+ retryable: false,
2406
2883
  status: "error"
2407
2884
  });
2408
2885
  }
2409
- return asTextResult(options.envelope);
2886
+ return asTextResult(envelope);
2887
+ }
2888
+ var PRIVATE_LIST_CACHE_HINT = {
2889
+ cacheScope: "private",
2890
+ ttlMs: 60000
2891
+ };
2892
+ var DYNAMOI_CACHE_HINTS = {
2893
+ "prompts/list": PRIVATE_LIST_CACHE_HINT,
2894
+ "resources/list": PRIVATE_LIST_CACHE_HINT,
2895
+ "resources/templates/list": PRIVATE_LIST_CACHE_HINT,
2896
+ "server/discover": PRIVATE_LIST_CACHE_HINT,
2897
+ "tools/list": PRIVATE_LIST_CACHE_HINT
2898
+ };
2899
+ function isObjectShapedJsonSchema(schema) {
2900
+ if (schema["type"] !== undefined) {
2901
+ return schema["type"] === "object";
2902
+ }
2903
+ if ([
2904
+ "properties",
2905
+ "patternProperties",
2906
+ "additionalProperties",
2907
+ "required"
2908
+ ].some((key) => (key in schema))) {
2909
+ return true;
2910
+ }
2911
+ return ["oneOf", "anyOf", "allOf"].some((key) => {
2912
+ const members = schema[key];
2913
+ return Array.isArray(members) && members.length > 0 && members.every((member) => typeof member === "object" && member !== null && isObjectShapedJsonSchema(member));
2914
+ });
2915
+ }
2916
+ function toAdvertisedJsonSchema(schema, io) {
2917
+ const { $schema: _dialect, ...jsonSchema } = z12.toJSONSchema(schema, {
2918
+ io,
2919
+ target: "draft-2020-12"
2920
+ });
2921
+ return jsonSchema["type"] === undefined && (io === "input" || isObjectShapedJsonSchema(jsonSchema)) ? { type: "object", ...jsonSchema } : jsonSchema;
2410
2922
  }
2411
2923
  function createDynamoiMcpServer(options) {
2412
- const toolProfile = options.toolProfile ?? "full";
2924
+ const toolProfile = options.toolProfile ?? "directory";
2413
2925
  const server = new McpServer({
2414
2926
  name: "dynamoi",
2415
2927
  version: DYNAMOI_MCP_VERSION,
2416
2928
  websiteUrl: options.websiteUrl ?? "https://dynamoi.com"
2417
2929
  }, {
2418
- instructions: toolProfile === "chatgpt-app" ? DYNAMOI_CHATGPT_APP_INSTRUCTIONS : DYNAMOI_MCP_INSTRUCTIONS
2930
+ cacheHints: DYNAMOI_CACHE_HINTS,
2931
+ capabilities: {
2932
+ resources: { listChanged: false },
2933
+ tools: { listChanged: false },
2934
+ ...toolProfile === "full" ? { prompts: { listChanged: false } } : {}
2935
+ },
2936
+ instructions: toolProfile === "directory" ? DYNAMOI_CHATGPT_APP_INSTRUCTIONS : DYNAMOI_MCP_INSTRUCTIONS
2419
2937
  });
2938
+ const advertisedTools = [];
2420
2939
  for (const def of getDynamoiToolDefinitions({ toolProfile })) {
2421
2940
  const title = def.title;
2422
2941
  const dispatcher = DYNAMOI_TOOL_DISPATCHERS[def.name];
2423
2942
  const idempotentHint = "idempotentHint" in def && typeof def.idempotentHint === "boolean" ? def.idempotentHint : undefined;
2424
2943
  const meta = {
2425
- securitySchemes: buildDynamoiToolSecuritySchemes(getDynamoiToolOAuthScopes(def.name, options.oauthScopes ?? DYNAMOI_BETTER_AUTH_MCP_SCOPES))
2944
+ securitySchemes: buildDynamoiToolSecuritySchemes(getDynamoiToolOAuthScopes(def.name, options.oauthScopes ?? DYNAMOI_BETTER_AUTH_MCP_SCOPES2))
2426
2945
  };
2427
2946
  if (def.name === "dynamoi_preview_smart_link_themes") {
2428
2947
  meta["openai/outputTemplate"] = SMART_LINK_THEME_PREVIEW_RESOURCE_URI;
2429
- meta["ui"] = { resourceUri: SMART_LINK_THEME_PREVIEW_RESOURCE_URI };
2948
+ meta.ui = { resourceUri: SMART_LINK_THEME_PREVIEW_RESOURCE_URI };
2430
2949
  }
2431
2950
  const annotations = {
2432
2951
  destructiveHint: def.destructiveHint,
@@ -2434,40 +2953,56 @@ function createDynamoiMcpServer(options) {
2434
2953
  readOnlyHint: def.readOnlyHint
2435
2954
  };
2436
2955
  if (typeof idempotentHint === "boolean") {
2437
- annotations["idempotentHint"] = idempotentHint;
2956
+ annotations.idempotentHint = idempotentHint;
2438
2957
  }
2958
+ const outputSchema = getAdvertisedToolOutputSchema({
2959
+ canonical: def.outputSchema,
2960
+ toolName: def.name,
2961
+ toolProfile
2962
+ });
2963
+ advertisedTools.push({
2964
+ _meta: meta,
2965
+ annotations,
2966
+ description: def.description,
2967
+ inputSchema: toAdvertisedJsonSchema(def.schema, "input"),
2968
+ name: def.name,
2969
+ outputSchema: toAdvertisedJsonSchema(outputSchema, "output"),
2970
+ securitySchemes: meta.securitySchemes,
2971
+ title
2972
+ });
2439
2973
  server.registerTool(def.name, {
2440
2974
  _meta: meta,
2441
2975
  annotations,
2442
2976
  description: def.description,
2443
2977
  inputSchema: def.schema,
2444
- outputSchema: getAdvertisedToolOutputSchema({
2445
- canonical: def.outputSchema,
2446
- toolName: def.name,
2447
- toolProfile
2448
- }),
2978
+ outputSchema,
2449
2979
  title
2450
2980
  }, async (input) => {
2981
+ const denied = options.authorizeToolCall?.(def.name);
2982
+ if (denied) {
2983
+ return denied;
2984
+ }
2451
2985
  const startedAt = Date.now();
2452
2986
  try {
2453
- const envelope = await dispatcher(options.adapter, input);
2987
+ const envelope = await dispatcher(options.adapter, input, toolProfile);
2988
+ const finalized = asValidatedTextResult({
2989
+ envelope,
2990
+ outputSchema: def.outputSchema,
2991
+ toolName: def.name
2992
+ });
2454
2993
  try {
2455
2994
  await options.onToolCall?.({
2456
2995
  durationMs: Date.now() - startedAt,
2457
- result: envelope,
2996
+ result: snapshotForObserver(finalized.structuredContent),
2458
2997
  toolName: def.name
2459
2998
  });
2460
2999
  } catch {}
2461
- return asValidatedTextResult({
2462
- envelope,
2463
- outputSchema: def.outputSchema,
2464
- toolName: def.name
2465
- });
3000
+ return finalized;
2466
3001
  } catch (error) {
2467
3002
  try {
2468
3003
  await options.onToolCall?.({
2469
3004
  durationMs: Date.now() - startedAt,
2470
- error,
3005
+ error: snapshotForObserver(error),
2471
3006
  toolName: def.name
2472
3007
  });
2473
3008
  } catch {}
@@ -2475,6 +3010,24 @@ function createDynamoiMcpServer(options) {
2475
3010
  }
2476
3011
  });
2477
3012
  }
3013
+ server.server.removeRequestHandler("tools/list");
3014
+ server.server.setRequestHandler("tools/list", () => ({
3015
+ tools: advertisedTools
3016
+ }));
3017
+ server.registerResource(DYNAMOI_ABOUT_RESOURCE.name, DYNAMOI_ABOUT_RESOURCE.uri, {
3018
+ cacheHint: { cacheScope: "public", ttlMs: 60 * 60 * 1000 },
3019
+ description: DYNAMOI_ABOUT_RESOURCE.description,
3020
+ mimeType: DYNAMOI_ABOUT_RESOURCE.mimeType,
3021
+ title: DYNAMOI_ABOUT_RESOURCE.title
3022
+ }, async (uri) => ({
3023
+ contents: [
3024
+ {
3025
+ mimeType: DYNAMOI_ABOUT_RESOURCE.mimeType,
3026
+ text: toolProfile === "directory" ? DYNAMOI_ABOUT_DIRECTORY_MARKDOWN : DYNAMOI_ABOUT_MARKDOWN,
3027
+ uri: uri.href
3028
+ }
3029
+ ]
3030
+ }));
2478
3031
  registerSmartLinkThemePreviewResource(server);
2479
3032
  if (toolProfile === "full") {
2480
3033
  registerDynamoiPrompts(server);
@@ -2483,113 +3036,175 @@ function createDynamoiMcpServer(options) {
2483
3036
  return server;
2484
3037
  }
2485
3038
  // src/transport/http.ts
2486
- import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
2487
- function isRecord(value) {
2488
- return typeof value === "object" && value !== null && !Array.isArray(value);
3039
+ import {
3040
+ createMcpHandler,
3041
+ isLegacyRequest,
3042
+ WebStandardStreamableHTTPServerTransport
3043
+ } from "@modelcontextprotocol/server";
3044
+ function methodNotAllowed() {
3045
+ return new Response(JSON.stringify({
3046
+ error: { code: -32000, message: "Method not allowed." },
3047
+ id: null,
3048
+ jsonrpc: "2.0"
3049
+ }), {
3050
+ headers: {
3051
+ Allow: "POST",
3052
+ "content-type": "application/json"
3053
+ },
3054
+ status: 405
3055
+ });
2489
3056
  }
2490
- function normalizeLegacyDynamoiToolCallArguments(parsedBody) {
2491
- if (Array.isArray(parsedBody)) {
2492
- return parsedBody.map((message) => normalizeLegacyDynamoiToolCallArguments(message));
2493
- }
2494
- if (!isRecord(parsedBody) || parsedBody.method !== "tools/call") {
2495
- return parsedBody;
3057
+ async function handleLegacyRequest(options) {
3058
+ const accept = options.request.headers.get("accept");
3059
+ const acceptsEventStream = accept?.includes("text/event-stream") ?? false;
3060
+ const acceptsJson = accept?.includes("application/json") || accept === "*/*" || !accept;
3061
+ const enableJsonResponse = !acceptsEventStream && Boolean(acceptsJson);
3062
+ let effectiveRequest = options.request;
3063
+ if (!(accept?.includes("application/json") && accept.includes("text/event-stream"))) {
3064
+ const headers = new Headers(options.request.headers);
3065
+ headers.set("accept", "application/json, text/event-stream");
3066
+ effectiveRequest = new Request(options.request.url, {
3067
+ headers,
3068
+ method: options.request.method,
3069
+ signal: options.request.signal
3070
+ });
2496
3071
  }
2497
- const params = parsedBody.params;
2498
- if (!isRecord(params) || params.name !== "dynamoi_get_smart_link") {
2499
- return parsedBody;
3072
+ const server = options.createServer();
3073
+ const transport = new WebStandardStreamableHTTPServerTransport({
3074
+ enableJsonResponse,
3075
+ sessionIdGenerator: undefined
3076
+ });
3077
+ let closed = false;
3078
+ const close = () => {
3079
+ if (!closed) {
3080
+ closed = true;
3081
+ options.request.signal.removeEventListener("abort", close);
3082
+ server.close().catch(() => {
3083
+ return;
3084
+ });
3085
+ }
3086
+ };
3087
+ options.request.signal.addEventListener("abort", close, { once: true });
3088
+ let response;
3089
+ try {
3090
+ await server.connect(transport);
3091
+ response = await transport.handleRequest(effectiveRequest, {
3092
+ parsedBody: options.parsedBody
3093
+ });
3094
+ } catch (error) {
3095
+ close();
3096
+ throw error;
2500
3097
  }
2501
- const normalizedArguments = normalizeLegacySmartLinkInclude(params.arguments);
2502
- if (normalizedArguments === params.arguments) {
2503
- return parsedBody;
3098
+ if (!(response.body && isEventStream(response))) {
3099
+ close();
3100
+ return response;
2504
3101
  }
2505
- return {
2506
- ...parsedBody,
2507
- params: {
2508
- ...params,
2509
- arguments: normalizedArguments
3102
+ return new Response(response.body.pipeThrough(new TransformStream({ flush: close })), {
3103
+ headers: response.headers,
3104
+ status: response.status,
3105
+ statusText: response.statusText
3106
+ });
3107
+ }
3108
+ function isEventStream(response) {
3109
+ return (response.headers.get("content-type") ?? "").includes("text/event-stream");
3110
+ }
3111
+ var modernServerFactories = new WeakMap;
3112
+ var modernHandler;
3113
+ function getModernHandler() {
3114
+ modernHandler ??= createMcpHandler(({ requestInfo }) => {
3115
+ const createServer = requestInfo && modernServerFactories.get(requestInfo);
3116
+ if (!createServer) {
3117
+ throw new Error("No MCP server factory is registered for this request.");
2510
3118
  }
2511
- };
3119
+ return createServer();
3120
+ }, { legacy: "reject", responseMode: "json" });
3121
+ return modernHandler;
2512
3122
  }
2513
3123
  async function handleMcpHttpRequest(options) {
2514
3124
  if (options.request.method.toUpperCase() !== "POST") {
2515
- return new Response(JSON.stringify({
2516
- error: { code: -32000, message: "Method not allowed." },
2517
- id: null,
2518
- jsonrpc: "2.0"
2519
- }), {
2520
- headers: {
2521
- Allow: "POST",
2522
- "content-type": "application/json"
2523
- },
2524
- status: 405
3125
+ return methodNotAllowed();
3126
+ }
3127
+ if (await isLegacyRequest(options.request, options.parsedBody)) {
3128
+ return handleLegacyRequest(options);
3129
+ }
3130
+ modernServerFactories.set(options.request, options.createServer);
3131
+ try {
3132
+ return await getModernHandler().fetch(options.request, {
3133
+ parsedBody: options.parsedBody
2525
3134
  });
3135
+ } finally {
3136
+ modernServerFactories.delete(options.request);
2526
3137
  }
2527
- const parsedBody = normalizeLegacyDynamoiToolCallArguments(options.parsedBody);
2528
- const transport = new WebStandardStreamableHTTPServerTransport;
2529
- const server = options.createServer();
2530
- await server.connect(transport);
2531
- return transport.handleRequest(options.request, {
2532
- parsedBody
2533
- });
2534
3138
  }
2535
3139
  export {
2536
- verifyAccessToken,
2537
- parseDynamoiGetSmartLinkInput,
2538
- handleMcpHttpRequest,
2539
- getDynamoiToolDefinitions,
2540
- createDynamoiMcpServer,
2541
- buildWwwAuthenticateHeader,
2542
- buildProtectedResourceMetadata,
2543
- ToolFormatSchema2 as ToolFormatSchema,
2544
- PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION,
2545
- PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH,
2546
- PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY,
2547
- PHASE_ONBOARDING_TOOL_DEFINITIONS,
2548
- PHASE_4_TOOL_DEFINITIONS,
2549
- PHASE_3_TOOL_DEFINITIONS,
2550
- PHASE_2_TOOL_DEFINITIONS,
2551
- PHASE_1_TOOL_DEFINITIONS,
2552
- DynamoiUpdateSmartLinkInputSchema,
2553
- DynamoiUpdateSmartLinkArtistSettingsInputSchema,
2554
- DynamoiUpdateCampaignInputSchema,
2555
- DynamoiUpdateBudgetInputSchema,
2556
- DynamoiStartYoutubeChannelLinkInputSchema,
2557
- DynamoiStartMetaConnectionInputSchema,
2558
- DynamoiSearchInputSchema,
2559
- DynamoiResumeCampaignInputSchema,
2560
- DynamoiPauseCampaignInputSchema,
2561
- DynamoiOpenAiSearchInputSchema,
2562
- DynamoiOpenAiFetchInputSchema,
2563
- DynamoiListSmartLinksInputSchema,
2564
- DynamoiListMediaAssetsInputSchema,
2565
- DynamoiListCampaignsInputSchema,
2566
- DynamoiListAvailableCountriesInputSchema,
2567
- DynamoiListArtistsInputSchema,
2568
- DynamoiLaunchCampaignInputSchema,
2569
- DynamoiGetSmartLinkInputSchema,
2570
- DynamoiGetSmartLinkArtistSettingsInputSchema,
2571
- DynamoiGetSmartLinkAnalyticsInputSchema,
2572
- DynamoiGetPlatformStatusInputSchema,
2573
- DynamoiGetOnboardingStatusInputSchema,
2574
- DynamoiGetDistributionApplicationInputSchema,
2575
- DynamoiGetCurrentUserInputSchema,
2576
- DynamoiGetCampaignReadinessInputSchema,
2577
- DynamoiGetCampaignInputSchema,
2578
- DynamoiGetCampaignDeploymentStatusInputSchema,
2579
- DynamoiGetCampaignAnalyticsInputSchema,
2580
- DynamoiGetBillingInputSchema,
2581
- DynamoiGetArtistInputSchema,
2582
- DynamoiGetArtistAnalyticsInputSchema,
2583
- DynamoiCreateSmartLinksFromSpotifyArtistInputSchema,
2584
- DynamoiCreateSmartLinkFromSpotifyInputSchema,
2585
- DynamoiApplyForDistributionInputSchema,
2586
- DateRangeSchema2 as DateRangeSchema,
3140
+ DISTRIBUTION_TOOL_DEFINITIONS,
3141
+ DYNAMOI_ABOUT_DIRECTORY_MARKDOWN,
3142
+ DYNAMOI_ABOUT_MARKDOWN,
3143
+ DYNAMOI_ABOUT_RESOURCE,
3144
+ DYNAMOI_ABOUT_TOOL_DEFINITION,
3145
+ DYNAMOI_BETTER_AUTH_MCP_SCOPES2 as DYNAMOI_BETTER_AUTH_MCP_SCOPES,
3146
+ DYNAMOI_MCP_TOOL_SCOPES2 as DYNAMOI_MCP_TOOL_SCOPES,
2587
3147
  DYNAMOI_MCP_VERSION,
2588
- DYNAMOI_MCP_TOOL_SCOPES,
2589
- DYNAMOI_MCP_SCOPES,
2590
- DYNAMOI_BETTER_AUTH_MCP_SCOPES,
2591
- DISTRIBUTION_TOOL_DEFINITIONS
3148
+ DYNAMOI_SHOP_FULL_SCOPE,
3149
+ DYNAMOI_SHOP_MAX_TARGET_COUNTRY_CODES,
3150
+ DateRangeSchema2 as DateRangeSchema,
3151
+ DynamoiApplyForDistributionInputSchema,
3152
+ DynamoiCreateSmartLinkFromSpotifyInputSchema,
3153
+ DynamoiCreateSmartLinksFromSpotifyArtistInputSchema,
3154
+ DynamoiGetArtistAnalyticsInputSchema,
3155
+ DynamoiGetArtistInputSchema,
3156
+ DynamoiGetBillingInputSchema,
3157
+ DynamoiGetCampaignAnalyticsInputSchema,
3158
+ DynamoiGetCampaignDeploymentStatusInputSchema,
3159
+ DynamoiGetCampaignInputSchema,
3160
+ DynamoiGetCampaignReadinessInputSchema,
3161
+ DynamoiGetCurrentUserInputSchema,
3162
+ DynamoiGetDistributionApplicationInputSchema,
3163
+ DynamoiGetOnboardingStatusInputSchema,
3164
+ DynamoiGetPlatformStatusInputSchema,
3165
+ DynamoiGetSmartLinkAnalyticsInputSchema,
3166
+ DynamoiGetSmartLinkArtistSettingsInputSchema,
3167
+ DynamoiGetSmartLinkInputSchema,
3168
+ DynamoiLaunchCampaignInputSchema,
3169
+ DynamoiListArtistsInputSchema,
3170
+ DynamoiListAvailableCountriesInputSchema,
3171
+ DynamoiListCampaignsInputSchema,
3172
+ DynamoiListMediaAssetsInputSchema,
3173
+ DynamoiListSmartLinksInputSchema,
3174
+ DynamoiOpenAiFetchInputSchema,
3175
+ DynamoiOpenAiSearchInputSchema,
3176
+ DynamoiPauseCampaignInputSchema,
3177
+ DynamoiResumeCampaignInputSchema,
3178
+ DynamoiSearchInputSchema,
3179
+ DynamoiShopCheckoutDataSchema,
3180
+ DynamoiShopCreateCheckoutInputSchema,
3181
+ DynamoiShopGetQuoteInputSchema,
3182
+ DynamoiShopQuoteDataSchema,
3183
+ DynamoiShopSelectionInputSchema,
3184
+ DynamoiShopTargetingInputSchema,
3185
+ DynamoiStartMetaConnectionInputSchema,
3186
+ DynamoiStartYoutubeChannelLinkInputSchema,
3187
+ DynamoiUpdateBudgetInputSchema,
3188
+ DynamoiUpdateCampaignInputSchema,
3189
+ DynamoiUpdateSmartLinkArtistSettingsInputSchema,
3190
+ DynamoiUpdateSmartLinkInputSchema,
3191
+ PHASE_1_TOOL_DEFINITIONS,
3192
+ PHASE_2_TOOL_DEFINITIONS,
3193
+ PHASE_3_TOOL_DEFINITIONS,
3194
+ PHASE_4_TOOL_DEFINITIONS,
3195
+ PHASE_ONBOARDING_TOOL_DEFINITIONS,
3196
+ PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY2 as PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY,
3197
+ PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH2 as PROSPECTIVE_BUDGET_FUNDING_CONSENT_COPY_HASH,
3198
+ PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION2 as PROSPECTIVE_BUDGET_FUNDING_CONSENT_VERSION,
3199
+ SHOP_TOOL_DEFINITIONS,
3200
+ ToolFormatSchema2 as ToolFormatSchema,
3201
+ buildWwwAuthenticateHeader2 as buildWwwAuthenticateHeader,
3202
+ createDynamoiMcpServer,
3203
+ getDynamoiAbout,
3204
+ getDynamoiToolDefinitions,
3205
+ handleMcpHttpRequest,
3206
+ parseDynamoiGetSmartLinkInput
2592
3207
  };
2593
3208
 
2594
- //# debugId=D3E585F59FF3955D64756E2164756E21
3209
+ //# debugId=2C14635B20D17DF664756E2164756E21
2595
3210
  //# sourceMappingURL=index.js.map