Skip to main content
Glama
AnisHerdev

Personal Assistant Memory Server

by AnisHerdev
README.md
# Expt 1: The "Personal Assistant" Memory Server (MCP SSE Service)

A complete implementation of a **Personal Assistant Memory Server** running as a **persistent background service (SSE / HTTP)** and an **MCP Client** powered by **Ollama (Local LLM)**.

---

## šŸ—ļø Architecture

```mermaid
flowchart LR
    subgraph BackgroundService["Background Service"]
        Server["server.py<br>MCP SSE Server<br>http://127.0.0.1:8000/sse"] --> DB[("notes.json")]
    end

    subgraph ClientApp["Client Application"]
        User["User Query"] --> Client["client.py<br>MCP Client"]
        Client -- "1. Tool Decision" --> LLM["Local Ollama LLM<br>(qwen2.5, llama3.2)"]
        Client -- "2. HTTP / SSE Calls" --> Server
    end
```

### Components:
- **Persistent MCP Server (`server.py`)**: Runs continuously as an SSE (Server-Sent Events) daemon on `http://127.0.0.1:8000/sse`. Exposes CRUD tools:
  - `save_note(content, tags)`: Saves a note with timestamp, ID, content, and tags.
  - `search_notes(query)`: Searches note content and tags.
  - `list_notes()`: Returns all stored notes.
  - `update_note(note_id, content, tags)`: Updates an existing note.
  - `delete_note(note_id)`: Removes a note from memory.
- **Database (`notes.json`)**: Persistent local JSON storage for notes.
- **MCP Client (`client.py`)**:
  - Connects to the running server over SSE (`http://127.0.0.1:8000/sse`).
  - Discovers tools dynamically from the server.
  - Uses Ollama LLM to decide whether to save, search, update, or delete notes based on user prompts.

---

## šŸš€ How to Run

### Step 1: Start the Background MCP Server (Terminal 1)

Open a terminal and start the server daemon:

```bash
python server.py
```

*Output:*
```
==================================================
šŸš€ Personal Assistant Memory Server (MCP SSE Service)
šŸ“” Listening on: http://127.0.0.1:8000/sse
šŸ› ļø  Exposed Tools: save_note, search_notes, list_notes, update_note, delete_note
šŸ’¾ Database: notes.json
==================================================
```

---

### Step 2: Run the MCP Client (Terminal 2)

With the server running in the background, open a second terminal and interact with it:

#### A. Interactive Mode
```bash
python client.py
```
```
You > Remember to submit the project report by Friday. Tag it as project and report.
>> [MCP Tool Call] -> save_note
   Arguments: {"content": "Submit the project report by Friday.", "tags": ["project", "report"]}
   Result: Note saved successfully with ID: a1b2c3d4 and tags: ['project', 'report']
Assistant > Saved your reminder to submit the project report by Friday.

You > When do I need to submit the report?
>> [MCP Tool Call] -> search_notes
   Arguments: {"query": "report"}
   Result: [...]
Assistant > The project report needs to be submitted by Friday.
```

#### B. One-Shot Query Mode
```bash
# Save note
python client.py "Save a note: Team standup is daily at 10 AM on Zoom. Tag: meeting, standup"

# Search notes
python client.py "When is the team standup?"

# List all notes
python client.py "Show me all my saved notes"
```

---

## šŸ“‚ Project Structure

```
personal-assistant-wwllm/
ā”œā”€ā”€ server.py          # Persistent MCP Server (SSE / HTTP Daemon)
ā”œā”€ā”€ client.py          # Interactive MCP Client with Ollama LLM
ā”œā”€ā”€ notes.json         # Local persistent memory store
ā”œā”€ā”€ requirements.txt   # Dependencies
└── README.md          # Documentation
```