@ampless/mcp-server 0.2.0-alpha.4 → 0.2.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +148 -0
- package/README.md +3 -0
- package/dist/chunk-KM6F5QJH.js +552 -0
- package/dist/{dist-es-ZP52SD4G.js → dist-es-J4X5E4TX.js} +1 -1
- package/dist/index.js +10 -542
- package/dist/tools/index.d.ts +56 -0
- package/dist/tools/index.js +12 -0
- package/package.json +6 -2
- /package/dist/{dist-es-NAMW5ZZ4.js → dist-es-OKPWYZO7.js} +0 -0
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/tools/post-mapping.ts
|
|
4
|
+
var POST_FIELDS = (
|
|
5
|
+
/* GraphQL */
|
|
6
|
+
`
|
|
7
|
+
fragment PostFields on Post {
|
|
8
|
+
siteId
|
|
9
|
+
postId
|
|
10
|
+
slug
|
|
11
|
+
title
|
|
12
|
+
excerpt
|
|
13
|
+
format
|
|
14
|
+
body
|
|
15
|
+
status
|
|
16
|
+
publishedAt
|
|
17
|
+
tags
|
|
18
|
+
}
|
|
19
|
+
`
|
|
20
|
+
);
|
|
21
|
+
function decodeBody(value) {
|
|
22
|
+
if (typeof value !== "string") return value;
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(value);
|
|
25
|
+
} catch {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function encodeBody(value) {
|
|
30
|
+
if (typeof value === "string") return value;
|
|
31
|
+
return JSON.stringify(value ?? null);
|
|
32
|
+
}
|
|
33
|
+
function toCorePost(p) {
|
|
34
|
+
return {
|
|
35
|
+
siteId: p.siteId,
|
|
36
|
+
postId: p.postId,
|
|
37
|
+
slug: p.slug,
|
|
38
|
+
title: p.title,
|
|
39
|
+
excerpt: p.excerpt ?? void 0,
|
|
40
|
+
format: p.format ?? "markdown",
|
|
41
|
+
body: decodeBody(p.body),
|
|
42
|
+
status: p.status ?? "draft",
|
|
43
|
+
publishedAt: p.publishedAt ?? void 0,
|
|
44
|
+
tags: (p.tags ?? []).filter((t) => typeof t === "string")
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/tools/list-posts.ts
|
|
49
|
+
var QUERY = (
|
|
50
|
+
/* GraphQL */
|
|
51
|
+
`
|
|
52
|
+
${POST_FIELDS}
|
|
53
|
+
query ListPosts($filter: ModelPostFilterInput, $limit: Int, $nextToken: String) {
|
|
54
|
+
listPosts(filter: $filter, limit: $limit, nextToken: $nextToken) {
|
|
55
|
+
items {
|
|
56
|
+
...PostFields
|
|
57
|
+
}
|
|
58
|
+
nextToken
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`
|
|
62
|
+
);
|
|
63
|
+
var listPostsSchema = {
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: {
|
|
66
|
+
siteId: { type: "string", description: 'Site identifier (defaults to "default")' },
|
|
67
|
+
status: {
|
|
68
|
+
type: "string",
|
|
69
|
+
enum: ["draft", "published", "all"],
|
|
70
|
+
description: 'Filter by status (default "all")'
|
|
71
|
+
},
|
|
72
|
+
limit: { type: "integer", minimum: 1, maximum: 100, description: "Max results (default 20)" },
|
|
73
|
+
nextToken: { type: "string", description: "Pagination cursor from a previous call" }
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
async function listPosts(client, defaultSiteId, args = {}) {
|
|
77
|
+
const siteId = args.siteId ?? defaultSiteId;
|
|
78
|
+
const status = args.status ?? "all";
|
|
79
|
+
const filter = { siteId: { eq: siteId } };
|
|
80
|
+
if (status !== "all") filter.status = { eq: status };
|
|
81
|
+
const data = await client.query(QUERY, { filter, limit: args.limit ?? 20, nextToken: args.nextToken });
|
|
82
|
+
return {
|
|
83
|
+
posts: data.listPosts.items.map(toCorePost),
|
|
84
|
+
nextToken: data.listPosts.nextToken
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/tools/get-post.ts
|
|
89
|
+
var GET_BY_ID = (
|
|
90
|
+
/* GraphQL */
|
|
91
|
+
`
|
|
92
|
+
${POST_FIELDS}
|
|
93
|
+
query GetPost($siteId: String!, $postId: ID!) {
|
|
94
|
+
getPost(siteId: $siteId, postId: $postId) {
|
|
95
|
+
...PostFields
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
`
|
|
99
|
+
);
|
|
100
|
+
var LIST_BY_SLUG = (
|
|
101
|
+
/* GraphQL */
|
|
102
|
+
`
|
|
103
|
+
${POST_FIELDS}
|
|
104
|
+
query GetPostBySlug($filter: ModelPostFilterInput!) {
|
|
105
|
+
listPosts(filter: $filter, limit: 1) {
|
|
106
|
+
items {
|
|
107
|
+
...PostFields
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
`
|
|
112
|
+
);
|
|
113
|
+
var getPostSchema = {
|
|
114
|
+
type: "object",
|
|
115
|
+
properties: {
|
|
116
|
+
siteId: { type: "string", description: 'Site identifier (defaults to "default")' },
|
|
117
|
+
slug: { type: "string", description: "Post slug" },
|
|
118
|
+
postId: { type: "string", description: "Post id (used when slug is omitted)" }
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
async function getPost(client, defaultSiteId, args) {
|
|
122
|
+
if (!args.slug && !args.postId) {
|
|
123
|
+
throw new Error("get_post requires either `slug` or `postId`");
|
|
124
|
+
}
|
|
125
|
+
const siteId = args.siteId ?? defaultSiteId;
|
|
126
|
+
if (args.postId) {
|
|
127
|
+
const data2 = await client.query(GET_BY_ID, { siteId, postId: args.postId });
|
|
128
|
+
return data2.getPost ? toCorePost(data2.getPost) : null;
|
|
129
|
+
}
|
|
130
|
+
const data = await client.query(LIST_BY_SLUG, {
|
|
131
|
+
filter: { siteId: { eq: siteId }, slug: { eq: args.slug } }
|
|
132
|
+
});
|
|
133
|
+
const item = data.listPosts.items[0];
|
|
134
|
+
return item ? toCorePost(item) : null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/tools/create-post.ts
|
|
138
|
+
import { composeSiteIdStatus, composeSiteIdSlug } from "ampless";
|
|
139
|
+
|
|
140
|
+
// src/posttag.ts
|
|
141
|
+
function entries(post) {
|
|
142
|
+
if (post.status !== "published" || !post.publishedAt || !post.tags?.length) return [];
|
|
143
|
+
return post.tags.map((tag) => ({
|
|
144
|
+
siteIdTag: `${post.siteId}#${tag}`,
|
|
145
|
+
publishedAtPostId: `${post.publishedAt}#${post.postId}`
|
|
146
|
+
}));
|
|
147
|
+
}
|
|
148
|
+
function entryKey(e) {
|
|
149
|
+
return `${e.siteIdTag}|${e.publishedAtPostId}`;
|
|
150
|
+
}
|
|
151
|
+
var CREATE_POST_TAG = (
|
|
152
|
+
/* GraphQL */
|
|
153
|
+
`
|
|
154
|
+
mutation CreatePostTag($input: CreatePostTagInput!) {
|
|
155
|
+
createPostTag(input: $input) {
|
|
156
|
+
siteIdTag
|
|
157
|
+
publishedAtPostId
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
`
|
|
161
|
+
);
|
|
162
|
+
var UPDATE_POST_TAG = (
|
|
163
|
+
/* GraphQL */
|
|
164
|
+
`
|
|
165
|
+
mutation UpdatePostTag($input: UpdatePostTagInput!) {
|
|
166
|
+
updatePostTag(input: $input) {
|
|
167
|
+
siteIdTag
|
|
168
|
+
publishedAtPostId
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
`
|
|
172
|
+
);
|
|
173
|
+
var DELETE_POST_TAG = (
|
|
174
|
+
/* GraphQL */
|
|
175
|
+
`
|
|
176
|
+
mutation DeletePostTag($input: DeletePostTagInput!) {
|
|
177
|
+
deletePostTag(input: $input) {
|
|
178
|
+
siteIdTag
|
|
179
|
+
publishedAtPostId
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
`
|
|
183
|
+
);
|
|
184
|
+
async function syncPostTags(client, post, oldPost) {
|
|
185
|
+
const oldEntries = oldPost ? entries(oldPost) : [];
|
|
186
|
+
const newEntries = entries(post);
|
|
187
|
+
const oldKeys = new Set(oldEntries.map(entryKey));
|
|
188
|
+
const newKeys = new Set(newEntries.map(entryKey));
|
|
189
|
+
await Promise.all(
|
|
190
|
+
oldEntries.filter((e) => !newKeys.has(entryKey(e))).map(
|
|
191
|
+
(e) => client.query(DELETE_POST_TAG, {
|
|
192
|
+
input: { siteIdTag: e.siteIdTag, publishedAtPostId: e.publishedAtPostId }
|
|
193
|
+
})
|
|
194
|
+
)
|
|
195
|
+
);
|
|
196
|
+
await Promise.all(
|
|
197
|
+
newEntries.filter((e) => !oldKeys.has(entryKey(e))).map(
|
|
198
|
+
(e) => client.query(CREATE_POST_TAG, {
|
|
199
|
+
input: {
|
|
200
|
+
siteIdTag: e.siteIdTag,
|
|
201
|
+
publishedAtPostId: e.publishedAtPostId,
|
|
202
|
+
siteId: post.siteId,
|
|
203
|
+
tag: e.siteIdTag.slice(post.siteId.length + 1),
|
|
204
|
+
postId: post.postId,
|
|
205
|
+
publishedAt: post.publishedAt,
|
|
206
|
+
slug: post.slug,
|
|
207
|
+
title: post.title,
|
|
208
|
+
excerpt: post.excerpt,
|
|
209
|
+
tags: post.tags ?? []
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
)
|
|
213
|
+
);
|
|
214
|
+
await Promise.all(
|
|
215
|
+
newEntries.filter((e) => oldKeys.has(entryKey(e))).map(
|
|
216
|
+
(e) => client.query(UPDATE_POST_TAG, {
|
|
217
|
+
input: {
|
|
218
|
+
siteIdTag: e.siteIdTag,
|
|
219
|
+
publishedAtPostId: e.publishedAtPostId,
|
|
220
|
+
slug: post.slug,
|
|
221
|
+
title: post.title,
|
|
222
|
+
excerpt: post.excerpt,
|
|
223
|
+
tags: post.tags ?? []
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
)
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// src/tools/create-post.ts
|
|
231
|
+
var MUTATION = (
|
|
232
|
+
/* GraphQL */
|
|
233
|
+
`
|
|
234
|
+
${POST_FIELDS}
|
|
235
|
+
mutation CreatePost($input: CreatePostInput!) {
|
|
236
|
+
createPost(input: $input) {
|
|
237
|
+
...PostFields
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
`
|
|
241
|
+
);
|
|
242
|
+
var createPostSchema = {
|
|
243
|
+
type: "object",
|
|
244
|
+
required: ["slug", "title", "format", "body"],
|
|
245
|
+
properties: {
|
|
246
|
+
siteId: { type: "string", description: 'Site identifier (defaults to "default")' },
|
|
247
|
+
postId: { type: "string", description: "Optional explicit id; auto-generated if omitted" },
|
|
248
|
+
slug: { type: "string" },
|
|
249
|
+
title: { type: "string" },
|
|
250
|
+
format: { type: "string", enum: ["tiptap", "markdown", "html"] },
|
|
251
|
+
body: {
|
|
252
|
+
description: "tiptap JSON (when format=tiptap), markdown source string, or raw HTML string"
|
|
253
|
+
},
|
|
254
|
+
status: { type: "string", enum: ["draft", "published"], default: "draft" },
|
|
255
|
+
excerpt: { type: "string" },
|
|
256
|
+
publishedAt: { type: "string", description: "ISO 8601 timestamp; required when status=published" },
|
|
257
|
+
tags: { type: "array", items: { type: "string" } }
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
async function createPost(client, defaultSiteId, args) {
|
|
261
|
+
const siteId = args.siteId ?? defaultSiteId;
|
|
262
|
+
const postId = args.postId ?? `post-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
263
|
+
const status = args.status ?? "draft";
|
|
264
|
+
const publishedAt = args.publishedAt ?? (status === "published" ? (/* @__PURE__ */ new Date()).toISOString() : void 0);
|
|
265
|
+
const data = await client.query(MUTATION, {
|
|
266
|
+
input: {
|
|
267
|
+
siteId,
|
|
268
|
+
postId,
|
|
269
|
+
slug: args.slug,
|
|
270
|
+
title: args.title,
|
|
271
|
+
excerpt: args.excerpt,
|
|
272
|
+
format: args.format,
|
|
273
|
+
body: encodeBody(args.body),
|
|
274
|
+
status,
|
|
275
|
+
publishedAt,
|
|
276
|
+
tags: args.tags,
|
|
277
|
+
// Denormalized GSI keys.
|
|
278
|
+
siteIdStatus: composeSiteIdStatus(siteId, status),
|
|
279
|
+
siteIdSlug: composeSiteIdSlug(siteId, args.slug)
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
const created = toCorePost(data.createPost);
|
|
283
|
+
await syncPostTags(client, created, null);
|
|
284
|
+
return created;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/tools/update-post.ts
|
|
288
|
+
import { composeSiteIdStatus as composeSiteIdStatus2, composeSiteIdSlug as composeSiteIdSlug2 } from "ampless";
|
|
289
|
+
var MUTATION2 = (
|
|
290
|
+
/* GraphQL */
|
|
291
|
+
`
|
|
292
|
+
${POST_FIELDS}
|
|
293
|
+
mutation UpdatePost($input: UpdatePostInput!) {
|
|
294
|
+
updatePost(input: $input) {
|
|
295
|
+
...PostFields
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
`
|
|
299
|
+
);
|
|
300
|
+
var updatePostSchema = {
|
|
301
|
+
type: "object",
|
|
302
|
+
required: ["postId"],
|
|
303
|
+
properties: {
|
|
304
|
+
postId: { type: "string" },
|
|
305
|
+
siteId: { type: "string", description: 'Site identifier (defaults to "default")' },
|
|
306
|
+
slug: { type: "string" },
|
|
307
|
+
title: { type: "string" },
|
|
308
|
+
excerpt: { type: "string" },
|
|
309
|
+
format: { type: "string", enum: ["tiptap", "markdown", "html"] },
|
|
310
|
+
body: { description: "tiptap JSON, markdown source, or raw HTML" },
|
|
311
|
+
status: { type: "string", enum: ["draft", "published"] },
|
|
312
|
+
publishedAt: { type: "string", description: "ISO 8601 timestamp" },
|
|
313
|
+
tags: { type: "array", items: { type: "string" } }
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
async function updatePost(client, defaultSiteId, args) {
|
|
317
|
+
const siteId = args.siteId ?? defaultSiteId;
|
|
318
|
+
const oldPost = await getPost(client, defaultSiteId, { postId: args.postId, siteId });
|
|
319
|
+
const input = { siteId, postId: args.postId };
|
|
320
|
+
if (args.slug !== void 0) input.slug = args.slug;
|
|
321
|
+
if (args.title !== void 0) input.title = args.title;
|
|
322
|
+
if (args.excerpt !== void 0) input.excerpt = args.excerpt;
|
|
323
|
+
if (args.format !== void 0) input.format = args.format;
|
|
324
|
+
if (args.body !== void 0) input.body = encodeBody(args.body);
|
|
325
|
+
if (args.status !== void 0) input.status = args.status;
|
|
326
|
+
if (args.publishedAt !== void 0) input.publishedAt = args.publishedAt;
|
|
327
|
+
if (args.tags !== void 0) input.tags = args.tags;
|
|
328
|
+
if (args.status !== void 0) {
|
|
329
|
+
input.siteIdStatus = composeSiteIdStatus2(siteId, args.status);
|
|
330
|
+
}
|
|
331
|
+
if (args.slug !== void 0) {
|
|
332
|
+
input.siteIdSlug = composeSiteIdSlug2(siteId, args.slug);
|
|
333
|
+
}
|
|
334
|
+
const data = await client.query(MUTATION2, { input });
|
|
335
|
+
const updated = toCorePost(data.updatePost);
|
|
336
|
+
await syncPostTags(client, updated, oldPost);
|
|
337
|
+
return updated;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// src/tools/delete-post.ts
|
|
341
|
+
var MUTATION3 = (
|
|
342
|
+
/* GraphQL */
|
|
343
|
+
`
|
|
344
|
+
mutation DeletePost($input: DeletePostInput!) {
|
|
345
|
+
deletePost(input: $input) {
|
|
346
|
+
siteId
|
|
347
|
+
postId
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
`
|
|
351
|
+
);
|
|
352
|
+
var deletePostSchema = {
|
|
353
|
+
type: "object",
|
|
354
|
+
required: ["postId"],
|
|
355
|
+
properties: {
|
|
356
|
+
postId: { type: "string" },
|
|
357
|
+
siteId: { type: "string", description: 'Site identifier (defaults to "default")' }
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
async function deletePost(client, defaultSiteId, args) {
|
|
361
|
+
const siteId = args.siteId ?? defaultSiteId;
|
|
362
|
+
const oldPost = await getPost(client, defaultSiteId, { postId: args.postId, siteId });
|
|
363
|
+
if (oldPost) {
|
|
364
|
+
await syncPostTags(client, { ...oldPost, status: "draft" }, oldPost);
|
|
365
|
+
}
|
|
366
|
+
const data = await client.query(MUTATION3, { input: { siteId, postId: args.postId } });
|
|
367
|
+
return { deleted: data.deletePost };
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// src/tools/media-key.ts
|
|
371
|
+
function sanitizeName(name) {
|
|
372
|
+
return name.replace(/[\x00-\x1f\x7f]/g, "").replace(/[\\/:*?"<>|]/g, "_").replace(/\s+/g, "_").replace(/^\.+/, "_").slice(0, 200) || "upload";
|
|
373
|
+
}
|
|
374
|
+
function buildMediaKey(filename, now = /* @__PURE__ */ new Date()) {
|
|
375
|
+
const safe = sanitizeName(filename);
|
|
376
|
+
const yyyy = now.getFullYear();
|
|
377
|
+
const mm = String(now.getMonth() + 1).padStart(2, "0");
|
|
378
|
+
return `public/media/${yyyy}/${mm}/${now.getTime()}-${safe}`;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/tools/upload-media.ts
|
|
382
|
+
var MUTATION4 = (
|
|
383
|
+
/* GraphQL */
|
|
384
|
+
`
|
|
385
|
+
mutation CreateMedia($input: CreateMediaInput!) {
|
|
386
|
+
createMedia(input: $input) {
|
|
387
|
+
siteId
|
|
388
|
+
mediaId
|
|
389
|
+
src
|
|
390
|
+
mimeType
|
|
391
|
+
size
|
|
392
|
+
delivery
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
`
|
|
396
|
+
);
|
|
397
|
+
var uploadMediaSchema = {
|
|
398
|
+
type: "object",
|
|
399
|
+
required: ["filename", "mimeType", "base64Data"],
|
|
400
|
+
properties: {
|
|
401
|
+
siteId: { type: "string", description: 'Site identifier (defaults to "default")' },
|
|
402
|
+
filename: { type: "string", description: "Original filename; sanitized server-side" },
|
|
403
|
+
mimeType: {
|
|
404
|
+
type: "string",
|
|
405
|
+
description: "IANA media type (e.g. image/webp, image/jpeg). The MCP server does not transcode \u2014 pass the MIME of the bytes you actually send."
|
|
406
|
+
},
|
|
407
|
+
base64Data: {
|
|
408
|
+
type: "string",
|
|
409
|
+
description: "Base64-encoded file contents. NO data:URL prefix. The MCP server uploads bytes verbatim \u2014 resize/encode client-side first if needed."
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
async function uploadMedia(graphql, storage, defaultSiteId, args) {
|
|
414
|
+
const siteId = args.siteId ?? defaultSiteId;
|
|
415
|
+
const body = Buffer.from(args.base64Data, "base64");
|
|
416
|
+
const key = buildMediaKey(args.filename);
|
|
417
|
+
const url = await storage.putObject(key, body, args.mimeType);
|
|
418
|
+
const mediaId = `media-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
419
|
+
const data = await graphql.query(MUTATION4, {
|
|
420
|
+
input: {
|
|
421
|
+
siteId,
|
|
422
|
+
mediaId,
|
|
423
|
+
src: key,
|
|
424
|
+
mimeType: args.mimeType,
|
|
425
|
+
size: body.length,
|
|
426
|
+
delivery: "nextjs"
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
return { media: data.createMedia, url };
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// src/tools/get-schema.ts
|
|
433
|
+
var getSchemaSchema = {
|
|
434
|
+
type: "object",
|
|
435
|
+
properties: {}
|
|
436
|
+
};
|
|
437
|
+
function getSchema() {
|
|
438
|
+
return {
|
|
439
|
+
contentTypes: [
|
|
440
|
+
{
|
|
441
|
+
name: "post",
|
|
442
|
+
identifier: ["siteId", "postId"],
|
|
443
|
+
fields: {
|
|
444
|
+
siteId: { type: "string", required: true },
|
|
445
|
+
postId: { type: "string", required: true, description: "auto-generated if omitted on create" },
|
|
446
|
+
slug: { type: "string", required: true, description: "URL slug, unique per site" },
|
|
447
|
+
title: { type: "string", required: true },
|
|
448
|
+
excerpt: { type: "string" },
|
|
449
|
+
format: { type: "enum", values: ["tiptap", "markdown", "html"], required: true },
|
|
450
|
+
body: {
|
|
451
|
+
type: "json",
|
|
452
|
+
description: "tiptap node JSON when format=tiptap; markdown source string when format=markdown; raw HTML string when format=html"
|
|
453
|
+
},
|
|
454
|
+
status: { type: "enum", values: ["draft", "published"], default: "draft" },
|
|
455
|
+
publishedAt: { type: "datetime", description: "ISO 8601" },
|
|
456
|
+
tags: { type: "string[]" }
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
{
|
|
460
|
+
name: "page",
|
|
461
|
+
identifier: ["siteId", "pageId"],
|
|
462
|
+
fields: {
|
|
463
|
+
siteId: { type: "string", required: true },
|
|
464
|
+
pageId: { type: "string", required: true },
|
|
465
|
+
slug: { type: "string", required: true },
|
|
466
|
+
title: { type: "string", required: true },
|
|
467
|
+
format: { type: "enum", values: ["tiptap", "markdown", "html"], required: true },
|
|
468
|
+
body: { type: "json" },
|
|
469
|
+
status: { type: "enum", values: ["draft", "published"] },
|
|
470
|
+
publishedAt: { type: "datetime" }
|
|
471
|
+
}
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
name: "media",
|
|
475
|
+
identifier: ["siteId", "mediaId"],
|
|
476
|
+
fields: {
|
|
477
|
+
siteId: { type: "string", required: true },
|
|
478
|
+
mediaId: { type: "string", required: true },
|
|
479
|
+
src: { type: "string", required: true, description: "S3 key" },
|
|
480
|
+
mimeType: { type: "string", required: true },
|
|
481
|
+
size: { type: "integer" },
|
|
482
|
+
delivery: { type: "string" }
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
],
|
|
486
|
+
formats: ["tiptap", "markdown", "html"],
|
|
487
|
+
notes: {
|
|
488
|
+
editorTrust: 'editor stores arbitrary HTML/JS verbatim \u2014 same trust shape as WordPress unfiltered_html capability. See docs/architecture/04-access-layer-mcp.md \xA7"editor \u306E\u4FE1\u983C\u30E2\u30C7\u30EB".',
|
|
489
|
+
tiptapBody: 'When format=tiptap, body is the tiptap document JSON: { type: "doc", content: [...] }. The renderer expects this shape.'
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// src/tools/index.ts
|
|
495
|
+
var tools = [
|
|
496
|
+
{
|
|
497
|
+
name: "list_posts",
|
|
498
|
+
description: "List posts in the CMS with optional filters by status. Returns up to `limit` posts (default 20) plus a `nextToken` cursor for pagination.",
|
|
499
|
+
inputSchema: listPostsSchema,
|
|
500
|
+
handler: (args, ctx) => listPosts(ctx.graphql, ctx.defaultSiteId, args)
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
name: "get_post",
|
|
504
|
+
description: "Fetch a single post by slug or postId. Returns null if not found.",
|
|
505
|
+
inputSchema: getPostSchema,
|
|
506
|
+
handler: (args, ctx) => getPost(ctx.graphql, ctx.defaultSiteId, args)
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
name: "create_post",
|
|
510
|
+
description: "Create a new post. Title and slug are required. Body shape depends on format: tiptap=JSON node tree, markdown=source string, html=raw HTML string. Defaults to status=draft.",
|
|
511
|
+
inputSchema: createPostSchema,
|
|
512
|
+
handler: (args, ctx) => createPost(ctx.graphql, ctx.defaultSiteId, args)
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
name: "update_post",
|
|
516
|
+
description: "Update an existing post by postId. Only the fields you pass are changed. Tag list / publishedAt changes also update the PostTag denormalized index.",
|
|
517
|
+
inputSchema: updatePostSchema,
|
|
518
|
+
handler: (args, ctx) => updatePost(ctx.graphql, ctx.defaultSiteId, args)
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: "delete_post",
|
|
522
|
+
description: "Delete a post by postId. Also drops associated PostTag index entries.",
|
|
523
|
+
inputSchema: deletePostSchema,
|
|
524
|
+
handler: (args, ctx) => deletePost(ctx.graphql, ctx.defaultSiteId, args)
|
|
525
|
+
},
|
|
526
|
+
{
|
|
527
|
+
name: "upload_media",
|
|
528
|
+
description: "Upload a file to the site's media S3 bucket. Pass base64-encoded bytes; the server stores them verbatim under public/media/YYYY/MM/. Returns the public URL and Media record. The server does not transcode \u2014 pre-process (e.g. resize/webp) on the client.",
|
|
529
|
+
inputSchema: uploadMediaSchema,
|
|
530
|
+
handler: (args, ctx) => uploadMedia(ctx.graphql, ctx.storage(), ctx.defaultSiteId, args)
|
|
531
|
+
},
|
|
532
|
+
{
|
|
533
|
+
name: "get_schema",
|
|
534
|
+
description: "Returns the CMS content schema (Post/Page/Media field shapes, format enum, notes). Useful as the first call to understand what fields are available.",
|
|
535
|
+
inputSchema: getSchemaSchema,
|
|
536
|
+
handler: async () => getSchema()
|
|
537
|
+
}
|
|
538
|
+
];
|
|
539
|
+
async function dispatchToolCall(name, args, ctx) {
|
|
540
|
+
const tool = tools.find((t) => t.name === name);
|
|
541
|
+
if (!tool) return null;
|
|
542
|
+
return tool.handler(args, ctx);
|
|
543
|
+
}
|
|
544
|
+
function getTools() {
|
|
545
|
+
return tools;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export {
|
|
549
|
+
tools,
|
|
550
|
+
dispatchToolCall,
|
|
551
|
+
getTools
|
|
552
|
+
};
|
|
@@ -400,7 +400,7 @@ var resolveProcessCredentials = async (options, profile) => import("./dist-es-OO
|
|
|
400
400
|
|
|
401
401
|
// ../../node_modules/.pnpm/@aws-sdk+credential-provider-ini@3.972.41/node_modules/@aws-sdk/credential-provider-ini/dist-es/resolveSsoCredentials.js
|
|
402
402
|
var resolveSsoCredentials = async (profile, profileData, options = {}, callerClientConfig) => {
|
|
403
|
-
const { fromSSO } = await import("./dist-es-
|
|
403
|
+
const { fromSSO } = await import("./dist-es-OKPWYZO7.js");
|
|
404
404
|
return fromSSO({
|
|
405
405
|
profile,
|
|
406
406
|
logger: options.logger,
|