# 3737123dush/mem0-mcp architecture

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

- Interactive diagram: https://gitdiagram.com/3737123dush/mem0-mcp
- Repository: https://github.com/3737123dush/mem0-mcp

## Overview

This repository offers two MCP servers for memory: a Python SSE server focused on coding preferences, and a Node.js stdio server for general memories. Clients invoke tools to add or search content, which the servers pass to Mem0; the Python server also exposes a tool to list all preferences. Both implementations are evidenced in source, while the README documents the Python/Cursor workflow. The graph omits unshown protocol internals.

Main entry points: [`main.py`](https://github.com/3737123dush/mem0-mcp/blob/main/main.py) (MCP tool server), [`node/mem0/src/index.ts`](https://github.com/3737123dush/mem0-mcp/blob/main/node/mem0/src/index.ts) (Tool dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_py_transport["Python SSE server"]
  node_python_sse["SSE endpoint<br/>[main.py]"]
  node_python_mcp["MCP tool server<br/>[main.py]"]
end

subgraph group_py_tools["Coding preference tools"]
  node_add_preference["Add preference<br/>[main.py]"]
  node_list_preferences["List preferences<br/>[main.py]"]
  node_search_preferences["Search preferences<br/>[main.py]"]
end

subgraph group_node_server["Node stdio server"]
  node_stdio_server["MCP stdio server<br/>[index.ts]"]
  node_tool_dispatch["Tool dispatch<br/>[index.ts]"]
  node_add_memory["Add memory<br/>[index.ts]"]
  node_search_memories["Search memories<br/>[index.ts]"]
end

node_cursor(("Cursor or MCP client"))
node_mem0_service["Mem0 API"]
node_mcp_client(("MCP client"))

node_cursor -->|"connects to"| node_python_sse
node_python_sse -->|"runs MCP"| node_python_mcp
node_python_mcp -->|"dispatches tool"| node_add_preference
node_python_mcp -->|"dispatches tool"| node_list_preferences
node_python_mcp -->|"dispatches tool"| node_search_preferences
node_add_preference -->|"adds memory"| node_mem0_service
node_list_preferences -->|"gets memories"| node_mem0_service
node_search_preferences -->|"searches memories"| node_mem0_service
node_mcp_client -->|"connects over stdio"| node_stdio_server
node_stdio_server -->|"handles requests"| node_tool_dispatch
node_tool_dispatch -->|"dispatches add"| node_add_memory
node_tool_dispatch -->|"dispatches search"| node_search_memories
node_add_memory -->|"adds memory"| node_mem0_service
node_search_memories -->|"searches memories"| node_mem0_service

click node_python_sse "https://github.com/3737123dush/mem0-mcp/blob/main/main.py"
click node_python_mcp "https://github.com/3737123dush/mem0-mcp/blob/main/main.py"
click node_add_preference "https://github.com/3737123dush/mem0-mcp/blob/main/main.py"
click node_list_preferences "https://github.com/3737123dush/mem0-mcp/blob/main/main.py"
click node_search_preferences "https://github.com/3737123dush/mem0-mcp/blob/main/main.py"
click node_stdio_server "https://github.com/3737123dush/mem0-mcp/blob/main/node/mem0/src/index.ts"
click node_tool_dispatch "https://github.com/3737123dush/mem0-mcp/blob/main/node/mem0/src/index.ts"
click node_add_memory "https://github.com/3737123dush/mem0-mcp/blob/main/node/mem0/src/index.ts"
click node_search_memories "https://github.com/3737123dush/mem0-mcp/blob/main/node/mem0/src/index.ts"

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_python_sse,node_python_mcp,node_cursor,node_mcp_client toneBlue
class node_add_preference,node_list_preferences,node_search_preferences toneAmber
class node_stdio_server,node_tool_dispatch,node_add_memory,node_search_memories,node_mem0_service toneMint
```

## Components

### Python SSE server

- [SSE endpoint](https://github.com/3737123dush/mem0-mcp/blob/main/main.py): `main.py`
- [MCP tool server](https://github.com/3737123dush/mem0-mcp/blob/main/main.py): `main.py`

### Coding preference tools

- [Add preference](https://github.com/3737123dush/mem0-mcp/blob/main/main.py): `main.py`
- [List preferences](https://github.com/3737123dush/mem0-mcp/blob/main/main.py): `main.py`
- [Search preferences](https://github.com/3737123dush/mem0-mcp/blob/main/main.py): `main.py`

### Node stdio server

- [MCP stdio server](https://github.com/3737123dush/mem0-mcp/blob/main/node/mem0/src/index.ts): `node/mem0/src/index.ts`
- [Tool dispatch](https://github.com/3737123dush/mem0-mcp/blob/main/node/mem0/src/index.ts): `node/mem0/src/index.ts`
- [Add memory](https://github.com/3737123dush/mem0-mcp/blob/main/node/mem0/src/index.ts): `node/mem0/src/index.ts`
- [Search memories](https://github.com/3737123dush/mem0-mcp/blob/main/node/mem0/src/index.ts): `node/mem0/src/index.ts`

### Other components

- **Cursor or MCP client**
- **Mem0 API**
- **MCP client**

## Connections

- Cursor or MCP client → SSE endpoint: connects to (evidence: `README.md`)
- SSE endpoint → MCP tool server: runs MCP (evidence: `main.py`)
- MCP tool server → Add preference: dispatches tool (evidence: `main.py`)
- MCP tool server → List preferences: dispatches tool (evidence: `main.py`)
- MCP tool server → Search preferences: dispatches tool (evidence: `main.py`)
- Add preference → Mem0 API: adds memory (evidence: `main.py`)
- List preferences → Mem0 API: gets memories (evidence: `main.py`)
- Search preferences → Mem0 API: searches memories (evidence: `main.py`)
- MCP client → MCP stdio server: connects over stdio (evidence: `node/mem0/src/index.ts`)
- MCP stdio server → Tool dispatch: handles requests (evidence: `node/mem0/src/index.ts`)
- Tool dispatch → Add memory: dispatches add (evidence: `node/mem0/src/index.ts`)
- Tool dispatch → Search memories: dispatches search (evidence: `node/mem0/src/index.ts`)
- Add memory → Mem0 API: adds memory (evidence: `node/mem0/src/index.ts`)
- Search memories → Mem0 API: searches memories (evidence: `node/mem0/src/index.ts`)
