# kamalesh0081/mcp-aws-memory-agent architecture

> Architecture diagram of the GitHub repository kamalesh0081/mcp-aws-memory-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kamalesh0081/mcp-aws-memory-agent
- Repository: https://github.com/kamalesh0081/mcp-aws-memory-agent

## Overview

This is a command-line conversational memory agent: a user’s message is handled by a LangChain agent using Gemini, which can call MCP memory tools; those tools retrieve or save memories in S3. The main stages are conversation, tool dispatch, memory operations, and persistence, with logging as a supporting layer. The README documents cross-session memory and the Gemini/LangChain/MCP capabilities; the graph follows the sampled source for their wiring. The S3 helper also writes a local JSON copy. Its error path references logging without importing it, so no working logging link from that helper is shown.

Main entry points: [`agent.py`](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/agent.py) (Conversational agent), [`s3_memory.py`](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/s3_memory.py) (S3 memory operations), [`mcp_server.py`](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/mcp_server.py) (MCP server), [`logger.py`](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/logger.py) (Conversation logger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Conversation"]
  node_agent["Conversational agent<br/>[agent.py]"]
  node_gemini{{"Gemini model"}}
end

subgraph group_orchestration["Agent orchestration"]
  node_mcp_client["MCP client<br/>[agent.py]"]
  node_mcp_server["MCP server<br/>[mcp_server.py]"]
end

subgraph group_memory["Memory service"]
  node_save_tool["Save memory tool<br/>[mcp_server.py]"]
  node_get_tool["Retrieve memory tool<br/>[mcp_server.py]"]
end

subgraph group_persistence["Persistence and logs"]
  node_memory_store["S3 memory operations<br/>[s3_memory.py]"]
  node_s3[("AWS S3")]
  node_local_copy["Local memory copy<br/>[user_memory.json]"]
  node_logger["Conversation logger<br/>[logger.py]"]
end

node_user(("User"))

node_user -->|"sends message"| node_agent
node_agent -->|"invokes model"| node_gemini
node_agent -->|"requests tools"| node_mcp_client
node_mcp_client -->|"connects over HTTP"| node_mcp_server
node_mcp_server -->|"registers tool"| node_save_tool
node_mcp_server -->|"registers tool"| node_get_tool
node_save_tool -->|"saves memory"| node_memory_store
node_get_tool -->|"retrieves memories"| node_memory_store
node_memory_store -->|"reads object"| node_s3
node_memory_store -->|"writes object"| node_s3
node_memory_store -->|"writes copy"| node_local_copy
node_agent -->|"logs conversation"| node_logger
node_save_tool -->|"logs save"| node_logger
node_get_tool -->|"logs retrieval"| node_logger
node_agent -->|"shows response"| node_user

click node_agent "https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/agent.py"
click node_mcp_client "https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/agent.py"
click node_mcp_server "https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/mcp_server.py"
click node_save_tool "https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/mcp_server.py"
click node_get_tool "https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/mcp_server.py"
click node_memory_store "https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/s3_memory.py"
click node_local_copy "https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/user_memory.json"
click node_logger "https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/logger.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_agent,node_gemini,node_user toneBlue
class node_mcp_client,node_mcp_server toneAmber
class node_save_tool,node_get_tool toneMint
class node_memory_store,node_s3,node_local_copy,node_logger toneRose
```

## Components

### Conversation

- [Conversational agent](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/agent.py): `agent.py`
- **Gemini model**

### Agent orchestration

- [MCP client](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/agent.py): `agent.py`
- [MCP server](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/mcp_server.py): `mcp_server.py`

### Memory service

- [Save memory tool](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/mcp_server.py): `mcp_server.py`
- [Retrieve memory tool](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/mcp_server.py): `mcp_server.py`

### Persistence and logs

- [S3 memory operations](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/s3_memory.py): `s3_memory.py`
- **AWS S3**
- [Local memory copy](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/user_memory.json): `user_memory.json`
- [Conversation logger](https://github.com/kamalesh0081/mcp-aws-memory-agent/blob/main/logger.py): `logger.py`

### Other components

- **User**

## Connections

- User → Conversational agent: sends message (evidence: `agent.py`)
- Conversational agent → Gemini model: invokes model (evidence: `agent.py`)
- Conversational agent → MCP client: requests tools (evidence: `agent.py`)
- MCP client → MCP server: connects over HTTP (evidence: `agent.py`)
- MCP server → Save memory tool: registers tool (evidence: `mcp_server.py`)
- MCP server → Retrieve memory tool: registers tool (evidence: `mcp_server.py`)
- Save memory tool → S3 memory operations: saves memory (evidence: `mcp_server.py`)
- Retrieve memory tool → S3 memory operations: retrieves memories (evidence: `mcp_server.py`)
- S3 memory operations → AWS S3: reads object (evidence: `s3_memory.py`)
- S3 memory operations → AWS S3: writes object (evidence: `s3_memory.py`)
- S3 memory operations → Local memory copy: writes copy (evidence: `s3_memory.py`)
- Conversational agent → Conversation logger: logs conversation (evidence: `agent.py`)
- Save memory tool → Conversation logger: logs save (evidence: `mcp_server.py`)
- Retrieve memory tool → Conversation logger: logs retrieval (evidence: `mcp_server.py`)
- Conversational agent → User: shows response (evidence: `agent.py`)
