mcp-adr-analysis-server
Version:
MCP server for analyzing Architectural Decision Records and project architecture
109 lines • 3.98 kB
JavaScript
/**
* Conversation Context Types
*
* Defines the structure for passing conversation context from calling LLMs
* to the MCP server for context-aware analysis.
*/
/**
* JSON Schema for conversation context - reusable across tools
*/
export const CONVERSATION_CONTEXT_SCHEMA = {
type: 'object',
description: 'Rich context from the calling LLM about user goals and discussion history',
properties: {
humanRequest: {
type: 'string',
description: 'Original human request text for context restoration and knowledge graph storage',
},
userGoals: {
type: 'array',
items: { type: 'string' },
description: 'Primary objectives the user wants to achieve (e.g., ["microservices migration", "improve security"])',
},
focusAreas: {
type: 'array',
items: { type: 'string' },
description: 'Specific areas of concern or interest (e.g., ["security", "performance", "maintainability"])',
},
constraints: {
type: 'array',
items: { type: 'string' },
description: 'Limitations, compliance requirements, or restrictions (e.g., ["GDPR compliance", "budget under $50k", "minimal downtime"])',
},
previousContext: {
type: 'string',
description: 'Relevant context from previous conversation (e.g., "User mentioned concerns about database splitting")',
},
projectPhase: {
type: 'string',
description: 'Current project phase (e.g., "planning", "development", "migration", "production")',
},
userRole: {
type: 'string',
description: 'User\'s role or expertise level (e.g., "senior architect", "developer", "project manager")',
},
requirements: {
type: 'array',
items: { type: 'string' },
description: 'Specific requirements or preferences mentioned',
},
timeline: {
type: 'string',
description: 'Timeline or urgency information (e.g., "launch in 3 months", "urgent migration")',
},
budget: {
type: 'string',
description: 'Budget or resource constraints (e.g., "limited budget", "enterprise scale")',
},
},
additionalProperties: false,
};
/**
* Utility function to extract context summary for prompts
*/
export function formatContextForPrompt(context) {
if (!context)
return '';
const sections = [];
if (context.humanRequest) {
sections.push(`Human Request: "${context.humanRequest}"`);
}
if (context.userGoals?.length) {
sections.push(`User Goals: ${context.userGoals.join(', ')}`);
}
if (context.focusAreas?.length) {
sections.push(`Focus Areas: ${context.focusAreas.join(', ')}`);
}
if (context.constraints?.length) {
sections.push(`Constraints: ${context.constraints.join(', ')}`);
}
if (context.projectPhase) {
sections.push(`Project Phase: ${context.projectPhase}`);
}
if (context.userRole) {
sections.push(`User Role: ${context.userRole}`);
}
if (context.timeline) {
sections.push(`Timeline: ${context.timeline}`);
}
if (context.previousContext) {
sections.push(`Previous Context: ${context.previousContext}`);
}
return sections.length > 0 ? `## User Context\n${sections.join('\n')}\n\n` : '';
}
/**
* Check if context contains meaningful information
*/
export function hasMeaningfulContext(context) {
if (!context)
return false;
return !!(context.humanRequest ||
context.userGoals?.length ||
context.focusAreas?.length ||
context.constraints?.length ||
context.previousContext ||
context.projectPhase ||
context.userRole ||
context.requirements?.length);
}
//# sourceMappingURL=conversation-context.js.map