How jktfe/myaimemory-mcp works
Main Components
• Client Interfaces & Command-Line Tools:
– The CLI (exposed via files like src/cli.ts and unified CLI commands) and direct scripts (e.g., direct-server.ts, direct-mcp.ts) that trigger memory updates.
– Shell scripts and Docker integration (Dockerfile, start-server.sh, etc.) which reflect deployment options.
• Transport Layer:
– Two main transport strategies are supported: HTTP (e.g., HttpTransport.ts, start-http-server.sh) and stdio (e.g., StdioTransport.ts).
– Indicate this layer as managing communication between client commands and the MCP server.
• Core MCP Engine:
– Includes core server components (e.g., ServerFactory.ts, MCP server implementations in src/core/server) that manage MCP communication.
– Handlers (DirectRequestHandler.ts, ToolHandlers.ts) which parse and process memory commands.
– Service Factories and services (e.g., PlatformService.ts, TemplateService.ts, CustomPlatformService.ts) for managing memory updates and platform synchronization.
• Memory Management Modules:
– Template Parser and Template Storage (templateParser.ts, templateStorage.ts) for converting between markdown format and structured memory objects.
– Memory Cache Service (MemoryCommandProcessor.ts) implementing caching with TTL-based strategies.
• Platform Synchronizers:
– Components responsible for interfacing with external systems (e.g., ClaudeDesktop, Windsurf, and possibly ClaudeWeb) are evident from the README and the file organization in services and platform-related utilities.
• Configuration & Environment:
– Support files like .env.example, config.json, and scripts (update-config.js, setupConfig.ts) indicate where system configuration is managed.
Relationships and Data/Control Flow
• User or system administrator triggers a memory update via the CLI or directly (using natural language commands described in the README).
• The input flows to the MCP server entry point (either via HTTP or stdio).
• The server then invokes the appropriate handler (DirectRequestHandler or ToolHandlers) to process the natural language command.
• The handler interacts with the core services: the Template Parser converts the markdown template to structured memory, and the Template Storage and Memory Cache Service handle local caching and persistence.
• Platform synchronizers (through PlatformService and associated adapters) push updates to configured endpoints (Claude Desktop, Claude Code, Windsurf, etc.).
• The overall system responds with confirmations and/or error messages, and the caching mechanism ensures high performance.
Architectural Patterns and Design Principles
• Modular Design: The separation between core modules (handlers, server, services, transport) ensures separation of concerns.
• Pluggable Transport Strategies: Using different transport methods (HTTP vs. stdio) allows the system to serve multiple integration scenarios.
• Command and Event Handling: Natural language commands are parsed and routed through dedicated handlers that update defined memory sections.
• Local-First and Security-Oriented: Emphasis on local data storage combined with robust testing (__tests__ folder) and controlled configuration (.env, .gitignore).
Relevant Technologies
• Languages & Framework: TypeScript is the primary language; Node.js runtime environment.
• Testing: Jest structure indicated by __tests__ folder and jest.config.js.
• Containerization: Dockerfile indicates a containerized deployment option.
• Scripting: Extensive use of shell scripts for various startup, sync, and permission fixing tasks.
• External API Integration: Optional use of Anthropic API as shown by environment variable ENABLE_ANTHROPIC.