@wsapichat/mcp-server 2.0.0 → 3.1.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/README.md +13 -9
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +47 -24
- package/dist/client/index.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +55 -31
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -36
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +77 -54
- package/dist/server.js.map +1 -1
- package/dist/tools/annotations.d.ts +10 -0
- package/dist/tools/annotations.d.ts.map +1 -0
- package/dist/tools/annotations.js +28 -0
- package/dist/tools/annotations.js.map +1 -0
- package/dist/tools/calls.d.ts +1 -1
- package/dist/tools/calls.d.ts.map +1 -1
- package/dist/tools/calls.js +17 -13
- package/dist/tools/calls.js.map +1 -1
- package/dist/tools/chats.d.ts +1 -1
- package/dist/tools/chats.d.ts.map +1 -1
- package/dist/tools/chats.js +171 -101
- package/dist/tools/chats.js.map +1 -1
- package/dist/tools/communities.d.ts +1 -1
- package/dist/tools/communities.d.ts.map +1 -1
- package/dist/tools/communities.js +192 -120
- package/dist/tools/communities.js.map +1 -1
- package/dist/tools/contacts.d.ts +1 -1
- package/dist/tools/contacts.d.ts.map +1 -1
- package/dist/tools/contacts.js +76 -53
- package/dist/tools/contacts.js.map +1 -1
- package/dist/tools/groups.d.ts +1 -1
- package/dist/tools/groups.d.ts.map +1 -1
- package/dist/tools/groups.js +243 -149
- package/dist/tools/groups.js.map +1 -1
- package/dist/tools/media.d.ts +1 -1
- package/dist/tools/media.d.ts.map +1 -1
- package/dist/tools/media.js +30 -12
- package/dist/tools/media.js.map +1 -1
- package/dist/tools/messaging-advanced.d.ts +1 -1
- package/dist/tools/messaging-advanced.d.ts.map +1 -1
- package/dist/tools/messaging-advanced.js +184 -107
- package/dist/tools/messaging-advanced.js.map +1 -1
- package/dist/tools/messaging.d.ts +1 -1
- package/dist/tools/messaging.d.ts.map +1 -1
- package/dist/tools/messaging.js +274 -153
- package/dist/tools/messaging.js.map +1 -1
- package/dist/tools/newsletters.d.ts +1 -1
- package/dist/tools/newsletters.d.ts.map +1 -1
- package/dist/tools/newsletters.js +85 -49
- package/dist/tools/newsletters.js.map +1 -1
- package/dist/tools/session.d.ts +1 -1
- package/dist/tools/session.d.ts.map +1 -1
- package/dist/tools/session.js +74 -42
- package/dist/tools/session.js.map +1 -1
- package/dist/tools/status.d.ts +1 -1
- package/dist/tools/status.d.ts.map +1 -1
- package/dist/tools/status.js +71 -45
- package/dist/tools/status.js.map +1 -1
- package/dist/tools/users.d.ts +1 -1
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js +115 -60
- package/dist/tools/users.js.map +1 -1
- package/dist/types/api.d.ts +5 -0
- package/dist/types/api.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +1 -1
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +43 -42
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +19 -19
- package/dist/utils/logger.js.map +1 -1
- package/dist/validation/schemas.d.ts +1 -1
- package/dist/validation/schemas.d.ts.map +1 -1
- package/dist/validation/schemas.js +50 -23
- package/dist/validation/schemas.js.map +1 -1
- package/package.json +2 -1
package/dist/tools/messaging.js
CHANGED
|
@@ -1,292 +1,413 @@
|
|
|
1
|
-
import { wsapiClient } from
|
|
2
|
-
import { createLogger } from
|
|
3
|
-
import { validateInput, sendTextMessageSchema, sendMediaMessageSchema, sendLinkMessageSchema, sendReactionMessageSchema, editMessageSchema, deleteMessageSchema, deleteMessageForMeSchema, markMessageAsReadSchema, starMessageSchema, pinMessageSchema, } from
|
|
4
|
-
const logger = createLogger(
|
|
1
|
+
import { wsapiClient } from "../client/index.js";
|
|
2
|
+
import { createLogger } from "../utils/logger.js";
|
|
3
|
+
import { validateInput, sendTextMessageSchema, sendMediaMessageSchema, sendLinkMessageSchema, sendReactionMessageSchema, editMessageSchema, deleteMessageSchema, deleteMessageForMeSchema, markMessageAsReadSchema, starMessageSchema, pinMessageSchema, } from "../validation/schemas.js";
|
|
4
|
+
const logger = createLogger("messaging-tools");
|
|
5
5
|
export const sendTextMessage = {
|
|
6
|
-
name:
|
|
7
|
-
description:
|
|
6
|
+
name: "whatsapp_send_text",
|
|
7
|
+
description: "Send a text message to a user JID or a group JID (<id>@g.us). The recipient receives it immediately and it cannot be unsent, only deleted with whatsapp_delete_message. Supports mentions, replies and a disappearing timer. Not idempotent: calling it twice sends two messages. Returns the message ID.",
|
|
8
|
+
annotations: CREATE,
|
|
8
9
|
inputSchema: {
|
|
9
|
-
type:
|
|
10
|
+
type: "object",
|
|
10
11
|
properties: {
|
|
11
|
-
to: { type:
|
|
12
|
-
text: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
to: { type: "string", description: "Recipient JID (user or group)" },
|
|
13
|
+
text: {
|
|
14
|
+
type: "string",
|
|
15
|
+
description: "Message text content (max 4096 characters)",
|
|
16
|
+
},
|
|
17
|
+
mentions: {
|
|
18
|
+
type: "array",
|
|
19
|
+
items: { type: "string" },
|
|
20
|
+
description: "JIDs of mentioned users",
|
|
21
|
+
},
|
|
22
|
+
replyTo: {
|
|
23
|
+
type: "string",
|
|
24
|
+
description: "ID of the message being replied to",
|
|
25
|
+
},
|
|
26
|
+
replyToSenderId: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Sender JID of the message being replied to",
|
|
29
|
+
},
|
|
30
|
+
isForwarded: { type: "boolean", description: "Mark as forwarded" },
|
|
31
|
+
ephemeralExpiration: {
|
|
32
|
+
type: "string",
|
|
33
|
+
enum: ["off", "24h", "7d", "90d"],
|
|
34
|
+
description: "Disappearing message timer",
|
|
35
|
+
},
|
|
18
36
|
},
|
|
19
|
-
required: [
|
|
37
|
+
required: ["to", "text"],
|
|
20
38
|
},
|
|
21
39
|
handler: async (args) => {
|
|
22
40
|
const input = validateInput(sendTextMessageSchema, args);
|
|
23
|
-
logger.info(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
logger.info("Sending text message", {
|
|
42
|
+
to: input.to,
|
|
43
|
+
textLength: input.text.length,
|
|
44
|
+
});
|
|
45
|
+
const result = await wsapiClient.post("/messages/text", input);
|
|
46
|
+
logger.info("Text message sent successfully", { messageId: result.id });
|
|
47
|
+
return {
|
|
48
|
+
success: true,
|
|
49
|
+
messageId: result.id,
|
|
50
|
+
message: "Text message sent successfully",
|
|
51
|
+
};
|
|
27
52
|
},
|
|
28
53
|
};
|
|
29
54
|
export const sendImageMessage = {
|
|
30
|
-
name:
|
|
31
|
-
description:
|
|
55
|
+
name: "whatsapp_send_image",
|
|
56
|
+
description: "Send an image, from base64 data or a public URL, with an optional caption, to a user or group JID. The recipient receives it immediately; set viewOnce for a view-once image. Not idempotent. Returns the message ID.",
|
|
57
|
+
annotations: CREATE,
|
|
32
58
|
inputSchema: {
|
|
33
|
-
type:
|
|
59
|
+
type: "object",
|
|
34
60
|
properties: {
|
|
35
|
-
to: { type:
|
|
36
|
-
data: { type:
|
|
37
|
-
url: { type:
|
|
38
|
-
mimeType: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
to: { type: "string", description: "Recipient JID" },
|
|
62
|
+
data: { type: "string", description: "Base64 encoded image data" },
|
|
63
|
+
url: { type: "string", description: "URL of the image" },
|
|
64
|
+
mimeType: {
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "MIME type (auto-detected if omitted)",
|
|
67
|
+
},
|
|
68
|
+
caption: { type: "string", description: "Caption for the image" },
|
|
69
|
+
mentions: {
|
|
70
|
+
type: "array",
|
|
71
|
+
items: { type: "string" },
|
|
72
|
+
description: "JIDs of mentioned users",
|
|
73
|
+
},
|
|
74
|
+
replyTo: { type: "string", description: "Message ID to reply to" },
|
|
75
|
+
replyToSenderId: {
|
|
76
|
+
type: "string",
|
|
77
|
+
description: "Sender JID of the replied message",
|
|
78
|
+
},
|
|
79
|
+
isForwarded: { type: "boolean", description: "Mark as forwarded" },
|
|
80
|
+
viewOnce: { type: "boolean", description: "Send as view-once" },
|
|
81
|
+
ephemeralExpiration: {
|
|
82
|
+
type: "string",
|
|
83
|
+
enum: ["off", "24h", "7d", "90d"],
|
|
84
|
+
},
|
|
46
85
|
},
|
|
47
|
-
required: [
|
|
86
|
+
required: ["to"],
|
|
48
87
|
},
|
|
49
88
|
handler: async (args) => {
|
|
50
89
|
const input = validateInput(sendMediaMessageSchema, args);
|
|
51
|
-
logger.info(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
90
|
+
logger.info("Sending image message", {
|
|
91
|
+
to: input.to,
|
|
92
|
+
hasCaption: !!input.caption,
|
|
93
|
+
});
|
|
94
|
+
const result = await wsapiClient.post("/messages/image", input);
|
|
95
|
+
logger.info("Image message sent successfully", { messageId: result.id });
|
|
96
|
+
return {
|
|
97
|
+
success: true,
|
|
98
|
+
messageId: result.id,
|
|
99
|
+
message: "Image message sent successfully",
|
|
100
|
+
};
|
|
55
101
|
},
|
|
56
102
|
};
|
|
57
103
|
export const sendVideoMessage = {
|
|
58
|
-
name:
|
|
59
|
-
description:
|
|
104
|
+
name: "whatsapp_send_video",
|
|
105
|
+
description: "Send a video, from base64 data or a public URL, with an optional caption, to a user or group JID. The recipient receives it immediately. Not idempotent. Returns the message ID.",
|
|
106
|
+
annotations: CREATE,
|
|
60
107
|
inputSchema: {
|
|
61
|
-
type:
|
|
108
|
+
type: "object",
|
|
62
109
|
properties: {
|
|
63
|
-
to: { type:
|
|
64
|
-
data: { type:
|
|
65
|
-
url: { type:
|
|
66
|
-
mimeType: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
110
|
+
to: { type: "string", description: "Recipient JID" },
|
|
111
|
+
data: { type: "string", description: "Base64 encoded video data" },
|
|
112
|
+
url: { type: "string", description: "URL of the video" },
|
|
113
|
+
mimeType: {
|
|
114
|
+
type: "string",
|
|
115
|
+
description: "MIME type (auto-detected if omitted)",
|
|
116
|
+
},
|
|
117
|
+
caption: { type: "string", description: "Caption for the video" },
|
|
118
|
+
mentions: { type: "array", items: { type: "string" } },
|
|
119
|
+
replyTo: { type: "string", description: "Message ID to reply to" },
|
|
120
|
+
replyToSenderId: {
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "Sender JID of the replied message",
|
|
123
|
+
},
|
|
124
|
+
isForwarded: { type: "boolean" },
|
|
125
|
+
viewOnce: { type: "boolean", description: "Send as view-once" },
|
|
126
|
+
ephemeralExpiration: {
|
|
127
|
+
type: "string",
|
|
128
|
+
enum: ["off", "24h", "7d", "90d"],
|
|
129
|
+
},
|
|
74
130
|
},
|
|
75
|
-
required: [
|
|
131
|
+
required: ["to"],
|
|
76
132
|
},
|
|
77
133
|
handler: async (args) => {
|
|
78
134
|
const input = validateInput(sendMediaMessageSchema, args);
|
|
79
|
-
logger.info(
|
|
80
|
-
const result = await wsapiClient.post(
|
|
81
|
-
logger.info(
|
|
82
|
-
return {
|
|
135
|
+
logger.info("Sending video message", { to: input.to });
|
|
136
|
+
const result = await wsapiClient.post("/messages/video", input);
|
|
137
|
+
logger.info("Video message sent successfully", { messageId: result.id });
|
|
138
|
+
return {
|
|
139
|
+
success: true,
|
|
140
|
+
messageId: result.id,
|
|
141
|
+
message: "Video message sent successfully",
|
|
142
|
+
};
|
|
83
143
|
},
|
|
84
144
|
};
|
|
85
145
|
export const sendLinkMessage = {
|
|
86
|
-
name:
|
|
87
|
-
description:
|
|
146
|
+
name: "whatsapp_send_link",
|
|
147
|
+
description: "Send a text message with a link preview (title, description and thumbnail). Use it instead of whatsapp_send_text when you want to control how the preview looks. Not idempotent. Returns the message ID.",
|
|
148
|
+
annotations: CREATE,
|
|
88
149
|
inputSchema: {
|
|
89
|
-
type:
|
|
150
|
+
type: "object",
|
|
90
151
|
properties: {
|
|
91
|
-
to: { type:
|
|
92
|
-
text: {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
152
|
+
to: { type: "string", description: "Recipient JID" },
|
|
153
|
+
text: {
|
|
154
|
+
type: "string",
|
|
155
|
+
description: "Message text (max 4096 characters)",
|
|
156
|
+
},
|
|
157
|
+
url: { type: "string", description: "URL to include" },
|
|
158
|
+
title: { type: "string", description: "Link preview title" },
|
|
159
|
+
description: { type: "string", description: "Link preview description" },
|
|
160
|
+
jpegThumbnail: { type: "string", description: "Base64 JPEG thumbnail" },
|
|
161
|
+
mentions: { type: "array", items: { type: "string" } },
|
|
162
|
+
replyTo: { type: "string" },
|
|
163
|
+
replyToSenderId: { type: "string" },
|
|
164
|
+
isForwarded: { type: "boolean" },
|
|
165
|
+
ephemeralExpiration: {
|
|
166
|
+
type: "string",
|
|
167
|
+
enum: ["off", "24h", "7d", "90d"],
|
|
168
|
+
},
|
|
102
169
|
},
|
|
103
|
-
required: [
|
|
170
|
+
required: ["to", "text", "url"],
|
|
104
171
|
},
|
|
105
172
|
handler: async (args) => {
|
|
106
173
|
const input = validateInput(sendLinkMessageSchema, args);
|
|
107
|
-
logger.info(
|
|
108
|
-
const result = await wsapiClient.post(
|
|
109
|
-
logger.info(
|
|
110
|
-
return {
|
|
174
|
+
logger.info("Sending link message", { to: input.to, url: input.url });
|
|
175
|
+
const result = await wsapiClient.post("/messages/link", input);
|
|
176
|
+
logger.info("Link message sent successfully", { messageId: result.id });
|
|
177
|
+
return {
|
|
178
|
+
success: true,
|
|
179
|
+
messageId: result.id,
|
|
180
|
+
message: "Link message sent successfully",
|
|
181
|
+
};
|
|
111
182
|
},
|
|
112
183
|
};
|
|
113
184
|
export const sendReactionMessage = {
|
|
114
|
-
name:
|
|
115
|
-
description:
|
|
185
|
+
name: "whatsapp_send_reaction",
|
|
186
|
+
description: "React to a message with an emoji, or remove this number's reaction by sending an empty string. Everyone in the chat sees it. Repeating it replaces the reaction. Returns a success confirmation.",
|
|
187
|
+
annotations: SET,
|
|
116
188
|
inputSchema: {
|
|
117
|
-
type:
|
|
189
|
+
type: "object",
|
|
118
190
|
properties: {
|
|
119
|
-
messageId: {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
191
|
+
messageId: {
|
|
192
|
+
type: "string",
|
|
193
|
+
description: "ID of the message to react to",
|
|
194
|
+
},
|
|
195
|
+
to: { type: "string", description: "Chat JID" },
|
|
196
|
+
senderId: {
|
|
197
|
+
type: "string",
|
|
198
|
+
description: "Sender of the original message (for groups)",
|
|
199
|
+
},
|
|
200
|
+
reaction: {
|
|
201
|
+
type: "string",
|
|
202
|
+
description: "Emoji reaction (empty string to remove)",
|
|
203
|
+
},
|
|
123
204
|
},
|
|
124
|
-
required: [
|
|
205
|
+
required: ["messageId", "to", "reaction"],
|
|
125
206
|
},
|
|
126
207
|
handler: async (args) => {
|
|
127
208
|
const input = validateInput(sendReactionMessageSchema, args);
|
|
128
|
-
logger.info(
|
|
209
|
+
logger.info("Sending reaction", {
|
|
210
|
+
messageId: input.messageId,
|
|
211
|
+
to: input.to,
|
|
212
|
+
});
|
|
129
213
|
const result = await wsapiClient.post(`/messages/${input.messageId}/reaction`, {
|
|
130
214
|
to: input.to,
|
|
131
215
|
senderId: input.senderId,
|
|
132
216
|
reaction: input.reaction,
|
|
133
217
|
});
|
|
134
|
-
logger.info(
|
|
135
|
-
return {
|
|
218
|
+
logger.info("Reaction sent successfully");
|
|
219
|
+
return {
|
|
220
|
+
success: true,
|
|
221
|
+
messageId: result.id,
|
|
222
|
+
message: "Reaction sent successfully",
|
|
223
|
+
};
|
|
136
224
|
},
|
|
137
225
|
};
|
|
138
226
|
export const editMessage = {
|
|
139
|
-
name:
|
|
140
|
-
description:
|
|
227
|
+
name: "whatsapp_edit_message",
|
|
228
|
+
description: "Edit the text of a message this number sent. Everyone in the chat sees it marked as edited. WhatsApp only allows it for about 15 minutes after sending. Returns a success confirmation.",
|
|
229
|
+
annotations: SET,
|
|
141
230
|
inputSchema: {
|
|
142
|
-
type:
|
|
231
|
+
type: "object",
|
|
143
232
|
properties: {
|
|
144
|
-
messageId: { type:
|
|
145
|
-
to: { type:
|
|
146
|
-
text: {
|
|
147
|
-
|
|
148
|
-
|
|
233
|
+
messageId: { type: "string", description: "ID of the message to edit" },
|
|
234
|
+
to: { type: "string", description: "Chat JID" },
|
|
235
|
+
text: {
|
|
236
|
+
type: "string",
|
|
237
|
+
description: "New text content (max 4096 characters)",
|
|
238
|
+
},
|
|
239
|
+
mentions: { type: "array", items: { type: "string" } },
|
|
240
|
+
ephemeralExpiration: {
|
|
241
|
+
type: "string",
|
|
242
|
+
enum: ["off", "24h", "7d", "90d"],
|
|
243
|
+
},
|
|
149
244
|
},
|
|
150
|
-
required: [
|
|
245
|
+
required: ["messageId", "to", "text"],
|
|
151
246
|
},
|
|
152
247
|
handler: async (args) => {
|
|
153
248
|
const input = validateInput(editMessageSchema, args);
|
|
154
|
-
logger.info(
|
|
249
|
+
logger.info("Editing message", { messageId: input.messageId });
|
|
155
250
|
const result = await wsapiClient.post(`/messages/${input.messageId}/edit`, {
|
|
156
251
|
to: input.to,
|
|
157
252
|
text: input.text,
|
|
158
253
|
mentions: input.mentions,
|
|
159
254
|
ephemeralExpiration: input.ephemeralExpiration,
|
|
160
255
|
});
|
|
161
|
-
logger.info(
|
|
162
|
-
return {
|
|
256
|
+
logger.info("Message edited successfully");
|
|
257
|
+
return {
|
|
258
|
+
success: true,
|
|
259
|
+
messageId: result.id,
|
|
260
|
+
message: "Message edited successfully",
|
|
261
|
+
};
|
|
163
262
|
},
|
|
164
263
|
};
|
|
165
264
|
export const deleteMessage = {
|
|
166
|
-
name:
|
|
167
|
-
description:
|
|
265
|
+
name: "whatsapp_delete_message",
|
|
266
|
+
description: "Delete a message for everyone in the chat. It cannot be undone; participants see that a message was deleted. Only works on messages this number sent (or, as group admin, on others' messages in the group). To hide a message only on this account, use whatsapp_delete_message_for_me. Returns a success confirmation.",
|
|
267
|
+
annotations: DESTRUCTIVE,
|
|
168
268
|
inputSchema: {
|
|
169
|
-
type:
|
|
269
|
+
type: "object",
|
|
170
270
|
properties: {
|
|
171
|
-
messageId: { type:
|
|
172
|
-
chatId: { type:
|
|
173
|
-
senderId: { type:
|
|
271
|
+
messageId: { type: "string", description: "ID of the message to delete" },
|
|
272
|
+
chatId: { type: "string", description: "Chat JID" },
|
|
273
|
+
senderId: { type: "string", description: "Message sender JID" },
|
|
174
274
|
},
|
|
175
|
-
required: [
|
|
275
|
+
required: ["messageId", "chatId", "senderId"],
|
|
176
276
|
},
|
|
177
277
|
handler: async (args) => {
|
|
178
278
|
const input = validateInput(deleteMessageSchema, args);
|
|
179
|
-
logger.info(
|
|
279
|
+
logger.info("Deleting message", { messageId: input.messageId });
|
|
180
280
|
await wsapiClient.post(`/messages/${input.messageId}/delete`, {
|
|
181
281
|
chatId: input.chatId,
|
|
182
282
|
senderId: input.senderId,
|
|
183
283
|
});
|
|
184
|
-
logger.info(
|
|
185
|
-
return { success: true, message:
|
|
284
|
+
logger.info("Message deleted successfully");
|
|
285
|
+
return { success: true, message: "Message deleted successfully" };
|
|
186
286
|
},
|
|
187
287
|
};
|
|
188
288
|
export const deleteMessageForMe = {
|
|
189
|
-
name:
|
|
190
|
-
description:
|
|
289
|
+
name: "whatsapp_delete_message_for_me",
|
|
290
|
+
description: "Delete a message only on this account. Other participants still see it. It cannot be undone. To remove it for everyone, use whatsapp_delete_message. Returns a success confirmation.",
|
|
291
|
+
annotations: DESTRUCTIVE,
|
|
191
292
|
inputSchema: {
|
|
192
|
-
type:
|
|
293
|
+
type: "object",
|
|
193
294
|
properties: {
|
|
194
|
-
messageId: { type:
|
|
195
|
-
chatId: { type:
|
|
196
|
-
senderId: { type:
|
|
197
|
-
isFromMe: {
|
|
198
|
-
|
|
295
|
+
messageId: { type: "string", description: "ID of the message to delete" },
|
|
296
|
+
chatId: { type: "string", description: "Chat JID" },
|
|
297
|
+
senderId: { type: "string", description: "Message sender JID" },
|
|
298
|
+
isFromMe: {
|
|
299
|
+
type: "boolean",
|
|
300
|
+
description: "Whether the message was sent by you",
|
|
301
|
+
},
|
|
302
|
+
timestamp: {
|
|
303
|
+
type: "string",
|
|
304
|
+
description: "Message timestamp (ISO 8601)",
|
|
305
|
+
},
|
|
199
306
|
},
|
|
200
|
-
required: [
|
|
307
|
+
required: ["messageId", "chatId"],
|
|
201
308
|
},
|
|
202
309
|
handler: async (args) => {
|
|
203
310
|
const input = validateInput(deleteMessageForMeSchema, args);
|
|
204
|
-
logger.info(
|
|
311
|
+
logger.info("Deleting message for me", { messageId: input.messageId });
|
|
205
312
|
await wsapiClient.post(`/messages/${input.messageId}/delete-for-me`, {
|
|
206
313
|
chatId: input.chatId,
|
|
207
314
|
senderId: input.senderId,
|
|
208
315
|
isFromMe: input.isFromMe,
|
|
209
316
|
timestamp: input.timestamp,
|
|
210
317
|
});
|
|
211
|
-
logger.info(
|
|
212
|
-
return { success: true, message:
|
|
318
|
+
logger.info("Message deleted for me successfully");
|
|
319
|
+
return { success: true, message: "Message deleted for me successfully" };
|
|
213
320
|
},
|
|
214
321
|
};
|
|
215
322
|
export const markMessageAsRead = {
|
|
216
|
-
name:
|
|
217
|
-
description:
|
|
323
|
+
name: "whatsapp_mark_message_read",
|
|
324
|
+
description: "Send a read receipt for a message, so the sender sees it as read (blue ticks, if their privacy settings allow). To mark a whole chat, use whatsapp_mark_chat_as_read. Returns a success confirmation.",
|
|
325
|
+
annotations: SET,
|
|
218
326
|
inputSchema: {
|
|
219
|
-
type:
|
|
327
|
+
type: "object",
|
|
220
328
|
properties: {
|
|
221
|
-
messageId: { type:
|
|
222
|
-
chatId: { type:
|
|
223
|
-
senderId: { type:
|
|
224
|
-
receiptType: {
|
|
329
|
+
messageId: { type: "string", description: "Message ID" },
|
|
330
|
+
chatId: { type: "string", description: "Chat JID" },
|
|
331
|
+
senderId: { type: "string", description: "Message sender JID" },
|
|
332
|
+
receiptType: {
|
|
333
|
+
type: "string",
|
|
334
|
+
enum: ["delivered", "sender", "read", "played"],
|
|
335
|
+
description: "Receipt type",
|
|
336
|
+
},
|
|
225
337
|
},
|
|
226
|
-
required: [
|
|
338
|
+
required: ["messageId", "chatId", "senderId", "receiptType"],
|
|
227
339
|
},
|
|
228
340
|
handler: async (args) => {
|
|
229
341
|
const input = validateInput(markMessageAsReadSchema, args);
|
|
230
|
-
logger.info(
|
|
342
|
+
logger.info("Marking message as read", { messageId: input.messageId });
|
|
231
343
|
await wsapiClient.post(`/messages/${input.messageId}/read`, {
|
|
232
344
|
chatId: input.chatId,
|
|
233
345
|
senderId: input.senderId,
|
|
234
346
|
receiptType: input.receiptType,
|
|
235
347
|
});
|
|
236
|
-
return { success: true, message:
|
|
348
|
+
return { success: true, message: "Message marked as read successfully" };
|
|
237
349
|
},
|
|
238
350
|
};
|
|
239
351
|
export const starMessage = {
|
|
240
|
-
name:
|
|
241
|
-
description:
|
|
352
|
+
name: "whatsapp_star_message",
|
|
353
|
+
description: "Star or unstar a message on this account. Only this account sees it. Returns a success confirmation.",
|
|
354
|
+
annotations: SET,
|
|
242
355
|
inputSchema: {
|
|
243
|
-
type:
|
|
356
|
+
type: "object",
|
|
244
357
|
properties: {
|
|
245
|
-
messageId: { type:
|
|
246
|
-
chatId: { type:
|
|
247
|
-
senderId: { type:
|
|
248
|
-
starred: {
|
|
358
|
+
messageId: { type: "string", description: "Message ID" },
|
|
359
|
+
chatId: { type: "string", description: "Chat JID" },
|
|
360
|
+
senderId: { type: "string", description: "Message sender JID" },
|
|
361
|
+
starred: {
|
|
362
|
+
type: "boolean",
|
|
363
|
+
description: "True to star, false to unstar",
|
|
364
|
+
},
|
|
249
365
|
},
|
|
250
|
-
required: [
|
|
366
|
+
required: ["messageId", "chatId", "senderId"],
|
|
251
367
|
},
|
|
252
368
|
handler: async (args) => {
|
|
253
369
|
const input = validateInput(starMessageSchema, args);
|
|
254
|
-
logger.info(
|
|
370
|
+
logger.info("Starring message", { messageId: input.messageId });
|
|
255
371
|
await wsapiClient.post(`/messages/${input.messageId}/star`, {
|
|
256
372
|
chatId: input.chatId,
|
|
257
373
|
senderId: input.senderId,
|
|
258
374
|
starred: input.starred,
|
|
259
375
|
});
|
|
260
|
-
return { success: true, message:
|
|
376
|
+
return { success: true, message: "Message starred successfully" };
|
|
261
377
|
},
|
|
262
378
|
};
|
|
263
379
|
export const pinMessage = {
|
|
264
|
-
name:
|
|
265
|
-
description:
|
|
380
|
+
name: "whatsapp_pin_message",
|
|
381
|
+
description: "Pin or unpin a message in a chat, optionally for a limited time. Everyone in the chat sees the pin. To pin a whole chat in the list, use whatsapp_pin_chat. Returns a success confirmation.",
|
|
382
|
+
annotations: SET,
|
|
266
383
|
inputSchema: {
|
|
267
|
-
type:
|
|
384
|
+
type: "object",
|
|
268
385
|
properties: {
|
|
269
|
-
messageId: { type:
|
|
270
|
-
chatId: { type:
|
|
271
|
-
senderId: { type:
|
|
272
|
-
pinned: { type:
|
|
273
|
-
pinExpiration: {
|
|
386
|
+
messageId: { type: "string", description: "Message ID" },
|
|
387
|
+
chatId: { type: "string", description: "Chat JID" },
|
|
388
|
+
senderId: { type: "string", description: "Message sender JID" },
|
|
389
|
+
pinned: { type: "boolean", description: "True to pin, false to unpin" },
|
|
390
|
+
pinExpiration: {
|
|
391
|
+
type: "string",
|
|
392
|
+
description: "Pin expiration (e.g. 24h, 7d, 30d)",
|
|
393
|
+
},
|
|
274
394
|
},
|
|
275
|
-
required: [
|
|
395
|
+
required: ["messageId", "chatId", "senderId"],
|
|
276
396
|
},
|
|
277
397
|
handler: async (args) => {
|
|
278
398
|
const input = validateInput(pinMessageSchema, args);
|
|
279
|
-
logger.info(
|
|
399
|
+
logger.info("Pinning message", { messageId: input.messageId });
|
|
280
400
|
await wsapiClient.post(`/messages/${input.messageId}/pin`, {
|
|
281
401
|
chatId: input.chatId,
|
|
282
402
|
senderId: input.senderId,
|
|
283
403
|
pinned: input.pinned,
|
|
284
404
|
pinExpiration: input.pinExpiration,
|
|
285
405
|
});
|
|
286
|
-
return { success: true, message:
|
|
406
|
+
return { success: true, message: "Message pin updated successfully" };
|
|
287
407
|
},
|
|
288
408
|
};
|
|
289
|
-
import { advancedMessagingTools } from
|
|
409
|
+
import { advancedMessagingTools } from "./messaging-advanced.js";
|
|
410
|
+
import { CREATE, DESTRUCTIVE, SET } from "./annotations.js";
|
|
290
411
|
export const messagingTools = {
|
|
291
412
|
sendTextMessage,
|
|
292
413
|
sendImageMessage,
|