Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat(mcp): accept { path, thumbnail } attachments for video covers

Gilad Resisie5f6fff33843
diff --git a/libraries/nestjs-libraries/src/chat/tools/integration.schedule.post.ts b/libraries/nestjs-libraries/src/chat/tools/integration.schedule.post.ts
index 19433a7fa..3eb5aa32a 100644
--- a/libraries/nestjs-libraries/src/chat/tools/integration.schedule.post.ts
+++ b/libraries/nestjs-libraries/src/chat/tools/integration.schedule.post.ts
@@ -27,6 +27,19 @@ const attachmentUrl = z
message: validUrlExtension.defaultMessage({} as any),
});
+// Attachments are either a plain URL string or { path, thumbnail? } where
+// thumbnail is an image URL (jpeg/png) used as the video's thumbnail / cover.
+const attachment = z.union([
+ attachmentUrl,
+ z.object({
+ path: attachmentUrl,
+ thumbnail: attachmentUrl.optional(),
+ }),
+]);
+
+const toMedia = (a: string | { path: string; thumbnail?: string }) =>
+ typeof a === 'string' ? { path: a } : { path: a.path, thumbnail: a.thumbnail };
+
@Injectable()
export class IntegrationSchedulePostTool implements AgentToolInterface {
constructor(
@@ -93,8 +106,10 @@ If the tools return errors, you would need to rerun it with the right parameters
"The content of the post, HTML, Each line must be wrapped in <p> here is the possible tags: h1, h2, h3, u, strong, li, ul, p (you can't have u and strong together)"
),
attachments: z
- .array(attachmentUrl)
- .describe('The image of the post (URLS)'),
+ .array(attachment)
+ .describe(
+ 'The media of the post: either an uploaded media URL string, or { path, thumbnail } where path is the uploaded video URL and thumbnail is the path of an uploaded jpeg/png (returned by uploadFromUrlTool) used as the video thumbnail / cover (e.g. Instagram Reel cover)'
+ ),
})
)
.describe(
@@ -163,9 +178,7 @@ If the tools return errors, you would need to rerun it with the right parameters
settings,
value: platform.postsAndComments.map((p: any) => ({
content: p.content,
- image: (p.attachments || []).map((path: string) => ({
- path,
- })),
+ image: (p.attachments || []).map(toMedia),
})),
},
]
@@ -229,9 +242,9 @@ If the tools return errors, you would need to rerun it with the right parameters
content: p.content,
id: makeId(10),
delay: 0,
- image: p.attachments.map((p: any) => ({
+ image: p.attachments.map((a: any) => ({
id: makeId(10),
- path: p,
+ ...toMedia(a),
})),
})),
},