strategic-intelligence-mcp
Version:
Strategic Intelligence MCP Server - connecting technical progress to business outcomes with systematic strategic planning
861 lines • 38.1 kB
JavaScript
#!/usr/bin/env node
// Strategic Intelligence MCP Server
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from '@modelcontextprotocol/sdk/types.js';
import { JSONStorageAdapter } from './storage/StorageAdapter.js';
import { ConversationTools } from './tools/conversationTools.js';
import { GoalTools } from './tools/goalTools.js';
import { TemplateTools } from './tools/templateTools.js';
import { IntegrationTools } from './tools/integrationTools.js';
import { IntelligenceTools } from './tools/intelligenceTools.js';
import { AnalyticsTools } from './tools/analyticsTools.js';
import { ForecastingTools } from './tools/forecastingTools.js';
import { CollaborationTools } from './tools/collaborationTools.js';
import { ReportingTools } from './tools/reportingTools.js';
import { InitializationTools } from './tools/initializationTools.js';
// Storage and tools initialization (async)
let storage;
let conversationTools;
let goalTools;
let templateTools;
let integrationTools;
let intelligenceTools;
let analyticsTools;
let forecastingTools;
let collaborationTools;
let reportingTools;
let initializationTools;
let isInitialized = false;
// Storage initialization with better error handling and logging
async function initializeStorage() {
try {
console.error('Strategic Intelligence MCP: Initializing storage...');
// Create storage adapter
storage = new JSONStorageAdapter('./strategic-data.json');
// Force early initialization of the storage by loading data
await storage.load();
console.error('Strategic Intelligence MCP: Storage loaded successfully');
// Initialize all tool classes
conversationTools = new ConversationTools(storage);
goalTools = new GoalTools(storage);
templateTools = new TemplateTools(storage);
integrationTools = new IntegrationTools(storage);
intelligenceTools = new IntelligenceTools(storage);
analyticsTools = new AnalyticsTools(storage);
forecastingTools = new ForecastingTools(storage);
collaborationTools = new CollaborationTools(storage);
reportingTools = new ReportingTools(storage);
initializationTools = new InitializationTools(storage);
isInitialized = true;
console.error('Strategic Intelligence MCP: All tools initialized successfully');
}
catch (error) {
console.error('Strategic Intelligence MCP: Failed to initialize storage:', error);
console.error('Strategic Intelligence MCP: Error details:', {
message: error instanceof Error ? error.message : 'Unknown error',
stack: error instanceof Error ? error.stack : 'No stack trace',
dataPath: './strategic-data.json'
});
throw error;
}
}
// Helper function to ensure storage is initialized
async function ensureInitialized() {
if (!isInitialized) {
await initializeStorage();
}
}
// Create MCP server
const server = new Server({
name: 'strategic-intelligence-mcp',
version: '1.0.0',
}, {
capabilities: {
tools: {},
},
});
// Minimal tool definitions for testing Claude Code compatibility
const TOOLS = {
// Project Setup Tools (1-3)
init_project: {
name: 'init_project',
description: 'Setup project context',
inputSchema: {
type: 'object',
properties: {
name: { type: 'string', description: 'Project name' },
industry: { type: 'string', description: 'Industry type' },
stage: { type: 'string', description: 'Development stage' }
},
required: ['name']
}
},
import_docs: {
name: 'import_docs',
description: 'Import business documents',
inputSchema: {
type: 'object',
properties: {
content: { type: 'string', description: 'Document content' },
type: { type: 'string', description: 'Document type' }
},
required: ['content', 'type']
}
},
setup_wizard: {
name: 'setup_wizard',
description: 'Quick project setup',
inputSchema: {
type: 'object',
properties: {
step: { type: 'string', description: 'Wizard step' }
},
required: ['step']
}
},
// Strategy Tools (4-8)
start_session: {
name: 'start_session',
description: 'Start strategy session',
inputSchema: {
type: 'object',
properties: {
type: { type: 'string', description: 'Session type' },
title: { type: 'string', description: 'Session title' }
},
required: ['type', 'title']
}
},
add_insight: {
name: 'add_insight',
description: 'Capture strategic insight',
inputSchema: {
type: 'object',
properties: {
sessionId: { type: 'string', description: 'Session ID' },
insight: { type: 'string', description: 'Insight content' },
impact: { type: 'string', description: 'Impact level' }
},
required: ['sessionId', 'insight', 'impact']
}
},
track_decision: {
name: 'track_decision',
description: 'Record strategic decision',
inputSchema: {
type: 'object',
properties: {
sessionId: { type: 'string', description: 'Session ID' },
decision: { type: 'string', description: 'Decision made' },
rationale: { type: 'string', description: 'Decision rationale' }
},
required: ['sessionId', 'decision', 'rationale']
}
},
add_action: {
name: 'add_action',
description: 'Add action item',
inputSchema: {
type: 'object',
properties: {
sessionId: { type: 'string', description: 'Session ID' },
action: { type: 'string', description: 'Action description' },
owner: { type: 'string', description: 'Action owner' },
due: { type: 'string', description: 'Due date' }
},
required: ['sessionId', 'action', 'owner', 'due']
}
},
get_session: {
name: 'get_session',
description: 'Get session details',
inputSchema: {
type: 'object',
properties: {
sessionId: { type: 'string', description: 'Session ID' }
},
required: ['sessionId']
}
},
// Goal Tools (9-12)
create_goal: {
name: 'create_goal',
description: 'Create business goal',
inputSchema: {
type: 'object',
properties: {
title: { type: 'string', description: 'Goal title' },
category: { type: 'string', description: 'Goal category' },
owner: { type: 'string', description: 'Goal owner' }
},
required: ['title', 'category', 'owner']
}
},
update_progress: {
name: 'update_progress',
description: 'Update goal progress',
inputSchema: {
type: 'object',
properties: {
goalId: { type: 'string', description: 'Goal ID' },
progress: { type: 'number', description: 'Progress percentage' }
},
required: ['goalId', 'progress']
}
},
add_milestone: {
name: 'add_milestone',
description: 'Add goal milestone',
inputSchema: {
type: 'object',
properties: {
goalId: { type: 'string', description: 'Goal ID' },
title: { type: 'string', description: 'Milestone title' },
date: { type: 'string', description: 'Target date' }
},
required: ['goalId', 'title', 'date']
}
},
list_goals: {
name: 'list_goals',
description: 'List all goals',
inputSchema: {
type: 'object',
properties: {
category: { type: 'string', description: 'Filter by category' }
}
}
},
// Analytics Tools (13-15)
run_analysis: {
name: 'run_analysis',
description: 'Run strategic analysis',
inputSchema: {
type: 'object',
properties: {
type: { type: 'string', description: 'Analysis type' },
depth: { type: 'string', description: 'Analysis depth' }
}
}
},
gen_dashboard: {
name: 'gen_dashboard',
description: 'Generate dashboard',
inputSchema: {
type: 'object',
properties: {
timeframe: { type: 'string', description: 'Time period' }
}
}
},
gen_report: {
name: 'gen_report',
description: 'Generate report',
inputSchema: {
type: 'object',
properties: {
type: { type: 'string', description: 'Report type' },
format: { type: 'string', description: 'Output format' }
}
}
},
// Template Tools (16-20)
list_conversation_templates: {
name: 'list_conversation_templates',
description: 'List conversation templates',
inputSchema: {
type: 'object',
properties: {}
}
},
get_conversation_template: {
name: 'get_conversation_template',
description: 'Get conversation template',
inputSchema: {
type: 'object',
properties: {
templateId: { type: 'string', description: 'Template ID' }
},
required: ['templateId']
}
},
start_templated_conversation: {
name: 'start_templated_conversation',
description: 'Start templated conversation',
inputSchema: {
type: 'object',
properties: {
templateId: { type: 'string', description: 'Template ID' },
title: { type: 'string', description: 'Conversation title' },
context: { type: 'object', description: 'Conversation context' }
},
required: ['templateId', 'title']
}
},
apply_template_guidance: {
name: 'apply_template_guidance',
description: 'Apply template guidance',
inputSchema: {
type: 'object',
properties: {
conversationId: { type: 'string', description: 'Conversation ID' },
templateId: { type: 'string', description: 'Template ID' },
sectionIndex: { type: 'number', description: 'Section index' }
},
required: ['conversationId', 'templateId', 'sectionIndex']
}
},
generate_conversation_report: {
name: 'generate_conversation_report',
description: 'Generate conversation report',
inputSchema: {
type: 'object',
properties: {
conversationId: { type: 'string', description: 'Conversation ID' },
includeTemplate: { type: 'boolean', description: 'Include template analysis' }
},
required: ['conversationId']
}
},
// Integration Tools (21-24)
extract_insights_from_files: {
name: 'extract_insights_from_files',
description: 'Extract insights from files',
inputSchema: {
type: 'object',
properties: {
includeInsights: { type: 'boolean', description: 'Include insights files' },
includeReflections: { type: 'boolean', description: 'Include reflections' },
minBusinessRelevance: { type: 'number', description: 'Min relevance score' }
}
}
},
generate_business_implications: {
name: 'generate_business_implications',
description: 'Generate business implications',
inputSchema: {
type: 'object',
properties: {
minBusinessRelevance: { type: 'number', description: 'Min relevance score' },
includeAlignmentMappings: { type: 'boolean', description: 'Include alignments' }
}
}
},
link_insight_to_conversation: {
name: 'link_insight_to_conversation',
description: 'Link insight to conversation',
inputSchema: {
type: 'object',
properties: {
conversationId: { type: 'string', description: 'Conversation ID' },
insightContent: { type: 'string', description: 'Insight content' },
category: { type: 'string', description: 'Insight category' },
impact: { type: 'string', description: 'Impact level' }
},
required: ['conversationId', 'insightContent', 'category', 'impact']
}
},
create_insight_based_conversation: {
name: 'create_insight_based_conversation',
description: 'Create insight-based conversation',
inputSchema: {
type: 'object',
properties: {
title: { type: 'string', description: 'Conversation title' },
type: { type: 'string', description: 'Conversation type' },
sourceInsights: { type: 'array', items: { type: 'string' }, description: 'Source insights' }
},
required: ['title', 'type', 'sourceInsights']
}
},
// Intelligence Tools (25-30)
create_technical_milestone: {
name: 'create_technical_milestone',
description: 'Create technical milestone with business impact',
inputSchema: {
type: 'object',
properties: {
name: { type: 'string', description: 'Milestone name' },
description: { type: 'string', description: 'Milestone description' },
category: { type: 'string', description: 'Milestone category' },
plannedDate: { type: 'string', description: 'Planned completion date' },
effort: { type: 'number', description: 'Estimated effort in hours' },
complexity: { type: 'string', description: 'Complexity level' }
},
required: ['name', 'description', 'category', 'plannedDate', 'effort', 'complexity']
}
},
update_milestone_progress: {
name: 'update_milestone_progress',
description: 'Update technical milestone progress',
inputSchema: {
type: 'object',
properties: {
milestoneId: { type: 'string', description: 'Milestone ID' },
completionPercentage: { type: 'number', description: 'Completion percentage' },
blockers: { type: 'array', items: { type: 'string' }, description: 'Current blockers' },
achievements: { type: 'array', items: { type: 'string' }, description: 'Recent achievements' }
},
required: ['milestoneId', 'completionPercentage']
}
},
analyze_development_business_alignment: {
name: 'analyze_development_business_alignment',
description: 'Analyze technical-business milestone alignment',
inputSchema: {
type: 'object',
properties: {
includeCorrelations: { type: 'boolean', description: 'Include correlations' },
includeProjections: { type: 'boolean', description: 'Include projections' },
includePredictiveInsights: { type: 'boolean', description: 'Include insights' }
}
}
},
generate_business_impact_forecast: {
name: 'generate_business_impact_forecast',
description: 'Generate business impact forecast from milestones',
inputSchema: {
type: 'object',
properties: {
timeframe: { type: 'string', description: 'Forecast timeframe' },
confidence: { type: 'string', description: 'Confidence level' },
includeScenarios: { type: 'boolean', description: 'Include scenarios' }
},
required: ['timeframe']
}
},
identify_strategic_opportunities: {
name: 'identify_strategic_opportunities',
description: 'Identify strategic opportunities from capabilities',
inputSchema: {
type: 'object',
properties: {
analysisType: { type: 'string', description: 'Analysis type' },
minImpact: { type: 'string', description: 'Minimum impact level' }
}
}
},
get_milestone_business_alignment: {
name: 'get_milestone_business_alignment',
description: 'Get business alignment analysis for milestone',
inputSchema: {
type: 'object',
properties: {
milestoneId: { type: 'string', description: 'Milestone ID to analyze' }
},
required: ['milestoneId']
}
},
// Advanced Analytics Tools (31-33)
generate_goal_health_report: {
name: 'generate_goal_health_report',
description: 'Generate goal health report with forecasting',
inputSchema: {
type: 'object',
properties: {
goalId: { type: 'string', description: 'Goal ID (optional)' },
includeForecasting: { type: 'boolean', description: 'Include forecasting' },
includeRecommendations: { type: 'boolean', description: 'Include recommendations' }
}
}
},
generate_pattern_analysis_report: {
name: 'generate_pattern_analysis_report',
description: 'Generate pattern analysis report with insights',
inputSchema: {
type: 'object',
properties: {
patternTypes: {
type: 'array',
items: {
type: 'string',
enum: ['efficiency', 'velocity', 'correlation', 'risk', 'opportunity', 'trend']
},
description: 'Types of patterns to analyze'
},
confidenceThreshold: {
type: 'number',
minimum: 0,
maximum: 100,
description: 'Min confidence threshold for patterns'
},
includeActionablePlan: { type: 'boolean', description: 'Include actionable plan' }
}
}
},
generate_executive_insights_brief: {
name: 'generate_executive_insights_brief',
description: 'Generate executive insights brief',
inputSchema: {
type: 'object',
properties: {
timeframe: {
type: 'string',
enum: ['30-days', '90-days', '6-months'],
description: 'Timeframe for insights analysis'
},
focusAreas: {
type: 'array',
items: {
type: 'string',
enum: ['competitive-advantage', 'market-timing', 'operational-efficiency', 'strategic-risks', 'all']
},
description: 'Areas of strategic focus'
}
}
}
},
// Forecasting Tools (34-41)
generate_scenario_forecast: {
name: 'generate_scenario_forecast',
description: 'Generate multi-scenario balanced forecasts',
inputSchema: {
type: 'object',
properties: {
timeframe: {
type: 'string',
enum: ['3-months', '6-months', '12-months', '18-months', '24-months'],
description: 'Forecast timeframe'
},
focusArea: {
type: 'string',
enum: ['revenue', 'growth', 'market-share', 'technical', 'all'],
description: 'Primary focus area for forecast'
},
includeDisruption: {
type: 'boolean',
description: 'Include market disruption scenarios'
}
},
required: ['timeframe']
}
},
identify_strategy_gaps: {
name: 'identify_strategy_gaps',
description: 'Identify gaps in current strategy across dimensions',
inputSchema: {
type: 'object',
properties: {
marketContext: {
type: 'array',
items: { type: 'string' },
description: 'Market context factors to consider'
},
minSeverity: {
type: 'string',
enum: ['minor', 'moderate', 'significant', 'critical'],
description: 'Minimum severity level to report'
}
}
}
},
generate_competitive_intelligence: {
name: 'generate_competitive_intelligence',
description: 'Generate competitive intelligence analysis',
inputSchema: {
type: 'object',
properties: {
marketSegment: { type: 'string', description: 'Market segment to analyze' },
marketSize: { type: 'number', description: 'Total addressable market size' },
competitors: {
type: 'array',
items: { type: 'string' },
description: 'List of specific competitors to analyze'
},
trends: {
type: 'array',
items: { type: 'string' },
description: 'Market trends to consider'
}
}
}
},
run_what_if_analysis: {
name: 'run_what_if_analysis',
description: 'Run what-if scenarios to test strategic assumptions',
inputSchema: {
type: 'object',
properties: {
scenarios: {
type: 'array',
items: {
type: 'object',
properties: {
name: { type: 'string', description: 'Scenario name' },
description: { type: 'string', description: 'Scenario description' },
assumptions: {
type: 'object',
properties: {
completionRateChange: { type: 'number', description: '% change in completion rate' },
revenueRealizationChange: { type: 'number', description: '% change in revenue' },
competitorActions: {
type: 'array',
items: { type: 'string' },
description: 'List of competitor actions'
},
marketChanges: {
type: 'array',
items: { type: 'string' },
description: 'List of market changes'
}
}
}
},
required: ['name', 'description', 'assumptions']
},
description: 'Scenarios to analyze'
},
timeframe: {
type: 'string',
enum: ['6-months', '12-months', '24-months'],
description: 'Analysis timeframe'
}
},
required: ['scenarios', 'timeframe']
}
},
generate_confidence_intervals: {
name: 'generate_confidence_intervals',
description: 'Generate confidence intervals for key metrics',
inputSchema: {
type: 'object',
properties: {
metric: {
type: 'string',
enum: ['revenue', 'customer-acquisition', 'market-share', 'milestone-completion'],
description: 'Metric to analyze'
},
timeframes: {
type: 'array',
items: {
type: 'string',
enum: ['3-months', '6-months', '12-months']
},
description: 'Timeframes to analyze'
},
confidenceLevels: {
type: 'array',
items: { type: 'number' },
description: 'Confidence levels (e.g., [50, 75, 90])'
}
},
required: ['metric', 'timeframes']
}
},
// Critical Analysis Tools (42-43)
run_critical_analysis: {
name: 'run_critical_analysis',
description: 'Run critical analysis to identify weaknesses',
inputSchema: {
type: 'object',
properties: {
analysisDepth: {
type: 'string',
enum: ['surface', 'standard', 'deep'],
description: 'Depth of critical analysis to perform'
},
focusAreas: {
type: 'array',
items: {
type: 'string',
enum: ['strategic', 'execution', 'market', 'financial', 'technical', 'organizational']
},
description: 'Specific areas to focus critical analysis on'
},
includeHardTruths: {
type: 'boolean',
description: 'Include uncomfortable truths teams avoid discussing'
},
includeMitigationStrategies: {
type: 'boolean',
description: 'Generate strategies to address weaknesses'
}
}
}
},
generate_skeptical_report: {
name: 'generate_skeptical_report',
description: 'Generate skeptical analysis report with hard truths',
inputSchema: {
type: 'object',
properties: {
focusAreas: {
type: 'array',
items: {
type: 'string',
enum: ['strategic', 'execution', 'market', 'financial', 'technical', 'organizational']
},
description: 'Areas to focus skeptical analysis on'
},
includeHardTruths: {
type: 'boolean',
description: 'Include uncomfortable truths about the project'
},
analysisDepth: {
type: 'string',
enum: ['surface', 'standard', 'deep'],
description: 'How deep to dig for weaknesses and issues'
}
}
}
}
};
// List tools handler
server.setRequestHandler(ListToolsRequestSchema, async () => {
try {
await ensureInitialized();
console.error('Strategic Intelligence MCP: Listing tools, storage initialized');
return {
tools: Object.values(TOOLS)
};
}
catch (error) {
console.error('Strategic Intelligence MCP: Error in list tools handler:', error);
throw new McpError(ErrorCode.InternalError, `Failed to initialize storage: ${error instanceof Error ? error.message : 'Unknown error'}`);
}
});
// Call tool handler - minimal version for testing
server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
try {
await ensureInitialized();
console.error(`Strategic Intelligence MCP: Executing tool '${name}', storage initialized`);
switch (name) {
// Project Setup Tools
case 'init_project':
return { content: [{ type: 'text', text: JSON.stringify(await initializationTools.initializeProjectContext(args), null, 2) }] };
case 'import_docs':
return { content: [{ type: 'text', text: JSON.stringify(await initializationTools.importContextFromDocument(args), null, 2) }] };
case 'setup_wizard':
return { content: [{ type: 'text', text: JSON.stringify(await initializationTools.quickSetupWizard(args), null, 2) }] };
// Strategy Tools
case 'start_session':
return { content: [{ type: 'text', text: JSON.stringify(await conversationTools.startStrategySession(args), null, 2) }] };
case 'add_insight':
return { content: [{ type: 'text', text: JSON.stringify(await conversationTools.captureStrategicInsight(args), null, 2) }] };
case 'track_decision':
return { content: [{ type: 'text', text: JSON.stringify(await conversationTools.trackStrategicDecision(args), null, 2) }] };
case 'add_action':
return { content: [{ type: 'text', text: JSON.stringify(await conversationTools.addActionItem(args), null, 2) }] };
case 'get_session':
return { content: [{ type: 'text', text: JSON.stringify(await conversationTools.getConversation(args), null, 2) }] };
// Goal Tools
case 'create_goal':
return { content: [{ type: 'text', text: JSON.stringify(await goalTools.createBusinessGoal(args), null, 2) }] };
case 'update_progress':
return { content: [{ type: 'text', text: JSON.stringify(await goalTools.updateGoalProgress(args), null, 2) }] };
case 'add_milestone':
return { content: [{ type: 'text', text: JSON.stringify(await goalTools.addMilestone(args), null, 2) }] };
case 'list_goals':
return { content: [{ type: 'text', text: JSON.stringify(await goalTools.listGoals(args), null, 2) }] };
// Analytics Tools
case 'run_analysis':
return { content: [{ type: 'text', text: JSON.stringify(await analyticsTools.runComprehensiveAnalysis(args), null, 2) }] };
case 'gen_dashboard':
return { content: [{ type: 'text', text: JSON.stringify(await analyticsTools.generateStrategicDashboard(args), null, 2) }] };
case 'gen_report':
return { content: [{ type: 'text', text: JSON.stringify(await reportingTools.generateStrategicReport(args), null, 2) }] };
// Template Tools
case 'list_conversation_templates':
return { content: [{ type: 'text', text: JSON.stringify(await templateTools.listConversationTemplates(), null, 2) }] };
case 'get_conversation_template':
return { content: [{ type: 'text', text: JSON.stringify(await templateTools.getConversationTemplate(args), null, 2) }] };
case 'start_templated_conversation':
return { content: [{ type: 'text', text: JSON.stringify(await templateTools.startTemplatedConversation(args), null, 2) }] };
case 'apply_template_guidance':
return { content: [{ type: 'text', text: JSON.stringify(await templateTools.applyTemplateGuidance(args), null, 2) }] };
case 'generate_conversation_report':
return { content: [{ type: 'text', text: JSON.stringify(await templateTools.generateConversationReport(args), null, 2) }] };
// Integration Tools
case 'extract_insights_from_files':
return { content: [{ type: 'text', text: JSON.stringify(await integrationTools.extractInsightsFromFiles(args), null, 2) }] };
case 'generate_business_implications':
return { content: [{ type: 'text', text: JSON.stringify(await integrationTools.generateBusinessImplications(args), null, 2) }] };
case 'link_insight_to_conversation':
return { content: [{ type: 'text', text: JSON.stringify(await integrationTools.linkInsightToConversation(args), null, 2) }] };
case 'create_insight_based_conversation':
return { content: [{ type: 'text', text: JSON.stringify(await integrationTools.createInsightBasedConversation(args), null, 2) }] };
// Intelligence Tools
case 'create_technical_milestone':
return { content: [{ type: 'text', text: JSON.stringify(await intelligenceTools.createTechnicalMilestone(args), null, 2) }] };
case 'update_milestone_progress':
return { content: [{ type: 'text', text: JSON.stringify(await intelligenceTools.updateMilestoneProgress(args), null, 2) }] };
case 'analyze_development_business_alignment':
return { content: [{ type: 'text', text: JSON.stringify(await intelligenceTools.analyzeDevelopmentBusinessAlignment(args), null, 2) }] };
case 'generate_business_impact_forecast':
return { content: [{ type: 'text', text: JSON.stringify(await intelligenceTools.generateBusinessImpactForecast(args), null, 2) }] };
case 'identify_strategic_opportunities':
return { content: [{ type: 'text', text: JSON.stringify(await intelligenceTools.identifyStrategicOpportunities(args), null, 2) }] };
case 'get_milestone_business_alignment':
return { content: [{ type: 'text', text: JSON.stringify(await intelligenceTools.getMilestoneBusinessAlignment(args), null, 2) }] };
// Advanced Analytics Tools
case 'generate_goal_health_report':
return { content: [{ type: 'text', text: JSON.stringify(await analyticsTools.generateGoalHealthReport(args), null, 2) }] };
case 'generate_pattern_analysis_report':
return { content: [{ type: 'text', text: JSON.stringify(await analyticsTools.generatePatternAnalysisReport(args), null, 2) }] };
case 'generate_executive_insights_brief':
return { content: [{ type: 'text', text: JSON.stringify(await analyticsTools.generateExecutiveInsightsBrief(args), null, 2) }] };
// Forecasting Tools
case 'generate_scenario_forecast':
return { content: [{ type: 'text', text: JSON.stringify(await forecastingTools.generateScenarioForecast(args), null, 2) }] };
case 'identify_strategy_gaps':
return { content: [{ type: 'text', text: JSON.stringify(await forecastingTools.identifyStrategyGaps(args), null, 2) }] };
case 'generate_competitive_intelligence':
return { content: [{ type: 'text', text: JSON.stringify(await forecastingTools.generateCompetitiveIntelligence(args), null, 2) }] };
case 'run_what_if_analysis':
return { content: [{ type: 'text', text: JSON.stringify(await forecastingTools.runWhatIfAnalysis(args), null, 2) }] };
case 'generate_confidence_intervals':
return { content: [{ type: 'text', text: JSON.stringify(await forecastingTools.generateConfidenceIntervals(args), null, 2) }] };
// Critical Analysis Tools
case 'run_critical_analysis':
return { content: [{ type: 'text', text: JSON.stringify(await analyticsTools.runCriticalAnalysis(args), null, 2) }] };
case 'generate_skeptical_report':
return { content: [{ type: 'text', text: JSON.stringify(await analyticsTools.generateSkepticalReport(args), null, 2) }] };
default:
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
}
}
catch (error) {
console.error(`Strategic Intelligence MCP: Error executing tool '${name}':`, error);
console.error('Strategic Intelligence MCP: Error details:', {
toolName: name,
arguments: args,
message: error instanceof Error ? error.message : 'Unknown error',
stack: error instanceof Error ? error.stack : 'No stack trace',
isStorageInitialized: isInitialized
});
const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
throw new McpError(ErrorCode.InternalError, `Error executing tool ${name}: ${errorMessage}`);
}
});
// Start the server
async function main() {
try {
console.error('Strategic Intelligence MCP: Starting server...');
// Initialize storage early
await initializeStorage();
const transport = new StdioServerTransport();
await server.connect(transport);
console.error('Strategic Intelligence MCP Server running on stdio');
}
catch (error) {
console.error('Strategic Intelligence MCP: Fatal error during startup:', error);
console.error('Strategic Intelligence MCP: Startup error details:', {
message: error instanceof Error ? error.message : 'Unknown error',
stack: error instanceof Error ? error.stack : 'No stack trace',
cwd: process.cwd(),
dataPath: './strategic-data.json'
});
process.exit(1);
}
}
main().catch((error) => {
console.error('Strategic Intelligence MCP: Fatal error in main():', error);
console.error('Strategic Intelligence MCP: Main error details:', {
message: error instanceof Error ? error.message : 'Unknown error',
stack: error instanceof Error ? error.stack : 'No stack trace'
});
process.exit(1);
});
//# sourceMappingURL=index.js.map