@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.
Files changed (84) hide show
  1. package/README.md +13 -9
  2. package/dist/client/index.d.ts +4 -0
  3. package/dist/client/index.d.ts.map +1 -1
  4. package/dist/client/index.js +47 -24
  5. package/dist/client/index.js.map +1 -1
  6. package/dist/config/index.d.ts +1 -1
  7. package/dist/config/index.d.ts.map +1 -1
  8. package/dist/config/index.js +55 -31
  9. package/dist/config/index.js.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +42 -36
  13. package/dist/index.js.map +1 -1
  14. package/dist/server.d.ts +2 -0
  15. package/dist/server.d.ts.map +1 -1
  16. package/dist/server.js +77 -54
  17. package/dist/server.js.map +1 -1
  18. package/dist/tools/annotations.d.ts +10 -0
  19. package/dist/tools/annotations.d.ts.map +1 -0
  20. package/dist/tools/annotations.js +28 -0
  21. package/dist/tools/annotations.js.map +1 -0
  22. package/dist/tools/calls.d.ts +1 -1
  23. package/dist/tools/calls.d.ts.map +1 -1
  24. package/dist/tools/calls.js +17 -13
  25. package/dist/tools/calls.js.map +1 -1
  26. package/dist/tools/chats.d.ts +1 -1
  27. package/dist/tools/chats.d.ts.map +1 -1
  28. package/dist/tools/chats.js +171 -101
  29. package/dist/tools/chats.js.map +1 -1
  30. package/dist/tools/communities.d.ts +1 -1
  31. package/dist/tools/communities.d.ts.map +1 -1
  32. package/dist/tools/communities.js +192 -120
  33. package/dist/tools/communities.js.map +1 -1
  34. package/dist/tools/contacts.d.ts +1 -1
  35. package/dist/tools/contacts.d.ts.map +1 -1
  36. package/dist/tools/contacts.js +76 -53
  37. package/dist/tools/contacts.js.map +1 -1
  38. package/dist/tools/groups.d.ts +1 -1
  39. package/dist/tools/groups.d.ts.map +1 -1
  40. package/dist/tools/groups.js +243 -149
  41. package/dist/tools/groups.js.map +1 -1
  42. package/dist/tools/media.d.ts +1 -1
  43. package/dist/tools/media.d.ts.map +1 -1
  44. package/dist/tools/media.js +30 -12
  45. package/dist/tools/media.js.map +1 -1
  46. package/dist/tools/messaging-advanced.d.ts +1 -1
  47. package/dist/tools/messaging-advanced.d.ts.map +1 -1
  48. package/dist/tools/messaging-advanced.js +184 -107
  49. package/dist/tools/messaging-advanced.js.map +1 -1
  50. package/dist/tools/messaging.d.ts +1 -1
  51. package/dist/tools/messaging.d.ts.map +1 -1
  52. package/dist/tools/messaging.js +274 -153
  53. package/dist/tools/messaging.js.map +1 -1
  54. package/dist/tools/newsletters.d.ts +1 -1
  55. package/dist/tools/newsletters.d.ts.map +1 -1
  56. package/dist/tools/newsletters.js +85 -49
  57. package/dist/tools/newsletters.js.map +1 -1
  58. package/dist/tools/session.d.ts +1 -1
  59. package/dist/tools/session.d.ts.map +1 -1
  60. package/dist/tools/session.js +74 -42
  61. package/dist/tools/session.js.map +1 -1
  62. package/dist/tools/status.d.ts +1 -1
  63. package/dist/tools/status.d.ts.map +1 -1
  64. package/dist/tools/status.js +71 -45
  65. package/dist/tools/status.js.map +1 -1
  66. package/dist/tools/users.d.ts +1 -1
  67. package/dist/tools/users.d.ts.map +1 -1
  68. package/dist/tools/users.js +115 -60
  69. package/dist/tools/users.js.map +1 -1
  70. package/dist/types/api.d.ts +5 -0
  71. package/dist/types/api.d.ts.map +1 -1
  72. package/dist/utils/errors.d.ts +1 -1
  73. package/dist/utils/errors.d.ts.map +1 -1
  74. package/dist/utils/errors.js +43 -42
  75. package/dist/utils/errors.js.map +1 -1
  76. package/dist/utils/logger.d.ts +1 -1
  77. package/dist/utils/logger.d.ts.map +1 -1
  78. package/dist/utils/logger.js +19 -19
  79. package/dist/utils/logger.js.map +1 -1
  80. package/dist/validation/schemas.d.ts +1 -1
  81. package/dist/validation/schemas.d.ts.map +1 -1
  82. package/dist/validation/schemas.js +50 -23
  83. package/dist/validation/schemas.js.map +1 -1
  84. package/package.json +2 -1
