@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.
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/dist/annotations.d.ts +20 -0
- package/dist/annotations.js +36 -0
- package/dist/annotations.js.map +1 -0
- package/dist/client/assets.d.ts +85 -0
- package/dist/client/assets.js +473 -0
- package/dist/client/assets.js.map +1 -0
- package/dist/client/auth-provider.d.ts +24 -0
- package/dist/client/auth-provider.js +10 -0
- package/dist/client/auth-provider.js.map +1 -0
- package/dist/client/builds.d.ts +82 -0
- package/dist/client/builds.js +166 -0
- package/dist/client/builds.js.map +1 -0
- package/dist/client/config.d.ts +18 -0
- package/dist/client/config.js +29 -0
- package/dist/client/config.js.map +1 -0
- package/dist/client/deploy-events.d.ts +98 -0
- package/dist/client/deploy-events.js +170 -0
- package/dist/client/deploy-events.js.map +1 -0
- package/dist/client/deploy-token.d.ts +48 -0
- package/dist/client/deploy-token.js +130 -0
- package/dist/client/deploy-token.js.map +1 -0
- package/dist/client/errors.d.ts +18 -0
- package/dist/client/errors.js +21 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/http.d.ts +68 -0
- package/dist/client/http.js +191 -0
- package/dist/client/http.js.map +1 -0
- package/dist/client/jwt.d.ts +13 -0
- package/dist/client/jwt.js +23 -0
- package/dist/client/jwt.js.map +1 -0
- package/dist/client/lock.d.ts +16 -0
- package/dist/client/lock.js +67 -0
- package/dist/client/lock.js.map +1 -0
- package/dist/client/pages.d.ts +47 -0
- package/dist/client/pages.js +131 -0
- package/dist/client/pages.js.map +1 -0
- package/dist/client/posts.d.ts +108 -0
- package/dist/client/posts.js +187 -0
- package/dist/client/posts.js.map +1 -0
- package/dist/client/project-ref.d.ts +68 -0
- package/dist/client/project-ref.js +118 -0
- package/dist/client/project-ref.js.map +1 -0
- package/dist/client/session-store.d.ts +81 -0
- package/dist/client/session-store.js +271 -0
- package/dist/client/session-store.js.map +1 -0
- package/dist/client/submissions.d.ts +59 -0
- package/dist/client/submissions.js +111 -0
- package/dist/client/submissions.js.map +1 -0
- package/dist/client/tier.d.ts +42 -0
- package/dist/client/tier.js +76 -0
- package/dist/client/tier.js.map +1 -0
- package/dist/content/index.d.ts +5 -0
- package/dist/content/index.js +28 -0
- package/dist/content/index.js.map +1 -0
- package/dist/context.d.ts +30 -0
- package/dist/context.js +2 -0
- package/dist/context.js.map +1 -0
- package/dist/guards.d.ts +55 -0
- package/dist/guards.js +168 -0
- package/dist/guards.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/progress.d.ts +7 -0
- package/dist/progress.js +25 -0
- package/dist/progress.js.map +1 -0
- package/dist/reference/prompts.d.ts +6 -0
- package/dist/reference/prompts.js +110 -0
- package/dist/reference/prompts.js.map +1 -0
- package/dist/reference/resources.d.ts +2 -0
- package/dist/reference/resources.js +41 -0
- package/dist/reference/resources.js.map +1 -0
- package/dist/reference/tool.d.ts +21 -0
- package/dist/reference/tool.js +50 -0
- package/dist/reference/tool.js.map +1 -0
- package/dist/reference/topics.d.ts +29 -0
- package/dist/reference/topics.js +91 -0
- package/dist/reference/topics.js.map +1 -0
- package/dist/reference.d.ts +9 -0
- package/dist/reference.js +20 -0
- package/dist/reference.js.map +1 -0
- package/dist/server.d.ts +29 -0
- package/dist/server.js +75 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/account.d.ts +34 -0
- package/dist/tools/account.js +128 -0
- package/dist/tools/account.js.map +1 -0
- package/dist/tools/builds.d.ts +95 -0
- package/dist/tools/builds.js +403 -0
- package/dist/tools/builds.js.map +1 -0
- package/dist/tools/files.d.ts +71 -0
- package/dist/tools/files.js +205 -0
- package/dist/tools/files.js.map +1 -0
- package/dist/tools/forms.d.ts +59 -0
- package/dist/tools/forms.js +177 -0
- package/dist/tools/forms.js.map +1 -0
- package/dist/tools/posts.d.ts +191 -0
- package/dist/tools/posts.js +600 -0
- package/dist/tools/posts.js.map +1 -0
- package/dist/tools/projects.d.ts +201 -0
- package/dist/tools/projects.js +553 -0
- package/dist/tools/projects.js.map +1 -0
- package/dist/tools/shared.d.ts +33 -0
- package/dist/tools/shared.js +41 -0
- package/dist/tools/shared.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +8 -0
- package/dist/version.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { McpServer, ServerContext } from "@modelcontextprotocol/server";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { type Clock } from "../client/deploy-events.js";
|
|
4
|
+
import type { ToolContext } from "../context.js";
|
|
5
|
+
/** Swappable in tests so the poll loop runs on a fake clock. */
|
|
6
|
+
export declare const buildToolsClock: {
|
|
7
|
+
current: Clock;
|
|
8
|
+
};
|
|
9
|
+
export declare const PublishBuildInput: z.ZodObject<{
|
|
10
|
+
project: z.ZodString;
|
|
11
|
+
build: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
12
|
+
confirm: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const PublishBuildOutput: z.ZodObject<{
|
|
15
|
+
project_id: z.ZodNumber;
|
|
16
|
+
build: z.ZodObject<{
|
|
17
|
+
id: z.ZodNumber;
|
|
18
|
+
number: z.ZodNullable<z.ZodNumber>;
|
|
19
|
+
previous_status: z.ZodNullable<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
status: z.ZodLiteral<"publishing">;
|
|
22
|
+
active_build_changed: z.ZodBoolean;
|
|
23
|
+
previous_active_build_id: z.ZodNullable<z.ZodNumber>;
|
|
24
|
+
after_event_id: z.ZodNumber;
|
|
25
|
+
plan_tier: z.ZodNullable<z.ZodEnum<{
|
|
26
|
+
free: "free";
|
|
27
|
+
pro: "pro";
|
|
28
|
+
pro_plus: "pro_plus";
|
|
29
|
+
}>>;
|
|
30
|
+
eta_seconds: z.ZodNumber;
|
|
31
|
+
eta: z.ZodString;
|
|
32
|
+
live_url: z.ZodNullable<z.ZodString>;
|
|
33
|
+
next: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type PublishBuildResult = z.infer<typeof PublishBuildOutput>;
|
|
36
|
+
export declare function runPublishBuild(ctx: ToolContext, args: z.infer<typeof PublishBuildInput>, nowMs?: number): Promise<PublishBuildResult>;
|
|
37
|
+
/** Kept well under the 60 s request timeout most MCP clients apply. */
|
|
38
|
+
export declare const MAX_WAIT_SECONDS = 45;
|
|
39
|
+
export declare const DEFAULT_WAIT_SECONDS = 20;
|
|
40
|
+
export declare const MAX_RETURNED_EVENTS = 100;
|
|
41
|
+
export declare const GetDeployStatusInput: z.ZodObject<{
|
|
42
|
+
project: z.ZodString;
|
|
43
|
+
build: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
44
|
+
after_event_id: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
wait_seconds: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
}, z.core.$strict>;
|
|
47
|
+
export declare const GetDeployStatusOutput: z.ZodObject<{
|
|
48
|
+
project_id: z.ZodNumber;
|
|
49
|
+
build: z.ZodObject<{
|
|
50
|
+
id: z.ZodNumber;
|
|
51
|
+
number: z.ZodNullable<z.ZodNumber>;
|
|
52
|
+
status: z.ZodNullable<z.ZodString>;
|
|
53
|
+
failure_reason: z.ZodNullable<z.ZodString>;
|
|
54
|
+
updated_at: z.ZodNullable<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
events: z.ZodArray<z.ZodObject<{
|
|
57
|
+
id: z.ZodNumber;
|
|
58
|
+
type: z.ZodString;
|
|
59
|
+
message: z.ZodString;
|
|
60
|
+
created_at: z.ZodNullable<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
events_truncated: z.ZodBoolean;
|
|
63
|
+
after_event_id: z.ZodNumber;
|
|
64
|
+
done: z.ZodBoolean;
|
|
65
|
+
succeeded: z.ZodNullable<z.ZodBoolean>;
|
|
66
|
+
waiting_for_start: z.ZodBoolean;
|
|
67
|
+
possibly_stuck: z.ZodBoolean;
|
|
68
|
+
live_url: z.ZodNullable<z.ZodString>;
|
|
69
|
+
next: z.ZodString;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
export type GetDeployStatusResult = z.infer<typeof GetDeployStatusOutput>;
|
|
72
|
+
/** Grace on top of the queue delay before a silent publish is called possibly stuck. */
|
|
73
|
+
export declare const STUCK_GRACE_MS: number;
|
|
74
|
+
export declare function runGetDeployStatus(ctx: ToolContext, args: z.infer<typeof GetDeployStatusInput>, handlerCtx?: ServerContext, clock?: Clock): Promise<GetDeployStatusResult>;
|
|
75
|
+
export declare const ListBuildsInput: z.ZodObject<{
|
|
76
|
+
project: z.ZodString;
|
|
77
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
export declare const ListBuildsOutput: z.ZodObject<{
|
|
80
|
+
project_id: z.ZodNumber;
|
|
81
|
+
active_build_id: z.ZodNullable<z.ZodNumber>;
|
|
82
|
+
builds: z.ZodArray<z.ZodObject<{
|
|
83
|
+
id: z.ZodNumber;
|
|
84
|
+
number: z.ZodNullable<z.ZodNumber>;
|
|
85
|
+
status: z.ZodNullable<z.ZodString>;
|
|
86
|
+
created_at: z.ZodNullable<z.ZodString>;
|
|
87
|
+
updated_at: z.ZodNullable<z.ZodString>;
|
|
88
|
+
failure_reason: z.ZodNullable<z.ZodString>;
|
|
89
|
+
active: z.ZodBoolean;
|
|
90
|
+
}, z.core.$strip>>;
|
|
91
|
+
count: z.ZodNumber;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
export type ListBuildsResult = z.infer<typeof ListBuildsOutput>;
|
|
94
|
+
export declare function runListBuilds(ctx: ToolContext, args: z.infer<typeof ListBuildsInput>): Promise<ListBuildsResult>;
|
|
95
|
+
export declare function registerBuildTools(server: McpServer, ctx: ToolContext): void;
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { OUT, RO } from "../annotations.js";
|
|
3
|
+
import { BUILD_ROW_COLUMNS, BuildRefInput, IN_PROGRESS_STATUSES, findBuild, findPublishingBuild, getBuildById, invokePublishBuild, parseBuildRef, setActiveBuild, } from "../client/builds.js";
|
|
4
|
+
import { getLatestDeployEventAt, getMaxDeployEventId, pollDeployStatus, realClock, } from "../client/deploy-events.js";
|
|
5
|
+
import { MicropageError } from "../client/errors.js";
|
|
6
|
+
import { eq } from "../client/http.js";
|
|
7
|
+
import { ProjectRef, resolveProject } from "../client/project-ref.js";
|
|
8
|
+
import { requireConfirm } from "../guards.js";
|
|
9
|
+
import { reportProgress } from "../progress.js";
|
|
10
|
+
import { gateTool, structuredResult } from "./shared.js";
|
|
11
|
+
/** Swappable in tests so the poll loop runs on a fake clock. */
|
|
12
|
+
export const buildToolsClock = { current: realClock };
|
|
13
|
+
const DEPLOY_GOTCHAS = "Right after deployment.completed the URL can still serve the previous version for a minute or so while Cloudflare " +
|
|
14
|
+
"updates its alias, and page paths redirect (308) to a trailing slash, so fetch with redirects followed (curl -L).";
|
|
15
|
+
async function resolveTargetBuild(ctx, project, ref) {
|
|
16
|
+
if (ref !== undefined)
|
|
17
|
+
return findBuild(ctx.http, project.id, parseBuildRef(ref));
|
|
18
|
+
if (project.active_build_id === null) {
|
|
19
|
+
throw new MicropageError("NO_BUILD", "This project has no active build yet. Call save_page to create a draft first.");
|
|
20
|
+
}
|
|
21
|
+
const row = await getBuildById(ctx.http, project.id, project.active_build_id, BUILD_ROW_COLUMNS);
|
|
22
|
+
if (!row) {
|
|
23
|
+
throw new MicropageError("BUILD_NOT_FOUND", "The project's active build no longer exists. Call list_builds and pass `build`.");
|
|
24
|
+
}
|
|
25
|
+
return row;
|
|
26
|
+
}
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// publish_build
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
export const PublishBuildInput = z
|
|
31
|
+
.object({
|
|
32
|
+
project: ProjectRef,
|
|
33
|
+
build: BuildRefInput.optional().describe("Which build to publish: the id save_page returned (\"id:4567\") or a build number (\"v12\" or 12). Defaults to " +
|
|
34
|
+
"the project's active build. Naming an older build republishes that snapshot and makes it the active build."),
|
|
35
|
+
confirm: z
|
|
36
|
+
.boolean()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Must be true. Publishing changes the public site; ask the user before setting it."),
|
|
39
|
+
})
|
|
40
|
+
.strict();
|
|
41
|
+
export const PublishBuildOutput = z.object({
|
|
42
|
+
project_id: z.number(),
|
|
43
|
+
build: z.object({
|
|
44
|
+
id: z.number(),
|
|
45
|
+
number: z.number().nullable(),
|
|
46
|
+
previous_status: z.string().nullable().describe("The build's status before this publish."),
|
|
47
|
+
}),
|
|
48
|
+
status: z.literal("publishing"),
|
|
49
|
+
active_build_changed: z.boolean().describe("True when the named build was not the active build and was made active."),
|
|
50
|
+
previous_active_build_id: z.number().nullable(),
|
|
51
|
+
after_event_id: z.number().describe("Pass to get_deploy_status so it only reports events from this publish."),
|
|
52
|
+
plan_tier: z.enum(["free", "pro", "pro_plus"]).nullable(),
|
|
53
|
+
eta_seconds: z.number().describe("Rough time until the site is live."),
|
|
54
|
+
eta: z.string(),
|
|
55
|
+
live_url: z.string().nullable(),
|
|
56
|
+
next: z.string(),
|
|
57
|
+
});
|
|
58
|
+
function etaFor(tier) {
|
|
59
|
+
if (tier === "pro_plus") {
|
|
60
|
+
return { eta_seconds: 90, eta: "Pro+ builds start right away; usually live in 1-2 minutes." };
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
eta_seconds: 270,
|
|
64
|
+
eta: "Builds wait about 3 minutes in the queue on this plan (Pro+ skips the wait), then take 1-2 minutes; " +
|
|
65
|
+
"expect the site in about 4-5 minutes.",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Puts the previous active build back after a publish that did not start, so
|
|
70
|
+
* a failed publish_build leaves the project as it found it. Best effort: the
|
|
71
|
+
* returned error says whether the restore worked.
|
|
72
|
+
*/
|
|
73
|
+
async function restoreActiveBuild(ctx, project, cause) {
|
|
74
|
+
const previous = project.active_build_id;
|
|
75
|
+
const base = cause instanceof MicropageError ? cause : null;
|
|
76
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
77
|
+
let note;
|
|
78
|
+
try {
|
|
79
|
+
await setActiveBuild(ctx.http, project.id, previous);
|
|
80
|
+
note =
|
|
81
|
+
previous === null
|
|
82
|
+
? "The project's active build was reset to none, as before. Nothing was published."
|
|
83
|
+
: `The project's active build was restored to id ${previous}, as before. Nothing was published.`;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
note =
|
|
87
|
+
`Restoring the previous active build (id ${previous ?? "none"}) also failed, so the build named here is still ` +
|
|
88
|
+
"the active build. Call list_builds to check, and publish_build again or pick the build to keep.";
|
|
89
|
+
}
|
|
90
|
+
return new MicropageError(base?.code ?? "PUBLISH_FAILED", `Starting the publish failed: ${reason} ${note}`, {
|
|
91
|
+
...(base?.status === undefined ? {} : { status: base.status }),
|
|
92
|
+
data: base?.data,
|
|
93
|
+
cause,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
export async function runPublishBuild(ctx, args, nowMs = Date.now()) {
|
|
97
|
+
requireConfirm(args, "Publishing a build");
|
|
98
|
+
await gateTool(ctx, "publish_build");
|
|
99
|
+
const project = await resolveProject(ctx, args.project);
|
|
100
|
+
const target = await resolveTargetBuild(ctx, project, args.build);
|
|
101
|
+
const running = await findPublishingBuild(ctx.http, project.id, nowMs);
|
|
102
|
+
if (running) {
|
|
103
|
+
throw new MicropageError("PUBLISH_IN_PROGRESS", `Build v${running.number ?? "?"} (id ${running.id}) of this project is still publishing. Wait for it: call ` +
|
|
104
|
+
`get_deploy_status with build "id:${running.id}", then retry. Nothing was changed.`);
|
|
105
|
+
}
|
|
106
|
+
if (!target.status) {
|
|
107
|
+
throw new MicropageError("BUILD_NOT_FOUND", `Build id ${target.id} has no status. Call list_builds and pick another build.`);
|
|
108
|
+
}
|
|
109
|
+
const activeChanged = target.id !== project.active_build_id;
|
|
110
|
+
if (activeChanged)
|
|
111
|
+
await setActiveBuild(ctx.http, project.id, target.id);
|
|
112
|
+
let afterEventId;
|
|
113
|
+
try {
|
|
114
|
+
afterEventId = await getMaxDeployEventId(ctx.http, target.id);
|
|
115
|
+
await invokePublishBuild(ctx.http, project.id, target.id);
|
|
116
|
+
}
|
|
117
|
+
catch (err) {
|
|
118
|
+
if (!activeChanged)
|
|
119
|
+
throw err;
|
|
120
|
+
throw await restoreActiveBuild(ctx, project, err);
|
|
121
|
+
}
|
|
122
|
+
let tier = null;
|
|
123
|
+
try {
|
|
124
|
+
tier = await ctx.tier.getPlanTier();
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// Only feeds the ETA.
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
project_id: project.id,
|
|
131
|
+
build: { id: target.id, number: target.number ?? null, previous_status: target.status },
|
|
132
|
+
status: "publishing",
|
|
133
|
+
active_build_changed: activeChanged,
|
|
134
|
+
previous_active_build_id: activeChanged ? project.active_build_id : null,
|
|
135
|
+
after_event_id: afterEventId,
|
|
136
|
+
plan_tier: tier,
|
|
137
|
+
...etaFor(tier),
|
|
138
|
+
live_url: project.live_url,
|
|
139
|
+
next: `Publishing started; it is not live yet. Call get_deploy_status with build "id:${target.id}" and ` +
|
|
140
|
+
`after_event_id ${afterEventId} to follow it until done is true.`,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
// get_deploy_status
|
|
145
|
+
// ---------------------------------------------------------------------------
|
|
146
|
+
/** Kept well under the 60 s request timeout most MCP clients apply. */
|
|
147
|
+
export const MAX_WAIT_SECONDS = 45;
|
|
148
|
+
export const DEFAULT_WAIT_SECONDS = 20;
|
|
149
|
+
export const MAX_RETURNED_EVENTS = 100;
|
|
150
|
+
export const GetDeployStatusInput = z
|
|
151
|
+
.object({
|
|
152
|
+
project: ProjectRef,
|
|
153
|
+
build: BuildRefInput.optional().describe("The build being published (publish_build returns it as \"id:<id>\"). Defaults to the project's active build."),
|
|
154
|
+
after_event_id: z
|
|
155
|
+
.number()
|
|
156
|
+
.int()
|
|
157
|
+
.nonnegative()
|
|
158
|
+
.optional()
|
|
159
|
+
.describe("Only report events after this id: pass publish_build's after_event_id, then the after_event_id this tool " +
|
|
160
|
+
"returned on the previous call. Omit it to see the build's whole event history; completion is then judged from the build status alone."),
|
|
161
|
+
wait_seconds: z
|
|
162
|
+
.number()
|
|
163
|
+
.int()
|
|
164
|
+
.min(0)
|
|
165
|
+
.max(MAX_WAIT_SECONDS)
|
|
166
|
+
.optional()
|
|
167
|
+
.describe(`How long to wait for the deploy to finish before returning, 0-${MAX_WAIT_SECONDS} (default ${DEFAULT_WAIT_SECONDS}). 0 returns a snapshot at once.`),
|
|
168
|
+
})
|
|
169
|
+
.strict();
|
|
170
|
+
const DeployEventOut = z.object({
|
|
171
|
+
id: z.number(),
|
|
172
|
+
type: z.string().describe("e.g. build.enqueued, deployment.started, deployment.domain_wiring, deployment.completed, build.failed."),
|
|
173
|
+
message: z.string(),
|
|
174
|
+
created_at: z.string().nullable(),
|
|
175
|
+
});
|
|
176
|
+
export const GetDeployStatusOutput = z.object({
|
|
177
|
+
project_id: z.number(),
|
|
178
|
+
build: z.object({
|
|
179
|
+
id: z.number(),
|
|
180
|
+
number: z.number().nullable(),
|
|
181
|
+
status: z.string().nullable().describe("draft, publishing, deployed or failed."),
|
|
182
|
+
failure_reason: z.string().nullable(),
|
|
183
|
+
updated_at: z.string().nullable(),
|
|
184
|
+
}),
|
|
185
|
+
events: z.array(DeployEventOut).describe("New events since after_event_id, oldest first."),
|
|
186
|
+
events_truncated: z.boolean().describe("True when older events were left out to keep the reply short."),
|
|
187
|
+
after_event_id: z.number().describe("Cursor for the next call."),
|
|
188
|
+
done: z
|
|
189
|
+
.boolean()
|
|
190
|
+
.describe("True when the publish finished (deployed or failed). With after_event_id only a deploy event after it counts; " +
|
|
191
|
+
"without, true also when the build is simply not publishing."),
|
|
192
|
+
succeeded: z.boolean().nullable().describe("True when deployed, false when failed, null while still running."),
|
|
193
|
+
waiting_for_start: z
|
|
194
|
+
.boolean()
|
|
195
|
+
.describe("True when after_event_id was given but the deploy has not started yet: a site rebuild after a post change is " +
|
|
196
|
+
"queued (up to about 3 minutes unless the account is Pro+) and only then shows events."),
|
|
197
|
+
possibly_stuck: z
|
|
198
|
+
.boolean()
|
|
199
|
+
.describe("True when the build has been publishing with no deploy events for much longer than a deploy takes."),
|
|
200
|
+
live_url: z.string().nullable(),
|
|
201
|
+
next: z.string(),
|
|
202
|
+
});
|
|
203
|
+
/** Grace on top of the queue delay before a silent publish is called possibly stuck. */
|
|
204
|
+
export const STUCK_GRACE_MS = 5 * 60 * 1000;
|
|
205
|
+
const QUEUE_DELAY_MS = 3 * 60 * 1000;
|
|
206
|
+
/**
|
|
207
|
+
* A build sitting in publishing with no deploy event for longer than the
|
|
208
|
+
* queue delay plus STUCK_GRACE_MS: most likely the publisher webhook never
|
|
209
|
+
* arrived, which nothing on the server retries.
|
|
210
|
+
*/
|
|
211
|
+
async function looksStuck(ctx, build, nowMs) {
|
|
212
|
+
let tier = null;
|
|
213
|
+
try {
|
|
214
|
+
tier = await ctx.tier.getPlanTier();
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
// Unknown plan: assume the queue delay applies.
|
|
218
|
+
}
|
|
219
|
+
const threshold = (tier === "pro_plus" ? 0 : QUEUE_DELAY_MS) + STUCK_GRACE_MS;
|
|
220
|
+
const lastEventAt = await getLatestDeployEventAt(ctx.http, build.id).catch(() => null);
|
|
221
|
+
const times = [build.updated_at, lastEventAt].map((t) => (t ? Date.parse(t) : Number.NaN)).filter((t) => !Number.isNaN(t));
|
|
222
|
+
if (times.length === 0)
|
|
223
|
+
return false;
|
|
224
|
+
return nowMs - Math.max(...times) > threshold;
|
|
225
|
+
}
|
|
226
|
+
export async function runGetDeployStatus(ctx, args, handlerCtx, clock = buildToolsClock.current) {
|
|
227
|
+
await gateTool(ctx, "get_deploy_status");
|
|
228
|
+
const project = await resolveProject(ctx, args.project);
|
|
229
|
+
const target = await resolveTargetBuild(ctx, project, args.build);
|
|
230
|
+
const waitSeconds = Math.min(args.wait_seconds ?? DEFAULT_WAIT_SECONDS, MAX_WAIT_SECONDS);
|
|
231
|
+
const cursorGiven = args.after_event_id !== undefined;
|
|
232
|
+
const poll = await pollDeployStatus({
|
|
233
|
+
http: ctx.http,
|
|
234
|
+
projectId: project.id,
|
|
235
|
+
buildId: target.id,
|
|
236
|
+
afterId: args.after_event_id ?? 0,
|
|
237
|
+
waitMs: waitSeconds * 1000,
|
|
238
|
+
clock,
|
|
239
|
+
// Without a cursor, a terminal event from an earlier publish of the same
|
|
240
|
+
// build would look like this one finishing; trust the status instead.
|
|
241
|
+
trustEvents: cursorGiven,
|
|
242
|
+
onPoll: handlerCtx
|
|
243
|
+
? async ({ elapsedMs, status, newEvents }) => {
|
|
244
|
+
const last = newEvents[newEvents.length - 1];
|
|
245
|
+
await reportProgress(handlerCtx, Math.min(waitSeconds, Math.round(elapsedMs / 1000)), waitSeconds, last ? last.message : `status: ${status ?? "unknown"}`);
|
|
246
|
+
}
|
|
247
|
+
: undefined,
|
|
248
|
+
});
|
|
249
|
+
const events = poll.events.slice(-MAX_RETURNED_EVENTS);
|
|
250
|
+
const b = poll.build;
|
|
251
|
+
const terminalType = poll.terminal_event?.type;
|
|
252
|
+
const succeeded = !poll.done
|
|
253
|
+
? null
|
|
254
|
+
: terminalType === "build.failed" || (!terminalType && b.status === "failed")
|
|
255
|
+
? false
|
|
256
|
+
: terminalType === "deployment.completed" || b.status === "deployed"
|
|
257
|
+
? true
|
|
258
|
+
: null;
|
|
259
|
+
const inProgress = IN_PROGRESS_STATUSES.has(b.status ?? "");
|
|
260
|
+
const possiblyStuck = !poll.done && inProgress && (await looksStuck(ctx, b, Date.now()));
|
|
261
|
+
const again = `Call get_deploy_status again with build "id:${b.id}" and after_event_id ${poll.after_event_id}.`;
|
|
262
|
+
let next;
|
|
263
|
+
if (poll.waiting_for_start) {
|
|
264
|
+
next =
|
|
265
|
+
`Waiting for the rebuild to start: build v${b.number ?? "?"} is ${b.status ?? "in an unknown state"} and no deploy ` +
|
|
266
|
+
"event has arrived since after_event_id. Site rebuilds are queued for up to about 3 minutes unless the account is " +
|
|
267
|
+
`Pro+, so this is expected at first. Nothing is live from this change yet. ${again}`;
|
|
268
|
+
}
|
|
269
|
+
else if (!poll.done) {
|
|
270
|
+
next = possiblyStuck
|
|
271
|
+
? `Build v${b.number ?? "?"} has been publishing with no deploy events for much longer than a deploy takes, so it is ` +
|
|
272
|
+
"possibly stuck (the publisher webhook may have failed). Tell the user and retry with publish_build; it accepts " +
|
|
273
|
+
`the retry once the build has been publishing for 30 minutes. Until then, ${again[0].toLowerCase()}${again.slice(1)}`
|
|
274
|
+
: `Still publishing. ${again}`;
|
|
275
|
+
}
|
|
276
|
+
else if (succeeded === true) {
|
|
277
|
+
next = `Deployed${project.live_url ? ` to ${project.live_url}` : ""}. ${DEPLOY_GOTCHAS}`;
|
|
278
|
+
}
|
|
279
|
+
else if (succeeded === false) {
|
|
280
|
+
next = `The publish failed${b.failure_reason ? `: ${b.failure_reason}` : ""}. Fix the source with save_page, then publish again.`;
|
|
281
|
+
}
|
|
282
|
+
else if (cursorGiven) {
|
|
283
|
+
next = `Build v${b.number ?? "?"} is ${b.status ?? "in an unknown state"}; the publish ended without a deploy event. Call list_builds or get_project to check what is live.`;
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
next = `Build v${b.number ?? "?"} is ${b.status ?? "in an unknown state"}, not publishing. Call publish_build to publish it.`;
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
project_id: project.id,
|
|
290
|
+
build: {
|
|
291
|
+
id: b.id,
|
|
292
|
+
number: b.number ?? null,
|
|
293
|
+
status: b.status ?? null,
|
|
294
|
+
failure_reason: b.failure_reason ?? null,
|
|
295
|
+
updated_at: b.updated_at ?? null,
|
|
296
|
+
},
|
|
297
|
+
events,
|
|
298
|
+
events_truncated: poll.events.length > events.length,
|
|
299
|
+
after_event_id: poll.after_event_id,
|
|
300
|
+
done: poll.done,
|
|
301
|
+
succeeded,
|
|
302
|
+
waiting_for_start: poll.waiting_for_start,
|
|
303
|
+
possibly_stuck: possiblyStuck,
|
|
304
|
+
live_url: project.live_url,
|
|
305
|
+
next,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
// ---------------------------------------------------------------------------
|
|
309
|
+
// list_builds
|
|
310
|
+
// ---------------------------------------------------------------------------
|
|
311
|
+
export const ListBuildsInput = z
|
|
312
|
+
.object({
|
|
313
|
+
project: ProjectRef,
|
|
314
|
+
limit: z.number().int().min(1).max(100).optional().describe("How many builds to return, newest first (default 20, max 100)."),
|
|
315
|
+
})
|
|
316
|
+
.strict();
|
|
317
|
+
export const ListBuildsOutput = z.object({
|
|
318
|
+
project_id: z.number(),
|
|
319
|
+
active_build_id: z.number().nullable(),
|
|
320
|
+
builds: z.array(z.object({
|
|
321
|
+
id: z.number(),
|
|
322
|
+
number: z.number().nullable(),
|
|
323
|
+
status: z.string().nullable().describe("draft, publishing, deployed or failed."),
|
|
324
|
+
created_at: z.string().nullable(),
|
|
325
|
+
updated_at: z.string().nullable(),
|
|
326
|
+
failure_reason: z.string().nullable(),
|
|
327
|
+
active: z.boolean().describe("The project's active build: what the editor shows and publish_build defaults to."),
|
|
328
|
+
})),
|
|
329
|
+
count: z.number(),
|
|
330
|
+
});
|
|
331
|
+
export async function runListBuilds(ctx, args) {
|
|
332
|
+
await gateTool(ctx, "list_builds");
|
|
333
|
+
const project = await resolveProject(ctx, args.project);
|
|
334
|
+
const rows = await ctx.http.select("builds", {
|
|
335
|
+
select: BUILD_ROW_COLUMNS,
|
|
336
|
+
filters: { project_id: eq(project.id) },
|
|
337
|
+
order: "number.desc",
|
|
338
|
+
limit: args.limit ?? 20,
|
|
339
|
+
});
|
|
340
|
+
const builds = rows.map((r) => ({
|
|
341
|
+
id: r.id,
|
|
342
|
+
number: r.number ?? null,
|
|
343
|
+
status: r.status ?? null,
|
|
344
|
+
created_at: r.created_at ?? null,
|
|
345
|
+
updated_at: r.updated_at ?? null,
|
|
346
|
+
failure_reason: r.failure_reason ?? null,
|
|
347
|
+
active: r.id === project.active_build_id,
|
|
348
|
+
}));
|
|
349
|
+
return { project_id: project.id, active_build_id: project.active_build_id, builds, count: builds.length };
|
|
350
|
+
}
|
|
351
|
+
// ---------------------------------------------------------------------------
|
|
352
|
+
export function registerBuildTools(server, ctx) {
|
|
353
|
+
server.registerTool("publish_build", {
|
|
354
|
+
title: "Publish a build to the live site",
|
|
355
|
+
description: `Deploy a micropage build to the project's public URL. This changes what visitors see, so only call it when the user explicitly asks to publish, and pass confirm: true.
|
|
356
|
+
|
|
357
|
+
Defaults to the active build (the draft save_page just wrote); pass \`build\` with the id save_page returned to be exact, or an older build number to roll back to it (that build becomes active). Refused while another build of the project is still publishing.
|
|
358
|
+
|
|
359
|
+
It returns at once with status publishing, after_event_id and an ETA (builds wait about 3 minutes in the queue unless the account is Pro+). Then call get_deploy_status with that build and after_event_id to follow it to the end. It does not save source; call save_page first.`,
|
|
360
|
+
inputSchema: PublishBuildInput,
|
|
361
|
+
outputSchema: PublishBuildOutput,
|
|
362
|
+
annotations: OUT,
|
|
363
|
+
}, async (args) => {
|
|
364
|
+
const result = await runPublishBuild(ctx, args);
|
|
365
|
+
return structuredResult(result, `Publishing build v${result.build.number ?? "?"} (id ${result.build.id}). ${result.eta} Follow it with get_deploy_status.`);
|
|
366
|
+
});
|
|
367
|
+
server.registerTool("get_deploy_status", {
|
|
368
|
+
title: "Follow a micropage deploy",
|
|
369
|
+
description: `Report the progress of a publish: the build status, the deploy events since after_event_id (queued, built, uploaded, domain wiring, completed or failed), whether it is done, and the live URL.
|
|
370
|
+
|
|
371
|
+
Call it after publish_build or publish_post, passing the build and after_event_id they returned, and keep calling it with the returned after_event_id until done is true. With after_event_id, only a deploy event after it ends the wait: a site rebuild after a post change is queued (up to about 3 minutes unless the account is Pro+) and reports waiting_for_start until it begins. It waits up to wait_seconds (default ${DEFAULT_WAIT_SECONDS}, max ${MAX_WAIT_SECONDS}) per call, sending progress notifications meanwhile. possibly_stuck flags a publish with no events for far longer than a deploy takes.
|
|
372
|
+
|
|
373
|
+
When it reports success: ${DEPLOY_GOTCHAS} Read-only; it never starts or cancels a deploy.`,
|
|
374
|
+
inputSchema: GetDeployStatusInput,
|
|
375
|
+
outputSchema: GetDeployStatusOutput,
|
|
376
|
+
annotations: RO,
|
|
377
|
+
}, async (args, handlerCtx) => {
|
|
378
|
+
const result = await runGetDeployStatus(ctx, args, handlerCtx);
|
|
379
|
+
const state = result.waiting_for_start
|
|
380
|
+
? "waiting for the rebuild to start"
|
|
381
|
+
: result.possibly_stuck
|
|
382
|
+
? "publishing, possibly stuck"
|
|
383
|
+
: !result.done
|
|
384
|
+
? "still publishing"
|
|
385
|
+
: result.succeeded === true ? "deployed" : result.succeeded === false ? "failed" : result.build.status ?? "idle";
|
|
386
|
+
return structuredResult(result, `Build v${result.build.number ?? "?"}: ${state}.`);
|
|
387
|
+
});
|
|
388
|
+
server.registerTool("list_builds", {
|
|
389
|
+
title: "List a project's builds",
|
|
390
|
+
description: `List a micropage project's builds, newest first: number, id, status (draft, publishing, deployed, failed), created and updated times, failure reason, and which build is active.
|
|
391
|
+
|
|
392
|
+
Use it to find a build to roll back to with publish_build, to see why a publish failed, or to check whether a publish is still running. Each save_page that cannot overwrite a draft adds a build; publishing reuses the build.
|
|
393
|
+
|
|
394
|
+
Read-only. To read a build's source use get_page_source with its number; for what is live right now use get_project.`,
|
|
395
|
+
inputSchema: ListBuildsInput,
|
|
396
|
+
outputSchema: ListBuildsOutput,
|
|
397
|
+
annotations: RO,
|
|
398
|
+
}, async (args) => {
|
|
399
|
+
const result = await runListBuilds(ctx, args);
|
|
400
|
+
return structuredResult(result, `${result.count} build(s).`);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
//# sourceMappingURL=builds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builds.js","sourceRoot":"","sources":["../../src/tools/builds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,SAAS,EACT,mBAAmB,EACnB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,cAAc,GAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,SAAS,GAGV,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAgB,MAAM,0BAA0B,CAAC;AAGpF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEzD,gEAAgE;AAChE,MAAM,CAAC,MAAM,eAAe,GAAuB,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAE1E,MAAM,cAAc,GAClB,oHAAoH;IACpH,mHAAmH,CAAC;AAEtH,KAAK,UAAU,kBAAkB,CAC/B,GAAgB,EAChB,OAAgB,EAChB,GAAgC;IAEhC,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAW,GAAG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,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC;QACvH,OAAO,gBAAgB,CAAC,MAAM,EAAE,UAAU,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,KAAK,KAAK,GAAG,CAAC,CAAC;IACrF,CAAC,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,aAAa,EACb;QACE,KAAK,EAAE,yBAAyB;QAChC,WAAW,EAAE;;;;qHAIkG;QAC/G,WAAW,EAAE,eAAe;QAC5B,YAAY,EAAE,gBAAgB;QAC9B,WAAW,EAAE,EAAE;KAChB,EACD,KAAK,EAAE,IAAI,EAAE,EAAE;QACb,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,OAAO,gBAAgB,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,YAAY,CAAC,CAAC;IAC/D,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/server";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import type { FetchLike } from "../client/http.js";
|
|
4
|
+
import type { ToolContext } from "../context.js";
|
|
5
|
+
export declare const AssetSourceInput: z.ZodUnion<readonly [z.ZodObject<{
|
|
6
|
+
path: z.ZodString;
|
|
7
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
8
|
+
url: z.ZodString;
|
|
9
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
10
|
+
base64: z.ZodString;
|
|
11
|
+
}, z.core.$strict>]>;
|
|
12
|
+
export declare const UploadAssetInput: z.ZodObject<{
|
|
13
|
+
project: z.ZodString;
|
|
14
|
+
filename: z.ZodString;
|
|
15
|
+
source: z.ZodUnion<readonly [z.ZodObject<{
|
|
16
|
+
path: z.ZodString;
|
|
17
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
18
|
+
url: z.ZodString;
|
|
19
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
20
|
+
base64: z.ZodString;
|
|
21
|
+
}, z.core.$strict>]>;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
declare const UploadAssetOutput: z.ZodObject<{
|
|
24
|
+
filename: z.ZodString;
|
|
25
|
+
markup: z.ZodString;
|
|
26
|
+
url: z.ZodString;
|
|
27
|
+
deduped: z.ZodBoolean;
|
|
28
|
+
replaced: z.ZodBoolean;
|
|
29
|
+
file_id: z.ZodString;
|
|
30
|
+
size_bytes: z.ZodNumber;
|
|
31
|
+
mime_type: z.ZodString;
|
|
32
|
+
content_hash: z.ZodString;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type UploadAssetResult = z.infer<typeof UploadAssetOutput>;
|
|
35
|
+
export interface UploadAssetDeps {
|
|
36
|
+
/** fetch for `{url}` sources. Never the micropage-authenticated client. */
|
|
37
|
+
fetchExternal?: FetchLike;
|
|
38
|
+
}
|
|
39
|
+
export declare function runUploadAsset(ctx: ToolContext, args: z.infer<typeof UploadAssetInput>, deps?: UploadAssetDeps): Promise<UploadAssetResult>;
|
|
40
|
+
export declare const ListFilesInput: z.ZodObject<{
|
|
41
|
+
project: z.ZodString;
|
|
42
|
+
}, z.core.$strict>;
|
|
43
|
+
declare const ListFilesOutput: z.ZodObject<{
|
|
44
|
+
files: z.ZodArray<z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
filename: z.ZodNullable<z.ZodString>;
|
|
47
|
+
mime_type: z.ZodNullable<z.ZodString>;
|
|
48
|
+
size_bytes: z.ZodNullable<z.ZodNumber>;
|
|
49
|
+
content_hash: z.ZodNullable<z.ZodString>;
|
|
50
|
+
created_at: z.ZodNullable<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
count: z.ZodNumber;
|
|
53
|
+
used_bytes: z.ZodNumber;
|
|
54
|
+
limit_mb: z.ZodNumber;
|
|
55
|
+
limit_bytes: z.ZodNumber;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export type ListFilesResult = z.infer<typeof ListFilesOutput>;
|
|
58
|
+
export declare function runListFiles(ctx: ToolContext, args: z.infer<typeof ListFilesInput>): Promise<ListFilesResult>;
|
|
59
|
+
export declare const GetFileUrlInput: z.ZodObject<{
|
|
60
|
+
project: z.ZodString;
|
|
61
|
+
filename: z.ZodString;
|
|
62
|
+
}, z.core.$strict>;
|
|
63
|
+
declare const GetFileUrlOutput: z.ZodObject<{
|
|
64
|
+
filename: z.ZodString;
|
|
65
|
+
file_id: z.ZodString;
|
|
66
|
+
url: z.ZodString;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export type GetFileUrlResult = z.infer<typeof GetFileUrlOutput>;
|
|
69
|
+
export declare function runGetFileUrl(ctx: ToolContext, args: z.infer<typeof GetFileUrlInput>): Promise<GetFileUrlResult>;
|
|
70
|
+
export declare function registerFileTools(server: McpServer, ctx: ToolContext): void;
|
|
71
|
+
export {};
|