UNPKG

mcp-adr-analysis-server

Version:

MCP server for analyzing Architectural Decision Records and project architecture

180 lines 6.25 kB
/** * Memory Snapshots Resource * * MCP Resource implementation for memory system snapshots and queries. * Bridges to memory-loading-tool for actual operations. * * URI Templates: * - adr://memory-snapshots/current - Current memory snapshot * - adr://memory-snapshots/query - Query memory entities * - adr://memory-snapshots/entity/{entityId} - Get specific entity * - adr://memory-snapshots/related/{entityId} - Find related entities * - adr://memory-snapshots/intelligence - Memory intelligence analysis * - adr://memory-snapshots/load-adrs - Load ADRs into memory * * Query Parameters: * - entityTypes: Filter by entity types (comma-separated) * - tags: Filter by tags (comma-separated) * - textQuery: Text search query * - relationshipTypes: Filter by relationship types (comma-separated) * - confidenceThreshold: Minimum confidence score (0-1) * - relevanceThreshold: Minimum relevance score (0-1) * - limit: Maximum results to return * - sortBy: Sort order (relevance, confidence, lastModified, created, accessCount) * - includeRelated: Include related entities (true/false) * - relationshipDepth: Depth of relationships to traverse (1-5) * - maxDepth: Maximum depth for find_related (1-10) * - forceReload: Force reload of ADRs (true/false) */ import { URLSearchParams } from 'url'; import { MemoryLoadingTool } from '../tools/memory-loading-tool.js'; export declare class MemorySnapshotsResource { private memoryLoadingTool; private logger; private cache; private readonly CACHE_TTL; constructor(memoryLoadingTool?: MemoryLoadingTool); /** * Parse memory URI to extract operation and entity ID */ private parseUri; /** * Parse query parameters from URI */ private parseQueryParams; /** * Convert query parameters to memory loading tool parameters */ private buildToolParams; /** * Extract structured data from memory loading tool response */ private extractMemoryData; /** * Generate human-readable content from memory data */ private formatMemoryContent; private formatSnapshotContent; private formatQueryContent; private formatEntityContent; private formatRelatedContent; private formatIntelligenceContent; private formatLoadAdrsContent; /** * Handle resource read request */ read(uri: string): Promise<{ contents: Array<{ uri: string; mimeType: string; text: string; }>; }>; /** * List available memory snapshot resources */ listTemplates(): Array<{ uriTemplate: string; name: string; description: string; mimeType: string; }>; } /** * Generate memory snapshots resource for knowledge graph and learning system access. * * Provides access to the MCP server's intelligent memory system including project analyses, * recommendations, deployments, and learned patterns. Supports temporal queries and * contextual retrieval for AI-enhanced decision making. * * **Query Parameters:** * - `type`: Snapshot type - "current" (latest), "historical" (time-based), "all" (complete) * - `projectId`: Filter by project identifier * - `since`: ISO timestamp for historical queries (e.g., "2025-10-01T00:00:00Z") * - `limit`: Maximum number of snapshots to return (default: 10, max: 100) * * **Memory System Features:** * - Project analysis history with patterns and predictions * - Recommendation tracking with success metrics * - Deployment history with trend analysis * - Configuration changes and their impacts * - Cross-project learning and insights * * @param _params - URL path parameters (currently unused, reserved for future routing) * @param searchParams - URL query parameters controlling snapshot selection * * @returns Promise resolving to resource generation result containing: * - data: Memory snapshots with metadata, timestamps, and relationships * - contentType: "application/json" * - lastModified: ISO timestamp of snapshot generation * - cacheKey: Unique identifier for caching * - ttl: Cache duration (60 seconds for real-time memory access) * - etag: Entity tag for cache validation * * @throws {Error} When memory system access fails or query parameters invalid * * @example * ```typescript * // Get current memory snapshot * const current = await generateMemorySnapshotsResource({}, new URLSearchParams()); * console.log(`Total memories: ${current.data.summary.total}`); * console.log(`Recent analyses: ${current.data.recent.analyses.length}`); * * // Get historical snapshots since specific date * const historical = await generateMemorySnapshotsResource( * {}, * new URLSearchParams('type=historical&since=2025-10-01T00:00:00Z&limit=50') * ); * * // Filter by project * const projectMemory = await generateMemorySnapshotsResource( * {}, * new URLSearchParams('projectId=mcp-adr-analysis-server') * ); * * // Expected output structure: * { * data: { * snapshot: { * id: "snapshot-2025-10-12", * timestamp: "2025-10-12T17:00:00.000Z", * type: "current" * }, * summary: { * total: 150, * byType: { * analysis: 50, * recommendation: 40, * deployment: 30, * configuration: 20, * interaction: 10 * } * }, * recent: { * analyses: [...], * recommendations: [...], * deployments: [...] * }, * insights: { * patterns: ["Frequent deployment on Fridays", "High test coverage correlates with success"], * predictions: ["Next deployment likely to succeed (95% confidence)"] * } * }, * contentType: "application/json", * cacheKey: "memory-snapshots:current", * ttl: 60 * } * ``` * * @since v2.0.0 * @see {@link MemorySnapshotsResource} for underlying memory access implementation */ export declare function generateMemorySnapshotsResource(_params?: Record<string, string>, searchParams?: URLSearchParams): Promise<{ data: any; contentType: string; lastModified: string; cacheKey: string; ttl: number; etag: string; }>; //# sourceMappingURL=memory-snapshots-resource.d.ts.map