@xreplyai/mcp 0.3.11 → 0.3.16
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.md +11 -19
- package/dist/index.js +0 -0
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/tools/communities.d.ts.map +1 -1
- package/dist/tools/communities.js +1 -7
- package/dist/tools/communities.js.map +1 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +100 -8
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/helpers.d.ts +4 -0
- package/dist/tools/helpers.d.ts.map +1 -0
- package/dist/tools/helpers.js +8 -0
- package/dist/tools/helpers.js.map +1 -0
- package/dist/tools/media.d.ts +6 -0
- package/dist/tools/media.d.ts.map +1 -0
- package/dist/tools/media.js +195 -0
- package/dist/tools/media.js.map +1 -0
- package/dist/tools/posts.d.ts.map +1 -1
- package/dist/tools/posts.js +214 -97
- package/dist/tools/posts.js.map +1 -1
- package/dist/tools/publish.d.ts.map +1 -1
- package/dist/tools/publish.js +1 -7
- package/dist/tools/publish.js.map +1 -1
- package/dist/types.d.ts +20 -29
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/tools/viral-library.d.ts +0 -3
- package/dist/tools/viral-library.d.ts.map +0 -1
- package/dist/tools/viral-library.js +0 -92
- package/dist/tools/viral-library.js.map +0 -1
package/dist/tools/posts.js
CHANGED
|
@@ -2,20 +2,14 @@ import { z } from "zod";
|
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
import { validateScheduledAt } from "../validation.js";
|
|
5
|
-
|
|
6
|
-
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
7
|
-
}
|
|
8
|
-
function err(error) {
|
|
9
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
10
|
-
return { content: [{ type: "text", text: `Error: ${message}` }], isError: true };
|
|
11
|
-
}
|
|
5
|
+
import { ok, err } from "./helpers.js";
|
|
12
6
|
const PostContentSchema = z.object({
|
|
13
|
-
platform: z.enum(["twitter", "linkedin", "youtube"]).describe("Target platform"),
|
|
14
|
-
body: z.string().min(1).max(3000).optional().describe("Post body text (max 280 for X, max 3000 for LinkedIn). Optional for YouTube video posts (used as video description)."),
|
|
7
|
+
platform: z.enum(["twitter", "linkedin", "youtube", "threads", "instagram", "bluesky", "facebook", "google_business"]).describe("Target platform"),
|
|
8
|
+
body: z.string().min(1).max(3000).optional().describe("Post body text (max 280 for X, max 3000 for LinkedIn, max 500 for Threads, max 300 for Bluesky, max 1500 for Google Business). Optional for YouTube video posts (used as video description)."),
|
|
15
9
|
content_type: z
|
|
16
|
-
.enum(["text", "single_image", "multi_image", "video"])
|
|
10
|
+
.enum(["text", "single_image", "multi_image", "video", "document"])
|
|
17
11
|
.optional()
|
|
18
|
-
.describe("Content type (default: text). Use video for LinkedIn and YouTube video posts."),
|
|
12
|
+
.describe("Content type (default: text). Use video for LinkedIn and YouTube video posts. Use document for LinkedIn carousel posts (PDF)."),
|
|
19
13
|
metadata: z
|
|
20
14
|
.object({
|
|
21
15
|
asset_urn: z.string().optional().describe("LinkedIn only — asset_urn from xreply_media_upload or xreply_video_upload"),
|
|
@@ -29,17 +23,23 @@ const PostContentSchema = z.object({
|
|
|
29
23
|
category_id: z.string().optional().describe("YouTube only — numeric category ID (default: 22 = People & Blogs)"),
|
|
30
24
|
tags: z.array(z.string()).optional().describe("YouTube only — array of tags"),
|
|
31
25
|
thumbnail_url: z.string().optional().describe("YouTube only — URL of thumbnail image to set after upload"),
|
|
26
|
+
image_url: z.string().optional().describe("Threads only — public HTTPS URL of image to attach (required for single_image content_type on Threads). Instagram only — public JPEG URL for single_image posts"),
|
|
27
|
+
image_urls: z.array(z.string()).optional().describe("Instagram only — 2-10 public JPEG URLs for carousel (multi_image) posts"),
|
|
28
|
+
video_url: z.string().optional().describe("Instagram only — public MOV/MP4 URL for Reels (video) posts"),
|
|
29
|
+
cover_url: z.string().optional().describe("Instagram only — custom thumbnail URL for Reels"),
|
|
30
|
+
share_to_feed: z.boolean().optional().describe("Instagram only — true to share Reel to Feed tab as well as Reels tab"),
|
|
31
|
+
document_urn: z.string().optional().describe("LinkedIn only — document_urn from xreply_linkedin_document_upload, for carousel (document) posts"),
|
|
32
32
|
})
|
|
33
33
|
.optional()
|
|
34
|
-
.describe("Metadata for the post content. For X images: media_id or media_ids. For LinkedIn images: asset_urn or asset_urns. For LinkedIn/YouTube video: asset_urn. For YouTube: title (required), privacy_status, category_id, tags, thumbnail_url. For X auto-retweet: auto_rt_hours. For X communities: community_id."),
|
|
34
|
+
.describe("Metadata for the post content. For X images: media_id or media_ids. For LinkedIn images: asset_urn or asset_urns. For LinkedIn/YouTube video: asset_urn. For LinkedIn carousel: document_urn. For YouTube: title (required), privacy_status, category_id, tags, thumbnail_url. For Threads image: image_url (public HTTPS URL). For X auto-retweet: auto_rt_hours. For X communities: community_id. For Instagram single_image: image_url. For Instagram multi_image carousel: image_urls (2-10 URLs). For Instagram video/reel: video_url, cover_url, share_to_feed."),
|
|
35
35
|
});
|
|
36
36
|
const CreatePostSchema = z.object({
|
|
37
|
-
body: z.string().min(1).max(280).optional().describe("Post body text for X only (max 280 chars). Use post_contents for LinkedIn or cross-posting."),
|
|
37
|
+
body: z.string().min(1).max(280).optional().describe("Post body text for X only (max 280 chars). Use post_contents for LinkedIn, Threads, Instagram, or cross-posting."),
|
|
38
38
|
post_contents: z
|
|
39
39
|
.array(PostContentSchema)
|
|
40
40
|
.min(1)
|
|
41
41
|
.optional()
|
|
42
|
-
.describe("Per-platform content. Use this for LinkedIn posts or when posting different text to multiple platforms."),
|
|
42
|
+
.describe("Per-platform content. Use this for LinkedIn, Threads, or Instagram posts, or when posting different text to multiple platforms."),
|
|
43
43
|
account_id: z
|
|
44
44
|
.number()
|
|
45
45
|
.int()
|
|
@@ -51,6 +51,7 @@ const CreatePostSchema = z.object({
|
|
|
51
51
|
.optional()
|
|
52
52
|
.describe("Array of social account IDs to post from. Takes precedence over account_id."),
|
|
53
53
|
});
|
|
54
|
+
const PLATFORM_ENUM = ["twitter", "linkedin", "threads", "instagram", "youtube", "bluesky", "facebook", "google_business"];
|
|
54
55
|
const GeneratePostSchema = z.object({
|
|
55
56
|
topic: z
|
|
56
57
|
.string()
|
|
@@ -62,13 +63,19 @@ const GeneratePostSchema = z.object({
|
|
|
62
63
|
.optional()
|
|
63
64
|
.describe("Writing angle for the post"),
|
|
64
65
|
platform: z
|
|
65
|
-
.enum(["twitter", "linkedin"])
|
|
66
|
+
.enum(["twitter", "linkedin", "threads", "instagram", "youtube", "bluesky"])
|
|
66
67
|
.optional()
|
|
67
|
-
.describe("Target platform —
|
|
68
|
+
.describe("Target platform for a single-platform post — controls output length and style. Use platforms (array) instead to generate for multiple platforms at once."),
|
|
69
|
+
platforms: z
|
|
70
|
+
.array(z.enum(PLATFORM_ENUM))
|
|
71
|
+
.min(2)
|
|
72
|
+
.max(5)
|
|
73
|
+
.optional()
|
|
74
|
+
.describe("Generate platform-native variants for multiple platforms at once (2-5 platforms). Each variant counts as 1 quota. Returns variants array instead of body."),
|
|
68
75
|
});
|
|
69
76
|
const GenerateBatchSchema = z.object({
|
|
70
77
|
category: z
|
|
71
|
-
.enum(["personalized", "trending"
|
|
78
|
+
.enum(["personalized", "trending"])
|
|
72
79
|
.describe("Category of posts to generate"),
|
|
73
80
|
count: z
|
|
74
81
|
.number()
|
|
@@ -76,10 +83,14 @@ const GenerateBatchSchema = z.object({
|
|
|
76
83
|
.min(1)
|
|
77
84
|
.max(9)
|
|
78
85
|
.describe("Number of posts to generate (1-9). Cannot exceed your remaining daily quota."),
|
|
86
|
+
platform: z
|
|
87
|
+
.enum(PLATFORM_ENUM)
|
|
88
|
+
.optional()
|
|
89
|
+
.describe("Target platform — controls output length and style (default: twitter)."),
|
|
79
90
|
});
|
|
80
91
|
const EditPostSchema = z.object({
|
|
81
92
|
id: z.number().int().positive().describe("Post ID"),
|
|
82
|
-
body: z.string().min(1).max(280).optional().describe("New X post body text (max 280 chars). Use post_contents to update LinkedIn or multiple platforms."),
|
|
93
|
+
body: z.string().min(1).max(280).optional().describe("New X post body text (max 280 chars). Use post_contents to update LinkedIn, Threads, Instagram, or multiple platforms."),
|
|
83
94
|
post_contents: z
|
|
84
95
|
.array(PostContentSchema)
|
|
85
96
|
.min(1)
|
|
@@ -94,6 +105,12 @@ const EditPostSchema = z.object({
|
|
|
94
105
|
const DeletePostSchema = z.object({
|
|
95
106
|
id: z.number().int().positive().describe("Post ID to delete"),
|
|
96
107
|
});
|
|
108
|
+
const CarouselGenerateSchema = z.object({
|
|
109
|
+
topic: z.string().max(280).optional(),
|
|
110
|
+
slide_count: z.number().int().min(3).max(12).optional(),
|
|
111
|
+
theme: z.enum(["dark", "light", "blue", "green"]).optional(),
|
|
112
|
+
cta_text: z.string().max(100).optional(),
|
|
113
|
+
});
|
|
97
114
|
export const postTools = [
|
|
98
115
|
{
|
|
99
116
|
name: "xreply_posts_list",
|
|
@@ -119,7 +136,10 @@ export const postTools = [
|
|
|
119
136
|
"For X images: call xreply_media_upload first, include media_id in metadata. " +
|
|
120
137
|
"For LinkedIn images: call xreply_media_upload first, include asset_urn in metadata. " +
|
|
121
138
|
"For LinkedIn video: call xreply_video_upload first, include asset_urn in metadata, set content_type to 'video'. " +
|
|
122
|
-
"For YouTube video: set platform to 'youtube', content_type to 'video', include title in metadata (required), privacy_status (default: private), and optionally tags/category_id/thumbnail_url. Body is used as the video description. After
|
|
139
|
+
"For YouTube video: set platform to 'youtube', content_type to 'video', include title in metadata (required), privacy_status (default: private), and optionally tags/category_id/thumbnail_url. Body is used as the video description. After creating the draft, call xreply_youtube_upload with the post_id and video file path BEFORE publishing — then call xreply_posts_publish. " +
|
|
140
|
+
"For Threads: set platform to 'threads', body (max 500 chars). Image posts are supported via image_url in metadata. " +
|
|
141
|
+
"For Bluesky: set platform to 'bluesky', body (max 300 chars). Text-only posts supported. " +
|
|
142
|
+
"For Facebook Page: set platform to 'facebook', body (max 63206 chars). Supports text and single_image (image_url in metadata).",
|
|
123
143
|
inputSchema: {
|
|
124
144
|
type: "object",
|
|
125
145
|
properties: {
|
|
@@ -127,21 +147,21 @@ export const postTools = [
|
|
|
127
147
|
type: "string",
|
|
128
148
|
minLength: 1,
|
|
129
149
|
maxLength: 280,
|
|
130
|
-
description: "Post body text for X only (max 280 chars). Use post_contents for LinkedIn or cross-posting.",
|
|
150
|
+
description: "Post body text for X only (max 280 chars). Use post_contents for LinkedIn, Threads, or cross-posting.",
|
|
131
151
|
},
|
|
132
152
|
post_contents: {
|
|
133
153
|
type: "array",
|
|
134
154
|
minItems: 1,
|
|
135
|
-
description: "Per-platform content. Use this for LinkedIn posts or when posting different text to multiple platforms.",
|
|
155
|
+
description: "Per-platform content. Use this for LinkedIn or Threads posts, or when posting different text to multiple platforms.",
|
|
136
156
|
items: {
|
|
137
157
|
type: "object",
|
|
138
158
|
properties: {
|
|
139
|
-
platform: { type: "string", enum: ["twitter", "linkedin", "youtube"], description: "Target platform" },
|
|
140
|
-
body: { type: "string", minLength: 1, maxLength:
|
|
141
|
-
content_type: { type: "string", enum: ["text", "single_image", "multi_image", "video"], description: "Content type (default: text). Use video for LinkedIn and YouTube video posts." },
|
|
159
|
+
platform: { type: "string", enum: ["twitter", "linkedin", "youtube", "threads", "instagram", "bluesky", "facebook"], description: "Target platform" },
|
|
160
|
+
body: { type: "string", minLength: 1, maxLength: 63206, description: "Post body (max 280 for X, max 3000 for LinkedIn, max 500 for Threads, max 300 for Bluesky, max 63206 for Facebook). For YouTube, used as video description (optional)." },
|
|
161
|
+
content_type: { type: "string", enum: ["text", "single_image", "multi_image", "video", "document", "poll"], description: "Content type (default: text). Use video for LinkedIn and YouTube video posts. Use document for LinkedIn carousel posts (PDF). Use poll for LinkedIn polls." },
|
|
142
162
|
metadata: {
|
|
143
163
|
type: "object",
|
|
144
|
-
description: "Metadata for the post content. For X images: media_id or media_ids. For LinkedIn images: asset_urn or asset_urns. For LinkedIn/YouTube video: set content_type to video. For YouTube: title (required), privacy_status, category_id, tags, thumbnail_url. For X auto-retweet: auto_rt_hours. For X communities: community_id.",
|
|
164
|
+
description: "Metadata for the post content. For X images: media_id or media_ids. For LinkedIn images: asset_urn or asset_urns. For LinkedIn/YouTube video: set content_type to video. For YouTube: title (required), privacy_status, category_id, tags, thumbnail_url. For Threads image: image_url (public HTTPS URL — no upload step needed). For X auto-retweet: auto_rt_hours. For X communities: community_id. For LinkedIn polls: question (max 140 chars), options (2-4 strings, max 30 chars each), duration (ONE_DAY, THREE_DAYS, SEVEN_DAYS, or FOURTEEN_DAYS).",
|
|
145
165
|
properties: {
|
|
146
166
|
media_id: { type: "string", description: "X only — media_id from xreply_media_upload (single image)" },
|
|
147
167
|
media_ids: { type: "array", items: { type: "string" }, description: "X only — multiple media_ids from xreply_media_upload" },
|
|
@@ -154,6 +174,11 @@ export const postTools = [
|
|
|
154
174
|
category_id: { type: "string", description: "YouTube only — numeric category ID (default: 22 = People & Blogs)" },
|
|
155
175
|
tags: { type: "array", items: { type: "string" }, description: "YouTube only — video tags" },
|
|
156
176
|
thumbnail_url: { type: "string", description: "YouTube only — URL of thumbnail image to set after upload completes" },
|
|
177
|
+
image_url: { type: "string", description: "Threads only — public HTTPS URL of image to attach (required for single_image content_type on Threads)" },
|
|
178
|
+
question: { type: "string", maxLength: 140, description: "LinkedIn poll only — the poll question (max 140 chars)" },
|
|
179
|
+
options: { type: "array", items: { type: "string", maxLength: 30 }, minItems: 2, maxItems: 4, description: "LinkedIn poll only — poll answer options (2-4 items, each max 30 chars)" },
|
|
180
|
+
duration: { type: "string", enum: ["ONE_DAY", "THREE_DAYS", "SEVEN_DAYS", "FOURTEEN_DAYS"], description: "LinkedIn poll only — how long the poll stays open" },
|
|
181
|
+
linkedin_org_id: { type: "string", description: "LinkedIn only — numeric org ID to post as an organization page instead of personal profile" },
|
|
157
182
|
},
|
|
158
183
|
},
|
|
159
184
|
},
|
|
@@ -198,7 +223,7 @@ export const postTools = [
|
|
|
198
223
|
},
|
|
199
224
|
{
|
|
200
225
|
name: "xreply_posts_generate",
|
|
201
|
-
description: "Generate
|
|
226
|
+
description: "Generate AI post(s) in the user's voice and auto-save as draft(s). Use platform (single) for one platform or platforms (array) for platform-native variants across multiple platforms at once. Each platform variant counts as 1 quota. Returns body + post for single-platform, variants + post for multi-platform.",
|
|
202
227
|
inputSchema: {
|
|
203
228
|
type: "object",
|
|
204
229
|
properties: {
|
|
@@ -214,8 +239,15 @@ export const postTools = [
|
|
|
214
239
|
},
|
|
215
240
|
platform: {
|
|
216
241
|
type: "string",
|
|
217
|
-
enum: ["twitter", "linkedin"],
|
|
218
|
-
description: "
|
|
242
|
+
enum: ["twitter", "linkedin", "threads", "instagram", "youtube", "bluesky"],
|
|
243
|
+
description: "Single target platform. Use platforms (array) instead for multi-platform generation.",
|
|
244
|
+
},
|
|
245
|
+
platforms: {
|
|
246
|
+
type: "array",
|
|
247
|
+
items: { type: "string", enum: ["twitter", "linkedin", "threads", "instagram", "youtube", "bluesky"] },
|
|
248
|
+
minItems: 2,
|
|
249
|
+
maxItems: 5,
|
|
250
|
+
description: "Generate for multiple platforms at once — each gets platform-native content. 2-5 platforms. Each counts as 1 quota.",
|
|
219
251
|
},
|
|
220
252
|
},
|
|
221
253
|
required: [],
|
|
@@ -225,16 +257,21 @@ export const postTools = [
|
|
|
225
257
|
const params = GeneratePostSchema.parse(args);
|
|
226
258
|
const billing = await client.get("/api/v1/billing/subscriptions/current");
|
|
227
259
|
const remaining = billing.quota.replies_remaining_today;
|
|
228
|
-
|
|
229
|
-
|
|
260
|
+
const platformCount = params.platforms ? params.platforms.length : 1;
|
|
261
|
+
if (remaining !== undefined && remaining !== null && remaining < platformCount) {
|
|
262
|
+
return err(`Insufficient quota: need ${platformCount} but only ${remaining} remaining today (${billing.quota.daily_limit}/day on ${billing.tier} plan). Resets at midnight.`);
|
|
263
|
+
}
|
|
264
|
+
if (params.platforms && params.platforms.length >= 2) {
|
|
265
|
+
const generated = await client.post("/api/v1/posts/generate", params);
|
|
266
|
+
const variants = generated.variants ?? [];
|
|
267
|
+
const postContents = variants.map((v) => ({ platform: v.platform, body: v.body, content_type: "text" }));
|
|
268
|
+
const saved = await client.post("/api/v1/posts", { post: {}, post_contents: postContents });
|
|
269
|
+
return ok({ variants, post: saved.post, quota_used: variants.length });
|
|
230
270
|
}
|
|
231
271
|
const generated = await client.post("/api/v1/posts/generate", params);
|
|
232
272
|
const platform = params.platform ?? "twitter";
|
|
233
273
|
const postContents = [{ platform, body: generated.body, content_type: "text" }];
|
|
234
|
-
const saved = await client.post("/api/v1/posts", {
|
|
235
|
-
post: {},
|
|
236
|
-
post_contents: postContents,
|
|
237
|
-
});
|
|
274
|
+
const saved = await client.post("/api/v1/posts", { post: {}, post_contents: postContents });
|
|
238
275
|
return ok({ body: generated.body, post: saved.post });
|
|
239
276
|
}
|
|
240
277
|
catch (e) {
|
|
@@ -244,13 +281,13 @@ export const postTools = [
|
|
|
244
281
|
},
|
|
245
282
|
{
|
|
246
283
|
name: "xreply_posts_generate_batch",
|
|
247
|
-
description: "Generate multiple AI posts at once in the user's voice. Use 'personalized' for posts tailored to your voice profile
|
|
284
|
+
description: "Generate multiple AI posts at once in the user's voice. Use 'personalized' for posts tailored to your voice profile or 'trending' for timely content. Returns an array of post body strings. Each post counts as 1 generation against the daily quota (5/day free, 100/day pro) — a single batch of 9 will exhaust a free account. Check xreply_billing_status first if quota is a concern.",
|
|
248
285
|
inputSchema: {
|
|
249
286
|
type: "object",
|
|
250
287
|
properties: {
|
|
251
288
|
category: {
|
|
252
289
|
type: "string",
|
|
253
|
-
enum: ["personalized", "trending"
|
|
290
|
+
enum: ["personalized", "trending"],
|
|
254
291
|
description: "Category of posts to generate",
|
|
255
292
|
},
|
|
256
293
|
count: {
|
|
@@ -259,12 +296,17 @@ export const postTools = [
|
|
|
259
296
|
maximum: 9,
|
|
260
297
|
description: "Number of posts to generate (1-9). Cannot exceed your remaining daily quota.",
|
|
261
298
|
},
|
|
299
|
+
platform: {
|
|
300
|
+
type: "string",
|
|
301
|
+
enum: ["twitter", "linkedin", "threads", "instagram", "youtube", "bluesky"],
|
|
302
|
+
description: "Target platform — controls output length and style (default: twitter).",
|
|
303
|
+
},
|
|
262
304
|
},
|
|
263
305
|
required: ["category", "count"],
|
|
264
306
|
},
|
|
265
307
|
async handler(args, client) {
|
|
266
308
|
try {
|
|
267
|
-
const { category, count } = GenerateBatchSchema.parse(args);
|
|
309
|
+
const { category, count, platform } = GenerateBatchSchema.parse(args);
|
|
268
310
|
const billing = await client.get("/api/v1/billing/subscriptions/current");
|
|
269
311
|
const remaining = billing.quota.replies_remaining_today;
|
|
270
312
|
if (remaining !== undefined && remaining !== null && remaining <= 0) {
|
|
@@ -281,7 +323,7 @@ export const postTools = [
|
|
|
281
323
|
const safeCount = remaining !== undefined && remaining !== null
|
|
282
324
|
? Math.min(count, remaining)
|
|
283
325
|
: count;
|
|
284
|
-
const result = await client.post("/api/v1/posts/generate_batch", { category, count: safeCount });
|
|
326
|
+
const result = await client.post("/api/v1/posts/generate_batch", { category, count: safeCount, ...(platform ? { platform } : {}) });
|
|
285
327
|
return ok(result);
|
|
286
328
|
}
|
|
287
329
|
catch (e) {
|
|
@@ -289,9 +331,83 @@ export const postTools = [
|
|
|
289
331
|
}
|
|
290
332
|
},
|
|
291
333
|
},
|
|
334
|
+
{
|
|
335
|
+
name: "xreply_carousel_generate",
|
|
336
|
+
description: "Generate an AI-written LinkedIn carousel post from a topic/prompt. The AI creates structured slides in the user's voice, renders them as a PDF, and auto-saves as a draft LinkedIn post. Returns the slides, post, and document_urn. Counts as 1 generation against the daily quota.",
|
|
337
|
+
inputSchema: {
|
|
338
|
+
type: "object",
|
|
339
|
+
properties: {
|
|
340
|
+
topic: {
|
|
341
|
+
type: "string",
|
|
342
|
+
maxLength: 280,
|
|
343
|
+
description: "Optional topic or prompt for the carousel. If omitted, AI picks from the user's voice profile.",
|
|
344
|
+
},
|
|
345
|
+
slide_count: {
|
|
346
|
+
type: "integer",
|
|
347
|
+
minimum: 3,
|
|
348
|
+
maximum: 12,
|
|
349
|
+
description: "Number of slides (3-12, default 3). Includes cover and CTA slides.",
|
|
350
|
+
},
|
|
351
|
+
theme: {
|
|
352
|
+
type: "string",
|
|
353
|
+
enum: ["dark", "light", "blue", "green"],
|
|
354
|
+
description: "Visual theme for the PDF (default: dark).",
|
|
355
|
+
},
|
|
356
|
+
cta_text: {
|
|
357
|
+
type: "string",
|
|
358
|
+
maxLength: 100,
|
|
359
|
+
description: "Custom text for the last slide (e.g. 'Follow me for more async tips'). If omitted, AI generates one.",
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
required: [],
|
|
363
|
+
},
|
|
364
|
+
async handler(args, client) {
|
|
365
|
+
try {
|
|
366
|
+
const billing = await client.get("/api/v1/billing/subscriptions/current");
|
|
367
|
+
const remaining = billing.quota.replies_remaining_today;
|
|
368
|
+
if (remaining !== undefined && remaining !== null && remaining < 1) {
|
|
369
|
+
return err(`Insufficient quota: 0 remaining today (${billing.quota.daily_limit}/day on ${billing.tier} plan). Resets at midnight.`);
|
|
370
|
+
}
|
|
371
|
+
const accounts = await client.get("/api/v1/social_accounts");
|
|
372
|
+
const linkedinAccount = accounts.social_accounts.find((a) => a.platform === "linkedin");
|
|
373
|
+
if (!linkedinAccount) {
|
|
374
|
+
return err("No LinkedIn account connected. Please connect LinkedIn in settings first.");
|
|
375
|
+
}
|
|
376
|
+
const parsed = CarouselGenerateSchema.parse(args);
|
|
377
|
+
const body = { social_account_id: linkedinAccount.id };
|
|
378
|
+
if (parsed.topic !== undefined)
|
|
379
|
+
body.topic = parsed.topic;
|
|
380
|
+
if (parsed.slide_count !== undefined)
|
|
381
|
+
body.slide_count = parsed.slide_count;
|
|
382
|
+
if (parsed.theme !== undefined)
|
|
383
|
+
body.theme = parsed.theme;
|
|
384
|
+
if (parsed.cta_text !== undefined)
|
|
385
|
+
body.cta_text = parsed.cta_text;
|
|
386
|
+
const generated = await client.post("/api/v1/posts/generate_carousel", body);
|
|
387
|
+
const saved = await client.post("/api/v1/posts", {
|
|
388
|
+
post: {},
|
|
389
|
+
post_contents: [{
|
|
390
|
+
platform: "linkedin",
|
|
391
|
+
body: generated.caption,
|
|
392
|
+
content_type: "document",
|
|
393
|
+
metadata: { document_urn: generated.document_urn, title: generated.title },
|
|
394
|
+
}],
|
|
395
|
+
});
|
|
396
|
+
return ok({
|
|
397
|
+
slides: generated.slides,
|
|
398
|
+
caption: generated.caption,
|
|
399
|
+
document_urn: generated.document_urn,
|
|
400
|
+
post: saved.post,
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
catch (e) {
|
|
404
|
+
return err(e);
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
},
|
|
292
408
|
{
|
|
293
409
|
name: "xreply_posts_edit",
|
|
294
|
-
description: "Edit a post's content, scheduled time, or auto-retweet setting. Use `body` to update X-only text, or `post_contents` to update per-platform content (LinkedIn, YouTube, or cross-platform). Set scheduled_at to an ISO 8601 datetime to schedule, or null to move back to draft. Cannot edit posts that are processing or already posted. " +
|
|
410
|
+
description: "Edit a post's content, scheduled time, or auto-retweet setting. Use `body` to update X-only text, or `post_contents` to update per-platform content (LinkedIn, YouTube, Threads, or cross-platform). Set scheduled_at to an ISO 8601 datetime to schedule, or null to move back to draft. Cannot edit posts that are processing or already posted. " +
|
|
295
411
|
"For X images: call xreply_media_upload first, include media_id in metadata. " +
|
|
296
412
|
"For LinkedIn images: call xreply_media_upload first, include asset_urn in metadata. " +
|
|
297
413
|
"For LinkedIn video: call xreply_video_upload first, include asset_urn in metadata, set content_type to 'video'. " +
|
|
@@ -308,12 +424,12 @@ export const postTools = [
|
|
|
308
424
|
items: {
|
|
309
425
|
type: "object",
|
|
310
426
|
properties: {
|
|
311
|
-
platform: { type: "string", enum: ["twitter", "linkedin", "youtube"], description: "Target platform" },
|
|
312
|
-
body: { type: "string", minLength: 1, maxLength:
|
|
313
|
-
content_type: { type: "string", enum: ["text", "single_image", "multi_image", "video"], description: "Content type (default: text). Use video for LinkedIn and YouTube video posts." },
|
|
427
|
+
platform: { type: "string", enum: ["twitter", "linkedin", "youtube", "threads", "instagram", "bluesky", "facebook"], description: "Target platform" },
|
|
428
|
+
body: { type: "string", minLength: 1, maxLength: 63206, description: "Post body (max 280 for X, max 3000 for LinkedIn, max 500 for Threads, max 300 for Bluesky, max 63206 for Facebook). For YouTube, used as video description (optional)." },
|
|
429
|
+
content_type: { type: "string", enum: ["text", "single_image", "multi_image", "video", "document", "poll"], description: "Content type (default: text). Use video for LinkedIn and YouTube video posts. Use document for LinkedIn carousel posts (PDF). Use poll for LinkedIn polls." },
|
|
314
430
|
metadata: {
|
|
315
431
|
type: "object",
|
|
316
|
-
description: "Metadata for the post content. For X images: media_id or media_ids. For LinkedIn images: asset_urn or asset_urns. For LinkedIn/YouTube video: set content_type to video. For YouTube: title (required), privacy_status, category_id, tags, thumbnail_url. For X auto-retweet: auto_rt_hours. For X communities: community_id.",
|
|
432
|
+
description: "Metadata for the post content. For X images: media_id or media_ids. For LinkedIn images: asset_urn or asset_urns. For LinkedIn/YouTube video: set content_type to video. For YouTube: title (required), privacy_status, category_id, tags, thumbnail_url. For Threads image: image_url (public HTTPS URL — no upload step needed). For X auto-retweet: auto_rt_hours. For X communities: community_id. For LinkedIn polls: question (max 140 chars), options (2-4 strings, max 30 chars each), duration (ONE_DAY, THREE_DAYS, SEVEN_DAYS, or FOURTEEN_DAYS).",
|
|
317
433
|
properties: {
|
|
318
434
|
media_id: { type: "string", description: "X only — media_id from xreply_media_upload (single image)" },
|
|
319
435
|
media_ids: { type: "array", items: { type: "string" }, description: "X only — multiple media_ids from xreply_media_upload" },
|
|
@@ -326,6 +442,11 @@ export const postTools = [
|
|
|
326
442
|
category_id: { type: "string", description: "YouTube only — numeric category ID (default: 22 = People & Blogs)" },
|
|
327
443
|
tags: { type: "array", items: { type: "string" }, description: "YouTube only — video tags" },
|
|
328
444
|
thumbnail_url: { type: "string", description: "YouTube only — URL of thumbnail image to set after upload completes" },
|
|
445
|
+
image_url: { type: "string", description: "Threads only — public HTTPS URL of image to attach (required for single_image content_type on Threads)" },
|
|
446
|
+
question: { type: "string", maxLength: 140, description: "LinkedIn poll only — the poll question (max 140 chars)" },
|
|
447
|
+
options: { type: "array", items: { type: "string", maxLength: 30 }, minItems: 2, maxItems: 4, description: "LinkedIn poll only — poll answer options (2-4 items, each max 30 chars)" },
|
|
448
|
+
duration: { type: "string", enum: ["ONE_DAY", "THREE_DAYS", "SEVEN_DAYS", "FOURTEEN_DAYS"], description: "LinkedIn poll only — how long the poll stays open" },
|
|
449
|
+
linkedin_org_id: { type: "string", description: "LinkedIn only — numeric org ID to post as an organization page instead of personal profile" },
|
|
329
450
|
},
|
|
330
451
|
},
|
|
331
452
|
},
|
|
@@ -512,43 +633,48 @@ export const postTools = [
|
|
|
512
633
|
},
|
|
513
634
|
{
|
|
514
635
|
name: "xreply_youtube_upload",
|
|
515
|
-
description: "Upload a local video file
|
|
516
|
-
"
|
|
517
|
-
"
|
|
518
|
-
"
|
|
519
|
-
"
|
|
520
|
-
"then confirms the upload. For scheduled posts, YouTube automatically publishes the video " +
|
|
521
|
-
"at the scheduled time — no further action needed after upload. " +
|
|
522
|
-
"The post_account_id is the id field inside post_accounts[] in the publish response where platform is 'youtube'. " +
|
|
523
|
-
"Supports all YouTube-accepted video formats (MP4, MOV, AVI, WMV, FLV, WebM, MPEG, 3GPP). Maximum file size: 100 MB. " +
|
|
636
|
+
description: "Upload a local video file for a YouTube post draft BEFORE publishing. " +
|
|
637
|
+
"Call this after xreply_posts_create (with platform 'youtube' and content_type 'video') but BEFORE xreply_posts_publish. " +
|
|
638
|
+
"The tool uploads the video to staging storage, then patches the post metadata with the storage key so the backend can finish the YouTube upload automatically after you publish. " +
|
|
639
|
+
"Once this succeeds, call xreply_posts_publish — the backend handles the rest asynchronously. " +
|
|
640
|
+
"Supports MP4, MOV, M4V, WebM, MPEG, 3GPP. Maximum file size: 50 MB. " +
|
|
524
641
|
"Note: requires filesystem access — works in Claude Code, Cursor, and mcporter (CLI). Not available in Claude.ai.",
|
|
525
642
|
inputSchema: {
|
|
526
643
|
type: "object",
|
|
527
644
|
properties: {
|
|
528
|
-
|
|
645
|
+
post_id: {
|
|
529
646
|
type: "integer",
|
|
530
|
-
description: "The
|
|
647
|
+
description: "The id of the YouTube post draft (from xreply_posts_create)",
|
|
531
648
|
},
|
|
532
649
|
video_path: {
|
|
533
650
|
type: "string",
|
|
534
|
-
description: "Absolute or relative path to the video file on disk (max
|
|
651
|
+
description: "Absolute or relative path to the video file on disk (max 50 MB)",
|
|
535
652
|
},
|
|
536
653
|
},
|
|
537
|
-
required: ["
|
|
654
|
+
required: ["post_id", "video_path"],
|
|
538
655
|
},
|
|
539
656
|
async handler(args, client) {
|
|
540
657
|
try {
|
|
541
|
-
const {
|
|
658
|
+
const { post_id, video_path } = z
|
|
542
659
|
.object({
|
|
543
|
-
|
|
660
|
+
post_id: z.number().int().positive(),
|
|
544
661
|
video_path: z.string().min(1),
|
|
545
662
|
})
|
|
546
663
|
.parse(args);
|
|
547
664
|
const resolvedPath = path.resolve(video_path);
|
|
548
|
-
const
|
|
665
|
+
const contentTypeMap = {
|
|
666
|
+
".mp4": "video/mp4",
|
|
667
|
+
".mov": "video/quicktime",
|
|
668
|
+
".m4v": "video/x-m4v",
|
|
669
|
+
".webm": "video/webm",
|
|
670
|
+
".mpeg": "video/mpeg",
|
|
671
|
+
".mpg": "video/mpeg",
|
|
672
|
+
".3gp": "video/3gpp",
|
|
673
|
+
};
|
|
549
674
|
const ext = path.extname(resolvedPath).toLowerCase();
|
|
550
|
-
|
|
551
|
-
|
|
675
|
+
const contentType = contentTypeMap[ext];
|
|
676
|
+
if (!contentType) {
|
|
677
|
+
return err(`Unsupported video format "${ext}". Supported: ${Object.keys(contentTypeMap).join(", ")}`);
|
|
552
678
|
}
|
|
553
679
|
let fileData;
|
|
554
680
|
try {
|
|
@@ -557,34 +683,18 @@ export const postTools = [
|
|
|
557
683
|
catch (e) {
|
|
558
684
|
return err(`Cannot read file at ${resolvedPath}: ${e instanceof Error ? e.message : String(e)}`);
|
|
559
685
|
}
|
|
560
|
-
const MAX_SIZE =
|
|
686
|
+
const MAX_SIZE = 50 * 1024 * 1024;
|
|
561
687
|
if (fileData.byteLength > MAX_SIZE) {
|
|
562
|
-
return err(`Video file is ${(fileData.byteLength / 1024 / 1024).toFixed(1)} MB — maximum allowed is
|
|
563
|
-
}
|
|
564
|
-
const status = await client.get(`/api/v1/youtube/uploads/${post_account_id}/status`);
|
|
565
|
-
if (status.platform_status !== "upload_pending") {
|
|
566
|
-
return err(`Expected platform_status "upload_pending" but got "${status.platform_status}". Has this upload already been completed?`);
|
|
567
|
-
}
|
|
568
|
-
if (!status.upload_url) {
|
|
569
|
-
return err("No upload_url found for this post account. The backend may not have successfully initiated the YouTube upload.");
|
|
688
|
+
return err(`Video file is ${(fileData.byteLength / 1024 / 1024).toFixed(1)} MB — maximum allowed is 50 MB.`);
|
|
570
689
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
".avi": "video/x-msvideo",
|
|
575
|
-
".wmv": "video/x-ms-wmv",
|
|
576
|
-
".flv": "video/x-flv",
|
|
577
|
-
".webm": "video/webm",
|
|
578
|
-
".mpeg": "video/mpeg",
|
|
579
|
-
".mpg": "video/mpeg",
|
|
580
|
-
".3gp": "video/3gpp",
|
|
581
|
-
};
|
|
582
|
-
const contentType = contentTypeMap[ext] ?? "video/mp4";
|
|
690
|
+
// Get a presigned R2 URL from the backend
|
|
691
|
+
const presign = await client.post("/api/v1/youtube/uploads/presign", { content_type: contentType });
|
|
692
|
+
// PUT the video directly to R2
|
|
583
693
|
const uploadController = new AbortController();
|
|
584
694
|
const uploadTimer = setTimeout(() => uploadController.abort(), 300_000);
|
|
585
695
|
let uploadResponse;
|
|
586
696
|
try {
|
|
587
|
-
uploadResponse = await fetch(
|
|
697
|
+
uploadResponse = await fetch(presign.upload_url, {
|
|
588
698
|
method: "PUT",
|
|
589
699
|
headers: { "Content-Type": contentType },
|
|
590
700
|
body: fileData,
|
|
@@ -594,26 +704,33 @@ export const postTools = [
|
|
|
594
704
|
catch (e) {
|
|
595
705
|
clearTimeout(uploadTimer);
|
|
596
706
|
if (e instanceof Error && e.name === "AbortError") {
|
|
597
|
-
return err("
|
|
707
|
+
return err("Video upload timed out after 5 minutes. Try a smaller file or check your connection.");
|
|
598
708
|
}
|
|
599
|
-
return err(`
|
|
709
|
+
return err(`Video upload failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
600
710
|
}
|
|
601
711
|
clearTimeout(uploadTimer);
|
|
602
712
|
if (!uploadResponse.ok) {
|
|
603
713
|
const body = await uploadResponse.text().catch(() => "");
|
|
604
|
-
return err(`
|
|
605
|
-
}
|
|
606
|
-
const location = uploadResponse.headers.get("Location") ?? uploadResponse.headers.get("location");
|
|
607
|
-
if (!location) {
|
|
608
|
-
return err("YouTube did not return a video location after upload. The upload may have succeeded — check your YouTube Studio.");
|
|
714
|
+
return err(`Video upload failed with HTTP ${uploadResponse.status}: ${body}`);
|
|
609
715
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
const
|
|
615
|
-
await client.
|
|
616
|
-
|
|
716
|
+
// Patch the post's YouTube content metadata with the r2_key so the backend
|
|
717
|
+
// can pick it up when the post is published
|
|
718
|
+
const post = await client.get(`/api/v1/posts/${post_id}`);
|
|
719
|
+
const ytContent = post.post?.post_contents?.find((pc) => pc.platform === "youtube");
|
|
720
|
+
const existingMeta = { ...ytContent?.metadata };
|
|
721
|
+
await client.patch(`/api/v1/posts/${post_id}`, {
|
|
722
|
+
post_contents: [
|
|
723
|
+
{
|
|
724
|
+
platform: "youtube",
|
|
725
|
+
metadata: { ...existingMeta, r2_key: presign.r2_key },
|
|
726
|
+
},
|
|
727
|
+
],
|
|
728
|
+
});
|
|
729
|
+
return ok({
|
|
730
|
+
success: true,
|
|
731
|
+
r2_key: presign.r2_key,
|
|
732
|
+
message: "Video uploaded to staging. Call xreply_posts_publish to complete the post.",
|
|
733
|
+
});
|
|
617
734
|
}
|
|
618
735
|
catch (e) {
|
|
619
736
|
return err(e);
|