@micropage-sh/mcp 0.1.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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -0
  3. package/dist/annotations.d.ts +20 -0
  4. package/dist/annotations.js +36 -0
  5. package/dist/annotations.js.map +1 -0
  6. package/dist/client/assets.d.ts +85 -0
  7. package/dist/client/assets.js +473 -0
  8. package/dist/client/assets.js.map +1 -0
  9. package/dist/client/auth-provider.d.ts +24 -0
  10. package/dist/client/auth-provider.js +10 -0
  11. package/dist/client/auth-provider.js.map +1 -0
  12. package/dist/client/builds.d.ts +82 -0
  13. package/dist/client/builds.js +166 -0
  14. package/dist/client/builds.js.map +1 -0
  15. package/dist/client/config.d.ts +18 -0
  16. package/dist/client/config.js +29 -0
  17. package/dist/client/config.js.map +1 -0
  18. package/dist/client/deploy-events.d.ts +98 -0
  19. package/dist/client/deploy-events.js +170 -0
  20. package/dist/client/deploy-events.js.map +1 -0
  21. package/dist/client/deploy-token.d.ts +48 -0
  22. package/dist/client/deploy-token.js +130 -0
  23. package/dist/client/deploy-token.js.map +1 -0
  24. package/dist/client/errors.d.ts +18 -0
  25. package/dist/client/errors.js +21 -0
  26. package/dist/client/errors.js.map +1 -0
  27. package/dist/client/http.d.ts +68 -0
  28. package/dist/client/http.js +191 -0
  29. package/dist/client/http.js.map +1 -0
  30. package/dist/client/jwt.d.ts +13 -0
  31. package/dist/client/jwt.js +23 -0
  32. package/dist/client/jwt.js.map +1 -0
  33. package/dist/client/lock.d.ts +16 -0
  34. package/dist/client/lock.js +67 -0
  35. package/dist/client/lock.js.map +1 -0
  36. package/dist/client/pages.d.ts +47 -0
  37. package/dist/client/pages.js +131 -0
  38. package/dist/client/pages.js.map +1 -0
  39. package/dist/client/posts.d.ts +108 -0
  40. package/dist/client/posts.js +187 -0
  41. package/dist/client/posts.js.map +1 -0
  42. package/dist/client/project-ref.d.ts +68 -0
  43. package/dist/client/project-ref.js +118 -0
  44. package/dist/client/project-ref.js.map +1 -0
  45. package/dist/client/session-store.d.ts +81 -0
  46. package/dist/client/session-store.js +271 -0
  47. package/dist/client/session-store.js.map +1 -0
  48. package/dist/client/submissions.d.ts +59 -0
  49. package/dist/client/submissions.js +111 -0
  50. package/dist/client/submissions.js.map +1 -0
  51. package/dist/client/tier.d.ts +42 -0
  52. package/dist/client/tier.js +76 -0
  53. package/dist/client/tier.js.map +1 -0
  54. package/dist/content/index.d.ts +5 -0
  55. package/dist/content/index.js +28 -0
  56. package/dist/content/index.js.map +1 -0
  57. package/dist/context.d.ts +30 -0
  58. package/dist/context.js +2 -0
  59. package/dist/context.js.map +1 -0
  60. package/dist/guards.d.ts +55 -0
  61. package/dist/guards.js +168 -0
  62. package/dist/guards.js.map +1 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +16 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/progress.d.ts +7 -0
  67. package/dist/progress.js +25 -0
  68. package/dist/progress.js.map +1 -0
  69. package/dist/reference/prompts.d.ts +6 -0
  70. package/dist/reference/prompts.js +110 -0
  71. package/dist/reference/prompts.js.map +1 -0
  72. package/dist/reference/resources.d.ts +2 -0
  73. package/dist/reference/resources.js +41 -0
  74. package/dist/reference/resources.js.map +1 -0
  75. package/dist/reference/tool.d.ts +21 -0
  76. package/dist/reference/tool.js +50 -0
  77. package/dist/reference/tool.js.map +1 -0
  78. package/dist/reference/topics.d.ts +29 -0
  79. package/dist/reference/topics.js +91 -0
  80. package/dist/reference/topics.js.map +1 -0
  81. package/dist/reference.d.ts +9 -0
  82. package/dist/reference.js +20 -0
  83. package/dist/reference.js.map +1 -0
  84. package/dist/server.d.ts +29 -0
  85. package/dist/server.js +75 -0
  86. package/dist/server.js.map +1 -0
  87. package/dist/tools/account.d.ts +34 -0
  88. package/dist/tools/account.js +128 -0
  89. package/dist/tools/account.js.map +1 -0
  90. package/dist/tools/builds.d.ts +95 -0
  91. package/dist/tools/builds.js +403 -0
  92. package/dist/tools/builds.js.map +1 -0
  93. package/dist/tools/files.d.ts +71 -0
  94. package/dist/tools/files.js +205 -0
  95. package/dist/tools/files.js.map +1 -0
  96. package/dist/tools/forms.d.ts +59 -0
  97. package/dist/tools/forms.js +177 -0
  98. package/dist/tools/forms.js.map +1 -0
  99. package/dist/tools/posts.d.ts +191 -0
  100. package/dist/tools/posts.js +600 -0
  101. package/dist/tools/posts.js.map +1 -0
  102. package/dist/tools/projects.d.ts +201 -0
  103. package/dist/tools/projects.js +553 -0
  104. package/dist/tools/projects.js.map +1 -0
  105. package/dist/tools/shared.d.ts +33 -0
  106. package/dist/tools/shared.js +41 -0
  107. package/dist/tools/shared.js.map +1 -0
  108. package/dist/version.d.ts +2 -0
  109. package/dist/version.js +8 -0
  110. package/dist/version.js.map +1 -0
  111. package/package.json +67 -0
