instance-mcp 0.1.0 → 0.2.0

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/dist/client.d.ts CHANGED
@@ -53,4 +53,32 @@ export declare class InstanceClient {
53
53
  variables?: Record<string, any>;
54
54
  }): Promise<any>;
55
55
  sendMessage(contactId: string, text: string, mediaUrl?: string): Promise<any>;
56
+ listScheduledPosts(params?: {
57
+ startDate?: string;
58
+ endDate?: string;
59
+ status?: string;
60
+ }): Promise<any>;
61
+ schedulePost(data: {
62
+ mediaUrls: string[];
63
+ caption: string;
64
+ scheduledAt: string;
65
+ mediaType?: string;
66
+ }): Promise<any>;
67
+ cancelScheduledPost(postId: string): Promise<any>;
68
+ getAudienceLists(): Promise<any>;
69
+ createAudienceList(data: {
70
+ name: string;
71
+ description?: string;
72
+ color?: string;
73
+ }): Promise<any>;
74
+ queryAudienceContacts(listId: string, params?: {
75
+ channelFilter?: string;
76
+ search?: string;
77
+ minScore?: number;
78
+ maxScore?: number;
79
+ page?: number;
80
+ limit?: number;
81
+ }): Promise<any>;
82
+ assignToAudienceList(listId: string, contactIds: string[]): Promise<any>;
83
+ deleteAudienceList(listId: string): Promise<any>;
56
84
  }
package/dist/client.js CHANGED
@@ -88,5 +88,31 @@ class InstanceClient {
88
88
  async sendMessage(contactId, text, mediaUrl) {
89
89
  return this.request('POST', '/api/v1/messages/send', { body: { contactId, text, mediaUrl } });
90
90
  }
91
+ // Content Scheduling
92
+ async listScheduledPosts(params) {
93
+ return this.request('GET', '/api/v1/posts', { query: params });
94
+ }
95
+ async schedulePost(data) {
96
+ return this.request('POST', '/api/v1/posts/schedule', { body: data });
97
+ }
98
+ async cancelScheduledPost(postId) {
99
+ return this.request('DELETE', `/api/v1/posts/${postId}`);
100
+ }
101
+ // Audience Lists & Segmentation
102
+ async getAudienceLists() {
103
+ return this.request('GET', '/api/v1/audience-lists');
104
+ }
105
+ async createAudienceList(data) {
106
+ return this.request('POST', '/api/v1/audience-lists', { body: data });
107
+ }
108
+ async queryAudienceContacts(listId, params) {
109
+ return this.request('GET', `/api/v1/audience-lists/${listId}/contacts`, { query: params });
110
+ }
111
+ async assignToAudienceList(listId, contactIds) {
112
+ return this.request('POST', `/api/v1/audience-lists/${listId}/assign`, { body: { contactIds } });
113
+ }
114
+ async deleteAudienceList(listId) {
115
+ return this.request('DELETE', `/api/v1/audience-lists/${listId}`);
116
+ }
91
117
  }
92
118
  exports.InstanceClient = InstanceClient;
package/dist/index.js CHANGED
@@ -167,6 +167,135 @@ server.tool("instance_send_message", "Send a direct message to a contact on Inst
167
167
  };
168
168
  }
169
169
  });
