UNPKG

mcp-adr-analysis-server

Version:

MCP server for analyzing Architectural Decision Records and project architecture

237 lines 7.69 kB
/** * Environment Analysis Resource - System environment details * URI Pattern: adr://environment_analysis * * Enhanced with Bridge Pattern to leverage comprehensive environment-analysis-tool * Supports query parameters for analysis types and features */ import { URLSearchParams } from 'url'; import { ResourceGenerationResult } from './index.js'; /** * Enhanced environment analysis interface with comprehensive capabilities */ export interface EnvironmentAnalysis { system: { platform: string; arch: string; release: string; nodeVersion: string; npmVersion: string; hostname: string; cpus: number; totalMemory: string; freeMemory: string; }; project: { root: string; hasGit: boolean; hasTypeScript: boolean; hasTests: boolean; packageManager: 'npm' | 'yarn' | 'pnpm' | 'unknown'; frameworks: string[]; }; dependencies: { runtime: Record<string, string>; development: Record<string, string>; peer: Record<string, string>; }; environment: { variables: Record<string, string | undefined>; paths: { node: string; npm: string; projectRoot: string; adrDirectory: string; }; }; capabilities: { aiExecution: boolean; knowledgeGraph: boolean; caching: boolean; masking: boolean; }; health: { diskSpace: { total: string; free: string; usagePercent: number; }; performance: { uptime: number; loadAverage: number[]; }; }; infrastructure?: { components: Record<string, any>; services: string[]; topology: string; }; containerization?: { detected: boolean; technologies: string[]; dockerfiles: number; composeFiles: number; kubernetes: boolean; security: { score: number; issues: string[]; }; }; cloudServices?: { providers: string[]; services: string[]; deployment: string; }; security?: { httpsEnabled: boolean; authenticationSetup: boolean; secretManagement: boolean; complianceFrameworks: string[]; vulnerabilities: number; }; deployment?: { cicdDetected: boolean; pipeline: string; automated: boolean; frequency: string; }; monitoring?: { toolsDetected: string[]; metricsEnabled: boolean; loggingEnabled: boolean; tracingEnabled: boolean; }; adrIntegration?: { requirementsExtracted: boolean; totalRequirements: number; infrastructureRequirements: string[]; securityRequirements: string[]; }; qualityAttributes?: { performance: string; scalability: string; reliability: string; maintainability: string; security: string; }; riskAssessment?: { risks: string[]; riskLevel: 'low' | 'medium' | 'high'; mitigations: string[]; }; analysisMetadata?: { analysisType: string; timestamp: string; confidence: number; source: 'basic' | 'comprehensive-tool'; memoryIntegration: boolean; }; } /** * Generate comprehensive environment analysis resource with infrastructure detection and cloud services discovery. * * Analyzes the runtime environment, system specifications, project dependencies, containerization setup, * cloud services configuration, and security posture to provide complete environmental context. * * **Query Parameters:** * - `type`: Analysis type - "specs" (system specs), "infrastructure" (detailed infra), or "security" (security focus) (default: "specs") * - `memory`: Enable memory integration for historical environment tracking (default: true) * - `comprehensive`: Use comprehensive analysis via tool bridge (default: true) * * **Comprehensive Mode includes:** * - Advanced infrastructure component detection (Kubernetes, Docker, databases) * - Cloud services discovery (AWS, Azure, GCP, Vercel, Netlify) * - Container security analysis with scoring * - HTTPS/authentication/secrets management checks * - Compliance framework detection (SOC2, HIPAA, GDPR, PCI-DSS) * - Real-time health metrics (disk space, load average, uptime) * * **Basic Mode includes:** * - System specifications (OS, arch, Node.js, npm versions) * - Project structure analysis (TypeScript, tests, package manager) * - Runtime dependencies catalog * - Environment variables overview * - Basic capability flags * * @param _params - URL path parameters (currently unused, reserved for future routing) * @param searchParams - URL query parameters controlling analysis depth and type * * @returns Promise resolving to resource generation result containing: * - data: Complete environment analysis with system, project, and infrastructure details * - contentType: "application/json" * - lastModified: ISO timestamp of generation * - cacheKey: Unique identifier based on analysis type and options * - ttl: Cache duration (300 seconds / 5 minutes) * - etag: Entity tag for cache validation * * @throws {Error} Rarely throws; gracefully handles analysis failures by: * - Falling back to basic analysis if comprehensive fails * - Returning partial data for unavailable metrics * - Logging warnings for non-critical errors * * @example * ```typescript * // Get comprehensive environment analysis * const env = await generateEnvironmentAnalysisResource( * {}, * new URLSearchParams('type=infrastructure&memory=true') * ); * * console.log(`Platform: ${env.data.system.platform} ${env.data.system.arch}`); * console.log(`Node: ${env.data.system.nodeVersion}`); * console.log(`AI Execution: ${env.data.capabilities.aiExecution ? 'Enabled' : 'Disabled'}`); * * // Check containerization * if (env.data.containerization?.detected) { * console.log(`Container tech: ${env.data.containerization.technologies.join(', ')}`); * console.log(`Security score: ${env.data.containerization.security.score}`); * } * * // Check cloud services * if (env.data.cloudServices) { * console.log(`Cloud providers: ${env.data.cloudServices.providers.join(', ')}`); * console.log(`Services: ${env.data.cloudServices.services.length}`); * } * * // Basic mode example (faster) * const basicEnv = await generateEnvironmentAnalysisResource( * {}, * new URLSearchParams('comprehensive=false') * ); * * // Expected output structure: * { * data: { * system: { * platform: "linux", * arch: "x64", * nodeVersion: "20.10.0", * npmVersion: "10.2.3" * }, * project: { * hasTypeScript: true, * hasTests: true, * frameworks: ["express", "jest"] * }, * capabilities: { * aiExecution: true, * knowledgeGraph: true, * caching: true * }, * containerization: { * detected: true, * technologies: ["docker"], * security: { score: 85 } * } * }, * contentType: "application/json", * cacheKey: "environment-analysis:specs:true:true", * ttl: 300 * } * ``` * * @since v2.0.0 * @see {@link environmentAnalysis} tool for underlying analysis engine */ export declare function generateEnvironmentAnalysisResource(_params?: Record<string, string>, searchParams?: URLSearchParams): Promise<ResourceGenerationResult>; //# sourceMappingURL=environment-analysis-resource.d.ts.map