@ampless/mcp-server 1.0.0-alpha.16 → 1.0.0-alpha.17
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.
|
@@ -131,96 +131,6 @@ async function getPost(client, args) {
|
|
|
131
131
|
import {
|
|
132
132
|
encodeAwsJson
|
|
133
133
|
} from "ampless";
|
|
134
|
-
|
|
135
|
-
// src/posttag.ts
|
|
136
|
-
function entries(post) {
|
|
137
|
-
if (post.status !== "published" || !post.publishedAt || !post.tags?.length) return [];
|
|
138
|
-
return post.tags.map((tag) => ({
|
|
139
|
-
tag,
|
|
140
|
-
publishedAtPostId: `${post.publishedAt}#${post.postId}`
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
143
|
-
function entryKey(e) {
|
|
144
|
-
return `${e.tag}|${e.publishedAtPostId}`;
|
|
145
|
-
}
|
|
146
|
-
var CREATE_POST_TAG = (
|
|
147
|
-
/* GraphQL */
|
|
148
|
-
`
|
|
149
|
-
mutation CreatePostTag($input: CreatePostTagInput!) {
|
|
150
|
-
createPostTag(input: $input) {
|
|
151
|
-
tag
|
|
152
|
-
publishedAtPostId
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
`
|
|
156
|
-
);
|
|
157
|
-
var UPDATE_POST_TAG = (
|
|
158
|
-
/* GraphQL */
|
|
159
|
-
`
|
|
160
|
-
mutation UpdatePostTag($input: UpdatePostTagInput!) {
|
|
161
|
-
updatePostTag(input: $input) {
|
|
162
|
-
tag
|
|
163
|
-
publishedAtPostId
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
`
|
|
167
|
-
);
|
|
168
|
-
var DELETE_POST_TAG = (
|
|
169
|
-
/* GraphQL */
|
|
170
|
-
`
|
|
171
|
-
mutation DeletePostTag($input: DeletePostTagInput!) {
|
|
172
|
-
deletePostTag(input: $input) {
|
|
173
|
-
tag
|
|
174
|
-
publishedAtPostId
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
`
|
|
178
|
-
);
|
|
179
|
-
async function syncPostTags(client, post, oldPost) {
|
|
180
|
-
const oldEntries = oldPost ? entries(oldPost) : [];
|
|
181
|
-
const newEntries = entries(post);
|
|
182
|
-
const oldKeys = new Set(oldEntries.map(entryKey));
|
|
183
|
-
const newKeys = new Set(newEntries.map(entryKey));
|
|
184
|
-
await Promise.all(
|
|
185
|
-
oldEntries.filter((e) => !newKeys.has(entryKey(e))).map(
|
|
186
|
-
(e) => client.query(DELETE_POST_TAG, {
|
|
187
|
-
input: { tag: e.tag, publishedAtPostId: e.publishedAtPostId }
|
|
188
|
-
})
|
|
189
|
-
)
|
|
190
|
-
);
|
|
191
|
-
await Promise.all(
|
|
192
|
-
newEntries.filter((e) => !oldKeys.has(entryKey(e))).map(
|
|
193
|
-
(e) => client.query(CREATE_POST_TAG, {
|
|
194
|
-
input: {
|
|
195
|
-
tag: e.tag,
|
|
196
|
-
publishedAtPostId: e.publishedAtPostId,
|
|
197
|
-
postId: post.postId,
|
|
198
|
-
publishedAt: post.publishedAt,
|
|
199
|
-
slug: post.slug,
|
|
200
|
-
title: post.title,
|
|
201
|
-
excerpt: post.excerpt,
|
|
202
|
-
tags: post.tags ?? []
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
)
|
|
206
|
-
);
|
|
207
|
-
await Promise.all(
|
|
208
|
-
newEntries.filter((e) => oldKeys.has(entryKey(e))).map(
|
|
209
|
-
(e) => client.query(UPDATE_POST_TAG, {
|
|
210
|
-
input: {
|
|
211
|
-
tag: e.tag,
|
|
212
|
-
publishedAtPostId: e.publishedAtPostId,
|
|
213
|
-
slug: post.slug,
|
|
214
|
-
title: post.title,
|
|
215
|
-
excerpt: post.excerpt,
|
|
216
|
-
tags: post.tags ?? []
|
|
217
|
-
}
|
|
218
|
-
})
|
|
219
|
-
)
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// src/tools/create-post.ts
|
|
224
134
|
var MUTATION = (
|
|
225
135
|
/* GraphQL */
|
|
226
136
|
`
|
|
@@ -288,9 +198,7 @@ async function createPost(client, args) {
|
|
|
288
198
|
metadata: args.metadata !== void 0 ? encodeAwsJson(args.metadata) : void 0
|
|
289
199
|
}
|
|
290
200
|
});
|
|
291
|
-
|
|
292
|
-
await syncPostTags(client, created, null);
|
|
293
|
-
return created;
|
|
201
|
+
return toCorePost(data.createPost);
|
|
294
202
|
}
|
|
295
203
|
|
|
296
204
|
// src/tools/update-post.ts
|
|
@@ -345,7 +253,6 @@ var updatePostSchema = {
|
|
|
345
253
|
}
|
|
346
254
|
};
|
|
347
255
|
async function updatePost(client, args) {
|
|
348
|
-
const oldPost = await getPost(client, { postId: args.postId });
|
|
349
256
|
const input = { postId: args.postId };
|
|
350
257
|
if (args.slug !== void 0) input.slug = args.slug;
|
|
351
258
|
if (args.title !== void 0) input.title = args.title;
|
|
@@ -357,9 +264,7 @@ async function updatePost(client, args) {
|
|
|
357
264
|
if (args.tags !== void 0) input.tags = args.tags;
|
|
358
265
|
if (args.metadata !== void 0) input.metadata = encodeAwsJson2(args.metadata);
|
|
359
266
|
const data = await client.query(MUTATION2, { input });
|
|
360
|
-
|
|
361
|
-
await syncPostTags(client, updated, oldPost);
|
|
362
|
-
return updated;
|
|
267
|
+
return toCorePost(data.updatePost);
|
|
363
268
|
}
|
|
364
269
|
|
|
365
270
|
// src/tools/delete-post.ts
|
|
@@ -381,10 +286,6 @@ var deletePostSchema = {
|
|
|
381
286
|
}
|
|
382
287
|
};
|
|
383
288
|
async function deletePost(client, args) {
|
|
384
|
-
const oldPost = await getPost(client, { postId: args.postId });
|
|
385
|
-
if (oldPost) {
|
|
386
|
-
await syncPostTags(client, { ...oldPost, status: "draft" }, oldPost);
|
|
387
|
-
}
|
|
388
289
|
const data = await client.query(MUTATION3, { input: { postId: args.postId } });
|
|
389
290
|
return { deleted: data.deletePost };
|
|
390
291
|
}
|
|
@@ -530,11 +431,11 @@ import {
|
|
|
530
431
|
var DEFAULT_MAX_BYTES = 50 * 1024 * 1024;
|
|
531
432
|
function extractZipFromBuffer(buffer, opts = {}) {
|
|
532
433
|
const maxBytes = opts.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
533
|
-
const
|
|
434
|
+
const entries = unzipSync(buffer);
|
|
534
435
|
const files = [];
|
|
535
436
|
const issues = [];
|
|
536
437
|
let totalBytes = 0;
|
|
537
|
-
for (const [name, data] of Object.entries(
|
|
438
|
+
for (const [name, data] of Object.entries(entries)) {
|
|
538
439
|
if (name.endsWith("/")) continue;
|
|
539
440
|
const reason = validateBundlePath(name);
|
|
540
441
|
if (reason) {
|
|
@@ -600,7 +501,6 @@ async function upsertStaticPost(graphql, slug, body, fields) {
|
|
|
600
501
|
}
|
|
601
502
|
const data2 = await graphql.query(UPDATE_MUTATION, { input: input2 });
|
|
602
503
|
const updated = toCorePost(data2.updatePost);
|
|
603
|
-
await syncPostTags(graphql, updated, existing);
|
|
604
504
|
return { post: updated, created: false };
|
|
605
505
|
}
|
|
606
506
|
if (!fields.title) {
|
|
@@ -625,7 +525,6 @@ async function upsertStaticPost(graphql, slug, body, fields) {
|
|
|
625
525
|
if (fields.metadata !== void 0) input.metadata = encodeAwsJson3(fields.metadata);
|
|
626
526
|
const data = await graphql.query(CREATE_MUTATION, { input });
|
|
627
527
|
const created = toCorePost(data.createPost);
|
|
628
|
-
await syncPostTags(graphql, created, null);
|
|
629
528
|
return { post: created, created: true };
|
|
630
529
|
}
|
|
631
530
|
|
package/dist/index.js
CHANGED
package/dist/tools/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ampless/mcp-server",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.17",
|
|
4
4
|
"description": "MCP server for ampless — lets AI agents (Claude Desktop, Cursor, Claude Code) read and write posts and media via AppSync",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@aws-sdk/client-s3": "^3.1053.0",
|
|
37
37
|
"amazon-cognito-identity-js": "^6.3.16",
|
|
38
38
|
"fflate": "^0.8.3",
|
|
39
|
-
"ampless": "1.0.0-alpha.
|
|
39
|
+
"ampless": "1.0.0-alpha.15"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"ampless",
|