UNPKG

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.

38 lines (37 loc) 1.44 kB
import { badRequest, ok, serverError } from "../../helpers/index.js"; /** * Controller for structured memory storage with template validation * Follows exact same pattern as existing MemoryStoreController */ export class MemoryStoreStructuredController { memoryStoreStructured; validator; constructor(memoryStoreStructured, validator) { this.memoryStoreStructured = memoryStoreStructured; this.validator = validator; } async handle(request) { try { const validationError = this.validator.validate(request.body); if (validationError) { return badRequest(validationError); } const { projectName, fileName, content, memoryType, tags } = request.body; const result = await this.memoryStoreStructured.execute({ fileName, content, memoryType, projectName, // These will be handled by the universal adapter forceDetection: false, validateIsolation: true, workingDirectory: '.', preferredProjectName: undefined }); return ok(`Structured memory "${fileName}" (${memoryType}) stored successfully in project ${result.projectContext.projectName} with template validation`); } catch (error) { return serverError(error); } } }