UNPKG

mcp-adr-analysis-server

Version:

MCP server for analyzing Architectural Decision Records and project architecture

291 lines 9.67 kB
/** * CE-MCP Tool Wrappers * * This module provides CE-MCP directive-based versions of high-token-cost tools. * Instead of executing prompts directly with OpenRouter, these tools return * orchestration directives that the host LLM can execute with minimal context. * * @see ADR-014: CE-MCP Architecture * @see docs/IMPLEMENTATION-PLAN.md Phase 2 */ import { OrchestrationDirective, StateMachineDirective } from '../types/ce-mcp.js'; /** * Arguments for CE-MCP analyze project ecosystem */ export interface CEMCPAnalyzeProjectEcosystemArgs { projectPath: string; analysisDepth?: 'basic' | 'standard' | 'comprehensive'; includeEnvironment?: boolean; knowledgeEnhancement?: boolean; learningEnabled?: boolean; technologyFocus?: string[]; analysisScope?: string[]; } /** * CE-MCP version of analyzeProjectEcosystem * * Returns an orchestration directive instead of executing the analysis directly. * This reduces token usage from ~12K to ~4K by: * - Deferring context assembly to sandbox operations * - Using lazy prompt loading * - Eliminating intermediate LLM calls * * Token Savings Breakdown: * - Knowledge generation: 3K → on-demand * - Memory retrieval: 2K → on-demand * - Environment analysis: 2.5K → on-demand * - Project structure: 2K → on-demand * - Reflexion context: 2K → on-demand */ export declare function createAnalyzeProjectEcosystemDirective(args: CEMCPAnalyzeProjectEcosystemArgs): OrchestrationDirective; /** * Arguments for CE-MCP ADR suggestion */ export interface CEMCPSuggestAdrsArgs { projectPath: string; codeChanges?: string; focusAreas?: string[]; maxSuggestions?: number; } /** * CE-MCP version of suggest_adrs * * Returns a state machine directive for multi-step ADR generation. * Reduces token usage from ~3.5K to ~1.5K by: * - Lazy loading ADR templates * - Deferring code analysis to sandbox * - Using state machine for sequential steps */ export declare function createSuggestAdrsDirective(args: CEMCPSuggestAdrsArgs): StateMachineDirective; /** * Arguments for CE-MCP rule generation */ export interface CEMCPGenerateRulesArgs { projectPath: string; ruleType: 'code-quality' | 'security' | 'architecture' | 'testing'; targetFramework?: string; severity?: 'error' | 'warning' | 'info'; } /** * CE-MCP version of generate_rules * * Returns an orchestration directive for rule generation. * Reduces token usage from ~4K to ~1.5K by: * - Lazy loading rule templates * - Deferring validation to sandbox * - Caching generated rules */ export declare function createGenerateRulesDirective(args: CEMCPGenerateRulesArgs): OrchestrationDirective; /** * Arguments for CE-MCP environment analysis */ export interface CEMCPAnalyzeEnvironmentArgs { projectPath: string; analysisType?: 'quick' | 'standard' | 'comprehensive'; includeInfrastructure?: boolean; } /** * CE-MCP version of analyze_environment * * Returns an orchestration directive for environment analysis. * Reduces token usage from ~2.5K to ~1K by: * - Deferring file scanning to sandbox * - Using cached environment patterns * - Lazy loading environment prompts */ export declare function createAnalyzeEnvironmentDirective(args: CEMCPAnalyzeEnvironmentArgs): OrchestrationDirective; /** * Arguments for CE-MCP deployment readiness */ export interface CEMCPDeploymentReadinessArgs { projectPath: string; targetEnvironment: 'development' | 'staging' | 'production'; checkTypes?: string[]; } /** * CE-MCP version of deployment_readiness * * Returns a state machine directive for deployment checks. * Reduces token usage from ~2K to ~800 tokens by: * - Sequential check execution in state machine * - Lazy loading of deployment patterns * - Early termination on critical failures */ export declare function createDeploymentReadinessDirective(args: CEMCPDeploymentReadinessArgs): StateMachineDirective; /** * Arguments for CE-MCP smart score */ export interface CEMCPSmartScoreArgs { projectPath: string; includeDetails?: boolean; scoringAreas?: string[]; } /** * CE-MCP version of smart_score * * Returns an orchestration directive for code quality scoring. * Reduces token usage from ~6K to ~2K by: * - Lazy loading scoring templates * - Deferring file analysis to sandbox * - Caching scoring results */ export declare function createSmartScoreDirective(args: CEMCPSmartScoreArgs): OrchestrationDirective; /** * Arguments for CE-MCP perform research */ export interface CEMCPPerformResearchArgs { topic: string; depth?: 'quick' | 'standard' | 'deep'; outputFormat?: 'summary' | 'detailed' | 'structured'; sources?: string[]; } /** * CE-MCP version of perform_research * * Returns a state machine directive for research workflows. * Reduces token usage from ~10K to ~3K by: * - Lazy loading research templates * - Sequential research phases in state machine * - Caching intermediate results */ export declare function createPerformResearchDirective(args: CEMCPPerformResearchArgs): StateMachineDirective; /** * Arguments for CE-MCP generate ADRs from PRD */ export interface CEMCPGenerateAdrsFromPrdArgs { prdPath: string; outputDirectory?: string; maxAdrs?: number; focusAreas?: string[]; } /** * CE-MCP version of generate_adrs_from_prd * * Returns a state machine directive for PRD-to-ADR generation. * Reduces token usage from ~8K to ~3K by: * - Lazy loading ADR templates * - Sequential PRD analysis phases * - Caching parsed PRD content */ export declare function createGenerateAdrsFromPrdDirective(args: CEMCPGenerateAdrsFromPrdArgs): StateMachineDirective; /** * Arguments for CE-MCP interactive ADR planning */ export interface CEMCPInteractiveAdrPlanningArgs { projectPath: string; sessionMode?: 'guided' | 'free-form'; existingAdrs?: string[]; } /** * CE-MCP version of interactive_adr_planning * * Returns a state machine directive for interactive ADR sessions. * Reduces token usage from ~6K to ~2K by: * - Lazy loading planning templates * - Sequential planning phases * - Context-aware suggestions */ export declare function createInteractiveAdrPlanningDirective(args: CEMCPInteractiveAdrPlanningArgs): StateMachineDirective; /** * Arguments for CE-MCP MCP planning */ export interface CEMCPMcpPlanningArgs { goal: string; constraints?: string[]; existingTools?: string[]; } /** * CE-MCP version of mcp_planning * * Returns an orchestration directive for MCP server planning. * Reduces token usage from ~6K to ~2K by: * - Lazy loading MCP patterns * - Deferring analysis to sandbox * - Caching planning results */ export declare function createMcpPlanningDirective(args: CEMCPMcpPlanningArgs): OrchestrationDirective; /** * Arguments for CE-MCP troubleshoot guided workflow */ export interface CEMCPTroubleshootGuidedWorkflowArgs { issue: string; context?: string; previousSteps?: string[]; } /** * CE-MCP version of troubleshoot_guided_workflow * * Returns a state machine directive for troubleshooting workflows. * Reduces token usage from ~7K to ~2.5K by: * - Lazy loading troubleshooting guides * - Sequential diagnostic phases * - Context-aware remediation */ export declare function createTroubleshootGuidedWorkflowDirective(args: CEMCPTroubleshootGuidedWorkflowArgs): StateMachineDirective; /** * Arguments for CE-MCP tool chain orchestrator */ export interface CEMCPToolChainOrchestratorArgs { operation: 'generate_plan' | 'analyze_intent' | 'suggest_tools' | 'validate_plan' | 'reality_check' | 'session_guidance'; userRequest: string; projectContext: { projectPath: string; adrDirectory?: string; todoPath?: string; hasADRs?: boolean; hasTODO?: boolean; projectType?: string; }; constraints?: { maxSteps?: number; timeLimit?: string; excludeTools?: string[]; prioritizeSpeed?: boolean; }; customInstructions?: string; sessionContext?: { conversationLength?: number; previousActions?: string[]; confusionIndicators?: string[]; lastSuccessfulAction?: string; stuckOnTask?: string; }; } /** * CE-MCP version of tool_chain_orchestrator * * Returns an orchestration directive for tool chain planning. * This eliminates the OpenRouter dependency by having the host LLM * (which already has full context) generate the tool execution plan directly. * * Key insight: The host LLM is better positioned to create plans because: * 1. It has the full conversation context * 2. It knows what tools it has already tried * 3. It can directly execute the plan without roundtrips * * Reduces token usage from ~8K to ~2K by: * - Eliminating OpenRouter API call overhead * - Providing structured directive format * - Enabling direct host LLM execution */ export declare function createToolChainOrchestratorDirective(args: CEMCPToolChainOrchestratorArgs): OrchestrationDirective; /** * Check if a tool should use CE-MCP directive mode */ export declare function shouldUseCEMCPDirective(toolName: string, config: { mode: string; }): boolean; /** * Get CE-MCP directive for a tool */ export declare function getCEMCPDirective(toolName: string, args: Record<string, unknown>): OrchestrationDirective | StateMachineDirective | null; /** * Format CE-MCP directive as MCP response */ export declare function formatDirectiveResponse(directive: OrchestrationDirective | StateMachineDirective): { content: Array<{ type: 'text'; text: string; }>; }; //# sourceMappingURL=ce-mcp-tools.d.ts.map