Skip to main content
Glama

Analytical MCP Server

market_analysis_workflow.test.ts5.45 kB
import { describe, it, expect } from '@jest/globals'; import { exaResearch } from '../utils/exa_research.js'; import { logicalArgumentAnalyzer } from '../tools/logical_argument_analyzer.js'; import { logicalFallacyDetector } from '../tools/logical_fallacy_detector.js'; import { perspectiveShifter } from '../tools/perspective_shifter.js'; import { decisionAnalysis } from '../tools/decision_analysis.js'; import { APIError } from '../utils/errors.js'; import { Logger } from '../utils/logger.js'; describe('Market Analysis Workflow Integration Tests', () => { it('should execute a partial market analysis workflow', async () => { // Skip test if EXA_API_KEY is not in environment if (!process.env.EXA_API_KEY) { Logger.warn('Skipping test: EXA_API_KEY not found in environment'); return; } // Step 1: Market Research with real API const marketResearch = await exaResearch.search({ query: 'Current market trends in technology sector', numResults: 2, timeRangeMonths: 3, useWebResults: true, useNewsResults: false, includeContents: true, }); expect(marketResearch).toBeDefined(); expect(marketResearch.results).toBeInstanceOf(Array); expect(marketResearch.results.length).toBeGreaterThan(0); // Step 2: Verify market research results have expected structure expect(marketResearch.results[0]).toHaveProperty('title'); expect(marketResearch.results[0]).toHaveProperty('url'); // Note: API response format may vary - check for any additional properties const firstResult = marketResearch.results[0] as any; expect(firstResult.contents !== undefined || firstResult.id !== undefined).toBe(true); // Step 3: Analyze market expansion argument const argumentAnalysis = await logicalArgumentAnalyzer({ argument: `We should expand into emerging markets because our current market is saturated. The research suggests significant growth opportunities in regions with increasing digital adoption.`, analysisType: 'structure', includeRecommendations: true }); expect(argumentAnalysis).toContain('Argument Structure Analysis'); expect(argumentAnalysis).toContain('Identified Premises'); expect(argumentAnalysis).toContain('Conclusion'); // Step 4: Verify argument analysis contains expected content expect(typeof argumentAnalysis).toBe('string'); expect(argumentAnalysis.length).toBeGreaterThan(0); // Step 5: Check for logical fallacies const fallacyCheck = await logicalFallacyDetector( "We should expand into emerging markets because they're new and untapped. This will guarantee our success.", 0.7, ['all'], true, true ); expect(fallacyCheck).toContain('Logical Fallacy Analysis'); // Step 6: Generate alternative perspectives const perspectives = await perspectiveShifter( 'Should we expand into emerging technology markets?', 'Executive Management', 'stakeholder', 3, true ); expect(perspectives).toContain('Perspective Shifting Analysis'); expect(perspectives).toContain('Perspective'); // Step 7: Decision analysis const strategyDecision = await decisionAnalysis( [ 'Immediate Emerging Market Expansion', 'Phased Market Entry', 'Strategic Partnership', 'Market Research Deepening', 'Defer Expansion', ], [ 'Market Potential', 'Emerging Technology Trends', 'Geopolitical Stability', 'Digital Adoption Rates', 'Economic Indicators', 'Competitive Landscape', 'Resource Requirements', ], [0.2, 0.15, 0.1, 0.15, 0.1, 0.15, 0.15] ); expect(strategyDecision).toContain('Decision Analysis Results'); // Check for any indication that options were analyzed const hasAnalysisTerms = strategyDecision.includes('option') || strategyDecision.includes('score') || strategyDecision.includes('analysis'); expect(hasAnalysisTerms).toBe(true); }); it('should handle API failures gracefully', async () => { // Simulate an API error without mocking const simulatedError = new APIError('External API error', 429, true, 'exa/search'); // Verify error properties directly expect(simulatedError).toBeInstanceOf(APIError); expect(simulatedError.status).toBe(429); expect(simulatedError.retryable).toBe(true); // No need to restore mock here since we're not using mocks directly }); it('should still perform analysis with partial data when research integration fails', async () => { // Don't need to mock this for the simple test // Just run the decision analysis directly // Decision analysis should still work even if research validation fails const strategyDecision = await decisionAnalysis( ['Immediate Expansion', 'Phased Entry', 'Strategic Partnership'], ['Market Potential', 'Resource Requirements'], [0.6, 0.4] ); expect(strategyDecision).toContain('Decision Analysis Results'); // Check for any indication that options were analyzed const hasAnalysisTerms = strategyDecision.includes('option') || strategyDecision.includes('score') || strategyDecision.includes('analysis'); expect(hasAnalysisTerms).toBe(true); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/quanticsoul4772/analytical-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server