@@ -0,0 +1,600 @@
1
+ import * as z from "zod";
2
+ import { DESTRUCTIVE, OUT, RO, hints } from "../annotations.js";
3
+ import { MicropageError } from "../client/errors.js";
4
+ import { countActiveSubscribers, deletePost, formNamesById, getPostBySlug, listPosts, postContentFingerprint, postNotFound, postWillEmail, publishPost, resolveHeroUrl, resolveListFormId, slugify, unhostedBodyImages, unpublishPost, upsertPost, } from "../client/posts.js";
5
+ import { getMaxProjectDeployEventId } from "../client/deploy-events.js";
6
+ import { ProjectRef, resolveProject } from "../client/project-ref.js";
7
+ import { DEFAULT_TOKEN_TTL_MS, confirmationTokens, elicitConfirmation, requireConfirm, requireConfirmationToken, } from "../guards.js";
8
+ import { gateTool, structuredResult } from "./shared.js";
9
+ const SlugInput = z
10
+ .string()
11
+ .trim()
12
+ .min(1)
13
+ .max(200)
14
+ .describe('The post\'s slug, as list_posts shows it (e.g. "launching-new-dashboard"). Normalised like the CLI does.');
15
+ function normaliseSlug(raw) {
16
+ const slug = slugify(raw);
17
+ if (!slug) {
18
+ throw new MicropageError("INVALID_SLUG", `"${raw}" has no letters or digits, so it is not a valid slug. Call list_posts to see slugs.`);
19
+ }
20
+ return slug;
21
+ }
22
+ const ProjectBrief = z.object({
23
+ id: z.number(),
24
+ uuid: z.string(),
25
+ live_url: z.string().nullable(),
26
+ });
27
+ function projectBrief(p) {
28
+ return { id: p.id, uuid: p.uuid, live_url: p.live_url };
29
+ }
30
+ /** Cursor for get_deploy_status, taken before a call that may queue a site rebuild; null when unreadable. */
31
+ async function projectCursor(ctx, project) {
32
+ return getMaxProjectDeployEventId(ctx.http, project.id).catch(() => null);
33
+ }
34
+ /**
35
+ * Reads the server's rebuild_build_id (the live build it queued a rebuild of).
36
+ * An older server leaves it out and rebuilds projects.active_build_id when
37
+ * `legacyRebuilds`, so that is what is reported then.
38
+ */
39
+ function rebuildOutcome(res, project, legacyRebuilds, cursor) {
40
+ const buildId = res.rebuild_build_id !== undefined
41
+ ? typeof res.rebuild_build_id === "number"
42
+ ? res.rebuild_build_id
43
+ : null
44
+ : legacyRebuilds
45
+ ? project.active_build_id
46
+ : null;
47
+ return { rebuild_queued: buildId !== null, build_id: buildId, after_event_id: buildId !== null ? cursor : null };
48
+ }
49
+ const BuildIdOutput = z
50
+ .number()
51
+ .nullable()
52
+ .describe("The build the site rebuild redeploys: the live one, not an unpublished page draft. Pass to get_deploy_status; null when nothing was rebuilt.");
53
+ const AfterEventIdOutput = z
54
+ .number()
55
+ .nullable()
56
+ .describe("Pass to get_deploy_status with build_id to see only events from this rebuild.");
57
+ function followNote(o) {
58
+ return o.after_event_id === null
59
+ ? "The deploy cursor could not be read, so check the site or get_project in a few minutes instead of get_deploy_status."
60
+ : `Follow it with get_deploy_status (build "id:${o.build_id}", after_event_id ${o.after_event_id}): it reports ` +
61
+ "waiting_for_start until the rebuild begins and done only once the rebuild's own deploy event arrives.";
62
+ }
63
+ // ---------------------------------------------------------------------------
64
+ // list_posts
65
+ // ---------------------------------------------------------------------------
66
+ export const ListPostsInput = z
67
+ .object({
68
+ project: ProjectRef,
69
+ slug: SlugInput.optional().describe("Omit to list every post. Pass a slug to get that one post in full, including body_markdown and every field upsert_post takes."),
70
+ })
71
+ .strict();
72
+ const PostSummary = z.object({
73
+ id: z.string(),
74
+ slug: z.string().nullable(),
75
+ title: z.string().nullable(),
76
+ visibility: z.string().nullable().describe("listed (in the /content index), unlisted (own page only) or none (email only)."),
77
+ published: z.boolean().describe("False means draft: not on the site and never emailed."),
78
+ published_at: z.string().nullable(),
79
+ email: z.boolean().describe("True when publishing emails the post to `list` (email enabled and a list set)."),
80
+ list: z.string().nullable().describe("Newsletter form name the post is sent to."),
81
+ send_status: z
82
+ .string()
83
+ .nullable()
84
+ .describe("Email send lifecycle (queued, sending, sent, failed); null for web-only posts, where it means nothing."),
85
+ recipient_count: z.number().nullable().describe("Recipients of the last send."),
86
+ created_at: z.string().nullable(),
87
+ });
88
+ const PostDetail = PostSummary.extend({
89
+ description: z.string().nullable(),
90
+ body_markdown: z.string(),
91
+ hero: z.string().nullable().describe("Hero image URL."),
92
+ subject: z.string().nullable().describe("Email subject (defaults to the title)."),
93
+ preview: z.string().nullable().describe("Email preheader / inbox preview text."),
94
+ sent_count: z.number().nullable(),
95
+ });
96
+ export const ListPostsOutput = z.object({
97
+ project: ProjectBrief,
98
+ count: z.number().optional().describe("Number of posts (list mode)."),
99
+ posts: z.array(PostSummary).optional().describe("Every post, newest first (list mode)."),
100
+ post: PostDetail.optional().describe("The one post asked for (slug mode)."),
101
+ });
102
+ function toSummary(row, lists) {
103
+ const email = postWillEmail(row);
104
+ return {
105
+ id: row.id,
106
+ slug: row.slug,
107
+ title: row.title,
108
+ visibility: row.web_visibility,
109
+ published: row.published_at !== null,
110
+ published_at: row.published_at,
111
+ email,
112
+ list: row.form_id ? (lists.get(row.form_id) ?? null) : null,
113
+ send_status: email ? row.status : null,
114
+ recipient_count: row.recipient_count,
115
+ created_at: row.created_at,
116
+ };
117
+ }
118
+ export async function runListPosts(ctx, args) {
119
+ await gateTool(ctx, "list_posts");
120
+ const project = await resolveProject(ctx, args.project);
121
+ if (args.slug === undefined) {
122
+ const rows = await listPosts(ctx.http, project.id);
123
+ const lists = await formNamesById(ctx.http, rows.map((r) => r.form_id).filter((id) => !!id));
124
+ const posts = rows.map((r) => toSummary(r, lists));
125
+ return { project: projectBrief(project), count: posts.length, posts };
126
+ }
127
+ const slug = normaliseSlug(args.slug);
128
+ const row = await getPostBySlug(ctx.http, project.id, slug);
129
+ if (!row)
130
+ throw postNotFound(slug);
131
+ const lists = await formNamesById(ctx.http, row.form_id ? [row.form_id] : []);
132
+ const post = {
133
+ ...toSummary(row, lists),
134
+ description: row.description,
135
+ body_markdown: row.body_markdown ?? "",
136
+ hero: row.hero_image,
137
+ subject: row.subject,
138
+ preview: row.preheader,
139
+ sent_count: row.sent_count,
140
+ };
141
+ return { project: projectBrief(project), post };
142
+ }
143
+ // ---------------------------------------------------------------------------
144
+ // upsert_post
145
+ // ---------------------------------------------------------------------------
146
+ export const UpsertPostInput = z
147
+ .object({
148
+ project: ProjectRef,
149
+ title: z.string().trim().min(1).max(500).describe("Post title. Required."),
150
+ slug: z
151
+ .string()
152
+ .trim()
153
+ .max(200)
154
+ .optional()
155
+ .describe("URL slug, unique per project; the post lives at /content/<slug>. Defaults to the slugified title. " +
156
+ "The slug picks which post is updated: an existing slug updates that post, a new one creates a post."),
157
+ body_markdown: z
158
+ .string()
159
+ .min(1)
160
+ .max(500_000)
161
+ .describe("Post body in Markdown. Images must already be hosted URLs: upload each image with upload_asset, get its URL " +
162
+ "with get_file_url, and write ![alt](https://...). Local paths are not uploaded here and would 404."),
163
+ description: z
164
+ .string()
165
+ .max(2000)
166
+ .optional()
167
+ .describe("Web summary for the /content archive, meta description and og tags. Omitted clears it."),
168
+ visibility: z
169
+ .enum(["listed", "unlisted"])
170
+ .optional()
171
+ .describe("listed (default): shown in the site's /content index. unlisted: has a page but is not listed."),
172
+ hero: z
173
+ .string()
174
+ .trim()
175
+ .max(2000)
176
+ .optional()
177
+ .describe("Hero image: an https URL, or the filename of an asset already uploaded to this project (call upload_asset first " +
178
+ "for a new image). Omitted clears it."),
179
+ email: z
180
+ .boolean()
181
+ .optional()
182
+ .describe("true makes the post an email to `list` when it is published (saving never sends). Default false: web only."),
183
+ list: z
184
+ .string()
185
+ .trim()
186
+ .min(1)
187
+ .max(200)
188
+ .optional()
189
+ .describe("Newsletter form name to send to (case-insensitive exact match). Required with email: true; only allowed with it."),
190
+ subject: z.string().max(500).optional().describe("Email subject. Defaults to the title."),
191
+ preview: z.string().max(500).optional().describe("Email preheader / inbox preview text."),
192
+ confirm_live_update: z
193
+ .boolean()
194
+ .optional()
195
+ .describe("Required (true) when the post is already published: saving then changes the live page at once and rebuilds the site. " +
196
+ "Ask the user before setting it."),
197
+ })
198
+ .strict();
199
+ export const UpsertPostOutput = z.object({
200
+ project: ProjectBrief,
201
+ post_id: z.string(),
202
+ slug: z.string(),
203
+ action: z.enum(["created", "updated"]),
204
+ published: z.boolean().describe("True when the post was already live, so this save changed the live page."),
205
+ rebuild_queued: z.boolean().describe("True when the save queued a site rebuild (only for published posts)."),
206
+ build_id: BuildIdOutput,
207
+ after_event_id: AfterEventIdOutput,
208
+ email: z.boolean(),
209
+ list: z.string().nullable(),
210
+ hero: z.string().nullable(),
211
+ warnings: z.array(z.string()),
212
+ });
213
+ export async function runUpsertPost(ctx, args) {
214
+ await gateTool(ctx, "upsert_post");
215
+ const email = args.email === true;
216
+ if (email && !args.list) {
217
+ throw new MicropageError("INVALID_ARGS", "email: true needs `list` (a newsletter form name; list_forms shows them). Nothing was saved.");
218
+ }
219
+ if (!email && args.list) {
220
+ throw new MicropageError("INVALID_ARGS", "`list` is only used with email: true. Pass email: true to make this post an email to that list, or drop `list`. Nothing was saved.");
221
+ }
222
+ const slug = args.slug ? normaliseSlug(args.slug) : slugify(args.title) || "post";
223
+ const project = await resolveProject(ctx, args.project);
224
+ const existing = await getPostBySlug(ctx.http, project.id, slug);
225
+ if (existing?.published_at && args.confirm_live_update !== true) {
226
+ throw new MicropageError("CONFIRM_REQUIRED", `The post "${slug}" is published (since ${existing.published_at}), so saving changes the live page immediately and ` +
227
+ "rebuilds the site. Ask the user to approve the live update, then call upsert_post again with confirm_live_update: true. " +
228
+ "Nothing was saved.");
229
+ }
230
+ const formId = email ? await resolveListFormId(ctx.http, project.id, args.list) : null;
231
+ const heroUrl = await resolveHeroUrl(ctx.http, project.id, args.hero);
232
+ const payload = {
233
+ project_id: project.id,
234
+ title: args.title,
235
+ slug,
236
+ body_markdown: args.body_markdown,
237
+ description: args.description || null,
238
+ web_visibility: args.visibility ?? "listed",
239
+ hero_image: heroUrl,
240
+ form_id: formId,
241
+ subject: args.subject || null,
242
+ preheader: args.preview || null,
243
+ };
244
+ const cursor = existing?.published_at ? await projectCursor(ctx, project) : null;
245
+ const res = await upsertPost(ctx.http, payload);
246
+ // An older upsert-post rebuilds active_build_id for every published save; a
247
+ // newer one reports the live build it rebuilt.
248
+ const rebuild = rebuildOutcome(res, project, res.published, cursor);
249
+ const warnings = [];
250
+ const unhosted = unhostedBodyImages(args.body_markdown);
251
+ if (unhosted.length > 0) {
252
+ warnings.push(`${unhosted.length} body image(s) are not hosted URLs and will 404 on the page: ${unhosted.join(", ")}. ` +
253
+ "Upload them with upload_asset, swap in the URLs from get_file_url and save again.");
254
+ }
255
+ if (!res.published)
256
+ warnings.push("Saved as a draft: not on the site and not emailed. preview_post_send then publish_post makes it live.");
257
+ return {
258
+ project: projectBrief(project),
259
+ post_id: res.post_id,
260
+ slug,
261
+ action: res.action,
262
+ published: res.published,
263
+ rebuild_queued: res.rebuild_build_id !== undefined ? rebuild.rebuild_queued : res.published,
264
+ build_id: rebuild.build_id,
265
+ after_event_id: rebuild.after_event_id,
266
+ email,
267
+ list: email ? args.list.trim() : null,
268
+ hero: heroUrl,
269
+ warnings,
270
+ };
271
+ }
272
+ function sendFacts(project, post) {
273
+ const willEmail = postWillEmail(post);
274
+ const alreadyPublished = post.published_at !== null;
275
+ return {
276
+ willEmail,
277
+ alreadyPublished,
278
+ tokenPayload: {
279
+ purpose: "publish_post",
280
+ project_id: project.id,
281
+ post_id: post.id,
282
+ content: postContentFingerprint(post),
283
+ email_enabled: post.email_enabled === true,
284
+ form_id: post.form_id,
285
+ already_published: alreadyPublished,
286
+ },
287
+ };
288
+ }
289
+ const RESEND_WARNING = "This post is already published, so publishing again RE-SENDS the email to everyone on the list and resets its click-through stats.";
290
+ const SEND_DISABLED = "Emailing from the MCP server is turned off. The user can turn it on by adding MICROPAGE_MCP_ALLOW_SEND=1 to this server's env in their MCP client config " +
291
+ "and restarting it, or publish from the micropage editor or with `micropage posts publish`. To publish on the web only, save the post with email: false " +
292
+ "(upsert_post), then call preview_post_send again.";
293
+ async function loadPost(ctx, project, rawSlug) {
294
+ const slug = normaliseSlug(rawSlug);
295
+ const post = await getPostBySlug(ctx.http, project.id, slug);
296
+ if (!post)
297
+ throw postNotFound(slug);
298
+ return post;
299
+ }
300
+ // ---------------------------------------------------------------------------
301
+ // preview_post_send
302
+ // ---------------------------------------------------------------------------
303
+ export const PreviewPostSendInput = z.object({ project: ProjectRef, slug: SlugInput }).strict();
304
+ export const PreviewPostSendOutput = z.object({
305
+ project: ProjectBrief,
306
+ post: z.object({
307
+ id: z.string(),
308
+ slug: z.string().nullable(),
309
+ title: z.string().nullable(),
310
+ subject: z.string().nullable(),
311
+ preview: z.string().nullable(),
312
+ visibility: z.string().nullable(),
313
+ }),
314
+ will_email: z.boolean().describe("True when publishing emails the list (email enabled and a list set)."),
315
+ list: z.string().nullable(),
316
+ recipient_count: z.number().nullable().describe("Active subscribers on the list right now; 0 when nothing is emailed."),
317
+ already_published: z.boolean(),
318
+ resend_warning: z.string().nullable(),
319
+ send_allowed: z.boolean().describe("MICROPAGE_MCP_ALLOW_SEND is set, so this server may email subscribers."),
320
+ publish_allowed: z.boolean().describe("Whether publish_post will go ahead for this post on this server."),
321
+ blocked_reason: z.string().nullable(),
322
+ confirmation_token: z.string().describe("Pass to publish_post. Invalid once the post changes, or after expires_in_seconds."),
323
+ expires_in_seconds: z.number(),
324
+ });
325
+ export async function runPreviewPostSend(ctx, args, tokens = confirmationTokens) {
326
+ await gateTool(ctx, "preview_post_send");
327
+ const project = await resolveProject(ctx, args.project);
328
+ const post = await loadPost(ctx, project, args.slug);
329
+ const facts = sendFacts(project, post);
330
+ const [lists, recipients] = await Promise.all([
331
+ formNamesById(ctx.http, post.form_id ? [post.form_id] : []),
332
+ facts.willEmail ? countActiveSubscribers(ctx.http, post.form_id) : Promise.resolve(0),
333
+ ]);
334
+ const blocked = facts.willEmail && !ctx.flags.allowSend;
335
+ return {
336
+ project: projectBrief(project),
337
+ post: {
338
+ id: post.id,
339
+ slug: post.slug,
340
+ title: post.title,
341
+ subject: post.subject,
342
+ preview: post.preheader,
343
+ visibility: post.web_visibility,
344
+ },
345
+ will_email: facts.willEmail,
346
+ list: post.form_id ? (lists.get(post.form_id) ?? null) : null,
347
+ recipient_count: recipients,
348
+ already_published: facts.alreadyPublished,
349
+ resend_warning: facts.willEmail && facts.alreadyPublished ? RESEND_WARNING : null,
350
+ send_allowed: ctx.flags.allowSend,
351
+ publish_allowed: !blocked,
352
+ blocked_reason: blocked ? SEND_DISABLED : null,
353
+ confirmation_token: tokens.mint(facts.tokenPayload),
354
+ expires_in_seconds: Math.round(DEFAULT_TOKEN_TTL_MS / 1000),
355
+ };
356
+ }
357
+ // ---------------------------------------------------------------------------
358
+ // publish_post
359
+ // ---------------------------------------------------------------------------
360
+ export const PublishPostInput = z
361
+ .object({
362
+ project: ProjectRef,
363
+ slug: SlugInput,
364
+ confirmation_token: z
365
+ .string()
366
+ .trim()
367
+ .min(1)
368
+ .max(200)
369
+ .describe("The confirmation_token from preview_post_send for this post, taken after its last change and shown to the user."),
370
+ })
371
+ .strict();
372
+ export const PublishPostOutput = z.object({
373
+ project: ProjectBrief,
374
+ post_id: z.string(),
375
+ slug: z.string(),
376
+ published_at: z.string(),
377
+ emailed: z.boolean(),
378
+ recipient_count: z.number().nullable(),
379
+ rebuild_queued: z.boolean().describe("True when a site rebuild was queued so the post appears under /content."),
380
+ build_id: BuildIdOutput,
381
+ after_event_id: AfterEventIdOutput,
382
+ note: z.string(),
383
+ });
384
+ export async function runPublishPost(ctx, args, handlerCtx, tokens = confirmationTokens) {
385
+ await gateTool(ctx, "publish_post");
386
+ const project = await resolveProject(ctx, args.project);
387
+ const post = await loadPost(ctx, project, args.slug);
388
+ const facts = sendFacts(project, post);
389
+ if (facts.willEmail && !ctx.flags.allowSend) {
390
+ throw new MicropageError("SEND_DISABLED", `"${post.slug}" is set to email its list when published. ${SEND_DISABLED} Nothing was changed.`);
391
+ }
392
+ requireConfirmationToken(tokens, args.confirmation_token, facts.tokenPayload, "preview_post_send");
393
+ if (facts.willEmail && handlerCtx) {
394
+ const [lists, recipients] = await Promise.all([
395
+ formNamesById(ctx.http, [post.form_id]),
396
+ countActiveSubscribers(ctx.http, post.form_id),
397
+ ]);
398
+ const listName = lists.get(post.form_id) ?? "newsletter";
399
+ const outcome = elicitConfirmation(handlerCtx, ctx.clientCapabilities(handlerCtx), {
400
+ key: "confirm_post_send",
401
+ message: `Publish "${post.title ?? post.slug}" and email it to ${recipients} subscriber(s) on the "${listName}" list?` +
402
+ (facts.alreadyPublished ? " It was already published, so this RE-SENDS it." : ""),
403
+ });
404
+ if (outcome.status === "pending")
405
+ return { kind: "input", result: outcome.result };
406
+ if (outcome.status === "declined") {
407
+ throw new MicropageError("DECLINED", "The user declined sending this post. Nothing was published or emailed.");
408
+ }
409
+ }
410
+ const cursor = post.web_visibility !== "none" ? await projectCursor(ctx, project) : null;
411
+ const res = await publishPost(ctx.http, project.id, post.slug);
412
+ const rebuild = rebuildOutcome(res, project, post.web_visibility !== "none" && project.active_build_id !== null, cursor);
413
+ const notes = [
414
+ res.emailed ? `Emailed to ${res.recipient_count} recipient(s); sending runs in the background.` : "Published on the web only; no email.",
415
+ rebuild.rebuild_queued
416
+ ? "A site rebuild of the live build was queued; the post appears under /content once it deploys. It starts after up to " +
417
+ `about 3 minutes in the queue unless the account is Pro+, then takes 1-2 minutes. ${followNote(rebuild)}`
418
+ : post.web_visibility === "none"
419
+ ? "The post has visibility none, so no web page changes."
420
+ : "The project has no published build yet, so the post is not on a site until the page is published with publish_build.",
421
+ ];
422
+ return {
423
+ kind: "done",
424
+ result: {
425
+ project: projectBrief(project),
426
+ post_id: res.post_id,
427
+ slug: post.slug,
428
+ published_at: res.published_at,
429
+ emailed: res.emailed,
430
+ recipient_count: typeof res.recipient_count === "number" ? res.recipient_count : null,
431
+ rebuild_queued: rebuild.rebuild_queued,
432
+ build_id: rebuild.build_id,
433
+ after_event_id: rebuild.after_event_id,
434
+ note: notes.join(" "),
435
+ },
436
+ };
437
+ }
438
+ // ---------------------------------------------------------------------------
439
+ // unpublish_post / delete_post
440
+ // ---------------------------------------------------------------------------
441
+ const ConfirmInput = z
442
+ .boolean()
443
+ .optional()
444
+ .describe("Must be true. Ask the user first: this changes the live site.");
445
+ export const UnpublishPostInput = z
446
+ .object({ project: ProjectRef, slug: SlugInput, confirm: ConfirmInput })
447
+ .strict();
448
+ export const UnpublishPostOutput = z.object({
449
+ project: ProjectBrief,
450
+ post_id: z.string().nullable(),
451
+ slug: z.string(),
452
+ unpublished: z.boolean(),
453
+ rebuild_queued: z.boolean().describe("True when a site rebuild of the live build was queued to take the post down."),
454
+ build_id: BuildIdOutput,
455
+ after_event_id: AfterEventIdOutput,
456
+ });
457
+ export async function runUnpublishPost(ctx, args) {
458
+ const slug = normaliseSlug(args.slug);
459
+ requireConfirm(args, `Unpublishing the post "${slug}"`);
460
+ await gateTool(ctx, "unpublish_post");
461
+ const project = await resolveProject(ctx, args.project);
462
+ const cursor = await projectCursor(ctx, project);
463
+ const res = await unpublishPost(ctx.http, project.id, slug);
464
+ const rebuild = rebuildOutcome(res, project, res.unpublished === true && project.active_build_id !== null, cursor);
465
+ return {
466
+ project: projectBrief(project),
467
+ post_id: res.post_id ?? null,
468
+ slug,
469
+ unpublished: res.unpublished === true,
470
+ ...rebuild,
471
+ };
472
+ }
473
+ export const DeletePostInput = z
474
+ .object({
475
+ project: ProjectRef,
476
+ slug: SlugInput,
477
+ confirm: ConfirmInput.describe("Must be true. Ask the user first: the post is deleted for good and leaves the live site."),
478
+ })
479
+ .strict();
480
+ export const DeletePostOutput = z.object({
481
+ project: ProjectBrief,
482
+ slug: z.string(),
483
+ deleted: z.boolean().describe("False when no post had that slug (nothing to delete)."),
484
+ rebuild_queued: z.boolean().describe("True when a site rebuild of the live build was queued to take the post down."),
485
+ build_id: BuildIdOutput,
486
+ after_event_id: AfterEventIdOutput,
487
+ });
488
+ export async function runDeletePost(ctx, args) {
489
+ const slug = normaliseSlug(args.slug);
490
+ requireConfirm(args, `Deleting the post "${slug}"`);
491
+ await gateTool(ctx, "delete_post");
492
+ const project = await resolveProject(ctx, args.project);
493
+ const cursor = await projectCursor(ctx, project);
494
+ const res = await deletePost(ctx.http, project.id, slug);
495
+ const rebuild = rebuildOutcome(res, project, res.deleted === true && project.active_build_id !== null, cursor);
496
+ return {
497
+ project: projectBrief(project),
498
+ slug,
499
+ deleted: res.deleted === true,
500
+ ...rebuild,
501
+ };
502
+ }
503
+ // ---------------------------------------------------------------------------
504
+ const REBUILD_NOTE = "The site rebuild redeploys the live build, so an unpublished page draft left by save_page or the editor stays a draft. " +
505
+ "It returns build_id and after_event_id to follow the rebuild with get_deploy_status.";
506
+ export function registerPostTools(server, ctx) {
507
+ server.registerTool("list_posts", {
508
+ title: "List or read micropage posts",
509
+ description: `List a project's posts (blog posts and newsletter emails), or read one in full.
510
+
511
+ Without \`slug\`: every post, newest first, with slug, title, visibility, whether it is published and when, whether publishing emails it, and the newsletter list name. With \`slug\`: that post in full, including body_markdown and every field under the same names upsert_post takes (title, description, visibility, hero, email, list, subject, preview).
512
+
513
+ Call it with a slug before editing a post: upsert_post replaces every field, so start from the current values. It does not say who will receive an email; preview_post_send does that. Read-only.`,
514
+ inputSchema: ListPostsInput,
515
+ outputSchema: ListPostsOutput,
516
+ annotations: RO,
517
+ }, async (args) => {
518
+ const result = await runListPosts(ctx, args);
519
+ const summary = result.post
520
+ ? `Post "${result.post.slug}" (${result.post.published ? "published" : "draft"}).`
521
+ : `${result.count ?? 0} post(s).`;
522
+ return structuredResult(result, summary);
523
+ });
524
+ server.registerTool("upsert_post", {
525
+ title: "Create or update a micropage post",
526
+ description: `Create or update one post (a blog post under /content and/or a newsletter email), keyed by slug: an existing slug is updated, a new one is created as a draft. Same as \`micropage posts push\` for one file; the arguments are the post front-matter fields plus body_markdown (see the micropage://posts/format resource).
527
+
528
+ Every call replaces the whole post: an omitted optional field (description, hero, subject, preview, email/list) is cleared. To edit, read the post with list_posts(slug) first and pass everything back.
529
+
530
+ Saving never sends email and never publishes a draft. But if the post is already published, the save changes the live page at once and rebuilds the site, so it needs confirm_live_update: true after the user agrees. ${REBUILD_NOTE}
531
+
532
+ Images are not uploaded here. For the hero pass an https URL or the filename of an asset uploaded with upload_asset; inside body_markdown use hosted URLs only (upload_asset, then get_file_url). To publish afterwards use preview_post_send, then publish_post.`,
533
+ inputSchema: UpsertPostInput,
534
+ outputSchema: UpsertPostOutput,
535
+ annotations: DESTRUCTIVE,
536
+ }, async (args) => {
537
+ const result = await runUpsertPost(ctx, args);
538
+ const state = result.published ? "live page updated, site rebuild queued" : "draft";
539
+ return structuredResult(result, `Post "${result.slug}" ${result.action} (${state}).`);
540
+ });
541
+ server.registerTool("preview_post_send", {
542
+ title: "Preview publishing a post",
543
+ description: `Show what publish_post would do for one post, and get the confirmation_token publish_post requires. Call it before every publish and show the user the result.
544
+
545
+ Reports whether publishing emails the newsletter list, the list name, the number of active subscribers it would go to, whether the post is already published (publishing again re-sends the email to the whole list), and whether this server is allowed to send email (MICROPAGE_MCP_ALLOW_SEND).
546
+
547
+ The token is tied to the post as it is now: any edit to the post (upsert_post) or to its list invalidates it, and it expires after 15 minutes or when the server restarts. Read-only: nothing is published or sent.`,
548
+ inputSchema: PreviewPostSendInput,
549
+ outputSchema: PreviewPostSendOutput,
550
+ annotations: RO,
551
+ }, async (args) => {
552
+ const result = await runPreviewPostSend(ctx, args);
553
+ const what = result.will_email
554
+ ? `Publishing emails ${result.recipient_count ?? "?"} subscriber(s) on "${result.list ?? "?"}"${result.already_published ? " AGAIN (re-send)" : ""}.`
555
+ : "Publishing puts the post on the web only; no email.";
556
+ return structuredResult(result, result.publish_allowed ? what : `${what} Blocked: ${result.blocked_reason}`);
557
+ });
558
+ server.registerTool("publish_post", {
559
+ title: "Publish a micropage post (may send email)",
560
+ description: `Publish a post: put it live on the site under /content and, if it has email enabled with a list, email it to every active subscriber on that list. Re-publishing an already-published post re-sends the email to the whole list. Same as \`micropage posts publish <slug>\`.
561
+
562
+ Needs the confirmation_token from preview_post_send, taken after the post's last change; show the user that preview and get their go-ahead first. A stale or missing token is refused with nothing changed.
563
+
564
+ Posts that would send email are refused unless the user has set MICROPAGE_MCP_ALLOW_SEND=1 in this server's config; there is no web-only override, so to publish such a post on the web only, save it with email: false first. When the client supports it the user is also asked to confirm the send directly. ${REBUILD_NOTE} Use unpublish_post to take a post down.`,
565
+ inputSchema: PublishPostInput,
566
+ outputSchema: PublishPostOutput,
567
+ annotations: OUT,
568
+ }, async (args, handlerCtx) => {
569
+ const outcome = await runPublishPost(ctx, args, handlerCtx);
570
+ if (outcome.kind === "input")
571
+ return outcome.result;
572
+ const r = outcome.result;
573
+ return structuredResult(r, `Published "${r.slug}"${r.emailed ? `, emailed ${r.recipient_count ?? "?"} recipient(s)` : ""}.`);
574
+ });
575
+ server.registerTool("unpublish_post", {
576
+ title: "Unpublish a micropage post",
577
+ description: `Take a published post off the site: its page 404s and it goes back to draft. The post itself is kept and can be published again later; emails already sent are not recalled. Same as \`micropage posts unpublish <slug>\`.
578
+
579
+ Needs confirm: true, which you should only pass after the user has agreed. Queues a site rebuild when the project has been published. ${REBUILD_NOTE} To remove a post for good use delete_post instead.`,
580
+ inputSchema: UnpublishPostInput,
581
+ outputSchema: UnpublishPostOutput,
582
+ annotations: OUT,
583
+ }, async (args) => {
584
+ const result = await runUnpublishPost(ctx, args);
585
+ return structuredResult(result, `Unpublished "${result.slug}"; it is a draft now.`);
586
+ });
587
+ server.registerTool("delete_post", {
588
+ title: "Delete a micropage post",
589
+ description: `Delete a post for good, removing it from the site if it was published. There is no undo; to only take it off the site use unpublish_post. Same as \`micropage posts rm <slug>\`.
590
+
591
+ Needs confirm: true, which you should only pass after the user has agreed. Deleting a slug that does not exist is not an error (deleted: false). Queues a site rebuild when a post was removed and the project has been published. ${REBUILD_NOTE}`,
592
+ inputSchema: DeletePostInput,
593
+ outputSchema: DeletePostOutput,
594
+ annotations: hints(OUT, { idempotentHint: true }),
595
+ }, async (args) => {
596
+ const result = await runDeletePost(ctx, args);
597
+ return structuredResult(result, result.deleted ? `Deleted "${result.slug}".` : `No post "${result.slug}"; nothing deleted.`);
598
+ });
599
+ }
600
+ //# sourceMappingURL=posts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"posts.js","sourceRoot":"","sources":["../../src/tools/posts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,aAAa,EACb,aAAa,EACb,SAAS,EACT,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,cAAc,EACd,iBAAiB,EACjB,OAAO,EACP,kBAAkB,EAClB,aAAa,EACb,UAAU,GAKX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAEpF,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,wBAAwB,GAGzB,MAAM,cAAc,CAAC;AACtB,OAA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