@rashidazarang/airtable-mcp 2.2.2 → 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.
@@ -262,11 +262,11 @@ const TOOLS_SCHEMA = [
262
262
  }
263
263
  ];
264
264
 
265
- // Prompts schema - AI-powered templates for common Airtable operations
265
+ // Enhanced AI-powered prompts for intelligent Airtable operations
266
266
  const PROMPTS_SCHEMA = [
267
267
  {
268
268
  name: 'analyze_data',
269
- description: 'Analyze data patterns and provide insights from Airtable records',
269
+ description: 'Advanced AI data analysis with statistical insights, pattern recognition, and predictive modeling',
270
270
  arguments: [
271
271
  {
272
272
  name: 'table',
@@ -275,19 +275,29 @@ const PROMPTS_SCHEMA = [
275
275
  },
276
276
  {
277
277
  name: 'analysis_type',
278
- description: 'Type of analysis (trends, summary, patterns, insights)',
278
+ description: 'Type of analysis (trends, statistical, patterns, predictive, anomaly_detection, correlation_matrix)',
279
279
  required: false
280
280
  },
281
281
  {
282
282
  name: 'field_focus',
283
283
  description: 'Specific fields to focus the analysis on',
284
284
  required: false
285
+ },
286
+ {
287
+ name: 'time_dimension',
288
+ description: 'Time field for temporal analysis',
289
+ required: false
290
+ },
291
+ {
292
+ name: 'confidence_level',
293
+ description: 'Statistical confidence level (0.90, 0.95, 0.99)',
294
+ required: false
285
295
  }
286
296
  ]
287
297
  },
288
298
  {
289
299
  name: 'create_report',
290
- description: 'Generate a comprehensive report based on Airtable data',
300
+ description: 'Generate intelligent reports with AI-powered insights, visualizations, and actionable recommendations',
291
301
  arguments: [
292
302
  {
293
303
  name: 'table',
@@ -296,19 +306,29 @@ const PROMPTS_SCHEMA = [
296
306
  },
297
307
  {
298
308
  name: 'report_type',
299
- description: 'Type of report (summary, detailed, dashboard, metrics)',
309
+ description: 'Type of report (executive_summary, operational_dashboard, analytical_deep_dive, performance_metrics, predictive_forecast)',
300
310
  required: false
301
311
  },
302
312
  {
303
313
  name: 'time_period',
304
- description: 'Time period for the report (if applicable)',
314
+ description: 'Time period for analysis (last_7_days, last_30_days, last_quarter, year_to_date, custom)',
315
+ required: false
316
+ },
317
+ {
318
+ name: 'stakeholder_level',
319
+ description: 'Target audience (executive, manager, analyst, operational)',
320
+ required: false
321
+ },
322
+ {
323
+ name: 'include_recommendations',
324
+ description: 'Include AI-generated actionable recommendations (true/false)',
305
325
  required: false
306
326
  }
307
327
  ]
308
328
  },
309
329
  {
310
330
  name: 'data_insights',
311
- description: 'Discover hidden insights and correlations in your Airtable data',
331
+ description: 'Discover hidden patterns, correlations, and business insights using advanced AI algorithms',
312
332
  arguments: [
313
333
  {
314
334
  name: 'tables',
@@ -317,23 +337,214 @@ const PROMPTS_SCHEMA = [
317
337
  },
318
338
  {
319
339
  name: 'insight_type',
320
- description: 'Type of insights to find (correlations, outliers, trends, predictions)',
340
+ description: 'Type of insights (correlations, outliers, trends, predictions, segmentation, attribution, churn_analysis)',
341
+ required: false
342
+ },
343
+ {
344
+ name: 'business_context',
345
+ description: 'Business domain context (sales, marketing, operations, finance, customer_success)',
346
+ required: false
347
+ },
348
+ {
349
+ name: 'insight_depth',
350
+ description: 'Analysis depth (surface, moderate, deep, comprehensive)',
321
351
  required: false
322
352
  }
323
353
  ]
324
354
  },
325
355
  {
326
356
  name: 'optimize_workflow',
327
- description: 'Suggest workflow optimizations based on your Airtable usage patterns',
357
+ description: 'AI-powered workflow optimization with automation recommendations and efficiency improvements',
328
358
  arguments: [
329
359
  {
330
360
  name: 'base_overview',
331
- description: 'Overview of the base structure and usage',
361
+ description: 'Overview of the base structure and current workflows',
332
362
  required: false
333
363
  },
334
364
  {
335
365
  name: 'optimization_focus',
336
- description: 'Focus area (automation, fields, views, collaboration)',
366
+ description: 'Focus area (automation, data_quality, collaboration, performance, integration, user_experience)',
367
+ required: false
368
+ },
369
+ {
370
+ name: 'current_pain_points',
371
+ description: 'Known issues or bottlenecks in current workflow',
372
+ required: false
373
+ },
374
+ {
375
+ name: 'team_size',
376
+ description: 'Number of users working with this base',
377
+ required: false
378
+ }
379
+ ]
380
+ },
381
+ {
382
+ name: 'smart_schema_design',
383
+ description: 'AI-assisted database schema optimization and field relationship analysis',
384
+ arguments: [
385
+ {
386
+ name: 'use_case',
387
+ description: 'Primary use case (crm, project_management, inventory, content_management, hr, finance)',
388
+ required: true
389
+ },
390
+ {
391
+ name: 'data_volume',
392
+ description: 'Expected data volume (small, medium, large, enterprise)',
393
+ required: false
394
+ },
395
+ {
396
+ name: 'integration_needs',
397
+ description: 'External systems to integrate with',
398
+ required: false
399
+ },
400
+ {
401
+ name: 'compliance_requirements',
402
+ description: 'Data compliance needs (gdpr, hipaa, sox, none)',
403
+ required: false
404
+ }
405
+ ]
406
+ },
407
+ {
408
+ name: 'data_quality_audit',
409
+ description: 'Comprehensive AI-powered data quality assessment with cleansing recommendations',
410
+ arguments: [
411
+ {
412
+ name: 'tables',
413
+ description: 'Tables to audit (comma-separated or "all")',
414
+ required: true
415
+ },
416
+ {
417
+ name: 'quality_dimensions',
418
+ description: 'Quality aspects to check (completeness, accuracy, consistency, validity, uniqueness, timeliness)',
419
+ required: false
420
+ },
421
+ {
422
+ name: 'severity_threshold',
423
+ description: 'Minimum severity level to report (low, medium, high, critical)',
424
+ required: false
425
+ },
426
+ {
427
+ name: 'auto_fix_suggestions',
428
+ description: 'Include automated fix suggestions (true/false)',
429
+ required: false
430
+ }
431
+ ]
432
+ },
433
+ {
434
+ name: 'predictive_analytics',
435
+ description: 'Advanced predictive modeling and forecasting using historical Airtable data',
436
+ arguments: [
437
+ {
438
+ name: 'table',
439
+ description: 'Table containing historical data',
440
+ required: true
441
+ },
442
+ {
443
+ name: 'target_field',
444
+ description: 'Field to predict or forecast',
445
+ required: true
446
+ },
447
+ {
448
+ name: 'prediction_horizon',
449
+ description: 'Forecast period (next_week, next_month, next_quarter, next_year)',
450
+ required: false
451
+ },
452
+ {
453
+ name: 'model_type',
454
+ description: 'Prediction model (trend_analysis, seasonal_forecast, regression, classification, time_series)',
455
+ required: false
456
+ },
457
+ {
458
+ name: 'feature_fields',
459
+ description: 'Fields to use as predictive features',
460
+ required: false
461
+ }
462
+ ]
463
+ },
464
+ {
465
+ name: 'natural_language_query',
466
+ description: 'Process natural language questions about your data and provide intelligent answers',
467
+ arguments: [
468
+ {
469
+ name: 'question',
470
+ description: 'Natural language question about your data',
471
+ required: true
472
+ },
473
+ {
474
+ name: 'context_tables',
475
+ description: 'Tables that might contain relevant data',
476
+ required: false
477
+ },
478
+ {
479
+ name: 'response_format',
480
+ description: 'Desired response format (narrative, data_summary, visualization_suggestion, action_items)',
481
+ required: false
482
+ },
483
+ {
484
+ name: 'include_confidence',
485
+ description: 'Include confidence scores for answers (true/false)',
486
+ required: false
487
+ }
488
+ ]
489
+ },
490
+ {
491
+ name: 'smart_data_transformation',
492
+ description: 'AI-assisted data transformation, cleaning, and enrichment with intelligent suggestions',
493
+ arguments: [
494
+ {
495
+ name: 'source_table',
496
+ description: 'Source table for transformation',
497
+ required: true
498
+ },
499
+ {
500
+ name: 'transformation_goal',
501
+ description: 'Goal (normalize, standardize, enrich, cleanse, aggregate, pivot)',
502
+ required: true
503
+ },
504
+ {
505
+ name: 'target_format',
506
+ description: 'Desired output format or structure',
507
+ required: false
508
+ },
509
+ {
510
+ name: 'quality_rules',
511
+ description: 'Data quality rules to apply during transformation',
512
+ required: false
513
+ },
514
+ {
515
+ name: 'preserve_history',
516
+ description: 'Maintain audit trail of changes (true/false)',
517
+ required: false
518
+ }
519
+ ]
520
+ },
521
+ {
522
+ name: 'automation_recommendations',
523
+ description: 'Generate intelligent automation suggestions based on workflow patterns and data analysis',
524
+ arguments: [
525
+ {
526
+ name: 'workflow_description',
527
+ description: 'Description of current manual processes',
528
+ required: false
529
+ },
530
+ {
531
+ name: 'automation_scope',
532
+ description: 'Scope (single_table, multi_table, cross_base, external_integration)',
533
+ required: false
534
+ },
535
+ {
536
+ name: 'frequency_patterns',
537
+ description: 'How often tasks are performed',
538
+ required: false
539
+ },
540
+ {
541
+ name: 'complexity_tolerance',
542
+ description: 'Acceptable automation complexity (simple, moderate, advanced)',
543
+ required: false
544
+ },
545
+ {
546
+ name: 'integration_capabilities',
547
+ description: 'Available integration tools (zapier, make, custom_api, native_automations)',
337
548
  required: false
338
549
  }
339
550
  ]
@@ -379,7 +590,7 @@ const server = http.createServer(async (req, res) => {
379
590
  res.writeHead(200, { 'Content-Type': 'application/json' });
380
591
  res.end(JSON.stringify({
381
592
  status: 'healthy',
382
- version: '2.2.2',
593
+ version: '3.0.0',
383
594
  timestamp: new Date().toISOString(),
384
595
  uptime: process.uptime()
385
596
  }));
@@ -409,10 +620,14 @@ const server = http.createServer(async (req, res) => {
409
620
  return;
410
621
  }
411
622
 
412
- // Sanitize all user inputs for HTML output
413
- const safeClientId = escapeHtml(clientId);
414
- const safeRedirectUri = escapeHtml(redirectUri);
415
- const safeState = escapeHtml(state || '');
623
+ // Create safe copies of all variables for JavaScript use
624
+ const safeRedirectUri = redirectUri.slice(0, 2000); // Limit length
625
+ const safeState = (state || '').slice(0, 200); // Limit length
626
+ const safeClientId = clientId.slice(0, 200); // Limit length
627
+
628
+ // Sanitize for HTML display only
629
+ const displayClientId = escapeHtml(safeClientId);
630
+ const displayRedirectUri = escapeHtml(safeRedirectUri);
416
631
 
417
632
  // Generate authorization code
418
633
  const authCode = crypto.randomBytes(32).toString('hex');
@@ -429,7 +644,8 @@ const server = http.createServer(async (req, res) => {
429
644
  'Referrer-Policy': 'no-referrer'
430
645
  });
431
646
 
432
- res.end(`<!DOCTYPE html>
647
+ // Build HTML with proper escaping and separation of concerns
648
+ const htmlContent = `<!DOCTYPE html>
433
649
  <html>
434
650
  <head>
435
651
  <meta charset="UTF-8">
@@ -438,8 +654,8 @@ const server = http.createServer(async (req, res) => {
438
654
  </head>
439
655
  <body>
440
656
  <h2>Airtable MCP Server - OAuth2 Authorization</h2>
441
- <p>Client ID: ${safeClientId}</p>
442
- <p>Redirect URI: ${safeRedirectUri}</p>
657
+ <p>Client ID: ${displayClientId}</p>
658
+ <p>Redirect URI: ${displayRedirectUri}</p>
443
659
  <div style="margin: 20px 0;">
444
660
  <button onclick="authorize()" style="background: #18BFFF; color: white; padding: 10px 20px; border: none; border-radius: 5px; cursor: pointer;">
445
661
  Authorize Application
@@ -449,20 +665,21 @@ const server = http.createServer(async (req, res) => {
449
665
  </button>
450
666
  </div>
451
667
  <script>
452
- // Use validated and sanitized values to prevent XSS
668
+ // All variables are safely JSON encoded to prevent XSS
453
669
  (function() {
454
- const baseUrl = ${JSON.stringify(redirectUri.slice(0, 2000))};
455
- const code = ${JSON.stringify(authCode)};
456
- const state = ${JSON.stringify((state || '').slice(0, 200))};
670
+ var config = ${JSON.stringify({
671
+ redirectUri: safeRedirectUri,
672
+ code: authCode,
673
+ state: safeState
674
+ })};
457
675
 
458
676
  window.authorize = function() {
459
677
  try {
460
- // Additional validation in JavaScript
461
- const url = new URL(baseUrl);
462
- if (!['http:', 'https:'].includes(url.protocol)) {
678
+ var url = new URL(config.redirectUri);
679
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
463
680
  throw new Error('Invalid protocol');
464
681
  }
465
- const finalUrl = baseUrl + '?code=' + encodeURIComponent(code) + '&state=' + encodeURIComponent(state);
682
+ var finalUrl = config.redirectUri + '?code=' + encodeURIComponent(config.code) + '&state=' + encodeURIComponent(config.state);
466
683
  window.location.href = finalUrl;
467
684
  } catch (e) {
468
685
  console.error('Authorization failed:', e);
@@ -472,12 +689,11 @@ const server = http.createServer(async (req, res) => {
472
689
 
473
690
  window.deny = function() {
474
691
  try {
475
- // Additional validation in JavaScript
476
- const url = new URL(baseUrl);
477
- if (!['http:', 'https:'].includes(url.protocol)) {
692
+ var url = new URL(config.redirectUri);
693
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') {
478
694
  throw new Error('Invalid protocol');
479
695
  }
480
- const finalUrl = baseUrl + '?error=access_denied&state=' + encodeURIComponent(state);
696
+ var finalUrl = config.redirectUri + '?error=access_denied&state=' + encodeURIComponent(config.state);
481
697
  window.location.href = finalUrl;
482
698
  } catch (e) {
483
699
  console.error('Denial failed:', e);
@@ -487,7 +703,9 @@ const server = http.createServer(async (req, res) => {
487
703
  })();
488
704
  </script>
489
705
  </body>
490
- </html>`);
706
+ </html>`;
707
+
708
+ res.end(htmlContent);
491
709
  return;
492
710
  }
493
711
 
@@ -612,9 +830,9 @@ const server = http.createServer(async (req, res) => {
612
830
  logging: {}
613
831
  },
614
832
  serverInfo: {
615
- name: 'Airtable MCP Server Enhanced',
616
- version: '2.2.2',
617
- description: 'Complete MCP 2024-11-05 server with Prompts, Sampling, Roots, Logging, and OAuth2'
833
+ name: 'Airtable MCP Server - AI Agent Enhanced',
834
+ version: '3.0.0',
835
+ description: 'Advanced AI-powered MCP server with 10 intelligent prompt templates, predictive analytics, and enterprise automation capabilities'
618
836
  }
619
837
  }
620
838
  };
@@ -808,7 +1026,7 @@ async function handleToolCall(request) {
808
1026
  }
809
1027
  }
810
1028
 
811
- // Prompt handlers
1029
+ // Enhanced AI-powered prompt handlers
812
1030
  async function handlePromptGet(request) {
813
1031
  const promptName = request.params.name;
814
1032
  const promptArgs = request.params.arguments || {};
@@ -823,74 +1041,400 @@ async function handlePromptGet(request) {
823
1041
 
824
1042
  switch (promptName) {
825
1043
  case 'analyze_data':
826
- const { table, analysis_type = 'summary', field_focus } = promptArgs;
1044
+ const { table, analysis_type = 'statistical', field_focus, time_dimension, confidence_level = '0.95' } = promptArgs;
827
1045
  messages = [
828
1046
  {
829
1047
  role: 'user',
830
1048
  content: {
831
1049
  type: 'text',
832
- text: `Please analyze the data in table "${table}".
833
- Analysis type: ${analysis_type}
834
- ${field_focus ? `Focus on fields: ${field_focus}` : ''}
835
-
836
- First, list the tables and their schemas, then retrieve sample records from "${table}"
837
- and provide insights based on the ${analysis_type} analysis type.`
1050
+ text: `🤖 ADVANCED DATA ANALYSIS REQUEST
1051
+
1052
+ **Table**: ${table}
1053
+ **Analysis Type**: ${analysis_type}
1054
+ **Confidence Level**: ${confidence_level}
1055
+ ${field_focus ? `**Focus Fields**: ${field_focus}` : ''}
1056
+ ${time_dimension ? `**Time Dimension**: ${time_dimension}` : ''}
1057
+
1058
+ **Instructions**:
1059
+ 1. First, examine the table schema and structure using list_tables with include_schema=true
1060
+ 2. Retrieve representative sample data using list_records with appropriate filters
1061
+ 3. Perform ${analysis_type} analysis with statistical rigor
1062
+ 4. Generate insights with confidence intervals and significance testing
1063
+ 5. Provide actionable recommendations based on findings
1064
+
1065
+ **Expected Deliverables**:
1066
+ - Statistical summary with key metrics
1067
+ - Pattern identification and trend analysis
1068
+ - Anomaly detection if applicable
1069
+ - Predictive insights where relevant
1070
+ - Visualization recommendations
1071
+ - Business impact assessment
1072
+
1073
+ Please use the available Airtable tools to gather data and provide comprehensive ${analysis_type} analysis.`
838
1074
  }
839
1075
  }
840
1076
  ];
841
1077
  break;
842
1078
 
843
1079
  case 'create_report':
844
- const { table: reportTable, report_type = 'summary', time_period } = promptArgs;
1080
+ const { table: reportTable, report_type = 'executive_summary', time_period = 'last_30_days', stakeholder_level = 'manager', include_recommendations = 'true' } = promptArgs;
845
1081
  messages = [
846
1082
  {
847
1083
  role: 'user',
848
1084
  content: {
849
1085
  type: 'text',
850
- text: `Create a ${report_type} report for table "${reportTable}".
851
- ${time_period ? `Time period: ${time_period}` : ''}
852
-
853
- Please gather the table schema and recent records, then generate a comprehensive
854
- ${report_type} report with key metrics, trends, and actionable insights.`
1086
+ text: `📊 INTELLIGENT REPORT GENERATION
1087
+
1088
+ **Target Table**: ${reportTable}
1089
+ **Report Type**: ${report_type}
1090
+ **Time Period**: ${time_period}
1091
+ **Stakeholder Level**: ${stakeholder_level}
1092
+ **Include Recommendations**: ${include_recommendations}
1093
+
1094
+ **Report Generation Process**:
1095
+ 1. Analyze table structure and data types
1096
+ 2. Extract relevant data for specified time period
1097
+ 3. Calculate key performance indicators
1098
+ 4. Identify trends and patterns
1099
+ 5. Generate visualizations suggestions
1100
+ 6. Create ${stakeholder_level}-appropriate narrative
1101
+
1102
+ **Report Sections**:
1103
+ - Executive Summary (key findings)
1104
+ - Data Overview and Quality Assessment
1105
+ - Trend Analysis and Patterns
1106
+ - Performance Metrics and KPIs
1107
+ - Risk Assessment and Opportunities
1108
+ ${include_recommendations === 'true' ? '- AI-Generated Recommendations' : ''}
1109
+ - Next Steps and Action Items
1110
+
1111
+ Please gather the necessary data and create a comprehensive ${report_type} tailored for ${stakeholder_level} level stakeholders.`
855
1112
  }
856
1113
  }
857
1114
  ];
858
1115
  break;
859
1116
 
860
1117
  case 'data_insights':
861
- const { tables, insight_type = 'correlations' } = promptArgs;
1118
+ const { tables, insight_type = 'correlations', business_context = 'general', insight_depth = 'moderate' } = promptArgs;
862
1119
  messages = [
863
1120
  {
864
1121
  role: 'user',
865
1122
  content: {
866
1123
  type: 'text',
867
- text: `Discover ${insight_type} insights across these tables: ${tables}
868
-
869
- Please examine the data structures and content to identify:
870
- - ${insight_type} patterns
871
- - Unexpected relationships
872
- - Optimization opportunities
873
- - Data quality insights`
1124
+ text: `🔍 ADVANCED DATA INSIGHTS DISCOVERY
1125
+
1126
+ **Target Tables**: ${tables}
1127
+ **Insight Type**: ${insight_type}
1128
+ **Business Context**: ${business_context}
1129
+ **Analysis Depth**: ${insight_depth}
1130
+
1131
+ **Discovery Framework**:
1132
+ 1. Multi-table schema analysis and relationship mapping
1133
+ 2. Cross-table data correlation analysis
1134
+ 3. Pattern recognition using ${business_context} domain knowledge
1135
+ 4. Statistical significance testing
1136
+ 5. Business impact quantification
1137
+
1138
+ **Insight Categories**:
1139
+ - ${insight_type} analysis with statistical validation
1140
+ - Hidden patterns and unexpected relationships
1141
+ - Segmentation opportunities
1142
+ - Predictive indicators
1143
+ - Data quality insights
1144
+ - Business optimization opportunities
1145
+
1146
+ **${business_context.toUpperCase()} CONTEXT ANALYSIS**:
1147
+ ${business_context === 'sales' ? '- Revenue drivers and conversion patterns\n- Customer lifetime value indicators\n- Sales cycle optimization opportunities' : ''}
1148
+ ${business_context === 'marketing' ? '- Campaign effectiveness and attribution\n- Customer segmentation insights\n- Channel performance analysis' : ''}
1149
+ ${business_context === 'operations' ? '- Process efficiency metrics\n- Resource utilization patterns\n- Bottleneck identification' : ''}
1150
+
1151
+ Please conduct ${insight_depth} analysis across the specified tables and provide actionable business insights.`
874
1152
  }
875
1153
  }
876
1154
  ];
877
1155
  break;
878
1156
 
879
1157
  case 'optimize_workflow':
880
- const { base_overview, optimization_focus = 'automation' } = promptArgs;
1158
+ const { base_overview, optimization_focus = 'automation', current_pain_points, team_size } = promptArgs;
1159
+ messages = [
1160
+ {
1161
+ role: 'user',
1162
+ content: {
1163
+ type: 'text',
1164
+ text: `⚡ AI-POWERED WORKFLOW OPTIMIZATION
1165
+
1166
+ **Optimization Focus**: ${optimization_focus}
1167
+ **Team Size**: ${team_size || 'Not specified'}
1168
+ ${base_overview ? `**Base Overview**: ${base_overview}` : ''}
1169
+ ${current_pain_points ? `**Current Pain Points**: ${current_pain_points}` : ''}
1170
+
1171
+ **Optimization Analysis**:
1172
+ 1. Workflow pattern analysis and bottleneck identification
1173
+ 2. Automation opportunity assessment
1174
+ 3. User experience and efficiency evaluation
1175
+ 4. Integration and scaling considerations
1176
+ 5. ROI analysis for proposed improvements
1177
+
1178
+ **${optimization_focus.toUpperCase()} OPTIMIZATION**:
1179
+ ${optimization_focus === 'automation' ? '- Identify repetitive manual tasks\n- Suggest automation workflows\n- Estimate time savings and ROI' : ''}
1180
+ ${optimization_focus === 'data_quality' ? '- Data validation and cleansing rules\n- Consistency and accuracy improvements\n- Quality monitoring systems' : ''}
1181
+ ${optimization_focus === 'collaboration' ? '- Team workflow improvements\n- Permission and access optimization\n- Communication enhancement strategies' : ''}
1182
+
1183
+ **Deliverables**:
1184
+ - Workflow efficiency assessment
1185
+ - Prioritized improvement recommendations
1186
+ - Implementation roadmap with timelines
1187
+ - Cost-benefit analysis
1188
+ - Change management considerations
1189
+
1190
+ Please analyze the current setup and provide comprehensive ${optimization_focus} optimization recommendations.`
1191
+ }
1192
+ }
1193
+ ];
1194
+ break;
1195
+
1196
+ case 'smart_schema_design':
1197
+ const { use_case, data_volume = 'medium', integration_needs, compliance_requirements = 'none' } = promptArgs;
1198
+ messages = [
1199
+ {
1200
+ role: 'user',
1201
+ content: {
1202
+ type: 'text',
1203
+ text: `🏗️ AI-ASSISTED SCHEMA OPTIMIZATION
1204
+
1205
+ **Use Case**: ${use_case}
1206
+ **Data Volume**: ${data_volume}
1207
+ **Compliance**: ${compliance_requirements}
1208
+ ${integration_needs ? `**Integrations**: ${integration_needs}` : ''}
1209
+
1210
+ **Schema Design Analysis**:
1211
+ 1. Current schema evaluation for ${use_case} best practices
1212
+ 2. Field type and relationship optimization
1213
+ 3. Performance and scalability assessment
1214
+ 4. Compliance requirement implementation
1215
+ 5. Integration compatibility review
1216
+
1217
+ **${use_case.toUpperCase()} OPTIMIZATION**:
1218
+ ${use_case === 'crm' ? '- Customer lifecycle tracking\n- Sales pipeline optimization\n- Contact relationship mapping' : ''}
1219
+ ${use_case === 'project_management' ? '- Task dependency modeling\n- Resource allocation tracking\n- Timeline and milestone management' : ''}
1220
+ ${use_case === 'inventory' ? '- Stock level monitoring\n- Supplier relationship tracking\n- Cost and pricing optimization' : ''}
1221
+
1222
+ **Recommendations**:
1223
+ - Optimal field types and relationships
1224
+ - Indexing and performance suggestions
1225
+ - Data validation and integrity rules
1226
+ - Automation and workflow triggers
1227
+ - Scaling and maintenance considerations
1228
+
1229
+ Please analyze the current schema and provide ${use_case}-optimized recommendations.`
1230
+ }
1231
+ }
1232
+ ];
1233
+ break;
1234
+
1235
+ case 'data_quality_audit':
1236
+ const { tables: auditTables, quality_dimensions = 'completeness,accuracy,consistency', severity_threshold = 'medium', auto_fix_suggestions = 'true' } = promptArgs;
1237
+ messages = [
1238
+ {
1239
+ role: 'user',
1240
+ content: {
1241
+ type: 'text',
1242
+ text: `🔍 COMPREHENSIVE DATA QUALITY AUDIT
1243
+
1244
+ **Tables to Audit**: ${auditTables}
1245
+ **Quality Dimensions**: ${quality_dimensions}
1246
+ **Severity Threshold**: ${severity_threshold}
1247
+ **Auto-Fix Suggestions**: ${auto_fix_suggestions}
1248
+
1249
+ **Audit Framework**:
1250
+ 1. Data completeness analysis (missing values, empty fields)
1251
+ 2. Accuracy assessment (format validation, range checks)
1252
+ 3. Consistency evaluation (cross-field validation, duplicates)
1253
+ 4. Validity verification (data type compliance, constraints)
1254
+ 5. Uniqueness analysis (duplicate detection, key integrity)
1255
+ 6. Timeliness review (data freshness, update patterns)
1256
+
1257
+ **Quality Assessment Process**:
1258
+ - Statistical analysis of data distribution
1259
+ - Pattern recognition for anomalies
1260
+ - Cross-table consistency validation
1261
+ - Historical trend analysis
1262
+ - Business rule compliance checking
1263
+
1264
+ **Deliverables**:
1265
+ - Quality score by dimension and table
1266
+ - Detailed issue identification and classification
1267
+ - Impact assessment and prioritization
1268
+ ${auto_fix_suggestions === 'true' ? '- Automated fix suggestions and scripts' : ''}
1269
+ - Data governance recommendations
1270
+ - Monitoring and maintenance strategies
1271
+
1272
+ Please conduct a thorough data quality audit focusing on ${quality_dimensions} dimensions.`
1273
+ }
1274
+ }
1275
+ ];
1276
+ break;
1277
+
1278
+ case 'predictive_analytics':
1279
+ const { table: predTable, target_field, prediction_horizon = 'next_month', model_type = 'trend_analysis', feature_fields } = promptArgs;
1280
+ messages = [
1281
+ {
1282
+ role: 'user',
1283
+ content: {
1284
+ type: 'text',
1285
+ text: `🔮 ADVANCED PREDICTIVE ANALYTICS
1286
+
1287
+ **Source Table**: ${predTable}
1288
+ **Target Field**: ${target_field}
1289
+ **Prediction Horizon**: ${prediction_horizon}
1290
+ **Model Type**: ${model_type}
1291
+ ${feature_fields ? `**Feature Fields**: ${feature_fields}` : ''}
1292
+
1293
+ **Predictive Modeling Process**:
1294
+ 1. Historical data analysis and trend identification
1295
+ 2. Feature engineering and variable selection
1296
+ 3. Model development using ${model_type} approach
1297
+ 4. Validation and accuracy assessment
1298
+ 5. Forecast generation for ${prediction_horizon}
1299
+ 6. Confidence intervals and uncertainty quantification
1300
+
1301
+ **${model_type.toUpperCase()} ANALYSIS**:
1302
+ ${model_type === 'time_series' ? '- Seasonal pattern detection\n- Trend decomposition\n- Cyclical behavior analysis' : ''}
1303
+ ${model_type === 'regression' ? '- Variable relationship modeling\n- Predictive factor identification\n- Statistical significance testing' : ''}
1304
+ ${model_type === 'classification' ? '- Category prediction modeling\n- Feature importance analysis\n- Classification accuracy metrics' : ''}
1305
+
1306
+ **Outputs**:
1307
+ - Historical pattern analysis
1308
+ - Predictive model performance metrics
1309
+ - Forecast values with confidence intervals
1310
+ - Key influencing factors identification
1311
+ - Model limitations and assumptions
1312
+ - Actionable insights and recommendations
1313
+
1314
+ Please develop a ${model_type} model to predict ${target_field} over ${prediction_horizon}.`
1315
+ }
1316
+ }
1317
+ ];
1318
+ break;
1319
+
1320
+ case 'natural_language_query':
1321
+ const { question, context_tables, response_format = 'narrative', include_confidence = 'true' } = promptArgs;
1322
+ messages = [
1323
+ {
1324
+ role: 'user',
1325
+ content: {
1326
+ type: 'text',
1327
+ text: `🗣️ NATURAL LANGUAGE DATA QUERY
1328
+
1329
+ **Question**: "${question}"
1330
+ ${context_tables ? `**Context Tables**: ${context_tables}` : ''}
1331
+ **Response Format**: ${response_format}
1332
+ **Include Confidence**: ${include_confidence}
1333
+
1334
+ **Query Processing Framework**:
1335
+ 1. Question analysis and intent recognition
1336
+ 2. Relevant table and field identification
1337
+ 3. Data retrieval strategy formulation
1338
+ 4. Analysis execution and result compilation
1339
+ 5. Natural language response generation
1340
+
1341
+ **Analysis Approach**:
1342
+ - Semantic understanding of the question
1343
+ - Automatic table and field mapping
1344
+ - Intelligent data filtering and aggregation
1345
+ - Statistical analysis where appropriate
1346
+ - Context-aware interpretation
1347
+
1348
+ **Response Requirements**:
1349
+ ${response_format === 'narrative' ? '- Conversational, easy-to-understand explanation\n- Supporting data and evidence\n- Contextual insights and implications' : ''}
1350
+ ${response_format === 'data_summary' ? '- Structured data summary\n- Key metrics and statistics\n- Trend identification' : ''}
1351
+ ${response_format === 'visualization_suggestion' ? '- Chart and graph recommendations\n- Data visualization best practices\n- Tool-specific guidance' : ''}
1352
+ ${include_confidence === 'true' ? '\n- Confidence scores for answers\n- Data quality indicators\n- Uncertainty acknowledgment' : ''}
1353
+
1354
+ Please analyze the available data and provide a comprehensive answer to: "${question}"`
1355
+ }
1356
+ }
1357
+ ];
1358
+ break;
1359
+
1360
+ case 'smart_data_transformation':
1361
+ const { source_table, transformation_goal, target_format, quality_rules, preserve_history = 'true' } = promptArgs;
1362
+ messages = [
1363
+ {
1364
+ role: 'user',
1365
+ content: {
1366
+ type: 'text',
1367
+ text: `🔄 INTELLIGENT DATA TRANSFORMATION
1368
+
1369
+ **Source Table**: ${source_table}
1370
+ **Transformation Goal**: ${transformation_goal}
1371
+ ${target_format ? `**Target Format**: ${target_format}` : ''}
1372
+ ${quality_rules ? `**Quality Rules**: ${quality_rules}` : ''}
1373
+ **Preserve History**: ${preserve_history}
1374
+
1375
+ **Transformation Framework**:
1376
+ 1. Source data analysis and quality assessment
1377
+ 2. Transformation strategy development
1378
+ 3. Data mapping and conversion rules
1379
+ 4. Quality validation and error handling
1380
+ 5. Output optimization and validation
1381
+
1382
+ **${transformation_goal.toUpperCase()} PROCESS**:
1383
+ ${transformation_goal === 'normalize' ? '- Database normalization principles\n- Redundancy elimination\n- Relationship optimization' : ''}
1384
+ ${transformation_goal === 'standardize' ? '- Format standardization\n- Value normalization\n- Consistency enforcement' : ''}
1385
+ ${transformation_goal === 'enrich' ? '- Data augmentation strategies\n- External data integration\n- Value-added field creation' : ''}
1386
+ ${transformation_goal === 'cleanse' ? '- Data validation and correction\n- Duplicate removal\n- Missing value handling' : ''}
1387
+
1388
+ **Deliverables**:
1389
+ - Transformation execution plan
1390
+ - Data mapping specifications
1391
+ - Quality validation results
1392
+ - Performance optimization recommendations
1393
+ ${preserve_history === 'true' ? '- Change audit trail and versioning' : ''}
1394
+ - Post-transformation validation
1395
+
1396
+ Please analyze the source data and execute ${transformation_goal} transformation with intelligent optimization.`
1397
+ }
1398
+ }
1399
+ ];
1400
+ break;
1401
+
1402
+ case 'automation_recommendations':
1403
+ const { workflow_description, automation_scope = 'single_table', frequency_patterns, complexity_tolerance = 'moderate', integration_capabilities } = promptArgs;
881
1404
  messages = [
882
1405
  {
883
1406
  role: 'user',
884
1407
  content: {
885
1408
  type: 'text',
886
- text: `Analyze the current Airtable setup and suggest ${optimization_focus} optimizations.
887
- ${base_overview ? `Base overview: ${base_overview}` : ''}
888
-
889
- Please review the table structures, field types, and relationships to recommend:
890
- - ${optimization_focus} improvements
891
- - Best practice implementations
892
- - Performance enhancements
893
- - Workflow streamlining opportunities`
1409
+ text: `🤖 INTELLIGENT AUTOMATION RECOMMENDATIONS
1410
+
1411
+ **Automation Scope**: ${automation_scope}
1412
+ **Complexity Tolerance**: ${complexity_tolerance}
1413
+ ${workflow_description ? `**Current Workflow**: ${workflow_description}` : ''}
1414
+ ${frequency_patterns ? `**Frequency Patterns**: ${frequency_patterns}` : ''}
1415
+ ${integration_capabilities ? `**Integration Tools**: ${integration_capabilities}` : ''}
1416
+
1417
+ **Automation Analysis Framework**:
1418
+ 1. Workflow pattern analysis and task identification
1419
+ 2. Automation opportunity assessment and prioritization
1420
+ 3. Technical feasibility and complexity evaluation
1421
+ 4. ROI calculation and benefit quantification
1422
+ 5. Implementation roadmap development
1423
+
1424
+ **${automation_scope.toUpperCase()} AUTOMATION**:
1425
+ ${automation_scope === 'single_table' ? '- Field auto-population rules\n- Data validation automation\n- Notification triggers' : ''}
1426
+ ${automation_scope === 'multi_table' ? '- Cross-table data synchronization\n- Workflow orchestration\n- Complex business logic automation' : ''}
1427
+ ${automation_scope === 'external_integration' ? '- API integration strategies\n- Data pipeline automation\n- Third-party tool connectivity' : ''}
1428
+
1429
+ **Recommendations**:
1430
+ - High-impact automation opportunities
1431
+ - Implementation complexity assessment
1432
+ - Cost-benefit analysis with ROI projections
1433
+ - Technical requirements and dependencies
1434
+ - Risk assessment and mitigation strategies
1435
+ - Success metrics and monitoring approach
1436
+
1437
+ Please analyze the workflow patterns and provide ${complexity_tolerance}-level automation recommendations for ${automation_scope} scope.`
894
1438
  }
895
1439
  }
896
1440
  ];