mcp-adr-analysis-server 2.12.0 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/src/mcp-adr-analysis-server.d.ts +1 -45
- package/dist/src/mcp-adr-analysis-server.d.ts.map +1 -1
- package/dist/src/mcp-adr-analysis-server.js +65 -938
- package/dist/src/mcp-adr-analysis-server.js.map +1 -1
- package/dist/src/tools/ce-mcp-tools.d.ts +46 -0
- package/dist/src/tools/ce-mcp-tools.d.ts.map +1 -1
- package/dist/src/tools/ce-mcp-tools.js +173 -1
- package/dist/src/tools/ce-mcp-tools.js.map +1 -1
- package/dist/src/tools/mcp-tool-schemas.d.ts.map +1 -1
- package/dist/src/tools/mcp-tool-schemas.js +6 -143
- package/dist/src/tools/mcp-tool-schemas.js.map +1 -1
- package/dist/src/tools/tool-catalog.d.ts.map +1 -1
- package/dist/src/tools/tool-catalog.js +13 -235
- package/dist/src/tools/tool-catalog.js.map +1 -1
- package/dist/src/tools/tool-dispatch.d.ts.map +1 -1
- package/dist/src/tools/tool-dispatch.js +2 -40
- package/dist/src/tools/tool-dispatch.js.map +1 -1
- package/dist/src/tools/tool-dispatcher.d.ts +5 -6
- package/dist/src/tools/tool-dispatcher.d.ts.map +1 -1
- package/dist/src/tools/tool-dispatcher.js +7 -31
- package/dist/src/tools/tool-dispatcher.js.map +1 -1
- package/dist/src/utils/file-system.d.ts.map +1 -1
- package/dist/src/utils/file-system.js +25 -35
- package/dist/src/utils/file-system.js.map +1 -1
- package/dist/src/utils/server-context-generator.d.ts.map +1 -1
- package/dist/src/utils/server-context-generator.js +0 -18
- package/dist/src/utils/server-context-generator.js.map +1 -1
- package/dist/src/utils/tiered-response-manager.d.ts +2 -1
- package/dist/src/utils/tiered-response-manager.d.ts.map +1 -1
- package/dist/src/utils/tiered-response-manager.js +4 -29
- package/dist/src/utils/tiered-response-manager.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ import { getEnhancedModeDefault, getKnowledgeEnhancementDefault, } from './utils
|
|
|
19
19
|
import { StateReinforcementManager } from './utils/state-reinforcement-manager.js';
|
|
20
20
|
import { ConversationMemoryManager } from './utils/conversation-memory-manager.js';
|
|
21
21
|
import { MemoryEntityManager } from './utils/memory-entity-manager.js';
|
|
22
|
-
|
|
22
|
+
// RootManager import removed — ADR-023 (#1673)
|
|
23
23
|
import { ServerContextGenerator } from './utils/server-context-generator.js';
|
|
24
24
|
import { createNoOpContext } from './types/tool-context.js';
|
|
25
25
|
import { getToolListForMCP } from './tools/tool-dispatcher.js';
|
|
@@ -84,7 +84,7 @@ export class McpAdrAnalysisServer {
|
|
|
84
84
|
stateReinforcementManager;
|
|
85
85
|
conversationMemoryManager;
|
|
86
86
|
memoryEntityManager;
|
|
87
|
-
rootManager
|
|
87
|
+
// rootManager removed — only consumers were removed host-native handlers, ADR-023 (#1673)
|
|
88
88
|
contextGenerator;
|
|
89
89
|
constructor() {
|
|
90
90
|
// Load and validate configuration
|
|
@@ -94,8 +94,7 @@ export class McpAdrAnalysisServer {
|
|
|
94
94
|
this.stateReinforcementManager = new StateReinforcementManager(this.kgManager);
|
|
95
95
|
this.conversationMemoryManager = new ConversationMemoryManager(this.kgManager);
|
|
96
96
|
this.memoryEntityManager = new MemoryEntityManager();
|
|
97
|
-
//
|
|
98
|
-
this.rootManager = new RootManager(this.config.projectPath, this.config.adrDirectory);
|
|
97
|
+
// rootManager init removed — ADR-023 (#1673)
|
|
99
98
|
// Initialize server context generator
|
|
100
99
|
this.contextGenerator = new ServerContextGenerator();
|
|
101
100
|
// Print configuration summary
|
|
@@ -590,139 +589,7 @@ export class McpAdrAnalysisServer {
|
|
|
590
589
|
/**
|
|
591
590
|
* Tool implementations
|
|
592
591
|
*/
|
|
593
|
-
|
|
594
|
-
try {
|
|
595
|
-
const { getAIExecutionStatus } = await import('./utils/prompt-execution.js');
|
|
596
|
-
const status = getAIExecutionStatus();
|
|
597
|
-
return {
|
|
598
|
-
content: [
|
|
599
|
-
{
|
|
600
|
-
type: 'text',
|
|
601
|
-
text: `# AI Execution Status Diagnostic
|
|
602
|
-
|
|
603
|
-
> **Note**: As of Phase 5, this server uses CE-MCP (Claude-Enriched MCP) mode by default.
|
|
604
|
-
> In CE-MCP mode, tools return orchestration directives that the host LLM executes directly,
|
|
605
|
-
> eliminating the need for external API calls. The configuration below applies to legacy mode only.
|
|
606
|
-
|
|
607
|
-
## Current Configuration
|
|
608
|
-
- **AI Execution Enabled**: ${status.isEnabled ? '✅ YES' : '❌ NO'}
|
|
609
|
-
- **Has API Key**: ${status.hasApiKey ? '✅ YES' : '❌ NO'}
|
|
610
|
-
- **Execution Mode**: ${status.executionMode}
|
|
611
|
-
- **AI Model**: ${status.model}
|
|
612
|
-
|
|
613
|
-
${
|
|
614
|
-
// CE-MCP is the DEFAULT mode and needs no API key. Reporting the absence of
|
|
615
|
-
// one as an "Issue Detected" -- immediately after saying no external API call
|
|
616
|
-
// is needed -- told every new user to go and buy a key they do not need.
|
|
617
|
-
// Legacy configuration is only a problem for someone who asked for it. (#1414)
|
|
618
|
-
status.executionMode === 'ce-mcp'
|
|
619
|
-
? `## ✅ Running in CE-MCP mode
|
|
620
|
-
|
|
621
|
-
No API key is required. Tools return orchestration directives that your host LLM
|
|
622
|
-
executes directly, which is why **AI Execution Enabled: NO** above is expected and
|
|
623
|
-
correct rather than a fault.
|
|
624
|
-
|
|
625
|
-
Note that only some tools currently return a directive; the rest return their
|
|
626
|
-
result directly. See ADR-014 and ADR-021.
|
|
627
|
-
|
|
628
|
-
Legacy OpenRouter execution is off by design. You only need the configuration
|
|
629
|
-
below if you deliberately want that older path.`
|
|
630
|
-
: status.reason
|
|
631
|
-
? `## ⚠️ Issue Detected
|
|
632
|
-
**Problem**: ${status.reason}
|
|
633
|
-
|
|
634
|
-
## Solution
|
|
635
|
-
${!status.hasApiKey
|
|
636
|
-
? `
|
|
637
|
-
1. Get an OpenRouter API key from https://openrouter.ai/keys
|
|
638
|
-
2. Add it to your MCP configuration:
|
|
639
|
-
\`\`\`json
|
|
640
|
-
{
|
|
641
|
-
"mcpServers": {
|
|
642
|
-
"adr-analysis": {
|
|
643
|
-
"command": "mcp-adr-analysis-server",
|
|
644
|
-
"env": {
|
|
645
|
-
"OPENROUTER_API_KEY": "your_api_key_here",
|
|
646
|
-
"EXECUTION_MODE": "full",
|
|
647
|
-
"AI_MODEL": "anthropic/claude-3-sonnet"
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
\`\`\`
|
|
653
|
-
3. Restart your MCP client (Claude Desktop, etc.)
|
|
654
|
-
`
|
|
655
|
-
: status.executionMode !== 'full'
|
|
656
|
-
? `
|
|
657
|
-
1. Update your MCP configuration to set EXECUTION_MODE to "full":
|
|
658
|
-
\`\`\`json
|
|
659
|
-
{
|
|
660
|
-
"mcpServers": {
|
|
661
|
-
"adr-analysis": {
|
|
662
|
-
"env": {
|
|
663
|
-
"EXECUTION_MODE": "full"
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
\`\`\`
|
|
669
|
-
2. Restart your MCP client
|
|
670
|
-
`
|
|
671
|
-
: ''}`
|
|
672
|
-
: `## ✅ Configuration Looks Good!
|
|
673
|
-
|
|
674
|
-
AI execution is properly configured. Tools should return actual results instead of prompts.
|
|
675
|
-
|
|
676
|
-
If you're still seeing prompts instead of results, try:
|
|
677
|
-
1. Restart your MCP client
|
|
678
|
-
2. Check your OpenRouter API key has sufficient credits
|
|
679
|
-
3. Verify network connectivity to OpenRouter.ai`}
|
|
680
|
-
|
|
681
|
-
${status.executionMode === 'ce-mcp'
|
|
682
|
-
? `## Environment Variables (CE-MCP mode)
|
|
683
|
-
No environment variables are required. CE-MCP mode is the default and works
|
|
684
|
-
without any API keys or execution-mode flags.
|
|
685
|
-
|
|
686
|
-
To switch to legacy OpenRouter execution instead, set:
|
|
687
|
-
- **OPENROUTER_API_KEY**: Your OpenRouter API key
|
|
688
|
-
- **EXECUTION_MODE**: \`full\`
|
|
689
|
-
- **AI_MODEL**: AI model to use (optional, defaults to claude-3-sonnet)`
|
|
690
|
-
: `## Environment Variables Expected
|
|
691
|
-
- **OPENROUTER_API_KEY**: Your OpenRouter API key
|
|
692
|
-
- **EXECUTION_MODE**: Set to "full" for AI execution
|
|
693
|
-
- **AI_MODEL**: AI model to use (optional, defaults to claude-3-sonnet)
|
|
694
|
-
|
|
695
|
-
## Testing
|
|
696
|
-
After fixing the configuration, try calling \`suggest_adrs\` - it should return actual ADR suggestions instead of prompts.`}
|
|
697
|
-
`,
|
|
698
|
-
},
|
|
699
|
-
],
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
catch (error) {
|
|
703
|
-
return {
|
|
704
|
-
content: [
|
|
705
|
-
{
|
|
706
|
-
type: 'text',
|
|
707
|
-
text: `# AI Execution Status Check Failed
|
|
708
|
-
|
|
709
|
-
**Error**: ${error instanceof Error ? error.message : String(error)}
|
|
710
|
-
|
|
711
|
-
This diagnostic tool checks the execution configuration. The server defaults to
|
|
712
|
-
CE-MCP mode, which requires no API key — so if you have not set any environment
|
|
713
|
-
variables, this error is unlikely to be a configuration problem.
|
|
714
|
-
|
|
715
|
-
## Manual Check (legacy OpenRouter mode only)
|
|
716
|
-
If you explicitly set EXECUTION_MODE=full, verify these environment variables:
|
|
717
|
-
- OPENROUTER_API_KEY
|
|
718
|
-
- EXECUTION_MODE=full
|
|
719
|
-
- AI_MODEL (optional)
|
|
720
|
-
`,
|
|
721
|
-
},
|
|
722
|
-
],
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
}
|
|
592
|
+
// checkAIExecutionStatus removed — host-native, ADR-023 (#1673)
|
|
726
593
|
async getWorkflowGuidance(args) {
|
|
727
594
|
const { goal, projectContext, availableAssets = [], timeframe = 'thorough_review', primaryConcerns = [], } = args;
|
|
728
595
|
try {
|
|
@@ -840,65 +707,15 @@ Provide a comprehensive workflow guide that includes:
|
|
|
840
707
|
|
|
841
708
|
Make the guidance **actionable, specific, and outcome-focused** so the user can immediately start executing the recommended workflow.
|
|
842
709
|
`;
|
|
843
|
-
//
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
});
|
|
853
|
-
if (executionResult.isAIGenerated) {
|
|
854
|
-
// AI execution successful - return actual workflow guidance
|
|
855
|
-
return formatMCPResponse({
|
|
856
|
-
...executionResult,
|
|
857
|
-
content: `# Workflow Guidance & Tool Recommendations
|
|
858
|
-
|
|
859
|
-
## Your Context
|
|
860
|
-
- **Goal**: ${goal}
|
|
861
|
-
- **Project Context**: ${projectContext}
|
|
862
|
-
- **Available Assets**: ${availableAssets.length > 0 ? availableAssets.join(', ') : 'None specified'}
|
|
863
|
-
- **Timeframe**: ${timeframe}
|
|
864
|
-
- **Primary Concerns**: ${primaryConcerns.length > 0 ? primaryConcerns.join(', ') : 'General analysis'}
|
|
865
|
-
|
|
866
|
-
## AI-Generated Workflow Guidance
|
|
867
|
-
|
|
868
|
-
${executionResult.content}
|
|
869
|
-
|
|
870
|
-
## Quick Reference: Available Tools
|
|
871
|
-
|
|
872
|
-
**Core Analysis**: analyze_project_ecosystem, get_architectural_context, generate_adrs_from_prd, analyze_content_security
|
|
873
|
-
**ADR Management**: suggest_adrs, generate_adr_from_decision, discover_existing_adrs
|
|
874
|
-
**Security**: generate_content_masking, configure_custom_patterns, validate_content_masking
|
|
875
|
-
**Governance**: generate_rules, validate_rules, create_rule_set
|
|
876
|
-
**Environment**: analyze_environment, analyze_deployment_progress
|
|
877
|
-
**Utilities**: manage_cache, configure_output_masking, check_ai_execution_status
|
|
878
|
-
|
|
879
|
-
## Next Steps
|
|
880
|
-
|
|
881
|
-
1. **Start with the recommended primary workflow** above
|
|
882
|
-
2. **Call the first tool** with the suggested parameters
|
|
883
|
-
3. **Review the results** and proceed to the next step
|
|
884
|
-
4. **Track progress** using the success metrics provided
|
|
885
|
-
5. **Adjust as needed** based on your specific findings
|
|
886
|
-
|
|
887
|
-
This guidance is tailored to your specific context and goals for maximum effectiveness!
|
|
888
|
-
`,
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
else {
|
|
892
|
-
// Fallback to prompt-only mode
|
|
893
|
-
return {
|
|
894
|
-
content: [
|
|
895
|
-
{
|
|
896
|
-
type: 'text',
|
|
897
|
-
text: workflowPrompt,
|
|
898
|
-
},
|
|
899
|
-
],
|
|
900
|
-
};
|
|
901
|
-
}
|
|
710
|
+
// CE-MCP: return prompt text directly; directive intercepts in CE-MCP mode.
|
|
711
|
+
return {
|
|
712
|
+
content: [
|
|
713
|
+
{
|
|
714
|
+
type: 'text',
|
|
715
|
+
text: workflowPrompt,
|
|
716
|
+
},
|
|
717
|
+
],
|
|
718
|
+
};
|
|
902
719
|
}
|
|
903
720
|
catch (error) {
|
|
904
721
|
throw new McpAdrError(`Failed to generate workflow guidance: ${error instanceof Error ? error.message : String(error)}`, 'WORKFLOW_ERROR');
|
|
@@ -1065,77 +882,15 @@ Ensure all development guidance:
|
|
|
1065
882
|
|
|
1066
883
|
Make the guidance **actionable, specific, and immediately implementable** so developers can start coding with confidence and architectural alignment.
|
|
1067
884
|
`;
|
|
1068
|
-
//
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
Consider team context, technology stack, and development phase to provide tailored recommendations.`,
|
|
1078
|
-
});
|
|
1079
|
-
if (executionResult.isAIGenerated) {
|
|
1080
|
-
// AI execution successful - return actual development guidance
|
|
1081
|
-
return formatMCPResponse({
|
|
1082
|
-
...executionResult,
|
|
1083
|
-
content: `# Development Guidance & Implementation Roadmap
|
|
1084
|
-
|
|
1085
|
-
## Your Development Context
|
|
1086
|
-
- **Development Phase**: ${developmentPhase}
|
|
1087
|
-
- **Technology Stack**: ${technologyStack.length > 0 ? technologyStack.join(', ') : 'Not specified'}
|
|
1088
|
-
- **Current Progress**: ${currentProgress || 'Starting fresh'}
|
|
1089
|
-
- **Team Context**: ${teamContext.size} team with ${teamContext.experienceLevel} experience
|
|
1090
|
-
- **Timeline**: ${timeline || 'Not specified'}
|
|
1091
|
-
- **Focus Areas**: ${focusAreas.length > 0 ? focusAreas.join(', ') : 'General development'}
|
|
1092
|
-
- **ADRs to Implement**: ${adrsToImplement.length > 0 ? adrsToImplement.join(', ') : 'None specified'}
|
|
1093
|
-
|
|
1094
|
-
## AI-Generated Development Guidance
|
|
1095
|
-
|
|
1096
|
-
${executionResult.content}
|
|
1097
|
-
|
|
1098
|
-
## Integration with Workflow Tools
|
|
1099
|
-
|
|
1100
|
-
This development guidance works seamlessly with other MCP tools:
|
|
1101
|
-
|
|
1102
|
-
### **Workflow Integration**
|
|
1103
|
-
1. **get_workflow_guidance** → Recommends architectural process
|
|
1104
|
-
2. **get_development_guidance** → Guides implementation (this tool)
|
|
1105
|
-
3. **validate_rules** → Ensures code follows architectural decisions
|
|
1106
|
-
4. **analyze_deployment_progress** → Tracks implementation progress
|
|
1107
|
-
|
|
1108
|
-
### **Quality Assurance Tools**
|
|
1109
|
-
- **generate_rules** → Extract coding standards from ADRs
|
|
1110
|
-
- **validate_rules** → Validate code against architectural rules
|
|
1111
|
-
- **analyze_content_security** → Security validation during development
|
|
1112
|
-
|
|
1113
|
-
### **Documentation Tools**
|
|
1114
|
-
- **discover_existing_adrs** → Reference existing architectural decisions
|
|
1115
|
-
|
|
1116
|
-
## Next Steps: From Architecture to Code
|
|
1117
|
-
|
|
1118
|
-
1. **📋 Review the Development Roadmap** above
|
|
1119
|
-
2. **🏗️ Set Up Project Structure** as recommended
|
|
1120
|
-
3. **🧪 Implement Testing Strategy** early in development
|
|
1121
|
-
4. **📊 Track Progress** using the success metrics provided
|
|
1122
|
-
5. **🔄 Iterate and Refine** based on implementation learnings
|
|
1123
|
-
|
|
1124
|
-
This guidance ensures your development work is **architecturally aligned**, **quality-focused**, and **efficiently executed**!
|
|
1125
|
-
`,
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
else {
|
|
1129
|
-
// Fallback to prompt-only mode
|
|
1130
|
-
return {
|
|
1131
|
-
content: [
|
|
1132
|
-
{
|
|
1133
|
-
type: 'text',
|
|
1134
|
-
text: developmentPrompt,
|
|
1135
|
-
},
|
|
1136
|
-
],
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
885
|
+
// CE-MCP: return prompt text directly; directive intercepts in CE-MCP mode.
|
|
886
|
+
return {
|
|
887
|
+
content: [
|
|
888
|
+
{
|
|
889
|
+
type: 'text',
|
|
890
|
+
text: developmentPrompt,
|
|
891
|
+
},
|
|
892
|
+
],
|
|
893
|
+
};
|
|
1139
894
|
}
|
|
1140
895
|
catch (error) {
|
|
1141
896
|
throw new McpAdrError(`Failed to generate development guidance: ${error instanceof Error ? error.message : String(error)}`, 'DEVELOPMENT_ERROR');
|
|
@@ -1335,15 +1090,9 @@ ${environmentResult.content[0].text}
|
|
|
1335
1090
|
enhancedAnalysisPrompt =
|
|
1336
1091
|
baseProjectAnalysisPrompt.prompt + knowledgeContext + environmentAnalysisContext;
|
|
1337
1092
|
}
|
|
1338
|
-
// Execute the analysis with AI if enabled, otherwise return prompt
|
|
1339
|
-
ctx.info('🤖 Phase 6: Executing AI-powered ecosystem analysis');
|
|
1340
|
-
ctx.report_progress(85, 100);
|
|
1341
|
-
const { executeEcosystemAnalysisPrompt, formatMCPResponse } = await import('./utils/prompt-execution.js');
|
|
1342
|
-
const executionResult = await executeEcosystemAnalysisPrompt(enhancedAnalysisPrompt, baseProjectAnalysisPrompt.instructions, {
|
|
1343
|
-
temperature: 0.1,
|
|
1344
|
-
maxTokens: 6000,
|
|
1345
|
-
});
|
|
1346
1093
|
// Step 6: Record project structure to knowledge graph
|
|
1094
|
+
ctx.info('📊 Phase 6: Recording project structure');
|
|
1095
|
+
ctx.report_progress(85, 100);
|
|
1347
1096
|
try {
|
|
1348
1097
|
this.logger.info('Recording project structure to knowledge graph');
|
|
1349
1098
|
const projectStructureSnapshot = {
|
|
@@ -1361,84 +1110,15 @@ ${environmentResult.content[0].text}
|
|
|
1361
1110
|
}
|
|
1362
1111
|
catch (kgError) {
|
|
1363
1112
|
this.logger.warn('Failed to record project structure to knowledge graph:', kgError);
|
|
1364
|
-
// Don't fail the entire analysis if KG recording fails
|
|
1365
1113
|
}
|
|
1366
1114
|
ctx.info('✅ Ecosystem analysis completed successfully');
|
|
1367
1115
|
ctx.report_progress(100, 100);
|
|
1368
|
-
//
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
## Analysis Configuration
|
|
1376
|
-
- **Project Path**: ${projectPath}
|
|
1377
|
-
- **Analysis Depth**: ${analysisDepth}
|
|
1378
|
-
- **Recursive Depth**: ${recursiveDepth}
|
|
1379
|
-
- **Environment Analysis**: ${includeEnvironment ? '✅ Included' : '❌ Excluded'}
|
|
1380
|
-
- **Analysis Scope**: ${analysisScope.length > 0 ? analysisScope.join(', ') : 'Full ecosystem analysis'}
|
|
1381
|
-
|
|
1382
|
-
## Enhancement Features
|
|
1383
|
-
- **Knowledge Generation**: ${enhancedMode && knowledgeEnhancement ? '✅ Enabled' : '❌ Disabled'}
|
|
1384
|
-
- **Reflexion Learning**: ${enhancedMode && learningEnabled ? '✅ Enabled' : '❌ Disabled'}
|
|
1385
|
-
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled' : '❌ Disabled'}
|
|
1386
|
-
- **Technology Focus**: ${technologyFocus.length > 0 ? technologyFocus.join(', ') : 'Auto-detect'}
|
|
1387
|
-
- **Knowledge Graph**: ✅ Project structure recorded
|
|
1388
|
-
|
|
1389
|
-
${knowledgeContext}
|
|
1390
|
-
|
|
1391
|
-
${reflexionContext}
|
|
1392
|
-
|
|
1393
|
-
## Comprehensive Ecosystem Analysis Results
|
|
1394
|
-
|
|
1395
|
-
${executionResult.content}
|
|
1396
|
-
|
|
1397
|
-
${includeEnvironment
|
|
1398
|
-
? `
|
|
1399
|
-
|
|
1400
|
-
## Environment Integration Summary
|
|
1401
|
-
|
|
1402
|
-
The analysis above includes comprehensive environment analysis covering:
|
|
1403
|
-
- **Infrastructure Specifications**: Deployment and runtime environment details
|
|
1404
|
-
- **Containerization**: Docker, Kubernetes, and container orchestration analysis
|
|
1405
|
-
- **Environment Requirements**: Configuration and dependency requirements
|
|
1406
|
-
- **Compliance Assessment**: Security and regulatory compliance evaluation
|
|
1407
|
-
|
|
1408
|
-
This integrated approach provides complete understanding of both codebase patterns AND operational environment.
|
|
1409
|
-
`
|
|
1410
|
-
: ''}
|
|
1411
|
-
|
|
1412
|
-
## Next Steps: Complete Ecosystem Understanding
|
|
1413
|
-
|
|
1414
|
-
Based on the comprehensive analysis above:
|
|
1415
|
-
|
|
1416
|
-
### **Immediate Actions**
|
|
1417
|
-
1. **Review Ecosystem Overview**: Examine the complete technology stack and environment context
|
|
1418
|
-
2. **Assess Integration Points**: Understand how code patterns relate to operational environment
|
|
1419
|
-
3. **Identify Critical Dependencies**: Focus on key dependencies between code and infrastructure
|
|
1420
|
-
|
|
1421
|
-
### **Strategic Planning**
|
|
1422
|
-
4. **Address Architectural Issues**: Prioritize improvements based on both code and environment analysis
|
|
1423
|
-
5. **Plan Environment Optimization**: Optimize deployment and operational configurations
|
|
1424
|
-
6. **Update Documentation**: Document both architectural decisions and environment specifications
|
|
1425
|
-
|
|
1426
|
-
### **Implementation Roadmap**
|
|
1427
|
-
7. **Implement Code Improvements**: Execute code-level architectural enhancements
|
|
1428
|
-
8. **Optimize Environment**: Improve infrastructure and deployment configurations
|
|
1429
|
-
9. **Monitor Integration**: Ensure code and environment changes work together effectively
|
|
1430
|
-
|
|
1431
|
-
This comprehensive ecosystem analysis provides the foundation for informed architectural and operational decisions.
|
|
1432
|
-
`,
|
|
1433
|
-
});
|
|
1434
|
-
}
|
|
1435
|
-
else {
|
|
1436
|
-
// Fallback to prompt-only mode
|
|
1437
|
-
return {
|
|
1438
|
-
content: [
|
|
1439
|
-
{
|
|
1440
|
-
type: 'text',
|
|
1441
|
-
text: `# Comprehensive Project Ecosystem Analysis
|
|
1116
|
+
// CE-MCP: return prompt text directly; directive intercepts in CE-MCP mode.
|
|
1117
|
+
return {
|
|
1118
|
+
content: [
|
|
1119
|
+
{
|
|
1120
|
+
type: 'text',
|
|
1121
|
+
text: `# Comprehensive Project Ecosystem Analysis
|
|
1442
1122
|
|
|
1443
1123
|
This comprehensive analysis provides deep recursive project understanding with integrated environment analysis.
|
|
1444
1124
|
|
|
@@ -1467,47 +1147,10 @@ ${enhancedAnalysisPrompt}
|
|
|
1467
1147
|
|
|
1468
1148
|
## Enhanced Implementation Instructions
|
|
1469
1149
|
|
|
1470
|
-
${baseProjectAnalysisPrompt.instructions}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
${enhancedMode && knowledgeEnhancement
|
|
1475
|
-
? `
|
|
1476
|
-
#### Knowledge Enhancement
|
|
1477
|
-
- Apply technology-specific knowledge to ecosystem analysis
|
|
1478
|
-
- Use domain expertise to identify patterns and anti-patterns
|
|
1479
|
-
- Leverage architectural best practices for technology stack evaluation
|
|
1480
|
-
`
|
|
1481
|
-
: ''}
|
|
1482
|
-
|
|
1483
|
-
${enhancedMode && learningEnabled
|
|
1484
|
-
? `
|
|
1485
|
-
#### Learning Integration
|
|
1486
|
-
- Apply lessons learned from past ecosystem analyses
|
|
1487
|
-
- Use memory insights to improve pattern recognition accuracy
|
|
1488
|
-
- Incorporate feedback from previous analysis outcomes
|
|
1489
|
-
`
|
|
1490
|
-
: ''}
|
|
1491
|
-
|
|
1492
|
-
## Expected Enhanced Output
|
|
1493
|
-
|
|
1494
|
-
The enhanced analysis should provide:
|
|
1495
|
-
1. **Technology Stack Analysis** with domain knowledge context
|
|
1496
|
-
2. **Architectural Pattern Detection** informed by past experiences
|
|
1497
|
-
3. **Ecosystem Health Assessment** using learned evaluation criteria
|
|
1498
|
-
4. **Improvement Recommendations** based on domain best practices
|
|
1499
|
-
5. **Learning Insights** for future analysis improvement
|
|
1500
|
-
|
|
1501
|
-
## Quality Assurance
|
|
1502
|
-
|
|
1503
|
-
- Ensure analysis leverages all available enhancement features
|
|
1504
|
-
- Verify technology-specific knowledge is properly applied
|
|
1505
|
-
- Confirm learning insights improve analysis accuracy
|
|
1506
|
-
- Validate recommendations align with domain best practices`,
|
|
1507
|
-
},
|
|
1508
|
-
],
|
|
1509
|
-
};
|
|
1510
|
-
}
|
|
1150
|
+
${baseProjectAnalysisPrompt.instructions}`,
|
|
1151
|
+
},
|
|
1152
|
+
],
|
|
1153
|
+
};
|
|
1511
1154
|
}
|
|
1512
1155
|
catch (error) {
|
|
1513
1156
|
throw new McpAdrError(`Failed to analyze project ecosystem: ${error instanceof Error ? error.message : String(error)}`, 'ANALYSIS_ERROR');
|
|
@@ -1681,74 +1324,15 @@ After this analysis, follow this **outcome-focused workflow**:
|
|
|
1681
1324
|
|
|
1682
1325
|
This approach ensures that architectural work is **grounded in measurable outcomes** and **aligned with project success**.
|
|
1683
1326
|
`;
|
|
1684
|
-
//
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
}
|
|
1693
|
-
if (executionResult.isAIGenerated) {
|
|
1694
|
-
// AI execution successful - return actual analysis results
|
|
1695
|
-
return formatMCPResponse({
|
|
1696
|
-
...executionResult,
|
|
1697
|
-
content: `# Architectural Context Analysis Results
|
|
1698
|
-
|
|
1699
|
-
${filePath ? `## Target File: ${filePath}` : '## Project-wide Analysis'}
|
|
1700
|
-
|
|
1701
|
-
## Project Information
|
|
1702
|
-
- **Project Path**: ${projectPath}
|
|
1703
|
-
- **Analysis Scope**: ${filePath ? 'File-specific' : 'Project-wide'}
|
|
1704
|
-
- **ADR Directory**: ${this.config.adrDirectory}
|
|
1705
|
-
|
|
1706
|
-
## ADR Infrastructure Setup
|
|
1707
|
-
|
|
1708
|
-
The analysis includes automatic ADR infrastructure setup:
|
|
1709
|
-
|
|
1710
|
-
${adrDirectoryCheckPrompt.instructions}
|
|
1711
|
-
|
|
1712
|
-
${adrDirectorySetupPrompt.instructions}
|
|
1713
|
-
|
|
1714
|
-
## AI Analysis Results
|
|
1715
|
-
|
|
1716
|
-
${executionResult.content}
|
|
1717
|
-
|
|
1718
|
-
## Outcome-Focused Next Steps
|
|
1719
|
-
|
|
1720
|
-
Based on the architectural analysis, follow this **grounded workflow**:
|
|
1721
|
-
|
|
1722
|
-
### **Immediate Actions (This Week)**
|
|
1723
|
-
1. **Review Analysis**: Examine the architectural context and recommendations above
|
|
1724
|
-
2. **Set Up ADRs**: Ensure ADR directory structure is created and ready
|
|
1725
|
-
3. **Identify Quick Wins**: Focus on low-effort, high-impact improvements
|
|
1726
|
-
|
|
1727
|
-
### **Short-term Goals (Next Month)**
|
|
1728
|
-
4. **Document Key Decisions**: Create ADRs for the most significant architectural choices
|
|
1729
|
-
5. **Address Critical Issues**: Tackle the highest-priority architectural concerns
|
|
1730
|
-
6. **Establish Metrics**: Set up measurement for the success metrics identified
|
|
1731
|
-
|
|
1732
|
-
### **Long-term Vision (Next Quarter)**
|
|
1733
|
-
7. **Implement Roadmap**: Execute the architectural improvement plan
|
|
1734
|
-
8. **Monitor Progress**: Track success metrics and adjust approach as needed
|
|
1735
|
-
9. **Continuous Improvement**: Establish regular architectural reviews
|
|
1736
|
-
|
|
1737
|
-
This **outcome-focused approach** ensures architectural work delivers **measurable value** and keeps the project **grounded in clear objectives**.
|
|
1738
|
-
`,
|
|
1739
|
-
});
|
|
1740
|
-
}
|
|
1741
|
-
else {
|
|
1742
|
-
// Fallback to prompt-only mode
|
|
1743
|
-
return {
|
|
1744
|
-
content: [
|
|
1745
|
-
{
|
|
1746
|
-
type: 'text',
|
|
1747
|
-
text: architecturalPrompt,
|
|
1748
|
-
},
|
|
1749
|
-
],
|
|
1750
|
-
};
|
|
1751
|
-
}
|
|
1327
|
+
// CE-MCP: return prompt text directly; directive intercepts in CE-MCP mode.
|
|
1328
|
+
return {
|
|
1329
|
+
content: [
|
|
1330
|
+
{
|
|
1331
|
+
type: 'text',
|
|
1332
|
+
text: architecturalPrompt,
|
|
1333
|
+
},
|
|
1334
|
+
],
|
|
1335
|
+
};
|
|
1752
1336
|
}
|
|
1753
1337
|
catch (error) {
|
|
1754
1338
|
throw new McpAdrError(`Failed to get architectural context: ${error instanceof Error ? error.message : String(error)}`, 'ANALYSIS_ERROR');
|
|
@@ -1909,88 +1493,14 @@ For each generated ADR, create a file creation prompt using the following patter
|
|
|
1909
1493
|
- Confirm all decisions are traceable back to PRD requirements with domain context
|
|
1910
1494
|
`;
|
|
1911
1495
|
// Execute the ADR generation with AI if enabled, otherwise return prompt
|
|
1912
|
-
ctx.info('🤖 Phase 6: Executing AI-powered ADR generation');
|
|
1913
|
-
ctx.report_progress(90, 100);
|
|
1914
|
-
const { executeADRGenerationPrompt, formatMCPResponse } = await import('./utils/prompt-execution.js');
|
|
1915
|
-
const executionResult = await executeADRGenerationPrompt(adrPrompt, 'Generate comprehensive ADRs from PRD analysis with enhanced domain knowledge and optimization', {
|
|
1916
|
-
temperature: 0.1,
|
|
1917
|
-
maxTokens: 8000,
|
|
1918
|
-
systemPrompt: `You are an expert software architect who creates comprehensive Architectural Decision Records (ADRs) from Product Requirements Documents (PRDs).
|
|
1919
|
-
Generate well-structured ADRs that follow best practices and include all necessary sections.
|
|
1920
|
-
Focus on extracting architectural decisions from the PRD and creating actionable ADRs with clear reasoning.`,
|
|
1921
|
-
});
|
|
1922
1496
|
ctx.info('✅ ADR generation completed successfully');
|
|
1923
1497
|
ctx.report_progress(100, 100);
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
## Enhancement Features
|
|
1931
|
-
- **APE Optimization**: ${enhancedMode && promptOptimization ? '✅ Enabled' : '❌ Disabled'}
|
|
1932
|
-
- **Knowledge Generation**: ${enhancedMode && knowledgeEnhancement ? '✅ Enabled' : '❌ Disabled'}
|
|
1933
|
-
- **PRD Type Optimization**: ${prdType}
|
|
1934
|
-
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled' : '❌ Disabled'}
|
|
1935
|
-
|
|
1936
|
-
## Source Information
|
|
1937
|
-
- **PRD Path**: ${prdPath}
|
|
1938
|
-
- **Output Directory**: ${outputDirectory}
|
|
1939
|
-
|
|
1940
|
-
## Generated ADRs
|
|
1941
|
-
|
|
1942
|
-
${executionResult.content}
|
|
1943
|
-
|
|
1944
|
-
## Next Steps
|
|
1945
|
-
|
|
1946
|
-
1. **Review Generated ADRs**: Examine each ADR for completeness and accuracy
|
|
1947
|
-
2. **Save ADR Files**: Create individual .md files for each ADR in ${outputDirectory}
|
|
1948
|
-
3. **Update ADR Index**: Add new ADRs to your project's ADR catalog
|
|
1949
|
-
4. **Stakeholder Review**: Share ADRs with team for feedback and approval
|
|
1950
|
-
5. **Implementation Planning**: Create tasks for implementing the architectural decisions
|
|
1951
|
-
|
|
1952
|
-
## File Creation Commands
|
|
1953
|
-
|
|
1954
|
-
To save the generated ADRs, create individual files in ${outputDirectory}:
|
|
1955
|
-
|
|
1956
|
-
\`\`\`bash
|
|
1957
|
-
# Create ADR directory if it doesn't exist
|
|
1958
|
-
mkdir -p ${outputDirectory}
|
|
1959
|
-
|
|
1960
|
-
# Save each ADR as a separate file (example)
|
|
1961
|
-
# Replace [NUMBER] and [TITLE] with actual values from generated ADRs
|
|
1962
|
-
# cat > "${outputDirectory}/001-example-decision.md" << 'EOF'
|
|
1963
|
-
# [ADR content here]
|
|
1964
|
-
# EOF
|
|
1965
|
-
\`\`\`
|
|
1966
|
-
`,
|
|
1967
|
-
});
|
|
1968
|
-
}
|
|
1969
|
-
else {
|
|
1970
|
-
// Fallback to prompt-only mode
|
|
1971
|
-
return {
|
|
1972
|
-
content: [
|
|
1973
|
-
{
|
|
1974
|
-
type: 'text',
|
|
1975
|
-
text: `# Enhanced ADR Generation from PRD: ${prdPath}
|
|
1976
|
-
|
|
1977
|
-
## Advanced Prompt-Driven ADR Generation Process
|
|
1978
|
-
|
|
1979
|
-
This tool uses a 100% prompt-driven architecture enhanced with advanced prompting techniques:
|
|
1980
|
-
|
|
1981
|
-
### Enhancement Features
|
|
1982
|
-
- **APE Optimization**: ${enhancedMode && promptOptimization ? '✅ Enabled - Prompts optimized for superior quality' : '❌ Disabled'}
|
|
1983
|
-
- **Knowledge Generation**: ${enhancedMode && knowledgeEnhancement ? '✅ Enabled - Domain knowledge enhanced analysis' : '❌ Disabled'}
|
|
1984
|
-
- **PRD Type Optimization**: ${prdType} - Tailored for specific domain requirements
|
|
1985
|
-
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled - All advanced features active' : '❌ Disabled - Basic mode'}
|
|
1986
|
-
|
|
1987
|
-
### Enhanced AI Agent Workflow
|
|
1988
|
-
|
|
1989
|
-
1. **Validate PRD file existence** using secure file system operations
|
|
1990
|
-
2. **Read PRD content** safely with proper security validation
|
|
1991
|
-
3. **Apply domain knowledge** to enhance understanding (if enabled)
|
|
1992
|
-
4. **Generate optimized ADRs** using APE-enhanced prompts (if enabled)
|
|
1993
|
-
5. **Create enhanced ADR files** in the specified output directory: ${outputDirectory}
|
|
1498
|
+
// CE-MCP: return prompt text directly; directive intercepts in CE-MCP mode.
|
|
1499
|
+
return {
|
|
1500
|
+
content: [
|
|
1501
|
+
{
|
|
1502
|
+
type: 'text',
|
|
1503
|
+
text: `# Enhanced ADR Generation from PRD: ${prdPath}
|
|
1994
1504
|
|
|
1995
1505
|
## Execution Instructions
|
|
1996
1506
|
|
|
@@ -1998,49 +1508,15 @@ Please execute the following enhanced comprehensive prompt:
|
|
|
1998
1508
|
|
|
1999
1509
|
${adrPrompt}
|
|
2000
1510
|
|
|
2001
|
-
##
|
|
2002
|
-
|
|
2003
|
-
${enhancedMode && knowledgeEnhancement
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
: ''}
|
|
2011
|
-
|
|
2012
|
-
${enhancedMode && promptOptimization
|
|
2013
|
-
? `
|
|
2014
|
-
### APE Optimization
|
|
2015
|
-
- Prompts have been automatically optimized for quality
|
|
2016
|
-
- Enhanced evaluation criteria ensure superior ADR generation
|
|
2017
|
-
- Optimization focused on task completion, clarity, and specificity
|
|
2018
|
-
`
|
|
2019
|
-
: ''}
|
|
2020
|
-
|
|
2021
|
-
## Security and Validation
|
|
2022
|
-
|
|
2023
|
-
- All file operations include security validation
|
|
2024
|
-
- Path traversal protection is enabled
|
|
2025
|
-
- System directory access is prevented
|
|
2026
|
-
- User confirmation is required for file creation
|
|
2027
|
-
- Content validation ensures safe enhanced ADR generation
|
|
2028
|
-
|
|
2029
|
-
## Expected Enhanced Workflow
|
|
2030
|
-
|
|
2031
|
-
1. Execute file existence check for: ${prdPath}
|
|
2032
|
-
2. If file exists, read PRD content securely
|
|
2033
|
-
3. Apply domain knowledge to enhance PRD understanding
|
|
2034
|
-
4. Analyze PRD content using optimized prompts
|
|
2035
|
-
5. Generate domain-enhanced individual ADRs for each decision
|
|
2036
|
-
6. Create file creation prompts for each enhanced ADR
|
|
2037
|
-
7. Confirm with user before writing files to: ${outputDirectory}
|
|
2038
|
-
|
|
2039
|
-
The enhanced process maintains full traceability from PRD requirements to generated ADRs while providing superior quality through advanced prompting techniques and ensuring security and user control over file operations.`,
|
|
2040
|
-
},
|
|
2041
|
-
],
|
|
2042
|
-
};
|
|
2043
|
-
}
|
|
1511
|
+
## Enhancement Features
|
|
1512
|
+
- **APE Optimization**: ${enhancedMode && promptOptimization ? '✅ Enabled' : '❌ Disabled'}
|
|
1513
|
+
- **Knowledge Generation**: ${enhancedMode && knowledgeEnhancement ? '✅ Enabled' : '❌ Disabled'}
|
|
1514
|
+
- **PRD Type Optimization**: ${prdType}
|
|
1515
|
+
- **Enhanced Mode**: ${enhancedMode ? '✅ Enabled' : '❌ Disabled'}
|
|
1516
|
+
- **Output Directory**: ${outputDirectory}`,
|
|
1517
|
+
},
|
|
1518
|
+
],
|
|
1519
|
+
};
|
|
2044
1520
|
}
|
|
2045
1521
|
catch (error) {
|
|
2046
1522
|
throw new McpAdrError(`Failed to generate ADR prompts from PRD: ${error instanceof Error ? error.message : String(error)}`, 'PROMPT_GENERATION_ERROR');
|
|
@@ -4091,146 +3567,11 @@ Please provide:
|
|
|
4091
3567
|
process.exit(0);
|
|
4092
3568
|
});
|
|
4093
3569
|
}
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
*/
|
|
4100
|
-
async listRoots() {
|
|
4101
|
-
const roots = this.rootManager.listRoots();
|
|
4102
|
-
const rootsList = roots
|
|
4103
|
-
.map(r => `### ${r.name}\n\n**Path**: \`${r.path}\`\n\n**Description**: ${r.description}\n`)
|
|
4104
|
-
.join('\n');
|
|
4105
|
-
return {
|
|
4106
|
-
content: [
|
|
4107
|
-
{
|
|
4108
|
-
type: 'text',
|
|
4109
|
-
text: `# Available File System Roots\n\nThese are the directories that can be accessed by this MCP server.\n\n${rootsList}\nUse these paths with \`read_directory\` and \`read_file\` tools to explore and access files.`,
|
|
4110
|
-
},
|
|
4111
|
-
],
|
|
4112
|
-
};
|
|
4113
|
-
}
|
|
4114
|
-
/**
|
|
4115
|
-
* Read directory contents (MCP best practice for autonomous file discovery)
|
|
4116
|
-
*/
|
|
4117
|
-
async readDirectory(args) {
|
|
4118
|
-
const targetPath = args.path || this.config.projectPath;
|
|
4119
|
-
try {
|
|
4120
|
-
const path = await import('path');
|
|
4121
|
-
const resolvedPath = path.resolve(targetPath);
|
|
4122
|
-
// Security check: ensure path is within accessible roots
|
|
4123
|
-
if (!this.rootManager.isPathAllowed(resolvedPath)) {
|
|
4124
|
-
const roots = this.rootManager.listRoots();
|
|
4125
|
-
const rootList = roots.map(r => ` - ${r.name}: ${r.path}`).join('\n');
|
|
4126
|
-
throw new McpAdrError(`Access denied: Path '${targetPath}' is outside accessible roots.\n\nAccessible roots:\n${rootList}\n\nUse list_roots tool for more details.`, 'ACCESS_DENIED');
|
|
4127
|
-
}
|
|
4128
|
-
const { readdir } = await import('fs/promises');
|
|
4129
|
-
const entries = await readdir(resolvedPath, { withFileTypes: true });
|
|
4130
|
-
const files = entries.filter(e => e.isFile()).map(e => `📄 ${e.name}`);
|
|
4131
|
-
const dirs = entries.filter(e => e.isDirectory()).map(e => `📁 ${e.name}/`);
|
|
4132
|
-
const root = this.rootManager.getRootForPath(resolvedPath);
|
|
4133
|
-
const relPath = this.rootManager.getRelativePathFromRoot(resolvedPath);
|
|
4134
|
-
const filesList = files.length > 0 ? files.join('\n') : '(no files)';
|
|
4135
|
-
const dirsList = dirs.length > 0 ? dirs.join('\n') : '(no directories)';
|
|
4136
|
-
return {
|
|
4137
|
-
content: [
|
|
4138
|
-
{
|
|
4139
|
-
type: 'text',
|
|
4140
|
-
text: `# Directory: ${targetPath}\n\n**Root**: ${root?.name}\n**Relative Path**: ${relPath || '/'}\n**Full Path**: \`${resolvedPath}\`\n\n## Directories (${dirs.length})\n\n${dirsList}\n\n## Files (${files.length})\n\n${filesList}`,
|
|
4141
|
-
},
|
|
4142
|
-
],
|
|
4143
|
-
};
|
|
4144
|
-
}
|
|
4145
|
-
catch (error) {
|
|
4146
|
-
throw new McpAdrError(`Failed to read directory: ${error instanceof Error ? error.message : String(error)}`, 'DIRECTORY_READ_ERROR');
|
|
4147
|
-
}
|
|
4148
|
-
}
|
|
4149
|
-
async readFile(args) {
|
|
4150
|
-
const { filePath } = args;
|
|
4151
|
-
try {
|
|
4152
|
-
const fs = await import('fs/promises');
|
|
4153
|
-
const path = await import('path');
|
|
4154
|
-
// Resolve path (handle both relative and absolute paths)
|
|
4155
|
-
const safePath = path.resolve(filePath);
|
|
4156
|
-
// Security check: ensure path is within accessible roots
|
|
4157
|
-
if (!this.rootManager.isPathAllowed(safePath)) {
|
|
4158
|
-
const roots = this.rootManager.listRoots();
|
|
4159
|
-
const rootList = roots.map(r => ` - ${r.name}: ${r.path}`).join('\n');
|
|
4160
|
-
throw new McpAdrError(`Access denied: Path '${filePath}' is outside accessible roots.\n\nAccessible roots:\n${rootList}\n\nUse list_roots tool for more details.`, 'ACCESS_DENIED');
|
|
4161
|
-
}
|
|
4162
|
-
const content = await fs.readFile(safePath, 'utf-8');
|
|
4163
|
-
return {
|
|
4164
|
-
content: [
|
|
4165
|
-
{
|
|
4166
|
-
type: 'text',
|
|
4167
|
-
text: content,
|
|
4168
|
-
},
|
|
4169
|
-
],
|
|
4170
|
-
};
|
|
4171
|
-
}
|
|
4172
|
-
catch (error) {
|
|
4173
|
-
throw new McpAdrError(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`, 'FILE_READ_ERROR');
|
|
4174
|
-
}
|
|
4175
|
-
}
|
|
4176
|
-
async writeFile(args) {
|
|
4177
|
-
const { filePath, content } = args;
|
|
4178
|
-
try {
|
|
4179
|
-
const fs = await import('fs/promises');
|
|
4180
|
-
const path = await import('path');
|
|
4181
|
-
// Resolve path relative to project path for security
|
|
4182
|
-
const safePath = path.resolve(this.config.projectPath, filePath);
|
|
4183
|
-
// Security check: ensure path is within project directory
|
|
4184
|
-
if (!safePath.startsWith(this.config.projectPath)) {
|
|
4185
|
-
throw new McpAdrError('Access denied: Path is outside project directory', 'ACCESS_DENIED');
|
|
4186
|
-
}
|
|
4187
|
-
// Ensure directory exists
|
|
4188
|
-
await fs.mkdir(path.dirname(safePath), { recursive: true });
|
|
4189
|
-
// Write file
|
|
4190
|
-
await fs.writeFile(safePath, content, 'utf-8');
|
|
4191
|
-
return {
|
|
4192
|
-
content: [
|
|
4193
|
-
{
|
|
4194
|
-
type: 'text',
|
|
4195
|
-
text: `Successfully wrote to ${filePath}`,
|
|
4196
|
-
},
|
|
4197
|
-
],
|
|
4198
|
-
};
|
|
4199
|
-
}
|
|
4200
|
-
catch (error) {
|
|
4201
|
-
throw new McpAdrError(`Failed to write file: ${error instanceof Error ? error.message : String(error)}`, 'FILE_WRITE_ERROR');
|
|
4202
|
-
}
|
|
4203
|
-
}
|
|
4204
|
-
async listDirectory(args) {
|
|
4205
|
-
const { path: dirPath } = args;
|
|
4206
|
-
try {
|
|
4207
|
-
const fs = await import('fs/promises');
|
|
4208
|
-
const path = await import('path');
|
|
4209
|
-
// Resolve path relative to project path for security
|
|
4210
|
-
const safePath = path.resolve(this.config.projectPath, dirPath);
|
|
4211
|
-
// Security check: ensure path is within project directory
|
|
4212
|
-
if (!safePath.startsWith(this.config.projectPath)) {
|
|
4213
|
-
throw new McpAdrError('Access denied: Path is outside project directory', 'ACCESS_DENIED');
|
|
4214
|
-
}
|
|
4215
|
-
const entries = await fs.readdir(safePath, { withFileTypes: true });
|
|
4216
|
-
const fileList = entries.map(entry => ({
|
|
4217
|
-
name: entry.name,
|
|
4218
|
-
type: entry.isDirectory() ? 'directory' : 'file',
|
|
4219
|
-
path: path.join(dirPath, entry.name),
|
|
4220
|
-
}));
|
|
4221
|
-
return {
|
|
4222
|
-
content: [
|
|
4223
|
-
{
|
|
4224
|
-
type: 'text',
|
|
4225
|
-
text: JSON.stringify(fileList, null, 2),
|
|
4226
|
-
},
|
|
4227
|
-
],
|
|
4228
|
-
};
|
|
4229
|
-
}
|
|
4230
|
-
catch (error) {
|
|
4231
|
-
throw new McpAdrError(`Failed to list directory: ${error instanceof Error ? error.message : String(error)}`, 'DIRECTORY_LIST_ERROR');
|
|
4232
|
-
}
|
|
4233
|
-
}
|
|
3570
|
+
// listRoots removed — host-native, ADR-023 (#1673)
|
|
3571
|
+
// readDirectory removed — host-native, ADR-023 (#1673)
|
|
3572
|
+
// readFile removed — host-native, ADR-023 (#1673)
|
|
3573
|
+
// writeFile removed — host-native, ADR-023 (#1673)
|
|
3574
|
+
// listDirectory removed — host-native, ADR-023 (#1673)
|
|
4234
3575
|
async generateDeploymentGuidance(args) {
|
|
4235
3576
|
try {
|
|
4236
3577
|
const { generateDeploymentGuidance } = await import('./tools/deployment-guidance-tool.js');
|
|
@@ -4435,113 +3776,7 @@ This tool has been deprecated and replaced with memory-centric health scoring.
|
|
|
4435
3776
|
throw new McpAdrError(`Server context generation failed: ${error instanceof Error ? error.message : String(error)}`, 'SERVER_CONTEXT_ERROR');
|
|
4436
3777
|
}
|
|
4437
3778
|
}
|
|
4438
|
-
|
|
4439
|
-
* Get Current Datetime Tool
|
|
4440
|
-
* Returns the current date and time in various formats for ADR generation and timestamping
|
|
4441
|
-
*/
|
|
4442
|
-
async getCurrentDatetime(args) {
|
|
4443
|
-
const { timezone = 'UTC', format = 'all', includeTimestamp = true } = args;
|
|
4444
|
-
try {
|
|
4445
|
-
const now = new Date();
|
|
4446
|
-
// Format date for different timezones
|
|
4447
|
-
const formatOptions = {
|
|
4448
|
-
timeZone: timezone,
|
|
4449
|
-
year: 'numeric',
|
|
4450
|
-
month: '2-digit',
|
|
4451
|
-
day: '2-digit',
|
|
4452
|
-
hour: '2-digit',
|
|
4453
|
-
minute: '2-digit',
|
|
4454
|
-
second: '2-digit',
|
|
4455
|
-
hour12: false,
|
|
4456
|
-
};
|
|
4457
|
-
// Get date parts for the specified timezone
|
|
4458
|
-
const formatter = new Intl.DateTimeFormat('en-CA', {
|
|
4459
|
-
timeZone: timezone,
|
|
4460
|
-
year: 'numeric',
|
|
4461
|
-
month: '2-digit',
|
|
4462
|
-
day: '2-digit',
|
|
4463
|
-
});
|
|
4464
|
-
const parts = formatter.formatToParts(now);
|
|
4465
|
-
const year = parts.find(p => p.type === 'year')?.value || '';
|
|
4466
|
-
const month = parts.find(p => p.type === 'month')?.value || '';
|
|
4467
|
-
const day = parts.find(p => p.type === 'day')?.value || '';
|
|
4468
|
-
// ADR date format: YYYY-MM-DD
|
|
4469
|
-
const adrDate = `${year}-${month}-${day}`;
|
|
4470
|
-
// ISO 8601 format
|
|
4471
|
-
const isoDate = now.toISOString();
|
|
4472
|
-
// Human-readable format
|
|
4473
|
-
const humanFormatter = new Intl.DateTimeFormat('en-US', {
|
|
4474
|
-
...formatOptions,
|
|
4475
|
-
weekday: 'long',
|
|
4476
|
-
month: 'long',
|
|
4477
|
-
});
|
|
4478
|
-
const humanDate = humanFormatter.format(now);
|
|
4479
|
-
// Build response based on requested format
|
|
4480
|
-
let responseData = {};
|
|
4481
|
-
switch (format) {
|
|
4482
|
-
case 'iso':
|
|
4483
|
-
responseData = { iso: isoDate };
|
|
4484
|
-
break;
|
|
4485
|
-
case 'human':
|
|
4486
|
-
responseData = { human: humanDate };
|
|
4487
|
-
break;
|
|
4488
|
-
case 'adr':
|
|
4489
|
-
responseData = { adr: adrDate };
|
|
4490
|
-
break;
|
|
4491
|
-
case 'all':
|
|
4492
|
-
default:
|
|
4493
|
-
responseData = {
|
|
4494
|
-
iso: isoDate,
|
|
4495
|
-
human: humanDate,
|
|
4496
|
-
adr: adrDate,
|
|
4497
|
-
timezone: timezone,
|
|
4498
|
-
};
|
|
4499
|
-
}
|
|
4500
|
-
if (includeTimestamp) {
|
|
4501
|
-
responseData['timestamp'] = now.getTime();
|
|
4502
|
-
}
|
|
4503
|
-
const responseText = `# Current Date and Time
|
|
4504
|
-
|
|
4505
|
-
## Formats
|
|
4506
|
-
${format === 'all' || format === 'iso' ? `- **ISO 8601**: ${isoDate}` : ''}
|
|
4507
|
-
${format === 'all' || format === 'human' ? `- **Human Readable**: ${humanDate}` : ''}
|
|
4508
|
-
${format === 'all' || format === 'adr' ? `- **ADR Date (YYYY-MM-DD)**: ${adrDate}` : ''}
|
|
4509
|
-
${format === 'all' ? `- **Timezone**: ${timezone}` : ''}
|
|
4510
|
-
${includeTimestamp ? `- **Unix Timestamp (ms)**: ${now.getTime()}` : ''}
|
|
4511
|
-
|
|
4512
|
-
## Usage for ADR Generation
|
|
4513
|
-
|
|
4514
|
-
When generating ADRs, use the ADR date format (\`${adrDate}\`) in the Date field:
|
|
4515
|
-
|
|
4516
|
-
\`\`\`markdown
|
|
4517
|
-
# ADR-XXXX: [Title]
|
|
4518
|
-
|
|
4519
|
-
## Date
|
|
4520
|
-
${adrDate}
|
|
4521
|
-
|
|
4522
|
-
## Status
|
|
4523
|
-
Proposed
|
|
4524
|
-
\`\`\`
|
|
4525
|
-
|
|
4526
|
-
## Raw Data
|
|
4527
|
-
|
|
4528
|
-
\`\`\`json
|
|
4529
|
-
${JSON.stringify(responseData, null, 2)}
|
|
4530
|
-
\`\`\`
|
|
4531
|
-
`;
|
|
4532
|
-
return {
|
|
4533
|
-
content: [
|
|
4534
|
-
{
|
|
4535
|
-
type: 'text',
|
|
4536
|
-
text: responseText,
|
|
4537
|
-
},
|
|
4538
|
-
],
|
|
4539
|
-
};
|
|
4540
|
-
}
|
|
4541
|
-
catch (error) {
|
|
4542
|
-
throw new McpAdrError(`Failed to get current datetime: ${error instanceof Error ? error.message : String(error)}`, 'DATETIME_ERROR');
|
|
4543
|
-
}
|
|
4544
|
-
}
|
|
3779
|
+
// getCurrentDatetime removed — host-native, ADR-023 (#1673)
|
|
4545
3780
|
/**
|
|
4546
3781
|
* Set Project Path Tool - Dynamic Session Configuration
|
|
4547
3782
|
*
|
|
@@ -4567,8 +3802,7 @@ ${JSON.stringify(responseData, null, 2)}
|
|
|
4567
3802
|
}
|
|
4568
3803
|
// Update the server configuration
|
|
4569
3804
|
this.config.projectPath = absolutePath;
|
|
4570
|
-
//
|
|
4571
|
-
this.rootManager = new RootManager(absolutePath, this.config.adrDirectory);
|
|
3805
|
+
// rootManager re-init removed — ADR-023 (#1673)
|
|
4572
3806
|
this.logger.info(`Project path changed: ${previousPath} -> ${absolutePath}`);
|
|
4573
3807
|
const responseText = `# Project Path Updated
|
|
4574
3808
|
|
|
@@ -4600,112 +3834,5 @@ To make this permanent, set the \`PROJECT_PATH\` environment variable.
|
|
|
4600
3834
|
throw new McpAdrError(`Failed to set project path: ${error instanceof Error ? error.message : String(error)}`, 'SET_PROJECT_PATH_ERROR');
|
|
4601
3835
|
}
|
|
4602
3836
|
}
|
|
4603
|
-
/**
|
|
4604
|
-
* Load Prompt Tool - CE-MCP Phase 4 Lazy Loading
|
|
4605
|
-
*
|
|
4606
|
-
* @description Loads prompts on-demand instead of eagerly loading all prompts at startup.
|
|
4607
|
-
* This reduces token usage by ~96% (from 28K tokens to ~1K on-demand).
|
|
4608
|
-
*
|
|
4609
|
-
* @param args - Load prompt arguments
|
|
4610
|
-
* @param args.promptName - Name of the prompt to load
|
|
4611
|
-
* @param args.section - Optional section within the prompt
|
|
4612
|
-
* @param args.estimateOnly - If true, returns only token estimate
|
|
4613
|
-
* @returns Promise<CallToolResult> - Loaded prompt content or estimate
|
|
4614
|
-
*/
|
|
4615
|
-
async loadPrompt(args) {
|
|
4616
|
-
const { promptName, section, estimateOnly = false } = args;
|
|
4617
|
-
// Import the prompt catalog dynamically to enable lazy loading
|
|
4618
|
-
const { getPromptLoader, getPromptMetadata, calculateTokenSavings } = await import('./prompts/prompt-catalog.js');
|
|
4619
|
-
const metadata = getPromptMetadata(promptName);
|
|
4620
|
-
if (!metadata) {
|
|
4621
|
-
const availablePrompts = [
|
|
4622
|
-
'adr-suggestion',
|
|
4623
|
-
'deployment-analysis',
|
|
4624
|
-
'environment-analysis',
|
|
4625
|
-
'research-question',
|
|
4626
|
-
'rule-generation',
|
|
4627
|
-
'analysis',
|
|
4628
|
-
'research-integration',
|
|
4629
|
-
'validated-pattern',
|
|
4630
|
-
'security',
|
|
4631
|
-
];
|
|
4632
|
-
return {
|
|
4633
|
-
content: [
|
|
4634
|
-
{
|
|
4635
|
-
type: 'text',
|
|
4636
|
-
text: JSON.stringify({
|
|
4637
|
-
success: false,
|
|
4638
|
-
error: `Unknown prompt: ${promptName}`,
|
|
4639
|
-
availablePrompts,
|
|
4640
|
-
hint: 'Use one of the available prompt names listed above',
|
|
4641
|
-
}, null, 2),
|
|
4642
|
-
},
|
|
4643
|
-
],
|
|
4644
|
-
isError: true,
|
|
4645
|
-
};
|
|
4646
|
-
}
|
|
4647
|
-
// If estimate only, return token information without loading
|
|
4648
|
-
if (estimateOnly) {
|
|
4649
|
-
const loader = getPromptLoader();
|
|
4650
|
-
const estimatedTokens = loader.getEstimatedTokens(promptName, section);
|
|
4651
|
-
const savings = calculateTokenSavings([promptName]);
|
|
4652
|
-
return {
|
|
4653
|
-
content: [
|
|
4654
|
-
{
|
|
4655
|
-
type: 'text',
|
|
4656
|
-
text: JSON.stringify({
|
|
4657
|
-
success: true,
|
|
4658
|
-
promptName,
|
|
4659
|
-
section: section || 'full',
|
|
4660
|
-
estimatedTokens,
|
|
4661
|
-
metadata: {
|
|
4662
|
-
file: metadata.file,
|
|
4663
|
-
category: metadata.category,
|
|
4664
|
-
totalTokens: metadata.tokens,
|
|
4665
|
-
availableSections: metadata.sections,
|
|
4666
|
-
loadOnDemand: metadata.loadOnDemand,
|
|
4667
|
-
},
|
|
4668
|
-
tokenSavings: {
|
|
4669
|
-
loaded: savings.loaded,
|
|
4670
|
-
total: savings.total,
|
|
4671
|
-
saved: savings.saved,
|
|
4672
|
-
percentage: `${savings.percentage}%`,
|
|
4673
|
-
},
|
|
4674
|
-
}, null, 2),
|
|
4675
|
-
},
|
|
4676
|
-
],
|
|
4677
|
-
};
|
|
4678
|
-
}
|
|
4679
|
-
// Load the prompt content
|
|
4680
|
-
try {
|
|
4681
|
-
const loader = getPromptLoader();
|
|
4682
|
-
const content = await loader.loadPrompt(promptName, section);
|
|
4683
|
-
return {
|
|
4684
|
-
content: [
|
|
4685
|
-
{
|
|
4686
|
-
type: 'text',
|
|
4687
|
-
text: `# Loaded Prompt: ${promptName}${section ? ` (section: ${section})` : ''}
|
|
4688
|
-
|
|
4689
|
-
## Metadata
|
|
4690
|
-
- **Category**: ${metadata.category}
|
|
4691
|
-
- **Estimated Tokens**: ${metadata.tokens}
|
|
4692
|
-
- **Available Sections**: ${metadata.sections.join(', ')}
|
|
4693
|
-
|
|
4694
|
-
## Content
|
|
4695
|
-
|
|
4696
|
-
${content}
|
|
4697
|
-
|
|
4698
|
-
---
|
|
4699
|
-
|
|
4700
|
-
*Loaded on-demand via CE-MCP lazy loading system. Token savings: ~96% compared to eager loading all prompts.*
|
|
4701
|
-
`,
|
|
4702
|
-
},
|
|
4703
|
-
],
|
|
4704
|
-
};
|
|
4705
|
-
}
|
|
4706
|
-
catch (error) {
|
|
4707
|
-
throw new McpAdrError(`Failed to load prompt '${promptName}'${section ? ` section '${section}'` : ''}: ${error instanceof Error ? error.message : String(error)}`, 'PROMPT_LOAD_ERROR');
|
|
4708
|
-
}
|
|
4709
|
-
}
|
|
4710
3837
|
}
|
|
4711
3838
|
//# sourceMappingURL=mcp-adr-analysis-server.js.map
|