mongodb-memory-bank-mcp
Version:
FIXED: MongoDB Memory Bank MCP with bulletproof error handling, smart operations, and session state management. Eliminates [object Object] errors and user confusion.
33 lines (32 loc) • 1.21 kB
JavaScript
export class ProjectContext {
memoryRepository;
projectRepository;
constructor(memoryRepository, projectRepository) {
this.memoryRepository = memoryRepository;
this.projectRepository = projectRepository;
}
async getContext(params) {
const { projectName, limit = 20 } = params;
// Ensure project exists
await this.projectRepository.ensureProject(projectName);
// Get project stats
const stats = await this.memoryRepository.getProjectStats(projectName);
// Get recent memories
const memories = await this.memoryRepository.listByProject(projectName);
const limitedMemories = memories.slice(0, limit);
// Create project object
const project = {
name: projectName,
createdAt: new Date(), // This would come from actual project data in full implementation
lastAccessed: stats.lastActivity,
memoryCount: stats.totalMemories,
tags: stats.commonTags
};
return {
project,
memories: limitedMemories,
totalWords: stats.totalWords,
commonTags: stats.commonTags
};
}
}