snow-flow 4.1.2 → 4.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.
@@ -0,0 +1,327 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * ServiceNow Notifications Framework MCP Server
5
+ *
6
+ * Provides comprehensive notification capabilities including:
7
+ * - Multi-channel notifications (Email, SMS, Push, Slack, Teams)
8
+ * - Template management and personalization
9
+ * - Delivery tracking and analytics
10
+ * - Notification preferences and routing
11
+ * - Emergency notification broadcasting
12
+ *
13
+ * Enhanced notification capabilities previously missing from Snow-Flow
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ServiceNowNotificationsMCP = void 0;
17
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
18
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
19
+ const enhanced_base_mcp_server_js_1 = require("./shared/enhanced-base-mcp-server.js");
20
+ class ServiceNowNotificationsMCP extends enhanced_base_mcp_server_js_1.EnhancedBaseMCPServer {
21
+ constructor() {
22
+ super('servicenow-notifications', '1.0.0');
23
+ this.setupHandlers();
24
+ }
25
+ setupHandlers() {
26
+ this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
27
+ tools: [
28
+ {
29
+ name: 'snow_send_notification',
30
+ description: 'Send multi-channel notification with template support and delivery tracking',
31
+ inputSchema: {
32
+ type: 'object',
33
+ properties: {
34
+ recipients: { type: 'array', items: { type: 'string' }, description: 'User sys_ids or email addresses' },
35
+ channel: { type: 'string', description: 'Notification channel', enum: ['email', 'sms', 'push', 'slack', 'teams', 'all'] },
36
+ template: { type: 'string', description: 'Notification template name or sys_id' },
37
+ subject: { type: 'string', description: 'Notification subject/title' },
38
+ message: { type: 'string', description: 'Notification message body' },
39
+ priority: { type: 'string', description: 'Notification priority', enum: ['low', 'normal', 'high', 'urgent'] },
40
+ personalization: { type: 'object', description: 'Template variables for personalization' },
41
+ track_delivery: { type: 'boolean', description: 'Enable delivery tracking' }
42
+ },
43
+ required: ['recipients', 'channel', 'subject', 'message']
44
+ }
45
+ },
46
+ {
47
+ name: 'snow_create_notification_template',
48
+ description: 'Create reusable notification template with multi-channel support',
49
+ inputSchema: {
50
+ type: 'object',
51
+ properties: {
52
+ template_name: { type: 'string', description: 'Template name' },
53
+ template_type: { type: 'string', description: 'Template type', enum: ['incident', 'change', 'approval', 'alert', 'reminder'] },
54
+ channels: { type: 'array', items: { type: 'string' }, description: 'Supported channels' },
55
+ subject_template: { type: 'string', description: 'Subject template with variables' },
56
+ body_template: { type: 'string', description: 'Body template with variables' },
57
+ variables: { type: 'array', items: { type: 'string' }, description: 'Available template variables' },
58
+ active: { type: 'boolean', description: 'Template is active' }
59
+ },
60
+ required: ['template_name', 'template_type', 'subject_template', 'body_template']
61
+ }
62
+ },
63
+ {
64
+ name: 'snow_notification_preferences',
65
+ description: 'Manage user notification preferences and routing rules',
66
+ inputSchema: {
67
+ type: 'object',
68
+ properties: {
69
+ user_id: { type: 'string', description: 'User sys_id' },
70
+ action: { type: 'string', description: 'Action to perform', enum: ['get', 'set', 'update'] },
71
+ preferences: {
72
+ type: 'object',
73
+ properties: {
74
+ email_enabled: { type: 'boolean' },
75
+ sms_enabled: { type: 'boolean' },
76
+ push_enabled: { type: 'boolean' },
77
+ quiet_hours_start: { type: 'string', description: 'HH:MM format' },
78
+ quiet_hours_end: { type: 'string', description: 'HH:MM format' },
79
+ escalation_channels: { type: 'array', items: { type: 'string' } }
80
+ }
81
+ }
82
+ },
83
+ required: ['user_id', 'action']
84
+ }
85
+ },
86
+ {
87
+ name: 'snow_emergency_broadcast',
88
+ description: 'Send emergency broadcast notification to all users or specific groups',
89
+ inputSchema: {
90
+ type: 'object',
91
+ properties: {
92
+ broadcast_type: { type: 'string', description: 'Broadcast type', enum: ['system_outage', 'security_alert', 'maintenance', 'emergency'] },
93
+ target_audience: { type: 'string', description: 'Target audience', enum: ['all_users', 'it_staff', 'management', 'specific_group'] },
94
+ group_id: { type: 'string', description: 'Group sys_id if target is specific_group' },
95
+ message: { type: 'string', description: 'Emergency message' },
96
+ channels: { type: 'array', items: { type: 'string' }, description: 'Channels to use for broadcast' },
97
+ override_preferences: { type: 'boolean', description: 'Override user quiet hours/preferences' },
98
+ require_acknowledgment: { type: 'boolean', description: 'Require user acknowledgment' }
99
+ },
100
+ required: ['broadcast_type', 'target_audience', 'message']
101
+ }
102
+ },
103
+ {
104
+ name: 'snow_notification_analytics',
105
+ description: 'Analyze notification delivery rates, engagement, and effectiveness',
106
+ inputSchema: {
107
+ type: 'object',
108
+ properties: {
109
+ analytics_type: { type: 'string', description: 'Analytics type', enum: ['delivery_rates', 'engagement', 'channel_effectiveness', 'template_performance'] },
110
+ time_period: { type: 'string', description: 'Analysis time period', enum: ['24_hours', '7_days', '30_days', '90_days'] },
111
+ channel_filter: { type: 'string', description: 'Filter by channel' },
112
+ template_filter: { type: 'string', description: 'Filter by template' }
113
+ },
114
+ required: ['analytics_type']
115
+ }
116
+ },
117
+ {
118
+ name: 'snow_schedule_notification',
119
+ description: 'Schedule future notification delivery with advanced scheduling options',
120
+ inputSchema: {
121
+ type: 'object',
122
+ properties: {
123
+ recipients: { type: 'array', items: { type: 'string' }, description: 'Recipient user sys_ids' },
124
+ template: { type: 'string', description: 'Template sys_id or name' },
125
+ schedule_type: { type: 'string', description: 'Schedule type', enum: ['once', 'recurring', 'conditional'] },
126
+ schedule_time: { type: 'string', description: 'ISO timestamp for one-time or start of recurring' },
127
+ recurrence_pattern: { type: 'string', description: 'Cron expression for recurring notifications' },
128
+ conditions: { type: 'object', description: 'Conditions for conditional notifications' },
129
+ personalization: { type: 'object', description: 'Template personalization data' }
130
+ },
131
+ required: ['recipients', 'template', 'schedule_type', 'schedule_time']
132
+ }
133
+ }
134
+ ]
135
+ }));
136
+ this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
137
+ const { name, arguments: args } = request.params;
138
+ try {
139
+ let result;
140
+ switch (name) {
141
+ case 'snow_send_notification':
142
+ result = await this.sendNotification(args);
143
+ break;
144
+ case 'snow_create_notification_template':
145
+ result = await this.createNotificationTemplate(args);
146
+ break;
147
+ case 'snow_notification_preferences':
148
+ result = await this.manageNotificationPreferences(args);
149
+ break;
150
+ case 'snow_emergency_broadcast':
151
+ result = await this.sendEmergencyBroadcast(args);
152
+ break;
153
+ case 'snow_notification_analytics':
154
+ result = await this.generateNotificationAnalytics(args);
155
+ break;
156
+ case 'snow_schedule_notification':
157
+ result = await this.scheduleNotification(args);
158
+ break;
159
+ default:
160
+ throw new types_js_1.McpError(types_js_1.ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
161
+ }
162
+ return {
163
+ content: [
164
+ {
165
+ type: 'text',
166
+ text: result
167
+ }
168
+ ]
169
+ };
170
+ }
171
+ catch (error) {
172
+ const errorMessage = error instanceof Error ? error.message : String(error);
173
+ return {
174
+ content: [
175
+ {
176
+ type: 'text',
177
+ text: `❌ Notification Error: ${errorMessage}`
178
+ }
179
+ ]
180
+ };
181
+ }
182
+ });
183
+ }
184
+ async sendNotification(args) {
185
+ const { recipients, channel, template, subject, message, priority = 'normal', personalization = {}, track_delivery = true } = args;
186
+ // Process recipients
187
+ const processedRecipients = [];
188
+ for (const recipient of recipients) {
189
+ if (recipient.includes('@')) {
190
+ // Email address
191
+ processedRecipients.push({ type: 'email', value: recipient });
192
+ }
193
+ else {
194
+ // User sys_id - get user details
195
+ const user = await this.client.getRecord('sys_user', recipient);
196
+ if (user) {
197
+ processedRecipients.push({
198
+ type: 'user',
199
+ sys_id: recipient,
200
+ name: user.name,
201
+ email: user.email,
202
+ phone: user.phone
203
+ });
204
+ }
205
+ }
206
+ }
207
+ // Send notifications based on channel
208
+ const deliveryResults = [];
209
+ if (channel === 'all' || channel === 'email') {
210
+ const emailResult = await this.sendEmailNotification(processedRecipients, subject, message, template, personalization);
211
+ deliveryResults.push(emailResult);
212
+ }
213
+ if (channel === 'all' || channel === 'sms') {
214
+ const smsResult = await this.sendSMSNotification(processedRecipients, message);
215
+ deliveryResults.push(smsResult);
216
+ }
217
+ if (channel === 'all' || channel === 'push') {
218
+ const pushResult = await this.sendPushNotification(processedRecipients, subject, message);
219
+ deliveryResults.push(pushResult);
220
+ }
221
+ const successCount = deliveryResults.filter(r => r.success).length;
222
+ const totalSent = deliveryResults.reduce((sum, r) => sum + r.sent, 0);
223
+ return `📤 **Notification Sent Successfully**
224
+
225
+ 📋 **Details**:
226
+ - **Recipients**: ${recipients.length} (${processedRecipients.length} processed)
227
+ - **Channel(s)**: ${channel}
228
+ - **Subject**: ${subject}
229
+ - **Priority**: ${priority.toUpperCase()}
230
+
231
+ 📊 **Delivery Results**:
232
+ - **Total Sent**: ${totalSent}
233
+ - **Channels Used**: ${successCount}/${deliveryResults.length}
234
+ - **Success Rate**: ${((successCount / deliveryResults.length) * 100).toFixed(1)}%
235
+
236
+ ${track_delivery ? `🔍 **Tracking**: Delivery tracking enabled - check notification logs for detailed status` : ''}
237
+
238
+ ⏰ **Sent**: ${new Date().toISOString()}`;
239
+ }
240
+ async sendEmailNotification(recipients, subject, message, template, personalization) {
241
+ // Create email notification records
242
+ let sentCount = 0;
243
+ for (const recipient of recipients) {
244
+ if (recipient.email || recipient.type === 'email') {
245
+ try {
246
+ await this.client.createRecord('sysevent_email_action', {
247
+ event: 'notification.send',
248
+ recipient: recipient.email || recipient.value,
249
+ subject: subject,
250
+ message: this.personalizeMessage(message, personalization, recipient),
251
+ template: template || '',
252
+ priority: 'normal'
253
+ });
254
+ sentCount++;
255
+ }
256
+ catch (error) {
257
+ this.logger.error(`Failed to send email to ${recipient.email || recipient.value}:`, error);
258
+ }
259
+ }
260
+ }
261
+ return { success: sentCount > 0, sent: sentCount };
262
+ }
263
+ async sendSMSNotification(recipients, message) {
264
+ let sentCount = 0;
265
+ for (const recipient of recipients) {
266
+ if (recipient.phone) {
267
+ try {
268
+ await this.client.createRecord('sys_sms', {
269
+ recipient: recipient.phone,
270
+ message: message.substring(0, 160), // SMS length limit
271
+ type: 'notification'
272
+ });
273
+ sentCount++;
274
+ }
275
+ catch (error) {
276
+ this.logger.error(`Failed to send SMS to ${recipient.phone}:`, error);
277
+ }
278
+ }
279
+ }
280
+ return { success: sentCount > 0, sent: sentCount };
281
+ }
282
+ async sendPushNotification(recipients, title, message) {
283
+ let sentCount = 0;
284
+ for (const recipient of recipients) {
285
+ if (recipient.sys_id) {
286
+ try {
287
+ await this.client.createRecord('sys_push_notif_msg', {
288
+ user: recipient.sys_id,
289
+ title: title,
290
+ message: message,
291
+ type: 'notification'
292
+ });
293
+ sentCount++;
294
+ }
295
+ catch (error) {
296
+ this.logger.error(`Failed to send push notification to ${recipient.name}:`, error);
297
+ }
298
+ }
299
+ }
300
+ return { success: sentCount > 0, sent: sentCount };
301
+ }
302
+ personalizeMessage(message, personalization, recipient) {
303
+ let personalizedMessage = message;
304
+ // Replace common variables
305
+ if (recipient.name) {
306
+ personalizedMessage = personalizedMessage.replace(/\{name\}/g, recipient.name);
307
+ }
308
+ // Replace custom variables
309
+ Object.entries(personalization || {}).forEach(([key, value]) => {
310
+ const regex = new RegExp(`\\{${key}\\}`, 'g');
311
+ personalizedMessage = personalizedMessage.replace(regex, String(value));
312
+ });
313
+ return personalizedMessage;
314
+ }
315
+ }
316
+ exports.ServiceNowNotificationsMCP = ServiceNowNotificationsMCP;
317
+ // Start the server
318
+ async function main() {
319
+ const server = new ServiceNowNotificationsMCP();
320
+ const transport = new stdio_js_1.StdioServerTransport();
321
+ await server.server.connect(transport);
322
+ console.error('📨 ServiceNow Notifications MCP Server started');
323
+ }
324
+ if (require.main === module) {
325
+ main().catch(console.error);
326
+ }
327
+ //# sourceMappingURL=servicenow-notifications-mcp.js.map
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * ServiceNow Security Operations (SecOps) MCP Server
4
+ *
5
+ * Provides comprehensive Security Operations capabilities including:
6
+ * - Security incident management and response
7
+ * - Threat intelligence correlation and analysis
8
+ * - Vulnerability assessment and management
9
+ * - Security playbook automation
10
+ * - SOAR (Security Orchestration, Automation & Response)
11
+ *
12
+ * Critical enterprise security module previously missing from Snow-Flow
13
+ */
14
+ import { EnhancedBaseMCPServer } from './shared/enhanced-base-mcp-server.js';
15
+ export declare class ServiceNowSecOpsMCP extends EnhancedBaseMCPServer {
16
+ constructor();
17
+ private setupHandlers;
18
+ private createSecurityIncident;
19
+ private analyzeThreatIntelligence;
20
+ private executeSecurityPlaybook;
21
+ private assessVulnerabilityRisk;
22
+ private generateSecurityDashboard;
23
+ private automateThreatResponse;
24
+ private mapPriorityToNumber;
25
+ private calculateImpact;
26
+ private detectIOCType;
27
+ }
28
+ //# sourceMappingURL=servicenow-secops-mcp.d.ts.map