@@ -1,292 +1,413 @@
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');
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: 'whatsapp_send_text',
7
- description: 'Send a text message to a WhatsApp contact or group. Supports mentions, replies, and ephemeral expiration.',
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: 'object',
10
+ type: "object",
10
11
  properties: {
11
- to: { type: 'string', description: 'Recipient JID (user or group)' },
12
- text: { type: 'string', description: 'Message text content (max 4096 characters)' },
13
- mentions: { type: 'array', items: { type: 'string' }, description: 'JIDs of mentioned users' },
14
- replyTo: { type: 'string', description: 'ID of the message being replied to' },
15
- replyToSenderId: { type: 'string', description: 'Sender JID of the message being replied to' },
16
- isForwarded: { type: 'boolean', description: 'Mark as forwarded' },
17
- ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'], description: 'Disappearing message timer' },
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: ['to', 'text'],
37
+ required: ["to", "text"],
20
38
  },
21
39
  handler: async (args) => {
22
40
  const input = validateInput(sendTextMessageSchema, args);
23
- logger.info('Sending text message', { to: input.to, textLength: input.text.length });
24
- const result = await wsapiClient.post('/messages/text', input);
25
- logger.info('Text message sent successfully', { messageId: result.id });
26
- return { success: true, messageId: result.id, message: 'Text message sent successfully' };
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: 'whatsapp_send_image',
31
- description: 'Send an image message. Provide either data (base64) or url.',
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: 'object',
59
+ type: "object",
34
60
  properties: {
35
- to: { type: 'string', description: 'Recipient JID' },
36
- data: { type: 'string', description: 'Base64 encoded image data' },
37
- url: { type: 'string', description: 'URL of the image' },
38
- mimeType: { type: 'string', description: 'MIME type (auto-detected if omitted)' },
39
- caption: { type: 'string', description: 'Caption for the image' },
40
- mentions: { type: 'array', items: { type: 'string' }, description: 'JIDs of mentioned users' },
41
- replyTo: { type: 'string', description: 'Message ID to reply to' },
42
- replyToSenderId: { type: 'string', description: 'Sender JID of the replied message' },
43
- isForwarded: { type: 'boolean', description: 'Mark as forwarded' },
44
- viewOnce: { type: 'boolean', description: 'Send as view-once' },
45
- ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'] },
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: ['to'],
86
+ required: ["to"],
48
87
  },
49
88
  handler: async (args) => {
50
89
  const input = validateInput(sendMediaMessageSchema, args);
51
- logger.info('Sending image message', { to: input.to, hasCaption: !!input.caption });
52
- const result = await wsapiClient.post('/messages/image', input);
53
- logger.info('Image message sent successfully', { messageId: result.id });
54
- return { success: true, messageId: result.id, message: 'Image message sent successfully' };
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: 'whatsapp_send_video',
59
- description: 'Send a video message. Provide either data (base64) or url.',
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: 'object',
108
+ type: "object",
62
109
  properties: {
63
- to: { type: 'string', description: 'Recipient JID' },
64
- data: { type: 'string', description: 'Base64 encoded video data' },
65
- url: { type: 'string', description: 'URL of the video' },
66
- mimeType: { type: 'string', description: 'MIME type (auto-detected if omitted)' },
67
- caption: { type: 'string', description: 'Caption for the video' },
68
- mentions: { type: 'array', items: { type: 'string' } },
69
- replyTo: { type: 'string', description: 'Message ID to reply to' },
70
- replyToSenderId: { type: 'string', description: 'Sender JID of the replied message' },
71
- isForwarded: { type: 'boolean' },
72
- viewOnce: { type: 'boolean', description: 'Send as view-once' },
73
- ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'] },
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: ['to'],
131
+ required: ["to"],
76
132
  },
77
133
  handler: async (args) => {
78
134
  const input = validateInput(sendMediaMessageSchema, args);
79
- logger.info('Sending video message', { to: input.to });
80
- const result = await wsapiClient.post('/messages/video', input);
81
- logger.info('Video message sent successfully', { messageId: result.id });
82
- return { success: true, messageId: result.id, message: 'Video message sent successfully' };
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: 'whatsapp_send_link',
87
- description: 'Send a link message with optional preview.',
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: 'object',
150
+ type: "object",
90
151
  properties: {
91
- to: { type: 'string', description: 'Recipient JID' },
92
- text: { type: 'string', description: 'Message text (max 4096 characters)' },
93
- url: { type: 'string', description: 'URL to include' },
94
- title: { type: 'string', description: 'Link preview title' },
95
- description: { type: 'string', description: 'Link preview description' },
96
- jpegThumbnail: { type: 'string', description: 'Base64 JPEG thumbnail' },
97
- mentions: { type: 'array', items: { type: 'string' } },
98
- replyTo: { type: 'string' },
99
- replyToSenderId: { type: 'string' },
100
- isForwarded: { type: 'boolean' },
101
- ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'] },
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: ['to', 'text', 'url'],
170
+ required: ["to", "text", "url"],
104
171
  },
105
172
  handler: async (args) => {
106
173
  const input = validateInput(sendLinkMessageSchema, args);
107
- logger.info('Sending link message', { to: input.to, url: input.url });
108
- const result = await wsapiClient.post('/messages/link', input);
109
- logger.info('Link message sent successfully', { messageId: result.id });
110
- return { success: true, messageId: result.id, message: 'Link message sent successfully' };
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: 'whatsapp_send_reaction',
115
- description: 'Send a reaction (emoji) to a message. Send empty string to remove reaction.',
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: 'object',
189
+ type: "object",
118
190
  properties: {
119
- messageId: { type: 'string', description: 'ID of the message to react to' },
120
- to: { type: 'string', description: 'Chat JID' },
121
- senderId: { type: 'string', description: 'Sender of the original message (for groups)' },
122
- reaction: { type: 'string', description: 'Emoji reaction (empty string to remove)' },
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: ['messageId', 'to', 'reaction'],
205
+ required: ["messageId", "to", "reaction"],
125
206
  },
126
207
  handler: async (args) => {
127
208
  const input = validateInput(sendReactionMessageSchema, args);
128
- logger.info('Sending reaction', { messageId: input.messageId, to: input.to });
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('Reaction sent successfully');
135
- return { success: true, messageId: result.id, message: 'Reaction sent successfully' };
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: 'whatsapp_edit_message',
140
- description: 'Edit a previously sent text message.',
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: 'object',
231
+ type: "object",
143
232
  properties: {
144
- messageId: { type: 'string', description: 'ID of the message to edit' },
145
- to: { type: 'string', description: 'Chat JID' },
146
- text: { type: 'string', description: 'New text content (max 4096 characters)' },
147
- mentions: { type: 'array', items: { type: 'string' } },
148
- ephemeralExpiration: { type: 'string', enum: ['off', '24h', '7d', '90d'] },
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: ['messageId', 'to', 'text'],
245
+ required: ["messageId", "to", "text"],
151
246
  },
152
247
  handler: async (args) => {
153
248
  const input = validateInput(editMessageSchema, args);
154
- logger.info('Editing message', { messageId: input.messageId });
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('Message edited successfully');
162
- return { success: true, messageId: result.id, message: 'Message edited successfully' };
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: 'whatsapp_delete_message',
167
- description: 'Delete a message for all participants.',
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: 'object',
269
+ type: "object",
170
270
  properties: {
171
- messageId: { type: 'string', description: 'ID of the message to delete' },
172
- chatId: { type: 'string', description: 'Chat JID' },
173
- senderId: { type: 'string', description: 'Message sender JID' },
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: ['messageId', 'chatId', 'senderId'],
275
+ required: ["messageId", "chatId", "senderId"],
176
276
  },
177
277
  handler: async (args) => {
178
278
  const input = validateInput(deleteMessageSchema, args);
179
- logger.info('Deleting message', { messageId: input.messageId });
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('Message deleted successfully');
185
- return { success: true, message: 'Message deleted successfully' };
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: 'whatsapp_delete_message_for_me',
190
- description: 'Delete a message only for yourself.',
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: 'object',
293
+ type: "object",
193
294
  properties: {
194
- messageId: { type: 'string', description: 'ID of the message to delete' },
195
- chatId: { type: 'string', description: 'Chat JID' },
196
- senderId: { type: 'string', description: 'Message sender JID' },
197
- isFromMe: { type: 'boolean', description: 'Whether the message was sent by you' },
198
- timestamp: { type: 'string', description: 'Message timestamp (ISO 8601)' },
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: ['messageId', 'chatId'],
307
+ required: ["messageId", "chatId"],
201
308
  },
202
309
  handler: async (args) => {
203
310
  const input = validateInput(deleteMessageForMeSchema, args);
204
- logger.info('Deleting message for me', { messageId: input.messageId });
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('Message deleted for me successfully');
212
- return { success: true, message: 'Message deleted for me successfully' };
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: 'whatsapp_mark_message_read',
217
- description: 'Mark a message as read.',
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: 'object',
327
+ type: "object",
220
328
  properties: {
221
- messageId: { type: 'string', description: 'Message ID' },
222
- chatId: { type: 'string', description: 'Chat JID' },
223
- senderId: { type: 'string', description: 'Message sender JID' },
224
- receiptType: { type: 'string', enum: ['delivered', 'sender', 'read', 'played'], description: 'Receipt type' },
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: ['messageId', 'chatId', 'senderId', 'receiptType'],
338
+ required: ["messageId", "chatId", "senderId", "receiptType"],
227
339
  },
228
340
  handler: async (args) => {
229
341
  const input = validateInput(markMessageAsReadSchema, args);
230
- logger.info('Marking message as read', { messageId: input.messageId });
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: 'Message marked as read successfully' };
348
+ return { success: true, message: "Message marked as read successfully" };
237
349
  },
238
350
  };
239
351
  export const starMessage = {
240
- name: 'whatsapp_star_message',
241
- description: 'Star or unstar a message.',
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: 'object',
356
+ type: "object",
244
357
  properties: {
245
- messageId: { type: 'string', description: 'Message ID' },
246
- chatId: { type: 'string', description: 'Chat JID' },
247
- senderId: { type: 'string', description: 'Message sender JID' },
248
- starred: { type: 'boolean', description: 'True to star, false to unstar' },
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: ['messageId', 'chatId', 'senderId'],
366
+ required: ["messageId", "chatId", "senderId"],
251
367
  },
252
368
  handler: async (args) => {
253
369
  const input = validateInput(starMessageSchema, args);
254
- logger.info('Starring message', { messageId: input.messageId });
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: 'Message starred successfully' };
376
+ return { success: true, message: "Message starred successfully" };
261
377
  },
262
378
  };
263
379
  export const pinMessage = {
264
- name: 'whatsapp_pin_message',
265
- description: 'Pin or unpin a message in a chat.',
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: 'object',
384
+ type: "object",
268
385
  properties: {
269
- messageId: { type: 'string', description: 'Message ID' },
270
- chatId: { type: 'string', description: 'Chat JID' },
271
- senderId: { type: 'string', description: 'Message sender JID' },
272
- pinned: { type: 'boolean', description: 'True to pin, false to unpin' },
273
- pinExpiration: { type: 'string', description: 'Pin expiration (e.g. 24h, 7d, 30d)' },
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: ['messageId', 'chatId', 'senderId'],
395
+ required: ["messageId", "chatId", "senderId"],
276
396
  },
277
397
  handler: async (args) => {
278
398
  const input = validateInput(pinMessageSchema, args);
279
- logger.info('Pinning message', { messageId: input.messageId });
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: 'Message pin updated successfully' };
406
+ return { success: true, message: "Message pin updated successfully" };
287
407
  },
288
408
  };
289
- import { advancedMessagingTools } from './messaging-advanced.js';
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,