170
+ // 9. List Scheduled Posts
171
+ server.tool("instance_list_scheduled_posts", "List upcoming and past scheduled posts on Instagram with optional date and status filters.", {
172
+ startDate: zod_1.z.string().optional().describe("Optional start ISO date filter"),
173
+ endDate: zod_1.z.string().optional().describe("Optional end ISO date filter"),
174
+ status: zod_1.z.enum(["SCHEDULED", "PUBLISHED", "FAILED", "ALL"]).optional().describe("Filter by post status"),
175
+ }, async (args) => {
176
+ try {
177
+ const data = await client.listScheduledPosts(args);
178
+ return {
179
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
180
+ };
181
+ }
182
+ catch (err) {
183
+ return {
184
+ isError: true,
185
+ content: [{ type: "text", text: err.message || "Failed to list scheduled posts" }],
186
+ };
187
+ }
188
+ });
189
+ // 10. Schedule Post
190
+ server.tool("instance_schedule_post", "Schedule an Instagram post (image, reel, carousel, or story) with caption and publication time.", {
191
+ mediaUrls: zod_1.z.array(zod_1.z.string()).describe("Array of public media URLs to publish"),
192
+ caption: zod_1.z.string().describe("Post caption including hashtags"),
193
+ scheduledAt: zod_1.z.string().describe("ISO-8601 publication date/time string (must be in future)"),
194
+ mediaType: zod_1.z.enum(["IMAGE", "REEL", "CAROUSEL", "STORY"]).optional().describe("Post type (default: IMAGE)"),
195
+ }, async ({ mediaUrls, caption, scheduledAt, mediaType }) => {
196
+ try {
197
+ const data = await client.schedulePost({ mediaUrls, caption, scheduledAt, mediaType });
198
+ return {
199
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
200
+ };
201
+ }
202
+ catch (err) {
203
+ return {
204
+ isError: true,
205
+ content: [{ type: "text", text: err.message || "Failed to schedule post" }],
206
+ };
207
+ }
208
+ });
209
+ // 11. Cancel Scheduled Post
210
+ server.tool("instance_cancel_scheduled_post", "Cancel or delete an upcoming scheduled post before it is published.", {
211
+ postId: zod_1.z.string().describe("ID of the scheduled post to cancel"),
212
+ }, async ({ postId }) => {
213
+ try {
214
+ const data = await client.cancelScheduledPost(postId);
215
+ return {
216
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
217
+ };
218
+ }
219
+ catch (err) {
220
+ return {
221
+ isError: true,
222
+ content: [{ type: "text", text: err.message || "Failed to cancel scheduled post" }],
223
+ };
224
+ }
225
+ });
226
+ // 12. Get Audience Lists
227
+ server.tool("instance_get_audience_lists", "Get all audience lists and segmentation groups in the workspace with contact counts.", {}, async () => {
228
+ try {
229
+ const data = await client.getAudienceLists();
230
+ return {
231
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
232
+ };
233
+ }
234
+ catch (err) {
235
+ return {
236
+ isError: true,
237
+ content: [{ type: "text", text: err.message || "Failed to fetch audience lists" }],
238
+ };
239
+ }
240
+ });
241
+ // 13. Create Audience List
242
+ server.tool("instance_create_audience_list", "Create a new audience segmentation list (e.g. 'VIP Buyers', 'Black Friday Leads').", {
243
+ name: zod_1.z.string().describe("Name of the audience list"),
244
+ description: zod_1.z.string().optional().describe("Optional description"),
245
+ color: zod_1.z.string().optional().describe("Optional hex color or tag color"),
246
+ }, async (args) => {
247
+ try {
248
+ const data = await client.createAudienceList(args);
249
+ return {
250
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
251
+ };
252
+ }
253
+ catch (err) {
254
+ return {
255
+ isError: true,
256
+ content: [{ type: "text", text: err.message || "Failed to create audience list" }],
257
+ };
258
+ }
259
+ });
260
+ // 14. Query Audience Contacts
261
+ server.tool("instance_query_audience_contacts", "Query contacts in an audience list with deep channel (email/phone), score, and search filters.", {
262
+ listId: zod_1.z.string().describe("Target audience list ID"),
263
+ channelFilter: zod_1.z.enum(["all", "email", "phone", "both"]).optional().describe("Filter by available contact channel"),
264
+ search: zod_1.z.string().optional().describe("Search term for contact name, email, or username"),
265
+ page: zod_1.z.number().optional().describe("Page number (default: 1)"),
266
+ limit: zod_1.z.number().optional().describe("Page size (default: 25, max: 100)"),
267
+ }, async ({ listId, ...params }) => {
268
+ try {
269
+ const data = await client.queryAudienceContacts(listId, params);
270
+ return {
271
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
272
+ };
273
+ }
274
+ catch (err) {
275
+ return {
276
+ isError: true,
277
+ content: [{ type: "text", text: err.message || "Failed to query audience contacts" }],
278
+ };
279
+ }
280
+ });
281
+ // 15. Assign to Audience List
282
+ server.tool("instance_assign_to_audience_list", "Assign one or more contact IDs into an audience list.", {
283
+ listId: zod_1.z.string().describe("Target audience list ID"),
284
+ contactIds: zod_1.z.array(zod_1.z.string()).describe("Array of contact IDs to assign"),
285
+ }, async ({ listId, contactIds }) => {
286
+ try {
287
+ const data = await client.assignToAudienceList(listId, contactIds);
288
+ return {
289
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
290
+ };
291
+ }
292
+ catch (err) {
293
+ return {
294
+ isError: true,
295
+ content: [{ type: "text", text: err.message || "Failed to assign to audience list" }],
296
+ };
297
+ }
298
+ });
170
299
  async function main() {
171
300
  const transport = new stdio_js_1.StdioServerTransport();
172
301
  await server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instance-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Official Model Context Protocol (MCP) server for Instance AI Sales CRM",
5
5
  "private": false,
6
6
  "publishConfig": {