@atray/mcp 1.0.3 → 1.0.5
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/package.json +1 -1
- package/src/index.js +35 -1
- package/src/tools.js +16 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { tools } from './tools.js';
|
|
|
10
10
|
import { api } from './api.js';
|
|
11
11
|
|
|
12
12
|
const server = new Server(
|
|
13
|
-
{ name: 'atray-mcp', version: '1.0.
|
|
13
|
+
{ name: 'atray-mcp', version: '1.0.5' },
|
|
14
14
|
{ capabilities: { tools: {} } }
|
|
15
15
|
);
|
|
16
16
|
|
|
@@ -80,6 +80,9 @@ async function callTool(name, a) {
|
|
|
80
80
|
return api.post(`/posts/${id}/regenerate-image`, body);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
case 'uploadPostImage':
|
|
84
|
+
return uploadPostImage(a);
|
|
85
|
+
|
|
83
86
|
case 'uploadPostVideo':
|
|
84
87
|
return uploadPostVideo(a);
|
|
85
88
|
|
|
@@ -98,6 +101,37 @@ async function callTool(name, a) {
|
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
|
|
104
|
+
const IMAGE_MIME = { jpg: 'image/jpeg', jpeg: 'image/jpeg', png: 'image/png', webp: 'image/webp' };
|
|
105
|
+
|
|
106
|
+
async function uploadPostImage({ id, file_path, image_url }) {
|
|
107
|
+
if (!id) throw new Error('id (post UUID) is required');
|
|
108
|
+
if (!file_path && !image_url) throw new Error('Provide file_path (local file) or image_url (public URL)');
|
|
109
|
+
|
|
110
|
+
let buffer;
|
|
111
|
+
let filename;
|
|
112
|
+
if (file_path) {
|
|
113
|
+
buffer = await readFile(file_path);
|
|
114
|
+
filename = basename(file_path);
|
|
115
|
+
} else {
|
|
116
|
+
const res = await fetch(image_url);
|
|
117
|
+
if (!res.ok) throw new Error(`Failed to download image_url: HTTP ${res.status}`);
|
|
118
|
+
buffer = Buffer.from(await res.arrayBuffer());
|
|
119
|
+
filename = basename(new URL(image_url).pathname) || 'image.jpg';
|
|
120
|
+
if (!/\.(jpg|jpeg|png|webp)$/i.test(filename)) {
|
|
121
|
+
const ct = (res.headers.get('content-type') || '').toLowerCase();
|
|
122
|
+
const ext = Object.keys(IMAGE_MIME).find((k) => IMAGE_MIME[k] === ct.split(';')[0].trim());
|
|
123
|
+
if (ext) filename = 'image.' + ext;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const m = filename.toLowerCase().match(/\.(jpg|jpeg|png|webp)$/);
|
|
128
|
+
if (!m) throw new Error('Image must be .jpg, .jpeg, .png or .webp');
|
|
129
|
+
|
|
130
|
+
const base64 = buffer.toString('base64');
|
|
131
|
+
const ext = m[1] === 'jpg' ? 'jpeg' : m[1];
|
|
132
|
+
return api.post(`/posts/${id}/image`, { image: `data:image/${ext};base64,${base64}`, filename });
|
|
133
|
+
}
|
|
134
|
+
|
|
101
135
|
const VIDEO_MIME = { mp4: 'video/mp4', mov: 'video/quicktime', webm: 'video/webm' };
|
|
102
136
|
const VIDEO_MAX_BYTES = 120 * 1024 * 1024;
|
|
103
137
|
|
package/src/tools.js
CHANGED
|
@@ -152,6 +152,7 @@ export const tools = [
|
|
|
152
152
|
properties: {
|
|
153
153
|
campaign_id: { type: 'string', description: 'Campaign UUID to link to (optional)' },
|
|
154
154
|
type: { type: 'string', enum: ['text', 'carousel'], description: 'Post type (default: text)' },
|
|
155
|
+
placement: { type: 'string', enum: ['feed', 'story'], description: 'Publish destination (default: feed). "story" publishes as an Instagram Story (single media only; not for carousel).' },
|
|
155
156
|
caption_text: { type: 'string', description: 'Post caption text' },
|
|
156
157
|
cta: { type: 'string', description: 'Call-to-action text (e.g. "Link in bio")' },
|
|
157
158
|
hashtags: { type: 'array', items: { type: 'string' }, description: 'Hashtags (without #)' },
|
|
@@ -190,6 +191,7 @@ export const tools = [
|
|
|
190
191
|
image_description: { type: 'string', description: 'Image description for single-image posts' },
|
|
191
192
|
image_descriptions: { type: 'array', items: { type: 'string' }, description: 'Image descriptions per slide for carousel posts (3-6 items)' },
|
|
192
193
|
context: { type: 'string', description: 'Context/brief for AI text generation' },
|
|
194
|
+
placement: { type: 'string', enum: ['feed', 'story'], description: 'Publish destination: feed or story (Instagram Story). Carousel posts are always feed.' },
|
|
193
195
|
status: { type: 'string', enum: ['draft', 'scheduled', 'published'] },
|
|
194
196
|
scheduled_at: { type: 'string', description: 'Publish datetime (ISO-8601, must be in the future)' },
|
|
195
197
|
image_text_enabled: { type: 'boolean' },
|
|
@@ -224,6 +226,20 @@ export const tools = [
|
|
|
224
226
|
},
|
|
225
227
|
},
|
|
226
228
|
|
|
229
|
+
{
|
|
230
|
+
name: 'uploadPostImage',
|
|
231
|
+
description: 'Uploads a custom image (jpg, jpeg, png or webp) as the post media, replacing the current AI-generated image. Provide either file_path (local file) or image_url (public URL to download from).',
|
|
232
|
+
inputSchema: {
|
|
233
|
+
type: 'object',
|
|
234
|
+
required: ['id'],
|
|
235
|
+
properties: {
|
|
236
|
+
id: { type: 'string', description: 'Post UUID' },
|
|
237
|
+
file_path: { type: 'string', description: 'Absolute path to a local image file (jpg, jpeg, png, webp)' },
|
|
238
|
+
image_url: { type: 'string', description: 'Public URL of the image to download and upload' },
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
|
|
227
243
|
{
|
|
228
244
|
name: 'uploadPostVideo',
|
|
229
245
|
description: 'Uploads a video (mp4, mov or webm; up to 120 MB) as the post media, replacing the current image/video. Provide either file_path (local file) or video_url (public URL to download from). When the post is published to Instagram, videos are posted as Reels (also shared to the feed). Scheduling works the same as image posts.',
|