@chykalophia/clickup-mcp-server 3.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/LICENSE +21 -0
- package/README.md +467 -0
- package/bin/clickup-mcp-server-ai.js +9 -0
- package/bin/clickup-mcp-server-basic.js +9 -0
- package/bin/clickup-mcp-server-efficiency.js +9 -0
- package/bin/clickup-mcp-server-enhanced.js +9 -0
- package/build/app.d.ts +1 -0
- package/build/app.js +2 -0
- package/build/app.js.map +1 -0
- package/build/clickup-client/attachments-enhanced.d.ts +128 -0
- package/build/clickup-client/attachments-enhanced.js +212 -0
- package/build/clickup-client/attachments-enhanced.js.map +1 -0
- package/build/clickup-client/auth.d.ts +254 -0
- package/build/clickup-client/auth.js +105 -0
- package/build/clickup-client/auth.js.map +1 -0
- package/build/clickup-client/chat-enhanced.d.ts +141 -0
- package/build/clickup-client/chat-enhanced.js +196 -0
- package/build/clickup-client/chat-enhanced.js.map +1 -0
- package/build/clickup-client/checklists.d.ts +87 -0
- package/build/clickup-client/checklists.js +63 -0
- package/build/clickup-client/checklists.js.map +1 -0
- package/build/clickup-client/comments-enhanced.d.ts +176 -0
- package/build/clickup-client/comments-enhanced.js +230 -0
- package/build/clickup-client/comments-enhanced.js.map +1 -0
- package/build/clickup-client/comments.d.ts +173 -0
- package/build/clickup-client/comments.js +312 -0
- package/build/clickup-client/comments.js.map +1 -0
- package/build/clickup-client/custom-fields-enhanced.d.ts +286 -0
- package/build/clickup-client/custom-fields-enhanced.js +416 -0
- package/build/clickup-client/custom-fields-enhanced.js.map +1 -0
- package/build/clickup-client/dependencies-enhanced.d.ts +144 -0
- package/build/clickup-client/dependencies-enhanced.js +142 -0
- package/build/clickup-client/dependencies-enhanced.js.map +1 -0
- package/build/clickup-client/docs-enhanced.d.ts +176 -0
- package/build/clickup-client/docs-enhanced.js +374 -0
- package/build/clickup-client/docs-enhanced.js.map +1 -0
- package/build/clickup-client/docs.d.ts +84 -0
- package/build/clickup-client/docs.js +156 -0
- package/build/clickup-client/docs.js.map +1 -0
- package/build/clickup-client/folders.d.ts +62 -0
- package/build/clickup-client/folders.js +53 -0
- package/build/clickup-client/folders.js.map +1 -0
- package/build/clickup-client/goals-enhanced.d.ts +163 -0
- package/build/clickup-client/goals-enhanced.js +309 -0
- package/build/clickup-client/goals-enhanced.js.map +1 -0
- package/build/clickup-client/index.d.ts +16 -0
- package/build/clickup-client/index.js +61 -0
- package/build/clickup-client/index.js.map +1 -0
- package/build/clickup-client/lists.d.ts +105 -0
- package/build/clickup-client/lists.js +108 -0
- package/build/clickup-client/lists.js.map +1 -0
- package/build/clickup-client/secure-client.d.ts +88 -0
- package/build/clickup-client/secure-client.js +275 -0
- package/build/clickup-client/secure-client.js.map +1 -0
- package/build/clickup-client/spaces.d.ts +58 -0
- package/build/clickup-client/spaces.js +28 -0
- package/build/clickup-client/spaces.js.map +1 -0
- package/build/clickup-client/tasks.d.ts +161 -0
- package/build/clickup-client/tasks.js +99 -0
- package/build/clickup-client/tasks.js.map +1 -0
- package/build/clickup-client/time-tracking-enhanced.d.ts +153 -0
- package/build/clickup-client/time-tracking-enhanced.js +292 -0
- package/build/clickup-client/time-tracking-enhanced.js.map +1 -0
- package/build/clickup-client/views-enhanced.d.ts +149 -0
- package/build/clickup-client/views-enhanced.js +210 -0
- package/build/clickup-client/views-enhanced.js.map +1 -0
- package/build/clickup-client/webhooks-enhanced.d.ts +119 -0
- package/build/clickup-client/webhooks-enhanced.js +169 -0
- package/build/clickup-client/webhooks-enhanced.js.map +1 -0
- package/build/controllers/lists.controller.d.ts +1 -0
- package/build/controllers/lists.controller.js +2 -0
- package/build/controllers/lists.controller.js.map +1 -0
- package/build/index-efficiency-simple.d.ts +2 -0
- package/build/index-efficiency-simple.js +379 -0
- package/build/index-efficiency-simple.js.map +1 -0
- package/build/index-enhanced-efficiency.d.ts +2 -0
- package/build/index-enhanced-efficiency.js +275 -0
- package/build/index-enhanced-efficiency.js.map +1 -0
- package/build/index-enhanced.d.ts +2 -0
- package/build/index-enhanced.js +74 -0
- package/build/index-enhanced.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +77 -0
- package/build/index.js.map +1 -0
- package/build/resources/checklist-resources.d.ts +2 -0
- package/build/resources/checklist-resources.js +102 -0
- package/build/resources/checklist-resources.js.map +1 -0
- package/build/resources/comment-resources.d.ts +2 -0
- package/build/resources/comment-resources.js +152 -0
- package/build/resources/comment-resources.js.map +1 -0
- package/build/resources/doc-resources.d.ts +2 -0
- package/build/resources/doc-resources.js +77 -0
- package/build/resources/doc-resources.js.map +1 -0
- package/build/resources/folder-resources.d.ts +2 -0
- package/build/resources/folder-resources.js +160 -0
- package/build/resources/folder-resources.js.map +1 -0
- package/build/resources/list-resources.d.ts +2 -0
- package/build/resources/list-resources.js +104 -0
- package/build/resources/list-resources.js.map +1 -0
- package/build/resources/space-resources.d.ts +2 -0
- package/build/resources/space-resources.js +104 -0
- package/build/resources/space-resources.js.map +1 -0
- package/build/resources/task-resources.d.ts +2 -0
- package/build/resources/task-resources.js +57 -0
- package/build/resources/task-resources.js.map +1 -0
- package/build/routes/lists.routes.d.ts +1 -0
- package/build/routes/lists.routes.js +2 -0
- package/build/routes/lists.routes.js.map +1 -0
- package/build/schemas/attachments-schemas.d.ts +201 -0
- package/build/schemas/attachments-schemas.js +250 -0
- package/build/schemas/attachments-schemas.js.map +1 -0
- package/build/schemas/chat-schemas.d.ts +478 -0
- package/build/schemas/chat-schemas.js +173 -0
- package/build/schemas/chat-schemas.js.map +1 -0
- package/build/schemas/custom-field-schemas.d.ts +1617 -0
- package/build/schemas/custom-field-schemas.js +384 -0
- package/build/schemas/custom-field-schemas.js.map +1 -0
- package/build/schemas/dependencies-schemas.d.ts +274 -0
- package/build/schemas/dependencies-schemas.js +176 -0
- package/build/schemas/dependencies-schemas.js.map +1 -0
- package/build/schemas/document-schemas.d.ts +433 -0
- package/build/schemas/document-schemas.js +168 -0
- package/build/schemas/document-schemas.js.map +1 -0
- package/build/schemas/goals-schemas.d.ts +961 -0
- package/build/schemas/goals-schemas.js +293 -0
- package/build/schemas/goals-schemas.js.map +1 -0
- package/build/schemas/time-tracking-schemas.d.ts +741 -0
- package/build/schemas/time-tracking-schemas.js +234 -0
- package/build/schemas/time-tracking-schemas.js.map +1 -0
- package/build/schemas/views-schemas.d.ts +1168 -0
- package/build/schemas/views-schemas.js +221 -0
- package/build/schemas/views-schemas.js.map +1 -0
- package/build/schemas/webhook-schemas.d.ts +1127 -0
- package/build/schemas/webhook-schemas.js +137 -0
- package/build/schemas/webhook-schemas.js.map +1 -0
- package/build/services/lists.service.d.ts +1 -0
- package/build/services/lists.service.js +2 -0
- package/build/services/lists.service.js.map +1 -0
- package/build/tools/attachments-tools-setup.d.ts +2 -0
- package/build/tools/attachments-tools-setup.js +387 -0
- package/build/tools/attachments-tools-setup.js.map +1 -0
- package/build/tools/chat-tools-enhanced.d.ts +5 -0
- package/build/tools/chat-tools-enhanced.js +396 -0
- package/build/tools/chat-tools-enhanced.js.map +1 -0
- package/build/tools/chat-tools.d.ts +2 -0
- package/build/tools/chat-tools.js +614 -0
- package/build/tools/chat-tools.js.map +1 -0
- package/build/tools/checklist-tools.d.ts +2 -0
- package/build/tools/checklist-tools.js +139 -0
- package/build/tools/checklist-tools.js.map +1 -0
- package/build/tools/comment-tools.d.ts +2 -0
- package/build/tools/comment-tools.js +295 -0
- package/build/tools/comment-tools.js.map +1 -0
- package/build/tools/custom-field-tools.d.ts +2 -0
- package/build/tools/custom-field-tools.js +578 -0
- package/build/tools/custom-field-tools.js.map +1 -0
- package/build/tools/dependencies-tools-setup.d.ts +2 -0
- package/build/tools/dependencies-tools-setup.js +319 -0
- package/build/tools/dependencies-tools-setup.js.map +1 -0
- package/build/tools/doc-tools-enhanced.d.ts +2 -0
- package/build/tools/doc-tools-enhanced.js +417 -0
- package/build/tools/doc-tools-enhanced.js.map +1 -0
- package/build/tools/doc-tools.d.ts +2 -0
- package/build/tools/doc-tools.js +109 -0
- package/build/tools/doc-tools.js.map +1 -0
- package/build/tools/goals-tools.d.ts +2 -0
- package/build/tools/goals-tools.js +422 -0
- package/build/tools/goals-tools.js.map +1 -0
- package/build/tools/helper-tools.d.ts +2 -0
- package/build/tools/helper-tools.js +363 -0
- package/build/tools/helper-tools.js.map +1 -0
- package/build/tools/space-tools.d.ts +2 -0
- package/build/tools/space-tools.js +45 -0
- package/build/tools/space-tools.js.map +1 -0
- package/build/tools/task-tools.d.ts +2 -0
- package/build/tools/task-tools.js +415 -0
- package/build/tools/task-tools.js.map +1 -0
- package/build/tools/time-tracking-tools.d.ts +2 -0
- package/build/tools/time-tracking-tools.js +329 -0
- package/build/tools/time-tracking-tools.js.map +1 -0
- package/build/tools/views-tools-setup.d.ts +2 -0
- package/build/tools/views-tools-setup.js +358 -0
- package/build/tools/views-tools-setup.js.map +1 -0
- package/build/tools/webhook-tools-setup.d.ts +2 -0
- package/build/tools/webhook-tools-setup.js +304 -0
- package/build/tools/webhook-tools-setup.js.map +1 -0
- package/build/tools/webhook-tools.d.ts +4 -0
- package/build/tools/webhook-tools.js +345 -0
- package/build/tools/webhook-tools.js.map +1 -0
- package/build/utils/clickup-comment-formatter.d.ts +124 -0
- package/build/utils/clickup-comment-formatter.js +504 -0
- package/build/utils/clickup-comment-formatter.js.map +1 -0
- package/build/utils/context-aware-suggestions.d.ts +45 -0
- package/build/utils/context-aware-suggestions.js +360 -0
- package/build/utils/context-aware-suggestions.js.map +1 -0
- package/build/utils/error-handling.d.ts +140 -0
- package/build/utils/error-handling.js +392 -0
- package/build/utils/error-handling.js.map +1 -0
- package/build/utils/markdown-styling.d.ts +40 -0
- package/build/utils/markdown-styling.js +344 -0
- package/build/utils/markdown-styling.js.map +1 -0
- package/build/utils/markdown.d.ts +54 -0
- package/build/utils/markdown.js +243 -0
- package/build/utils/markdown.js.map +1 -0
- package/build/utils/security.d.ts +79 -0
- package/build/utils/security.js +303 -0
- package/build/utils/security.js.map +1 -0
- package/build/utils/tool-efficiency.d.ts +59 -0
- package/build/utils/tool-efficiency.js +247 -0
- package/build/utils/tool-efficiency.js.map +1 -0
- package/package.json +130 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { WebhooksEnhancedClient } from '../clickup-client/webhooks-enhanced.js';
|
|
3
|
+
import { CreateWebhookSchema, UpdateWebhookSchema, WebhookFilterSchema, ValidateWebhookSignatureSchema, ProcessWebhookSchema, WebhookPayloadSchema } from '../schemas/webhook-schemas.js';
|
|
4
|
+
// Create clients
|
|
5
|
+
// const clickUpClient = createClickUpClient();
|
|
6
|
+
const webhooksClient = new WebhooksEnhancedClient(process.env.CLICKUP_API_TOKEN);
|
|
7
|
+
export function setupWebhookTools(server) {
|
|
8
|
+
// ========================================
|
|
9
|
+
// WEBHOOK MANAGEMENT OPERATIONS
|
|
10
|
+
// ========================================
|
|
11
|
+
server.tool('create_webhook', 'Create a new webhook in a ClickUp workspace. Webhooks allow real-time notifications when events occur.', {
|
|
12
|
+
workspace_id: z.string().min(1).describe('The ID of the workspace to create the webhook in'),
|
|
13
|
+
endpoint: z.string().url().describe('The URL endpoint that will receive webhook notifications'),
|
|
14
|
+
events: z.array(z.enum([
|
|
15
|
+
'taskCreated', 'taskUpdated', 'taskDeleted', 'taskStatusUpdated',
|
|
16
|
+
'taskAssigneeUpdated', 'taskDueDateUpdated', 'taskCommentPosted',
|
|
17
|
+
'taskCommentUpdated', 'taskTimeTracked', 'taskTimeUpdated',
|
|
18
|
+
'listCreated', 'listUpdated', 'listDeleted',
|
|
19
|
+
'folderCreated', 'folderUpdated', 'folderDeleted',
|
|
20
|
+
'spaceCreated', 'spaceUpdated', 'spaceDeleted',
|
|
21
|
+
'goalCreated', 'goalUpdated', 'goalDeleted', 'goalTargetUpdated'
|
|
22
|
+
])).describe('Array of events to subscribe to'),
|
|
23
|
+
health_check_url: z.string().url().optional().describe('Optional URL for webhook health checks'),
|
|
24
|
+
secret: z.string().optional().describe('Optional secret for HMAC signature validation')
|
|
25
|
+
}, async (args) => {
|
|
26
|
+
try {
|
|
27
|
+
const request = CreateWebhookSchema.parse(args);
|
|
28
|
+
const result = await webhooksClient.createWebhook(request);
|
|
29
|
+
return {
|
|
30
|
+
content: [{
|
|
31
|
+
type: 'text',
|
|
32
|
+
text: `Webhook created successfully:\n\n${JSON.stringify(result, null, 2)}`
|
|
33
|
+
}]
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return {
|
|
38
|
+
content: [{
|
|
39
|
+
type: 'text',
|
|
40
|
+
text: `Error creating webhook: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
41
|
+
}],
|
|
42
|
+
isError: true
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
server.tool('get_webhooks', 'Get all webhooks for a workspace with optional filtering by status or event type.', {
|
|
47
|
+
workspace_id: z.string().min(1).describe('The ID of the workspace to get webhooks from'),
|
|
48
|
+
status: z.enum(['active', 'inactive']).optional().describe('Filter webhooks by status'),
|
|
49
|
+
event_type: z.string().optional().describe('Filter webhooks by event type')
|
|
50
|
+
}, async (args) => {
|
|
51
|
+
try {
|
|
52
|
+
const filter = WebhookFilterSchema.parse(args);
|
|
53
|
+
const result = await webhooksClient.getWebhooks(filter);
|
|
54
|
+
return {
|
|
55
|
+
content: [{
|
|
56
|
+
type: 'text',
|
|
57
|
+
text: `Webhooks for workspace ${args.workspace_id}:\n\n${JSON.stringify(result, null, 2)}`
|
|
58
|
+
}]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return {
|
|
63
|
+
content: [{
|
|
64
|
+
type: 'text',
|
|
65
|
+
text: `Error getting webhooks: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
66
|
+
}],
|
|
67
|
+
isError: true
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
server.tool('get_webhook', 'Get detailed information about a specific webhook by its ID.', {
|
|
72
|
+
webhook_id: z.string().min(1).describe('The ID of the webhook to get')
|
|
73
|
+
}, async (args) => {
|
|
74
|
+
try {
|
|
75
|
+
const result = await webhooksClient.getWebhook(args.webhook_id);
|
|
76
|
+
return {
|
|
77
|
+
content: [{
|
|
78
|
+
type: 'text',
|
|
79
|
+
text: `Webhook details:\n\n${JSON.stringify(result, null, 2)}`
|
|
80
|
+
}]
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return {
|
|
85
|
+
content: [{
|
|
86
|
+
type: 'text',
|
|
87
|
+
text: `Error getting webhook: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
88
|
+
}],
|
|
89
|
+
isError: true
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
server.tool('update_webhook', 'Update an existing webhook\'s configuration including endpoint, events, and status.', {
|
|
94
|
+
webhook_id: z.string().min(1).describe('The ID of the webhook to update'),
|
|
95
|
+
endpoint: z.string().url().optional().describe('The new URL endpoint for webhook notifications'),
|
|
96
|
+
events: z.array(z.enum([
|
|
97
|
+
'taskCreated', 'taskUpdated', 'taskDeleted', 'taskStatusUpdated',
|
|
98
|
+
'taskAssigneeUpdated', 'taskDueDateUpdated', 'taskCommentPosted',
|
|
99
|
+
'taskCommentUpdated', 'taskTimeTracked', 'taskTimeUpdated',
|
|
100
|
+
'listCreated', 'listUpdated', 'listDeleted',
|
|
101
|
+
'folderCreated', 'folderUpdated', 'folderDeleted',
|
|
102
|
+
'spaceCreated', 'spaceUpdated', 'spaceDeleted',
|
|
103
|
+
'goalCreated', 'goalUpdated', 'goalDeleted', 'goalTargetUpdated'
|
|
104
|
+
])).optional().describe('New array of events to subscribe to'),
|
|
105
|
+
health_check_url: z.string().url().optional().describe('New URL for webhook health checks'),
|
|
106
|
+
secret: z.string().optional().describe('New secret for HMAC signature validation'),
|
|
107
|
+
status: z.enum(['active', 'inactive']).optional().describe('New status for the webhook')
|
|
108
|
+
}, async (args) => {
|
|
109
|
+
try {
|
|
110
|
+
const request = UpdateWebhookSchema.parse(args);
|
|
111
|
+
const result = await webhooksClient.updateWebhook(request);
|
|
112
|
+
return {
|
|
113
|
+
content: [{
|
|
114
|
+
type: 'text',
|
|
115
|
+
text: `Webhook updated successfully:\n\n${JSON.stringify(result, null, 2)}`
|
|
116
|
+
}]
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return {
|
|
121
|
+
content: [{
|
|
122
|
+
type: 'text',
|
|
123
|
+
text: `Error updating webhook: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
124
|
+
}],
|
|
125
|
+
isError: true
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
server.tool('delete_webhook', 'Delete a webhook from ClickUp. This will stop all notifications to the webhook endpoint.', {
|
|
130
|
+
webhook_id: z.string().min(1).describe('The ID of the webhook to delete')
|
|
131
|
+
}, async (args) => {
|
|
132
|
+
try {
|
|
133
|
+
const result = await webhooksClient.deleteWebhook(args.webhook_id);
|
|
134
|
+
return {
|
|
135
|
+
content: [{
|
|
136
|
+
type: 'text',
|
|
137
|
+
text: `Webhook deleted successfully: ${JSON.stringify(result, null, 2)}`
|
|
138
|
+
}]
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
return {
|
|
143
|
+
content: [{
|
|
144
|
+
type: 'text',
|
|
145
|
+
text: `Error deleting webhook: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
146
|
+
}],
|
|
147
|
+
isError: true
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
server.tool('get_webhook_event_history', 'Get the event history for a webhook including delivery status and response codes.', {
|
|
152
|
+
webhook_id: z.string().min(1).describe('The ID of the webhook to get event history for'),
|
|
153
|
+
limit: z.number().positive().optional().describe('Maximum number of events to return')
|
|
154
|
+
}, async (args) => {
|
|
155
|
+
try {
|
|
156
|
+
const result = await webhooksClient.getWebhookEventHistory(args.webhook_id, args.limit);
|
|
157
|
+
return {
|
|
158
|
+
content: [{
|
|
159
|
+
type: 'text',
|
|
160
|
+
text: `Webhook event history:\n\n${JSON.stringify(result, null, 2)}`
|
|
161
|
+
}]
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
return {
|
|
166
|
+
content: [{
|
|
167
|
+
type: 'text',
|
|
168
|
+
text: `Error getting webhook event history: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
169
|
+
}],
|
|
170
|
+
isError: true
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
server.tool('ping_webhook', 'Send a test ping to a webhook endpoint to verify it\'s working correctly.', {
|
|
175
|
+
webhook_id: z.string().min(1).describe('The ID of the webhook to ping')
|
|
176
|
+
}, async (args) => {
|
|
177
|
+
try {
|
|
178
|
+
const result = await webhooksClient.pingWebhook(args.webhook_id);
|
|
179
|
+
return {
|
|
180
|
+
content: [{
|
|
181
|
+
type: 'text',
|
|
182
|
+
text: `Webhook ping result:\n\n${JSON.stringify(result, null, 2)}`
|
|
183
|
+
}]
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
return {
|
|
188
|
+
content: [{
|
|
189
|
+
type: 'text',
|
|
190
|
+
text: `Error pinging webhook: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
191
|
+
}],
|
|
192
|
+
isError: true
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
server.tool('validate_webhook_signature', 'Validate the HMAC signature of a webhook payload to ensure authenticity.', {
|
|
197
|
+
payload: z.string().describe('The raw webhook payload as a string'),
|
|
198
|
+
signature: z.string().describe('The signature header from the webhook request'),
|
|
199
|
+
secret: z.string().describe('The webhook secret used for signature generation')
|
|
200
|
+
}, async (args) => {
|
|
201
|
+
try {
|
|
202
|
+
const request = ValidateWebhookSignatureSchema.parse(args);
|
|
203
|
+
const isValid = webhooksClient.validateWebhookSignature(request);
|
|
204
|
+
const result = { valid: isValid };
|
|
205
|
+
return {
|
|
206
|
+
content: [{
|
|
207
|
+
type: 'text',
|
|
208
|
+
text: `Webhook signature validation result:\n\n${JSON.stringify(result, null, 2)}`
|
|
209
|
+
}]
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
return {
|
|
214
|
+
content: [{
|
|
215
|
+
type: 'text',
|
|
216
|
+
text: `Error validating webhook signature: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
217
|
+
}],
|
|
218
|
+
isError: true
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
server.tool('process_webhook', 'Process an incoming webhook payload and extract structured information about the event.', {
|
|
223
|
+
payload: z.any().describe('The webhook payload object'),
|
|
224
|
+
validate_signature: z.boolean().default(true).describe('Whether to validate the webhook signature'),
|
|
225
|
+
signature: z.string().optional().describe('The signature header for validation'),
|
|
226
|
+
secret: z.string().optional().describe('The webhook secret for signature validation')
|
|
227
|
+
}, async (args) => {
|
|
228
|
+
try {
|
|
229
|
+
// Parse the payload if it's a string
|
|
230
|
+
let payload = args.payload;
|
|
231
|
+
if (typeof payload === 'string') {
|
|
232
|
+
payload = JSON.parse(payload);
|
|
233
|
+
}
|
|
234
|
+
const parsedPayload = WebhookPayloadSchema.parse(payload);
|
|
235
|
+
const request = ProcessWebhookSchema.parse({
|
|
236
|
+
...args,
|
|
237
|
+
payload: parsedPayload
|
|
238
|
+
});
|
|
239
|
+
const result = await webhooksClient.processWebhook(request);
|
|
240
|
+
return {
|
|
241
|
+
content: [{
|
|
242
|
+
type: 'text',
|
|
243
|
+
text: `Webhook processing result:\n\n${JSON.stringify(result, null, 2)}`
|
|
244
|
+
}]
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
return {
|
|
249
|
+
content: [{
|
|
250
|
+
type: 'text',
|
|
251
|
+
text: `Error processing webhook: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
252
|
+
}],
|
|
253
|
+
isError: true
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
server.tool('get_webhook_stats', 'Get statistics about webhook performance including success rate and response times.', {
|
|
258
|
+
webhook_id: z.string().min(1).describe('The ID of the webhook to get statistics for'),
|
|
259
|
+
days: z.number().positive().optional().describe('Number of days to include in statistics (default: 30)')
|
|
260
|
+
}, async (args) => {
|
|
261
|
+
try {
|
|
262
|
+
const result = await webhooksClient.getWebhookStats(args.webhook_id, args.days);
|
|
263
|
+
return {
|
|
264
|
+
content: [{
|
|
265
|
+
type: 'text',
|
|
266
|
+
text: `Webhook statistics:\n\n${JSON.stringify(result, null, 2)}`
|
|
267
|
+
}]
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
return {
|
|
272
|
+
content: [{
|
|
273
|
+
type: 'text',
|
|
274
|
+
text: `Error getting webhook statistics: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
275
|
+
}],
|
|
276
|
+
isError: true
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
server.tool('retry_webhook_events', 'Retry failed webhook events for a specific webhook.', {
|
|
281
|
+
webhook_id: z.string().min(1).describe('The ID of the webhook to retry events for'),
|
|
282
|
+
event_ids: z.array(z.string()).optional().describe('Optional array of specific event IDs to retry. If not provided, all failed events will be retried.')
|
|
283
|
+
}, async (args) => {
|
|
284
|
+
try {
|
|
285
|
+
const result = await webhooksClient.retryWebhookEvents(args.webhook_id, args.event_ids);
|
|
286
|
+
return {
|
|
287
|
+
content: [{
|
|
288
|
+
type: 'text',
|
|
289
|
+
text: `Webhook events retry result:\n\n${JSON.stringify(result, null, 2)}`
|
|
290
|
+
}]
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
return {
|
|
295
|
+
content: [{
|
|
296
|
+
type: 'text',
|
|
297
|
+
text: `Error retrying webhook events: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
298
|
+
}],
|
|
299
|
+
isError: true
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
//# sourceMappingURL=webhook-tools-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-tools-setup.js","sourceRoot":"","sources":["../../src/tools/webhook-tools-setup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,8BAA8B,EAC9B,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AAEvC,iBAAiB;AACjB,+CAA+C;AAC/C,MAAM,cAAc,GAAG,IAAI,sBAAsB,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAkB,CAAC,CAAC;AAElF,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IAEjD,2CAA2C;IAC3C,gCAAgC;IAChC,2CAA2C;IAE3C,MAAM,CAAC,IAAI,CACT,gBAAgB,EAChB,wGAAwG,EACxG;QACE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,kDAAkD,CAAC;QAC5F,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,0DAA0D,CAAC;QAC/F,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;YACrB,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB;YAChE,qBAAqB,EAAE,oBAAoB,EAAE,mBAAmB;YAChE,oBAAoB,EAAE,iBAAiB,EAAE,iBAAiB;YAC1D,aAAa,EAAE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EAAE;qBAC3E,CAAC;aACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,kCAAkC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE;qBACnG,CAAC;gBACF,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { WebhooksEnhancedClient } from '../clickup-client/webhooks-enhanced.js';
|
|
3
|
+
export declare function createWebhookTools(_client: WebhooksEnhancedClient): Tool[];
|
|
4
|
+
export declare function handleWebhookTool(name: string, args: any, client: WebhooksEnhancedClient): Promise<any>;
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { CreateWebhookSchema, UpdateWebhookSchema, WebhookFilterSchema, ValidateWebhookSignatureSchema, ProcessWebhookSchema, WebhookPayloadSchema } from '../schemas/webhook-schemas.js';
|
|
2
|
+
export function createWebhookTools(_client) {
|
|
3
|
+
return [
|
|
4
|
+
// Create webhook
|
|
5
|
+
{
|
|
6
|
+
name: 'create_webhook',
|
|
7
|
+
description: 'Create a new webhook in a ClickUp workspace. Webhooks allow real-time notifications when events occur.',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
workspace_id: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'The ID of the workspace to create the webhook in'
|
|
14
|
+
},
|
|
15
|
+
endpoint: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'The URL endpoint that will receive webhook notifications'
|
|
18
|
+
},
|
|
19
|
+
events: {
|
|
20
|
+
type: 'array',
|
|
21
|
+
items: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
enum: [
|
|
24
|
+
'taskCreated', 'taskUpdated', 'taskDeleted', 'taskStatusUpdated',
|
|
25
|
+
'taskAssigneeUpdated', 'taskDueDateUpdated', 'taskCommentPosted',
|
|
26
|
+
'taskCommentUpdated', 'taskTimeTracked', 'taskTimeUpdated',
|
|
27
|
+
'listCreated', 'listUpdated', 'listDeleted',
|
|
28
|
+
'folderCreated', 'folderUpdated', 'folderDeleted',
|
|
29
|
+
'spaceCreated', 'spaceUpdated', 'spaceDeleted',
|
|
30
|
+
'goalCreated', 'goalUpdated', 'goalDeleted', 'goalTargetUpdated'
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
description: 'Array of events to subscribe to'
|
|
34
|
+
},
|
|
35
|
+
health_check_url: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Optional URL for webhook health checks'
|
|
38
|
+
},
|
|
39
|
+
secret: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'Optional secret for HMAC signature validation'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
required: ['workspace_id', 'endpoint', 'events']
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
// Get webhooks
|
|
48
|
+
{
|
|
49
|
+
name: 'get_webhooks',
|
|
50
|
+
description: 'Get all webhooks for a workspace with optional filtering by status or event type.',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
workspace_id: {
|
|
55
|
+
type: 'string',
|
|
56
|
+
description: 'The ID of the workspace to get webhooks from'
|
|
57
|
+
},
|
|
58
|
+
status: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
enum: ['active', 'inactive'],
|
|
61
|
+
description: 'Filter webhooks by status'
|
|
62
|
+
},
|
|
63
|
+
event_type: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'Filter webhooks by event type'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
required: ['workspace_id']
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
// Get webhook
|
|
72
|
+
{
|
|
73
|
+
name: 'get_webhook',
|
|
74
|
+
description: 'Get detailed information about a specific webhook by its ID.',
|
|
75
|
+
inputSchema: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
properties: {
|
|
78
|
+
webhook_id: {
|
|
79
|
+
type: 'string',
|
|
80
|
+
description: 'The ID of the webhook to get'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
required: ['webhook_id']
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
// Update webhook
|
|
87
|
+
{
|
|
88
|
+
name: 'update_webhook',
|
|
89
|
+
description: 'Update an existing webhook\'s configuration including endpoint, events, and status.',
|
|
90
|
+
inputSchema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
webhook_id: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: 'The ID of the webhook to update'
|
|
96
|
+
},
|
|
97
|
+
endpoint: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
description: 'The new URL endpoint for webhook notifications'
|
|
100
|
+
},
|
|
101
|
+
events: {
|
|
102
|
+
type: 'array',
|
|
103
|
+
items: {
|
|
104
|
+
type: 'string',
|
|
105
|
+
enum: [
|
|
106
|
+
'taskCreated', 'taskUpdated', 'taskDeleted', 'taskStatusUpdated',
|
|
107
|
+
'taskAssigneeUpdated', 'taskDueDateUpdated', 'taskCommentPosted',
|
|
108
|
+
'taskCommentUpdated', 'taskTimeTracked', 'taskTimeUpdated',
|
|
109
|
+
'listCreated', 'listUpdated', 'listDeleted',
|
|
110
|
+
'folderCreated', 'folderUpdated', 'folderDeleted',
|
|
111
|
+
'spaceCreated', 'spaceUpdated', 'spaceDeleted',
|
|
112
|
+
'goalCreated', 'goalUpdated', 'goalDeleted', 'goalTargetUpdated'
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
description: 'New array of events to subscribe to'
|
|
116
|
+
},
|
|
117
|
+
health_check_url: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
description: 'New URL for webhook health checks'
|
|
120
|
+
},
|
|
121
|
+
secret: {
|
|
122
|
+
type: 'string',
|
|
123
|
+
description: 'New secret for HMAC signature validation'
|
|
124
|
+
},
|
|
125
|
+
status: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
enum: ['active', 'inactive'],
|
|
128
|
+
description: 'New status for the webhook'
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
required: ['webhook_id']
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
// Delete webhook
|
|
135
|
+
{
|
|
136
|
+
name: 'delete_webhook',
|
|
137
|
+
description: 'Delete a webhook from ClickUp. This will stop all notifications to the webhook endpoint.',
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
properties: {
|
|
141
|
+
webhook_id: {
|
|
142
|
+
type: 'string',
|
|
143
|
+
description: 'The ID of the webhook to delete'
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
required: ['webhook_id']
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
// Get webhook event history
|
|
150
|
+
{
|
|
151
|
+
name: 'get_webhook_event_history',
|
|
152
|
+
description: 'Get the event history for a webhook including delivery status and response codes.',
|
|
153
|
+
inputSchema: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
properties: {
|
|
156
|
+
webhook_id: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
description: 'The ID of the webhook to get event history for'
|
|
159
|
+
},
|
|
160
|
+
limit: {
|
|
161
|
+
type: 'number',
|
|
162
|
+
description: 'Maximum number of events to return'
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
required: ['webhook_id']
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
// Ping webhook
|
|
169
|
+
{
|
|
170
|
+
name: 'ping_webhook',
|
|
171
|
+
description: 'Send a test ping to a webhook endpoint to verify it\'s working correctly.',
|
|
172
|
+
inputSchema: {
|
|
173
|
+
type: 'object',
|
|
174
|
+
properties: {
|
|
175
|
+
webhook_id: {
|
|
176
|
+
type: 'string',
|
|
177
|
+
description: 'The ID of the webhook to ping'
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
required: ['webhook_id']
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
// Validate webhook signature
|
|
184
|
+
{
|
|
185
|
+
name: 'validate_webhook_signature',
|
|
186
|
+
description: 'Validate the HMAC signature of a webhook payload to ensure authenticity.',
|
|
187
|
+
inputSchema: {
|
|
188
|
+
type: 'object',
|
|
189
|
+
properties: {
|
|
190
|
+
payload: {
|
|
191
|
+
type: 'string',
|
|
192
|
+
description: 'The raw webhook payload as a string'
|
|
193
|
+
},
|
|
194
|
+
signature: {
|
|
195
|
+
type: 'string',
|
|
196
|
+
description: 'The signature header from the webhook request'
|
|
197
|
+
},
|
|
198
|
+
secret: {
|
|
199
|
+
type: 'string',
|
|
200
|
+
description: 'The webhook secret used for signature generation'
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
required: ['payload', 'signature', 'secret']
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
// Process webhook
|
|
207
|
+
{
|
|
208
|
+
name: 'process_webhook',
|
|
209
|
+
description: 'Process an incoming webhook payload and extract structured information about the event.',
|
|
210
|
+
inputSchema: {
|
|
211
|
+
type: 'object',
|
|
212
|
+
properties: {
|
|
213
|
+
payload: {
|
|
214
|
+
type: 'object',
|
|
215
|
+
description: 'The webhook payload object'
|
|
216
|
+
},
|
|
217
|
+
validate_signature: {
|
|
218
|
+
type: 'boolean',
|
|
219
|
+
description: 'Whether to validate the webhook signature',
|
|
220
|
+
default: true
|
|
221
|
+
},
|
|
222
|
+
signature: {
|
|
223
|
+
type: 'string',
|
|
224
|
+
description: 'The signature header for validation'
|
|
225
|
+
},
|
|
226
|
+
secret: {
|
|
227
|
+
type: 'string',
|
|
228
|
+
description: 'The webhook secret for signature validation'
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
required: ['payload']
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
// Get webhook statistics
|
|
235
|
+
{
|
|
236
|
+
name: 'get_webhook_stats',
|
|
237
|
+
description: 'Get statistics about webhook performance including success rate and response times.',
|
|
238
|
+
inputSchema: {
|
|
239
|
+
type: 'object',
|
|
240
|
+
properties: {
|
|
241
|
+
webhook_id: {
|
|
242
|
+
type: 'string',
|
|
243
|
+
description: 'The ID of the webhook to get statistics for'
|
|
244
|
+
},
|
|
245
|
+
days: {
|
|
246
|
+
type: 'number',
|
|
247
|
+
description: 'Number of days to include in statistics (default: 30)'
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
required: ['webhook_id']
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
// Retry webhook events
|
|
254
|
+
{
|
|
255
|
+
name: 'retry_webhook_events',
|
|
256
|
+
description: 'Retry failed webhook events for a specific webhook.',
|
|
257
|
+
inputSchema: {
|
|
258
|
+
type: 'object',
|
|
259
|
+
properties: {
|
|
260
|
+
webhook_id: {
|
|
261
|
+
type: 'string',
|
|
262
|
+
description: 'The ID of the webhook to retry events for'
|
|
263
|
+
},
|
|
264
|
+
event_ids: {
|
|
265
|
+
type: 'array',
|
|
266
|
+
items: {
|
|
267
|
+
type: 'string'
|
|
268
|
+
},
|
|
269
|
+
description: 'Optional array of specific event IDs to retry. If not provided, all failed events will be retried.'
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
required: ['webhook_id']
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
export async function handleWebhookTool(name, args, client) {
|
|
278
|
+
try {
|
|
279
|
+
switch (name) {
|
|
280
|
+
case 'create_webhook': {
|
|
281
|
+
const request = CreateWebhookSchema.parse(args);
|
|
282
|
+
return await client.createWebhook(request);
|
|
283
|
+
}
|
|
284
|
+
case 'get_webhooks': {
|
|
285
|
+
const filter = WebhookFilterSchema.parse(args);
|
|
286
|
+
return await client.getWebhooks(filter);
|
|
287
|
+
}
|
|
288
|
+
case 'get_webhook': {
|
|
289
|
+
const { webhook_id } = args;
|
|
290
|
+
return await client.getWebhook(webhook_id);
|
|
291
|
+
}
|
|
292
|
+
case 'update_webhook': {
|
|
293
|
+
const request = UpdateWebhookSchema.parse(args);
|
|
294
|
+
return await client.updateWebhook(request);
|
|
295
|
+
}
|
|
296
|
+
case 'delete_webhook': {
|
|
297
|
+
const { webhook_id } = args;
|
|
298
|
+
return await client.deleteWebhook(webhook_id);
|
|
299
|
+
}
|
|
300
|
+
case 'get_webhook_event_history': {
|
|
301
|
+
const { webhook_id, limit } = args;
|
|
302
|
+
return await client.getWebhookEventHistory(webhook_id, limit);
|
|
303
|
+
}
|
|
304
|
+
case 'ping_webhook': {
|
|
305
|
+
const { webhook_id } = args;
|
|
306
|
+
return await client.pingWebhook(webhook_id);
|
|
307
|
+
}
|
|
308
|
+
case 'validate_webhook_signature': {
|
|
309
|
+
const request = ValidateWebhookSignatureSchema.parse(args);
|
|
310
|
+
const isValid = client.validateWebhookSignature(request);
|
|
311
|
+
return { valid: isValid };
|
|
312
|
+
}
|
|
313
|
+
case 'process_webhook': {
|
|
314
|
+
// Parse the payload if it's a string
|
|
315
|
+
let payload = args.payload;
|
|
316
|
+
if (typeof payload === 'string') {
|
|
317
|
+
payload = JSON.parse(payload);
|
|
318
|
+
}
|
|
319
|
+
const parsedPayload = WebhookPayloadSchema.parse(payload);
|
|
320
|
+
const request = ProcessWebhookSchema.parse({
|
|
321
|
+
...args,
|
|
322
|
+
payload: parsedPayload
|
|
323
|
+
});
|
|
324
|
+
return await client.processWebhook(request);
|
|
325
|
+
}
|
|
326
|
+
case 'get_webhook_stats': {
|
|
327
|
+
const { webhook_id, days } = args;
|
|
328
|
+
return await client.getWebhookStats(webhook_id, days);
|
|
329
|
+
}
|
|
330
|
+
case 'retry_webhook_events': {
|
|
331
|
+
const { webhook_id, event_ids } = args;
|
|
332
|
+
return await client.retryWebhookEvents(webhook_id, event_ids);
|
|
333
|
+
}
|
|
334
|
+
default:
|
|
335
|
+
throw new Error(`Unknown webhook tool: ${name}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
if (error instanceof Error) {
|
|
340
|
+
throw new Error(`Webhook tool error: ${error.message}`);
|
|
341
|
+
}
|
|
342
|
+
throw error;
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
//# sourceMappingURL=webhook-tools.js.map
|