mcp-adr-analysis-server 2.1.19 → 2.1.22
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/README.md +1 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/src/config/ai-config.d.ts +54 -6
- package/dist/src/config/ai-config.d.ts.map +1 -1
- package/dist/src/config/ai-config.js +69 -6
- package/dist/src/config/ai-config.js.map +1 -1
- package/dist/src/config/ape-descriptions.d.ts +77 -0
- package/dist/src/config/ape-descriptions.d.ts.map +1 -0
- package/dist/src/config/ape-descriptions.js +177 -0
- package/dist/src/config/ape-descriptions.js.map +1 -0
- package/dist/src/index.d.ts +40 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +564 -8
- package/dist/src/index.js.map +1 -1
- package/dist/src/prompts/adr-suggestion-prompts.d.ts +5 -0
- package/dist/src/prompts/adr-suggestion-prompts.d.ts.map +1 -1
- package/dist/src/prompts/adr-suggestion-prompts.js +22 -1
- package/dist/src/prompts/adr-suggestion-prompts.js.map +1 -1
- package/dist/src/prompts/prompt-catalog.d.ts +95 -0
- package/dist/src/prompts/prompt-catalog.d.ts.map +1 -0
- package/dist/src/prompts/prompt-catalog.js +300 -0
- package/dist/src/prompts/prompt-catalog.js.map +1 -0
- package/dist/src/resources/adrs-discovered-resource.d.ts +124 -0
- package/dist/src/resources/adrs-discovered-resource.d.ts.map +1 -0
- package/dist/src/resources/adrs-discovered-resource.js +174 -0
- package/dist/src/resources/adrs-discovered-resource.js.map +1 -0
- package/dist/src/resources/adrs-review-resource.d.ts +82 -0
- package/dist/src/resources/adrs-review-resource.d.ts.map +1 -0
- package/dist/src/resources/adrs-review-resource.js +160 -0
- package/dist/src/resources/adrs-review-resource.js.map +1 -0
- package/dist/src/resources/architectural-context-resource.d.ts +95 -0
- package/dist/src/resources/architectural-context-resource.d.ts.map +1 -0
- package/dist/src/resources/architectural-context-resource.js +428 -0
- package/dist/src/resources/architectural-context-resource.js.map +1 -0
- package/dist/src/resources/conversation-snapshot-resource.d.ts +92 -0
- package/dist/src/resources/conversation-snapshot-resource.d.ts.map +1 -0
- package/dist/src/resources/conversation-snapshot-resource.js +122 -0
- package/dist/src/resources/conversation-snapshot-resource.js.map +1 -0
- package/dist/src/resources/deployment-status-resource.js +1 -1
- package/dist/src/resources/deployment-status-resource.js.map +1 -1
- package/dist/src/resources/environment-analysis-resource.js +1 -1
- package/dist/src/resources/environment-analysis-resource.js.map +1 -1
- package/dist/src/resources/knowledge-graph-resource.d.ts +129 -0
- package/dist/src/resources/knowledge-graph-resource.d.ts.map +1 -0
- package/dist/src/resources/knowledge-graph-resource.js +217 -0
- package/dist/src/resources/knowledge-graph-resource.js.map +1 -0
- package/dist/src/resources/memory-expand-resource.d.ts +90 -0
- package/dist/src/resources/memory-expand-resource.d.ts.map +1 -0
- package/dist/src/resources/memory-expand-resource.js +176 -0
- package/dist/src/resources/memory-expand-resource.js.map +1 -0
- package/dist/src/resources/memory-stats-resource.d.ts +77 -0
- package/dist/src/resources/memory-stats-resource.d.ts.map +1 -0
- package/dist/src/resources/memory-stats-resource.js +108 -0
- package/dist/src/resources/memory-stats-resource.js.map +1 -0
- package/dist/src/resources/project-metrics-resource.js +1 -1
- package/dist/src/resources/project-metrics-resource.js.map +1 -1
- package/dist/src/resources/resource-cache.d.ts.map +1 -1
- package/dist/src/resources/resource-cache.js +2 -1
- package/dist/src/resources/resource-cache.js.map +1 -1
- package/dist/src/resources/server-context-resource.d.ts +69 -0
- package/dist/src/resources/server-context-resource.d.ts.map +1 -0
- package/dist/src/resources/server-context-resource.js +104 -0
- package/dist/src/resources/server-context-resource.js.map +1 -0
- package/dist/src/resources/tool-catalog-resource.d.ts +122 -0
- package/dist/src/resources/tool-catalog-resource.d.ts.map +1 -0
- package/dist/src/resources/tool-catalog-resource.js +167 -0
- package/dist/src/resources/tool-catalog-resource.js.map +1 -0
- package/dist/src/tools/adr-bootstrap-validation-tool.d.ts.map +1 -1
- package/dist/src/tools/adr-bootstrap-validation-tool.js +7 -6
- package/dist/src/tools/adr-bootstrap-validation-tool.js.map +1 -1
- package/dist/src/tools/adr-suggestion-tool.d.ts +5 -0
- package/dist/src/tools/adr-suggestion-tool.d.ts.map +1 -1
- package/dist/src/tools/adr-suggestion-tool.js +40 -71
- package/dist/src/tools/adr-suggestion-tool.js.map +1 -1
- package/dist/src/tools/bootstrap-validation-loop-tool.d.ts +23 -1
- package/dist/src/tools/bootstrap-validation-loop-tool.d.ts.map +1 -1
- package/dist/src/tools/bootstrap-validation-loop-tool.js +15 -5
- package/dist/src/tools/bootstrap-validation-loop-tool.js.map +1 -1
- package/dist/src/tools/ce-mcp-tools.d.ts +291 -0
- package/dist/src/tools/ce-mcp-tools.d.ts.map +1 -0
- package/dist/src/tools/ce-mcp-tools.js +1188 -0
- package/dist/src/tools/ce-mcp-tools.js.map +1 -0
- package/dist/src/tools/content-masking-tool.d.ts +11 -0
- package/dist/src/tools/content-masking-tool.d.ts.map +1 -1
- package/dist/src/tools/content-masking-tool.js +13 -6
- package/dist/src/tools/content-masking-tool.js.map +1 -1
- package/dist/src/tools/deployment-readiness-tool.d.ts +11 -0
- package/dist/src/tools/deployment-readiness-tool.d.ts.map +1 -1
- package/dist/src/tools/deployment-readiness-tool.js +10 -4
- package/dist/src/tools/deployment-readiness-tool.js.map +1 -1
- package/dist/src/tools/environment-analysis-tool.d.ts +96 -1
- package/dist/src/tools/environment-analysis-tool.d.ts.map +1 -1
- package/dist/src/tools/environment-analysis-tool.js +38 -46
- package/dist/src/tools/environment-analysis-tool.js.map +1 -1
- package/dist/src/tools/research-question-tool.d.ts.map +1 -1
- package/dist/src/tools/research-question-tool.js +3 -2
- package/dist/src/tools/research-question-tool.js.map +1 -1
- package/dist/src/tools/review-existing-adrs-tool.d.ts +5 -0
- package/dist/src/tools/review-existing-adrs-tool.d.ts.map +1 -1
- package/dist/src/tools/review-existing-adrs-tool.js +123 -42
- package/dist/src/tools/review-existing-adrs-tool.js.map +1 -1
- package/dist/src/tools/rule-generation-tool.d.ts.map +1 -1
- package/dist/src/tools/rule-generation-tool.js +3 -5
- package/dist/src/tools/rule-generation-tool.js.map +1 -1
- package/dist/src/tools/search-codebase-tool.d.ts +148 -0
- package/dist/src/tools/search-codebase-tool.d.ts.map +1 -0
- package/dist/src/tools/search-codebase-tool.js +406 -0
- package/dist/src/tools/search-codebase-tool.js.map +1 -0
- package/dist/src/tools/smart-git-push-tool-v2.js +1 -1
- package/dist/src/tools/smart-git-push-tool-v2.js.map +1 -1
- package/dist/src/tools/tool-catalog.d.ts +134 -0
- package/dist/src/tools/tool-catalog.d.ts.map +1 -0
- package/dist/src/tools/tool-catalog.js +1431 -0
- package/dist/src/tools/tool-catalog.js.map +1 -0
- package/dist/src/tools/tool-chain-orchestrator.d.ts +11 -2
- package/dist/src/tools/tool-chain-orchestrator.d.ts.map +1 -1
- package/dist/src/tools/tool-chain-orchestrator.js +11 -2
- package/dist/src/tools/tool-chain-orchestrator.js.map +1 -1
- package/dist/src/tools/tool-dispatcher.d.ts +98 -0
- package/dist/src/tools/tool-dispatcher.d.ts.map +1 -0
- package/dist/src/tools/tool-dispatcher.js +225 -0
- package/dist/src/tools/tool-dispatcher.js.map +1 -0
- package/dist/src/tools/tree-sitter-code-tools.d.ts +184 -0
- package/dist/src/tools/tree-sitter-code-tools.d.ts.map +1 -0
- package/dist/src/tools/tree-sitter-code-tools.js +642 -0
- package/dist/src/tools/tree-sitter-code-tools.js.map +1 -0
- package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts +22 -0
- package/dist/src/tools/troubleshoot-guided-workflow-tool.d.ts.map +1 -1
- package/dist/src/tools/troubleshoot-guided-workflow-tool.js +20 -3
- package/dist/src/tools/troubleshoot-guided-workflow-tool.js.map +1 -1
- package/dist/src/tools/update-knowledge-tool.d.ts +89 -0
- package/dist/src/tools/update-knowledge-tool.d.ts.map +1 -0
- package/dist/src/tools/update-knowledge-tool.js +222 -0
- package/dist/src/tools/update-knowledge-tool.js.map +1 -0
- package/dist/src/types/ce-mcp.d.ts +248 -0
- package/dist/src/types/ce-mcp.d.ts.map +1 -0
- package/dist/src/types/ce-mcp.js +27 -0
- package/dist/src/types/ce-mcp.js.map +1 -0
- package/dist/src/utils/adr-context-detector.js +1 -1
- package/dist/src/utils/adr-context-detector.js.map +1 -1
- package/dist/src/utils/adr-planning-task-integration.d.ts +260 -0
- package/dist/src/utils/adr-planning-task-integration.d.ts.map +1 -0
- package/dist/src/utils/adr-planning-task-integration.js +466 -0
- package/dist/src/utils/adr-planning-task-integration.js.map +1 -0
- package/dist/src/utils/adr-timeline-extractor.d.ts.map +1 -1
- package/dist/src/utils/adr-timeline-extractor.js +3 -2
- package/dist/src/utils/adr-timeline-extractor.js.map +1 -1
- package/dist/src/utils/ai-executor.d.ts +10 -0
- package/dist/src/utils/ai-executor.d.ts.map +1 -1
- package/dist/src/utils/ai-executor.js +14 -3
- package/dist/src/utils/ai-executor.js.map +1 -1
- package/dist/src/utils/automatic-prompt-engineering.d.ts +5 -0
- package/dist/src/utils/automatic-prompt-engineering.d.ts.map +1 -1
- package/dist/src/utils/automatic-prompt-engineering.js +10 -90
- package/dist/src/utils/automatic-prompt-engineering.js.map +1 -1
- package/dist/src/utils/bootstrap-task-integration.d.ts +214 -0
- package/dist/src/utils/bootstrap-task-integration.d.ts.map +1 -0
- package/dist/src/utils/bootstrap-task-integration.js +365 -0
- package/dist/src/utils/bootstrap-task-integration.js.map +1 -0
- package/dist/src/utils/dag-executor.d.ts.map +1 -1
- package/dist/src/utils/dag-executor.js +48 -15
- package/dist/src/utils/dag-executor.js.map +1 -1
- package/dist/src/utils/deployment-task-integration.d.ts +260 -0
- package/dist/src/utils/deployment-task-integration.d.ts.map +1 -0
- package/dist/src/utils/deployment-task-integration.js +393 -0
- package/dist/src/utils/deployment-task-integration.js.map +1 -0
- package/dist/src/utils/dynamic-deployment-intelligence.js +1 -1
- package/dist/src/utils/dynamic-deployment-intelligence.js.map +1 -1
- package/dist/src/utils/enhanced-logging.d.ts +3 -0
- package/dist/src/utils/enhanced-logging.d.ts.map +1 -1
- package/dist/src/utils/enhanced-logging.js +9 -30
- package/dist/src/utils/enhanced-logging.js.map +1 -1
- package/dist/src/utils/environment-capability-registry.js +1 -1
- package/dist/src/utils/environment-capability-registry.js.map +1 -1
- package/dist/src/utils/file-system.d.ts.map +1 -1
- package/dist/src/utils/file-system.js +33 -3
- package/dist/src/utils/file-system.js.map +1 -1
- package/dist/src/utils/gitleaks-detector.js +1 -1
- package/dist/src/utils/gitleaks-detector.js.map +1 -1
- package/dist/src/utils/knowledge-graph-manager.d.ts +13 -0
- package/dist/src/utils/knowledge-graph-manager.d.ts.map +1 -1
- package/dist/src/utils/knowledge-graph-manager.js +13 -0
- package/dist/src/utils/knowledge-graph-manager.js.map +1 -1
- package/dist/src/utils/prompt-execution.d.ts +29 -1
- package/dist/src/utils/prompt-execution.d.ts.map +1 -1
- package/dist/src/utils/prompt-execution.js +29 -1
- package/dist/src/utils/prompt-execution.js.map +1 -1
- package/dist/src/utils/research-orchestrator.d.ts +87 -1
- package/dist/src/utils/research-orchestrator.d.ts.map +1 -1
- package/dist/src/utils/research-orchestrator.js +121 -17
- package/dist/src/utils/research-orchestrator.js.map +1 -1
- package/dist/src/utils/research-task-integration.d.ts +297 -0
- package/dist/src/utils/research-task-integration.d.ts.map +1 -0
- package/dist/src/utils/research-task-integration.js +449 -0
- package/dist/src/utils/research-task-integration.js.map +1 -0
- package/dist/src/utils/ripgrep-wrapper.d.ts.map +1 -1
- package/dist/src/utils/ripgrep-wrapper.js +17 -3
- package/dist/src/utils/ripgrep-wrapper.js.map +1 -1
- package/dist/src/utils/sandbox-executor.d.ts +145 -0
- package/dist/src/utils/sandbox-executor.d.ts.map +1 -0
- package/dist/src/utils/sandbox-executor.js +642 -0
- package/dist/src/utils/sandbox-executor.js.map +1 -0
- package/dist/src/utils/server-context-generator.d.ts +5 -0
- package/dist/src/utils/server-context-generator.d.ts.map +1 -1
- package/dist/src/utils/server-context-generator.js +38 -0
- package/dist/src/utils/server-context-generator.js.map +1 -1
- package/dist/src/utils/task-manager.d.ts +239 -0
- package/dist/src/utils/task-manager.d.ts.map +1 -0
- package/dist/src/utils/task-manager.js +528 -0
- package/dist/src/utils/task-manager.js.map +1 -0
- package/dist/src/utils/task-persistence.d.ts +82 -0
- package/dist/src/utils/task-persistence.d.ts.map +1 -0
- package/dist/src/utils/task-persistence.js +248 -0
- package/dist/src/utils/task-persistence.js.map +1 -0
- package/dist/src/utils/test-aware-defaults.d.ts +57 -0
- package/dist/src/utils/test-aware-defaults.d.ts.map +1 -0
- package/dist/src/utils/test-aware-defaults.js +71 -0
- package/dist/src/utils/test-aware-defaults.js.map +1 -0
- package/dist/src/utils/tree-sitter-analyzer.d.ts +42 -5
- package/dist/src/utils/tree-sitter-analyzer.d.ts.map +1 -1
- package/dist/src/utils/tree-sitter-analyzer.js +499 -17
- package/dist/src/utils/tree-sitter-analyzer.js.map +1 -1
- package/package.json +25 -20
- package/dist/src/tools/smart-git-push-tool.d.ts +0 -55
- package/dist/src/tools/smart-git-push-tool.d.ts.map +0 -1
- package/dist/src/tools/smart-git-push-tool.js +0 -1011
- package/dist/src/tools/smart-git-push-tool.js.map +0 -1
package/dist/src/index.js
CHANGED
|
@@ -17,12 +17,16 @@ import { CONVERSATION_CONTEXT_SCHEMA } from './types/conversation-context.js';
|
|
|
17
17
|
import { maskMcpResponse, createMaskingConfig, } from './utils/output-masking.js';
|
|
18
18
|
import { loadConfig, validateProjectPath, createLogger, printConfigSummary, } from './utils/config.js';
|
|
19
19
|
import { KnowledgeGraphManager } from './utils/knowledge-graph-manager.js';
|
|
20
|
+
import { getEnhancedModeDefault, getKnowledgeEnhancementDefault, } from './utils/test-aware-defaults.js';
|
|
20
21
|
import { StateReinforcementManager } from './utils/state-reinforcement-manager.js';
|
|
21
22
|
import { ConversationMemoryManager } from './utils/conversation-memory-manager.js';
|
|
22
23
|
import { MemoryEntityManager } from './utils/memory-entity-manager.js';
|
|
23
24
|
import { RootManager } from './utils/root-manager.js';
|
|
24
25
|
import { ServerContextGenerator } from './utils/server-context-generator.js';
|
|
25
26
|
import { createNoOpContext } from './types/tool-context.js';
|
|
27
|
+
import { executeSearchTools, getSearchToolsDefinition, } from './tools/tool-dispatcher.js';
|
|
28
|
+
import { shouldUseCEMCPDirective, getCEMCPDirective, formatDirectiveResponse, } from './tools/ce-mcp-tools.js';
|
|
29
|
+
import { loadAIConfig, isCEMCPEnabled } from './config/ai-config.js';
|
|
26
30
|
/**
|
|
27
31
|
* Get version from package.json
|
|
28
32
|
*/
|
|
@@ -166,6 +170,8 @@ export class McpAdrAnalysisServer {
|
|
|
166
170
|
this.server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
167
171
|
return {
|
|
168
172
|
tools: [
|
|
173
|
+
// Meta-tool for dynamic tool discovery (CE-MCP Phase 3)
|
|
174
|
+
getSearchToolsDefinition(),
|
|
169
175
|
{
|
|
170
176
|
name: 'analyze_project_ecosystem',
|
|
171
177
|
description: 'Comprehensive recursive project ecosystem analysis with advanced prompting techniques (Knowledge Generation + Reflexion)',
|
|
@@ -1388,6 +1394,54 @@ export class McpAdrAnalysisServer {
|
|
|
1388
1394
|
required: ['question'],
|
|
1389
1395
|
},
|
|
1390
1396
|
},
|
|
1397
|
+
{
|
|
1398
|
+
name: 'search_codebase',
|
|
1399
|
+
description: 'Atomic tool for searching codebase files based on query patterns. Returns raw file matches with relevance scores. Extracted from ResearchOrchestrator per ADR-018.',
|
|
1400
|
+
inputSchema: {
|
|
1401
|
+
type: 'object',
|
|
1402
|
+
properties: {
|
|
1403
|
+
query: {
|
|
1404
|
+
type: 'string',
|
|
1405
|
+
description: 'Search query (e.g., "Docker configuration", "authentication")',
|
|
1406
|
+
},
|
|
1407
|
+
projectPath: {
|
|
1408
|
+
type: 'string',
|
|
1409
|
+
description: 'Path to project root',
|
|
1410
|
+
default: '.',
|
|
1411
|
+
},
|
|
1412
|
+
scope: {
|
|
1413
|
+
type: 'array',
|
|
1414
|
+
items: { type: 'string' },
|
|
1415
|
+
description: 'Optional file scope patterns (e.g., ["src/**", "config/**"])',
|
|
1416
|
+
},
|
|
1417
|
+
includeContent: {
|
|
1418
|
+
type: 'boolean',
|
|
1419
|
+
description: 'Include file content in results',
|
|
1420
|
+
default: false,
|
|
1421
|
+
},
|
|
1422
|
+
maxFiles: {
|
|
1423
|
+
type: 'number',
|
|
1424
|
+
description: 'Maximum files to return',
|
|
1425
|
+
default: 20,
|
|
1426
|
+
minimum: 1,
|
|
1427
|
+
maximum: 100,
|
|
1428
|
+
},
|
|
1429
|
+
enableTreeSitter: {
|
|
1430
|
+
type: 'boolean',
|
|
1431
|
+
description: 'Use tree-sitter for enhanced analysis',
|
|
1432
|
+
default: true,
|
|
1433
|
+
},
|
|
1434
|
+
relevanceThreshold: {
|
|
1435
|
+
type: 'number',
|
|
1436
|
+
description: 'Minimum relevance threshold (0-1)',
|
|
1437
|
+
default: 0.2,
|
|
1438
|
+
minimum: 0,
|
|
1439
|
+
maximum: 1,
|
|
1440
|
+
},
|
|
1441
|
+
},
|
|
1442
|
+
required: ['query'],
|
|
1443
|
+
},
|
|
1444
|
+
},
|
|
1391
1445
|
{
|
|
1392
1446
|
name: 'llm_web_search',
|
|
1393
1447
|
description: 'LLM-managed web search using Firecrawl for cross-platform support',
|
|
@@ -2944,6 +2998,48 @@ export class McpAdrAnalysisServer {
|
|
|
2944
2998
|
properties: {},
|
|
2945
2999
|
},
|
|
2946
3000
|
},
|
|
3001
|
+
{
|
|
3002
|
+
name: 'update_knowledge',
|
|
3003
|
+
description: 'ADR-018: Simple CRUD operations for knowledge graph. Add/remove entities (intents, ADRs, tools, code) and relationships. Use knowledge://graph resource to read current state (zero token cost).',
|
|
3004
|
+
inputSchema: {
|
|
3005
|
+
type: 'object',
|
|
3006
|
+
properties: {
|
|
3007
|
+
operation: {
|
|
3008
|
+
type: 'string',
|
|
3009
|
+
enum: ['add_entity', 'remove_entity', 'add_relationship', 'remove_relationship'],
|
|
3010
|
+
description: 'Type of operation to perform on the knowledge graph',
|
|
3011
|
+
},
|
|
3012
|
+
entity: {
|
|
3013
|
+
type: 'string',
|
|
3014
|
+
description: 'Entity ID (for add_entity/remove_entity operations)',
|
|
3015
|
+
},
|
|
3016
|
+
entityType: {
|
|
3017
|
+
type: 'string',
|
|
3018
|
+
enum: ['intent', 'adr', 'code', 'tool', 'decision'],
|
|
3019
|
+
description: 'Type of entity (required for add_entity operation)',
|
|
3020
|
+
},
|
|
3021
|
+
relationship: {
|
|
3022
|
+
type: 'string',
|
|
3023
|
+
enum: ['implements', 'uses', 'created', 'depends-on', 'supersedes'],
|
|
3024
|
+
description: 'Relationship type (for add_relationship/remove_relationship)',
|
|
3025
|
+
},
|
|
3026
|
+
source: {
|
|
3027
|
+
type: 'string',
|
|
3028
|
+
description: 'Source node ID (for relationship operations)',
|
|
3029
|
+
},
|
|
3030
|
+
target: {
|
|
3031
|
+
type: 'string',
|
|
3032
|
+
description: 'Target node ID (for relationship operations)',
|
|
3033
|
+
},
|
|
3034
|
+
metadata: {
|
|
3035
|
+
type: 'object',
|
|
3036
|
+
description: 'Additional metadata for the entity or relationship',
|
|
3037
|
+
additionalProperties: true,
|
|
3038
|
+
},
|
|
3039
|
+
},
|
|
3040
|
+
required: ['operation'],
|
|
3041
|
+
},
|
|
3042
|
+
},
|
|
2947
3043
|
{
|
|
2948
3044
|
name: 'get_server_context',
|
|
2949
3045
|
description: "Generate a comprehensive context file showing the server's current state, memory, and capabilities. Creates .mcp-server-context.md that can be @ referenced in conversations for instant LLM awareness",
|
|
@@ -2972,6 +3068,86 @@ export class McpAdrAnalysisServer {
|
|
|
2972
3068
|
},
|
|
2973
3069
|
},
|
|
2974
3070
|
},
|
|
3071
|
+
{
|
|
3072
|
+
name: 'get_current_datetime',
|
|
3073
|
+
description: 'Get the current date and time in various formats. Useful for timestamping ADRs, research documents, and other architectural artifacts. Returns ISO 8601, human-readable, and ADR-specific date formats.',
|
|
3074
|
+
inputSchema: {
|
|
3075
|
+
type: 'object',
|
|
3076
|
+
properties: {
|
|
3077
|
+
timezone: {
|
|
3078
|
+
type: 'string',
|
|
3079
|
+
description: 'Timezone for the datetime (e.g., "UTC", "America/New_York", "Europe/London"). Defaults to UTC.',
|
|
3080
|
+
default: 'UTC',
|
|
3081
|
+
},
|
|
3082
|
+
format: {
|
|
3083
|
+
type: 'string',
|
|
3084
|
+
enum: ['iso', 'human', 'adr', 'all'],
|
|
3085
|
+
description: 'Output format: "iso" for ISO 8601, "human" for human-readable, "adr" for ADR date format (YYYY-MM-DD), "all" for all formats',
|
|
3086
|
+
default: 'all',
|
|
3087
|
+
},
|
|
3088
|
+
includeTimestamp: {
|
|
3089
|
+
type: 'boolean',
|
|
3090
|
+
description: 'Include Unix timestamp in milliseconds',
|
|
3091
|
+
default: true,
|
|
3092
|
+
},
|
|
3093
|
+
},
|
|
3094
|
+
},
|
|
3095
|
+
},
|
|
3096
|
+
// Session management tool for dynamic project switching
|
|
3097
|
+
{
|
|
3098
|
+
name: 'set_project_path',
|
|
3099
|
+
description: 'Dynamically set the active project path for the current session. Call this at the start of a session to switch between projects without restarting the server or modifying environment variables. All subsequent tool calls will use this path as the default.',
|
|
3100
|
+
inputSchema: {
|
|
3101
|
+
type: 'object',
|
|
3102
|
+
properties: {
|
|
3103
|
+
path: {
|
|
3104
|
+
type: 'string',
|
|
3105
|
+
description: 'Absolute path to the project directory. Must be an existing directory.',
|
|
3106
|
+
},
|
|
3107
|
+
validatePath: {
|
|
3108
|
+
type: 'boolean',
|
|
3109
|
+
description: 'Whether to validate that the path exists and is a directory (default: true)',
|
|
3110
|
+
default: true,
|
|
3111
|
+
},
|
|
3112
|
+
},
|
|
3113
|
+
required: ['path'],
|
|
3114
|
+
},
|
|
3115
|
+
},
|
|
3116
|
+
// CE-MCP Phase 4: Lazy Prompt Loading Tool
|
|
3117
|
+
{
|
|
3118
|
+
name: 'load_prompt',
|
|
3119
|
+
description: 'Load a specific prompt or prompt section on-demand. Part of CE-MCP lazy loading system that reduces token usage by ~96% by loading prompts only when needed. Use this to retrieve prompt templates for ADR generation, analysis, deployment, and other operations.',
|
|
3120
|
+
inputSchema: {
|
|
3121
|
+
type: 'object',
|
|
3122
|
+
properties: {
|
|
3123
|
+
promptName: {
|
|
3124
|
+
type: 'string',
|
|
3125
|
+
description: 'Name of the prompt to load (e.g., "adr-suggestion", "deployment-analysis", "environment-analysis", "research-question", "rule-generation", "analysis", "security")',
|
|
3126
|
+
enum: [
|
|
3127
|
+
'adr-suggestion',
|
|
3128
|
+
'deployment-analysis',
|
|
3129
|
+
'environment-analysis',
|
|
3130
|
+
'research-question',
|
|
3131
|
+
'rule-generation',
|
|
3132
|
+
'analysis',
|
|
3133
|
+
'research-integration',
|
|
3134
|
+
'validated-pattern',
|
|
3135
|
+
'security',
|
|
3136
|
+
],
|
|
3137
|
+
},
|
|
3138
|
+
section: {
|
|
3139
|
+
type: 'string',
|
|
3140
|
+
description: 'Specific section within the prompt to load. If not provided, loads the entire prompt. Available sections depend on the prompt.',
|
|
3141
|
+
},
|
|
3142
|
+
estimateOnly: {
|
|
3143
|
+
type: 'boolean',
|
|
3144
|
+
description: 'If true, returns only token estimate without loading the full prompt content',
|
|
3145
|
+
default: false,
|
|
3146
|
+
},
|
|
3147
|
+
},
|
|
3148
|
+
required: ['promptName'],
|
|
3149
|
+
},
|
|
3150
|
+
},
|
|
2975
3151
|
],
|
|
2976
3152
|
};
|
|
2977
3153
|
});
|
|
@@ -3040,6 +3216,18 @@ export class McpAdrAnalysisServer {
|
|
|
3040
3216
|
try {
|
|
3041
3217
|
let response;
|
|
3042
3218
|
const safeArgs = args || {};
|
|
3219
|
+
// CE-MCP Mode: Check if tool should return directive instead of executing
|
|
3220
|
+
const aiConfig = loadAIConfig();
|
|
3221
|
+
if (isCEMCPEnabled(aiConfig) &&
|
|
3222
|
+
shouldUseCEMCPDirective(name, { mode: aiConfig.executionMode })) {
|
|
3223
|
+
const directive = getCEMCPDirective(name, safeArgs);
|
|
3224
|
+
if (directive) {
|
|
3225
|
+
this.logger.info(`[CE-MCP] Returning directive for tool: ${name}`);
|
|
3226
|
+
return formatDirectiveResponse(directive);
|
|
3227
|
+
}
|
|
3228
|
+
// Fall through to legacy execution if no directive available
|
|
3229
|
+
this.logger.info(`[CE-MCP] No directive available for ${name}, using legacy path`);
|
|
3230
|
+
}
|
|
3043
3231
|
switch (name) {
|
|
3044
3232
|
case 'analyze_project_ecosystem':
|
|
3045
3233
|
response = await this.analyzeProjectEcosystem(safeArgs, context);
|
|
@@ -3128,6 +3316,9 @@ export class McpAdrAnalysisServer {
|
|
|
3128
3316
|
case 'perform_research':
|
|
3129
3317
|
response = await this.performResearch(safeArgs, context);
|
|
3130
3318
|
break;
|
|
3319
|
+
case 'search_codebase':
|
|
3320
|
+
response = await this.searchCodebase(safeArgs);
|
|
3321
|
+
break;
|
|
3131
3322
|
case 'llm_web_search':
|
|
3132
3323
|
response = await this.llmWebSearch(safeArgs);
|
|
3133
3324
|
break;
|
|
@@ -3211,9 +3402,31 @@ export class McpAdrAnalysisServer {
|
|
|
3211
3402
|
case 'get_memory_stats':
|
|
3212
3403
|
response = await this.getMemoryStats();
|
|
3213
3404
|
break;
|
|
3405
|
+
case 'update_knowledge':
|
|
3406
|
+
response = await this.updateKnowledge(safeArgs);
|
|
3407
|
+
break;
|
|
3214
3408
|
case 'get_server_context':
|
|
3215
3409
|
response = await this.getServerContext(safeArgs);
|
|
3216
3410
|
break;
|
|
3411
|
+
case 'get_current_datetime':
|
|
3412
|
+
response = await this.getCurrentDatetime(safeArgs);
|
|
3413
|
+
break;
|
|
3414
|
+
case 'search_tools':
|
|
3415
|
+
response = {
|
|
3416
|
+
content: [
|
|
3417
|
+
{
|
|
3418
|
+
type: 'text',
|
|
3419
|
+
text: JSON.stringify(executeSearchTools(safeArgs), null, 2),
|
|
3420
|
+
},
|
|
3421
|
+
],
|
|
3422
|
+
};
|
|
3423
|
+
break;
|
|
3424
|
+
case 'set_project_path':
|
|
3425
|
+
response = await this.setProjectPath(safeArgs);
|
|
3426
|
+
break;
|
|
3427
|
+
case 'load_prompt':
|
|
3428
|
+
response = await this.loadPrompt(safeArgs);
|
|
3429
|
+
break;
|
|
3217
3430
|
default:
|
|
3218
3431
|
throw new McpAdrError(`Unknown tool: ${name}`, 'UNKNOWN_TOOL');
|
|
3219
3432
|
}
|
|
@@ -3410,6 +3623,13 @@ export class McpAdrAnalysisServer {
|
|
|
3410
3623
|
description: 'Base code repository information for a platform pattern including URL, integration instructions, required files, and script entrypoint',
|
|
3411
3624
|
mimeType: 'application/json',
|
|
3412
3625
|
},
|
|
3626
|
+
// NEW Knowledge Graph Resource (ADR-018)
|
|
3627
|
+
{
|
|
3628
|
+
uri: 'knowledge://graph',
|
|
3629
|
+
name: 'Knowledge Graph',
|
|
3630
|
+
description: 'Read-only knowledge graph structure with nodes (intents, ADRs, tools, code files) and edges (relationships). Zero token cost for querying graph state. Use update_knowledge tool to modify.',
|
|
3631
|
+
mimeType: 'application/json',
|
|
3632
|
+
},
|
|
3413
3633
|
],
|
|
3414
3634
|
};
|
|
3415
3635
|
});
|
|
@@ -3579,6 +3799,10 @@ export class McpAdrAnalysisServer {
|
|
|
3579
3799
|
type: 'text',
|
|
3580
3800
|
text: `# AI Execution Status Diagnostic
|
|
3581
3801
|
|
|
3802
|
+
> **Note**: As of Phase 5, this server uses CE-MCP (Claude-Enriched MCP) mode by default.
|
|
3803
|
+
> In CE-MCP mode, tools return orchestration directives that the host LLM executes directly,
|
|
3804
|
+
> eliminating the need for external API calls. The configuration below applies to legacy mode only.
|
|
3805
|
+
|
|
3582
3806
|
## Current Configuration
|
|
3583
3807
|
- **AI Execution Enabled**: ${status.isEnabled ? '✅ YES' : '❌ NO'}
|
|
3584
3808
|
- **Has API Key**: ${status.hasApiKey ? '✅ YES' : '❌ NO'}
|
|
@@ -4092,7 +4316,9 @@ This guidance ensures your development work is **architecturally aligned**, **qu
|
|
|
4092
4316
|
const ctx = context || createNoOpContext();
|
|
4093
4317
|
// Use configured project path if not provided in args
|
|
4094
4318
|
const projectPath = args.projectPath || this.config.projectPath;
|
|
4095
|
-
const { includePatterns, enhancedMode =
|
|
4319
|
+
const { includePatterns, enhancedMode = getEnhancedModeDefault(), // Environment-aware default
|
|
4320
|
+
knowledgeEnhancement = getKnowledgeEnhancementDefault(), // Environment-aware default
|
|
4321
|
+
learningEnabled = true, technologyFocus = [], analysisDepth = 'comprehensive', includeEnvironment = true, recursiveDepth = 'comprehensive', analysisScope = [],
|
|
4096
4322
|
// conversationContext - TODO: implement context integration for ecosystem analysis
|
|
4097
4323
|
} = args;
|
|
4098
4324
|
this.logger.info(`Generating comprehensive ecosystem analysis for project at: ${projectPath}`);
|
|
@@ -4131,7 +4357,10 @@ This guidance ensures your development work is **architecturally aligned**, **qu
|
|
|
4131
4357
|
this.logger.warn('Failed to initialize ADR knowledge base:', error);
|
|
4132
4358
|
// Don't fail the entire analysis if ADR initialization fails
|
|
4133
4359
|
}
|
|
4134
|
-
//
|
|
4360
|
+
// DEPRECATED: Legacy context assembly for enhanced mode
|
|
4361
|
+
// This section is part of the OpenRouter execution path and will be removed
|
|
4362
|
+
// in a future release. For CE-MCP mode, use createAnalyzeProjectEcosystemDirective()
|
|
4363
|
+
// from src/tools/ce-mcp-tools.ts instead. See ADR-014.
|
|
4135
4364
|
let generateArchitecturalKnowledge = null;
|
|
4136
4365
|
let executeWithReflexion = null;
|
|
4137
4366
|
let retrieveRelevantMemories = null;
|
|
@@ -4698,7 +4927,9 @@ This **outcome-focused approach** ensures architectural work delivers **measurab
|
|
|
4698
4927
|
}
|
|
4699
4928
|
async generateAdrsFromPrd(args, context) {
|
|
4700
4929
|
const ctx = context || createNoOpContext();
|
|
4701
|
-
const { prdPath, enhancedMode =
|
|
4930
|
+
const { prdPath, enhancedMode = getEnhancedModeDefault(), // Environment-aware default
|
|
4931
|
+
promptOptimization = true, knowledgeEnhancement = getKnowledgeEnhancementDefault(), // Environment-aware default
|
|
4932
|
+
prdType = 'general', } = args;
|
|
4702
4933
|
const outputDirectory = args['outputDirectory'] || this.config.adrDirectory;
|
|
4703
4934
|
this.logger.info(`Generating enhanced ADRs from PRD: ${prdPath} to ${outputDirectory}`);
|
|
4704
4935
|
this.logger.info(`Enhancement features - APE: ${promptOptimization}, Knowledge: ${knowledgeEnhancement}, Type: ${prdType}`);
|
|
@@ -6182,13 +6413,11 @@ Please provide:
|
|
|
6182
6413
|
responseText += `**ADR Directory:** ${adrDirectory}\n`;
|
|
6183
6414
|
responseText += `**Total ADRs:** ${result.totalAdrs}\n\n`;
|
|
6184
6415
|
// Add timeline summary
|
|
6185
|
-
if (result.adrs.some(
|
|
6186
|
-
const withTimeline = result.adrs.filter(
|
|
6416
|
+
if (result.adrs.some(adr => adr.timeline)) {
|
|
6417
|
+
const withTimeline = result.adrs.filter(adr => adr.timeline).length;
|
|
6187
6418
|
responseText += `## Timeline Data\n\n`;
|
|
6188
6419
|
responseText += `- **ADRs with Timeline:** ${withTimeline}/${result.totalAdrs}\n`;
|
|
6189
|
-
const ages = result.adrs
|
|
6190
|
-
.filter((adr) => adr.timeline)
|
|
6191
|
-
.map((adr) => adr.timeline.age_days);
|
|
6420
|
+
const ages = result.adrs.filter(adr => adr.timeline).map(adr => adr.timeline.age_days);
|
|
6192
6421
|
if (ages.length > 0) {
|
|
6193
6422
|
const avgAge = Math.floor(ages.reduce((a, b) => a + b, 0) / ages.length);
|
|
6194
6423
|
const oldestAge = Math.max(...ages);
|
|
@@ -6321,6 +6550,21 @@ Please provide:
|
|
|
6321
6550
|
throw new McpAdrError(`Failed to perform research: ${error instanceof Error ? error.message : String(error)}`, 'RESEARCH_EXECUTION_ERROR');
|
|
6322
6551
|
}
|
|
6323
6552
|
}
|
|
6553
|
+
/**
|
|
6554
|
+
* Search codebase tool implementation
|
|
6555
|
+
*/
|
|
6556
|
+
async searchCodebase(args) {
|
|
6557
|
+
if (!('query' in args) || typeof args['query'] !== 'string') {
|
|
6558
|
+
throw new McpAdrError('Missing required parameter: query', 'INVALID_ARGUMENTS');
|
|
6559
|
+
}
|
|
6560
|
+
try {
|
|
6561
|
+
const { searchCodebaseTool } = await import('./tools/search-codebase-tool.js');
|
|
6562
|
+
return await searchCodebaseTool(args);
|
|
6563
|
+
}
|
|
6564
|
+
catch (error) {
|
|
6565
|
+
throw new McpAdrError(`Failed to search codebase: ${error instanceof Error ? error.message : String(error)}`, 'SEARCH_ERROR');
|
|
6566
|
+
}
|
|
6567
|
+
}
|
|
6324
6568
|
/**
|
|
6325
6569
|
* LLM web search tool implementation
|
|
6326
6570
|
*/
|
|
@@ -6666,6 +6910,33 @@ Please provide:
|
|
|
6666
6910
|
await import('./resources/validated-pattern-by-platform-resource.js');
|
|
6667
6911
|
await import('./resources/pattern-sources-by-platform-resource.js');
|
|
6668
6912
|
await import('./resources/pattern-base-code-by-platform-resource.js');
|
|
6913
|
+
// Phase 1 & 2 resources (PR #346)
|
|
6914
|
+
await import('./resources/server-context-resource.js');
|
|
6915
|
+
await import('./resources/memory-stats-resource.js');
|
|
6916
|
+
await import('./resources/conversation-snapshot-resource.js');
|
|
6917
|
+
await import('./resources/tool-catalog-resource.js');
|
|
6918
|
+
await import('./resources/adrs-discovered-resource.js');
|
|
6919
|
+
// Knowledge Graph Resource (ADR-018)
|
|
6920
|
+
const { generateKnowledgeGraphResource } = await import('./resources/knowledge-graph-resource.js');
|
|
6921
|
+
// Handle knowledge://graph specially to inject KnowledgeGraphManager
|
|
6922
|
+
if (uri === 'knowledge://graph') {
|
|
6923
|
+
const url = new globalThis.URL(uri);
|
|
6924
|
+
const result = await generateKnowledgeGraphResource({}, url.searchParams, this.kgManager);
|
|
6925
|
+
return {
|
|
6926
|
+
contents: [
|
|
6927
|
+
{
|
|
6928
|
+
uri,
|
|
6929
|
+
mimeType: result.contentType,
|
|
6930
|
+
text: JSON.stringify(result.data, null, 2),
|
|
6931
|
+
},
|
|
6932
|
+
],
|
|
6933
|
+
_meta: {
|
|
6934
|
+
lastModified: result.lastModified,
|
|
6935
|
+
etag: result.etag,
|
|
6936
|
+
cacheKey: result.cacheKey,
|
|
6937
|
+
},
|
|
6938
|
+
};
|
|
6939
|
+
}
|
|
6669
6940
|
// Try routing first (handles templated resources)
|
|
6670
6941
|
if (resourceRouter.canRoute(uri)) {
|
|
6671
6942
|
const result = await resourceRouter.route(uri);
|
|
@@ -7298,6 +7569,19 @@ This tool has been deprecated and replaced with memory-centric health scoring.
|
|
|
7298
7569
|
throw new McpAdrError(`Memory stats retrieval failed: ${error instanceof Error ? error.message : String(error)}`, 'MEMORY_STATS_ERROR');
|
|
7299
7570
|
}
|
|
7300
7571
|
}
|
|
7572
|
+
/**
|
|
7573
|
+
* Update Knowledge Tool (ADR-018)
|
|
7574
|
+
* Simple CRUD operations for knowledge graph
|
|
7575
|
+
*/
|
|
7576
|
+
async updateKnowledge(args) {
|
|
7577
|
+
try {
|
|
7578
|
+
const { updateKnowledge } = await import('./tools/update-knowledge-tool.js');
|
|
7579
|
+
return await updateKnowledge(args, createNoOpContext(), this.kgManager);
|
|
7580
|
+
}
|
|
7581
|
+
catch (error) {
|
|
7582
|
+
throw new McpAdrError(`Knowledge update failed: ${error instanceof Error ? error.message : String(error)}`, 'KNOWLEDGE_UPDATE_ERROR');
|
|
7583
|
+
}
|
|
7584
|
+
}
|
|
7301
7585
|
/**
|
|
7302
7586
|
* Get Server Context Tool
|
|
7303
7587
|
* Generates comprehensive server context file for LLM @ referencing
|
|
@@ -7311,6 +7595,278 @@ This tool has been deprecated and replaced with memory-centric health scoring.
|
|
|
7311
7595
|
throw new McpAdrError(`Server context generation failed: ${error instanceof Error ? error.message : String(error)}`, 'SERVER_CONTEXT_ERROR');
|
|
7312
7596
|
}
|
|
7313
7597
|
}
|
|
7598
|
+
/**
|
|
7599
|
+
* Get Current Datetime Tool
|
|
7600
|
+
* Returns the current date and time in various formats for ADR generation and timestamping
|
|
7601
|
+
*/
|
|
7602
|
+
async getCurrentDatetime(args) {
|
|
7603
|
+
const { timezone = 'UTC', format = 'all', includeTimestamp = true } = args;
|
|
7604
|
+
try {
|
|
7605
|
+
const now = new Date();
|
|
7606
|
+
// Format date for different timezones
|
|
7607
|
+
const formatOptions = {
|
|
7608
|
+
timeZone: timezone,
|
|
7609
|
+
year: 'numeric',
|
|
7610
|
+
month: '2-digit',
|
|
7611
|
+
day: '2-digit',
|
|
7612
|
+
hour: '2-digit',
|
|
7613
|
+
minute: '2-digit',
|
|
7614
|
+
second: '2-digit',
|
|
7615
|
+
hour12: false,
|
|
7616
|
+
};
|
|
7617
|
+
// Get date parts for the specified timezone
|
|
7618
|
+
const formatter = new Intl.DateTimeFormat('en-CA', {
|
|
7619
|
+
timeZone: timezone,
|
|
7620
|
+
year: 'numeric',
|
|
7621
|
+
month: '2-digit',
|
|
7622
|
+
day: '2-digit',
|
|
7623
|
+
});
|
|
7624
|
+
const parts = formatter.formatToParts(now);
|
|
7625
|
+
const year = parts.find(p => p.type === 'year')?.value || '';
|
|
7626
|
+
const month = parts.find(p => p.type === 'month')?.value || '';
|
|
7627
|
+
const day = parts.find(p => p.type === 'day')?.value || '';
|
|
7628
|
+
// ADR date format: YYYY-MM-DD
|
|
7629
|
+
const adrDate = `${year}-${month}-${day}`;
|
|
7630
|
+
// ISO 8601 format
|
|
7631
|
+
const isoDate = now.toISOString();
|
|
7632
|
+
// Human-readable format
|
|
7633
|
+
const humanFormatter = new Intl.DateTimeFormat('en-US', {
|
|
7634
|
+
...formatOptions,
|
|
7635
|
+
weekday: 'long',
|
|
7636
|
+
month: 'long',
|
|
7637
|
+
});
|
|
7638
|
+
const humanDate = humanFormatter.format(now);
|
|
7639
|
+
// Build response based on requested format
|
|
7640
|
+
let responseData = {};
|
|
7641
|
+
switch (format) {
|
|
7642
|
+
case 'iso':
|
|
7643
|
+
responseData = { iso: isoDate };
|
|
7644
|
+
break;
|
|
7645
|
+
case 'human':
|
|
7646
|
+
responseData = { human: humanDate };
|
|
7647
|
+
break;
|
|
7648
|
+
case 'adr':
|
|
7649
|
+
responseData = { adr: adrDate };
|
|
7650
|
+
break;
|
|
7651
|
+
case 'all':
|
|
7652
|
+
default:
|
|
7653
|
+
responseData = {
|
|
7654
|
+
iso: isoDate,
|
|
7655
|
+
human: humanDate,
|
|
7656
|
+
adr: adrDate,
|
|
7657
|
+
timezone: timezone,
|
|
7658
|
+
};
|
|
7659
|
+
}
|
|
7660
|
+
if (includeTimestamp) {
|
|
7661
|
+
responseData['timestamp'] = now.getTime();
|
|
7662
|
+
}
|
|
7663
|
+
const responseText = `# Current Date and Time
|
|
7664
|
+
|
|
7665
|
+
## Formats
|
|
7666
|
+
${format === 'all' || format === 'iso' ? `- **ISO 8601**: ${isoDate}` : ''}
|
|
7667
|
+
${format === 'all' || format === 'human' ? `- **Human Readable**: ${humanDate}` : ''}
|
|
7668
|
+
${format === 'all' || format === 'adr' ? `- **ADR Date (YYYY-MM-DD)**: ${adrDate}` : ''}
|
|
7669
|
+
${format === 'all' ? `- **Timezone**: ${timezone}` : ''}
|
|
7670
|
+
${includeTimestamp ? `- **Unix Timestamp (ms)**: ${now.getTime()}` : ''}
|
|
7671
|
+
|
|
7672
|
+
## Usage for ADR Generation
|
|
7673
|
+
|
|
7674
|
+
When generating ADRs, use the ADR date format (\`${adrDate}\`) in the Date field:
|
|
7675
|
+
|
|
7676
|
+
\`\`\`markdown
|
|
7677
|
+
# ADR-XXXX: [Title]
|
|
7678
|
+
|
|
7679
|
+
## Date
|
|
7680
|
+
${adrDate}
|
|
7681
|
+
|
|
7682
|
+
## Status
|
|
7683
|
+
Proposed
|
|
7684
|
+
\`\`\`
|
|
7685
|
+
|
|
7686
|
+
## Raw Data
|
|
7687
|
+
|
|
7688
|
+
\`\`\`json
|
|
7689
|
+
${JSON.stringify(responseData, null, 2)}
|
|
7690
|
+
\`\`\`
|
|
7691
|
+
`;
|
|
7692
|
+
return {
|
|
7693
|
+
content: [
|
|
7694
|
+
{
|
|
7695
|
+
type: 'text',
|
|
7696
|
+
text: responseText,
|
|
7697
|
+
},
|
|
7698
|
+
],
|
|
7699
|
+
};
|
|
7700
|
+
}
|
|
7701
|
+
catch (error) {
|
|
7702
|
+
throw new McpAdrError(`Failed to get current datetime: ${error instanceof Error ? error.message : String(error)}`, 'DATETIME_ERROR');
|
|
7703
|
+
}
|
|
7704
|
+
}
|
|
7705
|
+
/**
|
|
7706
|
+
* Set Project Path Tool - Dynamic Session Configuration
|
|
7707
|
+
*
|
|
7708
|
+
* @description Dynamically sets the active project path for the current session.
|
|
7709
|
+
* This allows switching between projects without restarting the server or modifying
|
|
7710
|
+
* environment variables. Updates both the config and the RootManager.
|
|
7711
|
+
*
|
|
7712
|
+
* @param args - Set project path arguments
|
|
7713
|
+
* @param args.path - Absolute path to the project directory
|
|
7714
|
+
* @param args.validatePath - Whether to validate the path exists (default: true)
|
|
7715
|
+
* @returns Promise<CallToolResult> - Confirmation of the path change
|
|
7716
|
+
*/
|
|
7717
|
+
async setProjectPath(args) {
|
|
7718
|
+
const { path: newPath, validatePath = true } = args;
|
|
7719
|
+
const { resolve } = await import('path');
|
|
7720
|
+
try {
|
|
7721
|
+
// Resolve to absolute path
|
|
7722
|
+
const absolutePath = resolve(newPath);
|
|
7723
|
+
const previousPath = this.config.projectPath;
|
|
7724
|
+
// Validate the path if requested
|
|
7725
|
+
if (validatePath) {
|
|
7726
|
+
await validateProjectPath(absolutePath);
|
|
7727
|
+
}
|
|
7728
|
+
// Update the server configuration
|
|
7729
|
+
this.config.projectPath = absolutePath;
|
|
7730
|
+
// Re-initialize the RootManager with the new path
|
|
7731
|
+
this.rootManager = new RootManager(absolutePath, this.config.adrDirectory);
|
|
7732
|
+
this.logger.info(`Project path changed: ${previousPath} -> ${absolutePath}`);
|
|
7733
|
+
const responseText = `# Project Path Updated
|
|
7734
|
+
|
|
7735
|
+
## Configuration
|
|
7736
|
+
- **Previous Path**: \`${previousPath}\`
|
|
7737
|
+
- **New Path**: \`${absolutePath}\`
|
|
7738
|
+
- **ADR Directory**: \`${this.config.adrDirectory}\`
|
|
7739
|
+
- **Full ADR Path**: \`${resolve(absolutePath, this.config.adrDirectory)}\`
|
|
7740
|
+
|
|
7741
|
+
## Status
|
|
7742
|
+
✅ Project path successfully updated for this session.
|
|
7743
|
+
|
|
7744
|
+
## Note
|
|
7745
|
+
All subsequent tool calls will use this path as the default project path.
|
|
7746
|
+
You can still override it per-tool by passing \`projectPath\` as an argument.
|
|
7747
|
+
|
|
7748
|
+
To make this permanent, set the \`PROJECT_PATH\` environment variable.
|
|
7749
|
+
`;
|
|
7750
|
+
return {
|
|
7751
|
+
content: [
|
|
7752
|
+
{
|
|
7753
|
+
type: 'text',
|
|
7754
|
+
text: responseText,
|
|
7755
|
+
},
|
|
7756
|
+
],
|
|
7757
|
+
};
|
|
7758
|
+
}
|
|
7759
|
+
catch (error) {
|
|
7760
|
+
throw new McpAdrError(`Failed to set project path: ${error instanceof Error ? error.message : String(error)}`, 'SET_PROJECT_PATH_ERROR');
|
|
7761
|
+
}
|
|
7762
|
+
}
|
|
7763
|
+
/**
|
|
7764
|
+
* Load Prompt Tool - CE-MCP Phase 4 Lazy Loading
|
|
7765
|
+
*
|
|
7766
|
+
* @description Loads prompts on-demand instead of eagerly loading all prompts at startup.
|
|
7767
|
+
* This reduces token usage by ~96% (from 28K tokens to ~1K on-demand).
|
|
7768
|
+
*
|
|
7769
|
+
* @param args - Load prompt arguments
|
|
7770
|
+
* @param args.promptName - Name of the prompt to load
|
|
7771
|
+
* @param args.section - Optional section within the prompt
|
|
7772
|
+
* @param args.estimateOnly - If true, returns only token estimate
|
|
7773
|
+
* @returns Promise<CallToolResult> - Loaded prompt content or estimate
|
|
7774
|
+
*/
|
|
7775
|
+
async loadPrompt(args) {
|
|
7776
|
+
const { promptName, section, estimateOnly = false } = args;
|
|
7777
|
+
// Import the prompt catalog dynamically to enable lazy loading
|
|
7778
|
+
const { getPromptLoader, getPromptMetadata, calculateTokenSavings } = await import('./prompts/prompt-catalog.js');
|
|
7779
|
+
const metadata = getPromptMetadata(promptName);
|
|
7780
|
+
if (!metadata) {
|
|
7781
|
+
const availablePrompts = [
|
|
7782
|
+
'adr-suggestion',
|
|
7783
|
+
'deployment-analysis',
|
|
7784
|
+
'environment-analysis',
|
|
7785
|
+
'research-question',
|
|
7786
|
+
'rule-generation',
|
|
7787
|
+
'analysis',
|
|
7788
|
+
'research-integration',
|
|
7789
|
+
'validated-pattern',
|
|
7790
|
+
'security',
|
|
7791
|
+
];
|
|
7792
|
+
return {
|
|
7793
|
+
content: [
|
|
7794
|
+
{
|
|
7795
|
+
type: 'text',
|
|
7796
|
+
text: JSON.stringify({
|
|
7797
|
+
success: false,
|
|
7798
|
+
error: `Unknown prompt: ${promptName}`,
|
|
7799
|
+
availablePrompts,
|
|
7800
|
+
hint: 'Use one of the available prompt names listed above',
|
|
7801
|
+
}, null, 2),
|
|
7802
|
+
},
|
|
7803
|
+
],
|
|
7804
|
+
isError: true,
|
|
7805
|
+
};
|
|
7806
|
+
}
|
|
7807
|
+
// If estimate only, return token information without loading
|
|
7808
|
+
if (estimateOnly) {
|
|
7809
|
+
const loader = getPromptLoader();
|
|
7810
|
+
const estimatedTokens = loader.getEstimatedTokens(promptName, section);
|
|
7811
|
+
const savings = calculateTokenSavings([promptName]);
|
|
7812
|
+
return {
|
|
7813
|
+
content: [
|
|
7814
|
+
{
|
|
7815
|
+
type: 'text',
|
|
7816
|
+
text: JSON.stringify({
|
|
7817
|
+
success: true,
|
|
7818
|
+
promptName,
|
|
7819
|
+
section: section || 'full',
|
|
7820
|
+
estimatedTokens,
|
|
7821
|
+
metadata: {
|
|
7822
|
+
file: metadata.file,
|
|
7823
|
+
category: metadata.category,
|
|
7824
|
+
totalTokens: metadata.tokens,
|
|
7825
|
+
availableSections: metadata.sections,
|
|
7826
|
+
loadOnDemand: metadata.loadOnDemand,
|
|
7827
|
+
},
|
|
7828
|
+
tokenSavings: {
|
|
7829
|
+
loaded: savings.loaded,
|
|
7830
|
+
total: savings.total,
|
|
7831
|
+
saved: savings.saved,
|
|
7832
|
+
percentage: `${savings.percentage}%`,
|
|
7833
|
+
},
|
|
7834
|
+
}, null, 2),
|
|
7835
|
+
},
|
|
7836
|
+
],
|
|
7837
|
+
};
|
|
7838
|
+
}
|
|
7839
|
+
// Load the prompt content
|
|
7840
|
+
try {
|
|
7841
|
+
const loader = getPromptLoader();
|
|
7842
|
+
const content = await loader.loadPrompt(promptName, section);
|
|
7843
|
+
return {
|
|
7844
|
+
content: [
|
|
7845
|
+
{
|
|
7846
|
+
type: 'text',
|
|
7847
|
+
text: `# Loaded Prompt: ${promptName}${section ? ` (section: ${section})` : ''}
|
|
7848
|
+
|
|
7849
|
+
## Metadata
|
|
7850
|
+
- **Category**: ${metadata.category}
|
|
7851
|
+
- **Estimated Tokens**: ${metadata.tokens}
|
|
7852
|
+
- **Available Sections**: ${metadata.sections.join(', ')}
|
|
7853
|
+
|
|
7854
|
+
## Content
|
|
7855
|
+
|
|
7856
|
+
${content}
|
|
7857
|
+
|
|
7858
|
+
---
|
|
7859
|
+
|
|
7860
|
+
*Loaded on-demand via CE-MCP lazy loading system. Token savings: ~96% compared to eager loading all prompts.*
|
|
7861
|
+
`,
|
|
7862
|
+
},
|
|
7863
|
+
],
|
|
7864
|
+
};
|
|
7865
|
+
}
|
|
7866
|
+
catch (error) {
|
|
7867
|
+
throw new McpAdrError(`Failed to load prompt '${promptName}'${section ? ` section '${section}'` : ''}: ${error instanceof Error ? error.message : String(error)}`, 'PROMPT_LOAD_ERROR');
|
|
7868
|
+
}
|
|
7869
|
+
}
|
|
7314
7870
|
}
|
|
7315
7871
|
/**
|
|
7316
7872
|
* Main execution function for the MCP ADR Analysis Server
|