Skip to content

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

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

Gilad Resisib318a6a5abcc
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 9fa08a8e0..8738c3d13 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(
@@ -95,8 +108,10 @@ If validation fails, the result contains output.errors describing what to fix; t
"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'
+ ),
})
)
.describe(
@@ -170,9 +185,7 @@ If validation fails, the result contains output.errors describing what to fix; t
settings,
value: platform.postsAndComments.map((p: any) => ({
content: p.content,
- image: (p.attachments || []).map((path: string) => ({
- path,
- })),
+ image: (p.attachments || []).map(toMedia),
})),
},
]
@@ -244,9 +257,9 @@ If validation fails, the result contains output.errors describing what to fix; t
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),
})),
})),
},