File size: 4,609 Bytes
38c39af
 
d317445
 
 
38c39af
d317445
38c39af
 
 
d317445
 
 
 
 
 
 
 
38c39af
 
d317445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122066b
d317445
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122066b
 
d317445
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
---
title: Long Term Memory MCP Server
emoji: ๐Ÿง 
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: "4.0.0"
app_file: app.py
pinned: false
license: mit
tags:
  - mcp-server-track
  - mcp
  - memory
  - rag
  - llm
  - conversation
short_description: MCP Server providing long-term memory for LLM conversations
---

# ๐Ÿง  Long Term Memory MCP Server

**Tags**: mcp-server-track

A Model Context Protocol (MCP) server that provides long-term memory capabilities for LLM conversations. This allows users to save important insights, conclusions, and context from conversations and retrieve them in future interactions.

## ๐ŸŽฏ Problem Solved

Current LLM interactions are stateless - they don't remember previous conversations or insights you've shared. This MCP server solves that by providing:

- **Persistent Memory**: Save important insights and context from conversations
- **Semantic Search**: Find relevant memories using natural language queries
- **Context Continuity**: Build upon previous conversations and learnings
- **Knowledge Accumulation**: Build a personal knowledge base over time

## ๐Ÿš€ Features

### MCP Server Tools
- `save_memory` - Save insights, conclusions, or context to long-term memory
- `search_memory` - Search through memories using semantic similarity
- `list_memories` - Browse all stored memories
- `delete_memory` - Remove specific memories

### Gradio Demo Interface
- Interactive web interface for testing all MCP tools
- Real-time memory statistics
- Semantic search with adjustable similarity thresholds
- Memory browsing and management

## ๐Ÿ› ๏ธ Technical Architecture

- **MCP Protocol**: Standards-compliant MCP server
- **Vector Storage**: ChromaDB for efficient semantic search
- **Embeddings**: SentenceTransformers (all-MiniLM-L6-v2) for semantic understanding
- **Interface**: Gradio web app for demonstration and testing
- **Storage**: Persistent local database

## ๐Ÿ“ฆ Installation & Usage

### Local Development
```bash
# Clone and install dependencies
pip install -r requirements.txt

# Run the application
python app.py
```

### Hugging Face Spaces
This Space runs both the MCP server and Gradio demo simultaneously.

## ๐ŸŽฎ Demo Video

-

## ๐Ÿ’ก Use Cases

### Example Scenario
1. **Initial Conversation**: You discuss quantum consciousness theories with an LLM
2. **Save Insight**: Use `save_memory` to store key conclusions
3. **Future Conversation**: LLM can `search_memory` to find relevant context
4. **Continuity**: Build upon previous insights in new discussions

### Sample Usage with Claude Desktop

**Saving a memory:**
```
User: "Save this insight to memory: 'Consciousness might emerge from quantum processes in microtubules, as proposed by Penrose-Hameroff theory. This could explain the hard problem of consciousness.' Title: 'Quantum Consciousness Theory', Tags: 'consciousness, quantum, penrose, microtubules'"

LLM: *Uses save_memory tool*
โœ… Memory saved successfully! ID: abc123...
```

**Searching memories:**
```
User: "What did we previously discuss about consciousness and quantum physics?"

LLM: *Uses search_memory tool*
๐Ÿ” Found relevant memory: "Quantum Consciousness Theory" - discusses how consciousness might emerge from quantum processes in microtubules...
```

## ๐Ÿ”ง MCP Client Configuration

### Claude Desktop
Add to your `claude_desktop_config.json`:
```json
{
  "mcpServers": {
    "long-term-memory": {
      "command": "python",
      "args": ["path/to/mcp_server.py"],
      "env": {}
    }
  }
}
```

### Cursor IDE
Configure in your MCP settings to connect to the server.

## ๐Ÿ“Š Memory Statistics

The system tracks:
- Total memories stored
- Content length statistics
- Tag usage patterns
- Timestamp-based organization

## ๐Ÿ” Privacy & Data

- All data stored locally in ChromaDB
- No external API calls for embeddings (uses local SentenceTransformers)
- Full control over your memory data
- Easy export/import capabilities

## ๐Ÿšง Future Enhancements

- [ ] Memory categorization and hierarchical organization
- [ ] Conversation threading and context linking
- [ ] Export/import functionality
- [ ] Advanced search filters (date, tags, content type)
- [ ] Memory summarization and consolidation
- [ ] Integration with external knowledge bases

## ๐Ÿค Contributing

This project was created for the [Hugging Face MCP Hackathon](https://huggingface.co/Agents-MCP-Hackathon). Contributions welcome!

## ๐Ÿ“ License

MIT License - Feel free to use and modify!

## Author
- [Andrei Zagrebin] (@cheeeaaat)
---

*Built with โค๏ธ for the Hugging Face MCP Hackathon - Track 1: MCP Server/Tool*