mcp-adr-analysis-server
Version:
MCP server for analyzing Architectural Decision Records and project architecture
260 lines • 8.54 kB
TypeScript
/**
* MCP Tasks Integration for Deployment Readiness Tool
*
* This module provides standardized task tracking for the deployment readiness tool,
* implementing ADR-020: MCP Tasks Integration Strategy.
*
* Key features:
* - Creates MCP Tasks for deployment validation operations
* - Tracks progress through validation phases (tests, history, code quality, ADR compliance)
* - Supports cancellation between phases
* - Provides memory integration for deployment assessment tracking
*
* @see ADR-020: MCP Tasks Integration Strategy
* @see https://modelcontextprotocol.io/specification/2025-11-25/basic/utilities/tasks
*/
import { type AdrTask, type TaskResult, type TaskManager } from './task-manager.js';
/**
* Deployment validation phases that map to MCP Task phases
*/
export declare const DEPLOYMENT_PHASES: readonly ["initialization", "test_validation", "code_quality_analysis", "deployment_history_analysis", "adr_compliance_check", "environment_research", "blocker_assessment", "final_report"];
export type DeploymentPhase = (typeof DEPLOYMENT_PHASES)[number];
/**
* Deployment task context for tracking state across validation steps
*/
export interface DeploymentTaskContext {
taskId: string;
currentPhase: DeploymentPhase;
operation: string;
targetEnvironment: string;
cancelled: boolean;
testValidationResult?: {
passed: boolean;
failureCount: number;
coveragePercentage: number;
};
codeQualityResult?: {
score: number;
securityIssues: number;
complexity: number;
};
historyAnalysisResult?: {
successRate: number;
rollbackRate: number;
recommendedAction: string;
};
adrComplianceResult?: {
score: number;
compliantAdrs: number;
totalAdrs: number;
};
blockerCount?: number;
}
/**
* Options for creating a deployment task
*/
export interface CreateDeploymentTaskOptions {
projectPath: string;
targetEnvironment: string;
operation: string;
strictMode?: boolean;
enableMemoryIntegration?: boolean;
enableTreeSitterAnalysis?: boolean;
enableResearchIntegration?: boolean;
}
/**
* Result from deployment task execution
*/
export interface DeploymentTaskResult extends TaskResult {
data?: {
isDeploymentReady: boolean;
overallScore: number;
confidence: number;
blockerCount: number;
testsPassed: boolean;
gitPushStatus: 'allowed' | 'blocked' | 'conditional';
memoryEntityId?: string;
};
}
/**
* Deployment Task Manager - Provides MCP Tasks integration for deployment readiness
*
* This class wraps the TaskManager to provide deployment-specific functionality:
* - Creates tasks with deployment validation phases
* - Tracks validation progress through multiple checks
* - Supports cancellation between phases
* - Integrates with memory for assessment tracking
*/
export declare class DeploymentTaskManager {
private taskManager;
private activeContexts;
constructor(taskManager?: TaskManager);
/**
* Initialize the deployment task manager
*/
initialize(): Promise<void>;
/**
* Create a new deployment task
*
* @returns The created task and context
*/
createDeploymentTask(options: CreateDeploymentTaskOptions): Promise<{
task: AdrTask;
context: DeploymentTaskContext;
}>;
/**
* Get deployment task context
*/
getContext(taskId: string): DeploymentTaskContext | undefined;
/**
* Start a deployment phase
*/
startPhase(taskId: string, phase: DeploymentPhase, message?: string): Promise<void>;
/**
* Update phase progress
*/
updatePhaseProgress(taskId: string, phase: DeploymentPhase, phaseProgress: number, message?: string): Promise<void>;
/**
* Complete a deployment phase
*/
completePhase(taskId: string, phase: DeploymentPhase, _message?: string): Promise<void>;
/**
* Fail a deployment phase
*/
failPhase(taskId: string, phase: DeploymentPhase, error: string): Promise<void>;
/**
* Store test validation result
*/
storeTestValidationResult(taskId: string, result: {
passed: boolean;
failureCount: number;
coveragePercentage: number;
}): Promise<void>;
/**
* Store code quality result
*/
storeCodeQualityResult(taskId: string, result: {
score: number;
securityIssues: number;
complexity: number;
}): Promise<void>;
/**
* Store deployment history analysis result
*/
storeHistoryAnalysisResult(taskId: string, result: {
successRate: number;
rollbackRate: number;
recommendedAction: string;
}): Promise<void>;
/**
* Store ADR compliance result
*/
storeAdrComplianceResult(taskId: string, result: {
score: number;
compliantAdrs: number;
totalAdrs: number;
}): Promise<void>;
/**
* Store blocker count
*/
storeBlockerCount(taskId: string, blockerCount: number): Promise<void>;
/**
* Check if task is cancelled
*/
isCancelled(taskId: string): Promise<boolean>;
/**
* Cancel a deployment task
*/
cancelTask(taskId: string, reason?: string): Promise<void>;
/**
* Complete a deployment task successfully
*/
completeTask(taskId: string, result: DeploymentTaskResult): Promise<void>;
/**
* Fail a deployment task
*/
failTask(taskId: string, error: string): Promise<void>;
/**
* Get task status
*/
getTaskStatus(taskId: string): Promise<{
task: AdrTask | null;
context: DeploymentTaskContext | undefined;
}>;
}
export declare function getDeploymentTaskManager(): DeploymentTaskManager;
/**
* Reset the global DeploymentTaskManager (for testing)
*/
export declare function resetDeploymentTaskManager(): Promise<void>;
/**
* Helper function to wrap deployment execution with task tracking
*
* This can be used by the deployment_readiness tool to automatically
* track progress through MCP Tasks.
*
* @example
* ```typescript
* const result = await executeDeploymentWithTaskTracking(
* {
* projectPath: '/path/to/project',
* targetEnvironment: 'production',
* operation: 'full_audit',
* },
* async (tracker) => {
* // Test validation phase
* await tracker.startPhase('test_validation');
* const testResult = await runTests();
* await tracker.storeTestValidationResult(testResult);
* await tracker.completePhase('test_validation');
*
* // Code quality phase
* await tracker.startPhase('code_quality_analysis');
* const qualityResult = await analyzeCodeQuality();
* await tracker.storeCodeQualityResult(qualityResult);
* await tracker.completePhase('code_quality_analysis');
*
* // Return final result
* return { isDeploymentReady: true, overallScore: 95 };
* }
* );
* ```
*/
export declare function executeDeploymentWithTaskTracking<T extends DeploymentTaskResult>(options: CreateDeploymentTaskOptions, executor: (tracker: DeploymentTaskTracker) => Promise<T['data']>): Promise<{
taskId: string;
result: T;
}>;
/**
* Task tracker interface provided to deployment executor
*/
export interface DeploymentTaskTracker {
taskId: string;
startPhase: (phase: DeploymentPhase, message?: string) => Promise<void>;
updatePhaseProgress: (phase: DeploymentPhase, progress: number, message?: string) => Promise<void>;
completePhase: (phase: DeploymentPhase, message?: string) => Promise<void>;
failPhase: (phase: DeploymentPhase, error: string) => Promise<void>;
storeTestValidationResult: (result: {
passed: boolean;
failureCount: number;
coveragePercentage: number;
}) => Promise<void>;
storeCodeQualityResult: (result: {
score: number;
securityIssues: number;
complexity: number;
}) => Promise<void>;
storeHistoryAnalysisResult: (result: {
successRate: number;
rollbackRate: number;
recommendedAction: string;
}) => Promise<void>;
storeAdrComplianceResult: (result: {
score: number;
compliantAdrs: number;
totalAdrs: number;
}) => Promise<void>;
storeBlockerCount: (count: number) => Promise<void>;
isCancelled: () => Promise<boolean>;
getContext: () => DeploymentTaskContext;
}
//# sourceMappingURL=deployment-task-integration.d.ts.map