You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A service that provides memory management for AI applications using Redis. This server helps manage both short-term and long-term memory for AI conversations, with features like automatic topic extraction, entity recognition, and context summarization.
3
+
Redis Memory Server is a high-performance and flexible server for managing
4
+
short-term and long-term memory for agents using Redis. It provides both REST
5
+
API endpoints and an MCP (Managed Control Plane) server interface for robust
6
+
memory operations in AI applications.
4
7
5
8
## Features
6
9
7
10
-**Short-Term Memory Management**
8
11
- Configurable window size for recent messages
9
-
- Automatic context summarization using LLMs
12
+
- Automatic conversation summarization using LLMs
10
13
- Token limit management based on model capabilities
11
14
12
15
-**Long-Term Memory**
13
-
- Semantic search capabilities
16
+
- Semantic search over messages
14
17
- Automatic message indexing
15
-
- Configurable memory retention
18
+
- Topic modeling with BERTopic
19
+
- Named Entity Recognition using BERT
16
20
17
21
-**Advanced Features**
18
-
- Topic extraction using BERTopic
19
-
- Named Entity Recognition using BERT
20
-
- Support for multiple model providers (OpenAI and Anthropic)
22
+
- Support for OpenAI and Anthropic model providers
21
23
- Namespace support for session isolation
22
24
23
-
## Get Started
24
25
25
-
### Docker Compose
26
+
##REST API Endpoints
26
27
27
-
To start the API using Docker Compose, follow these steps:
28
+
The following endpoints are available:
28
29
29
-
1. Ensure that Docker and Docker Compose are installed on your system.
30
+
-**GET /health**
31
+
A simple health check endpoint returning the current server time.
32
+
Example Response:
33
+
```json
34
+
{"now": 1616173200}
35
+
```
30
36
31
-
2. Open a terminal in the project root directory (where the docker-compose.yml file is located).
37
+
-**GET /sessions/**
38
+
Retrieves a paginated list of session IDs.
39
+
_Query Parameters:_
40
+
-`page` (int): Page number (default: 1)
41
+
-`size` (int): Number of sessions per page (default: 10)
42
+
-`namespace` (string, optional): Filter sessions by namespace.
32
43
33
-
3. (Optional) Set up your environment variables (such as OPENAI_API_KEY and ANTHROPIC_API_KEY) either in a .env file or by modifying the docker-compose.yml as needed.
44
+
-**GET /sessions/{session_id}/memory**
45
+
Retrieves conversation memory for a session, including messages and context.
34
46
35
-
4. Build and start the containers by running:
36
-
docker-compose up --build
37
-
38
-
5. Once the containers are up, the API will be available at http://localhost:8000. You can also access the interactive API documentation at http://localhost:8000/docs.
39
-
40
-
6. To stop the containers, press Ctrl+C in the terminal and then run:
41
-
docker-compose down
42
-
43
-
Happy coding!
47
+
-**POST /sessions/{session_id}/memory**
48
+
Adds messages (and optional context) to a session's memory.
49
+
_Request Body Example:_
50
+
```json
51
+
{
52
+
"messages": [
53
+
{"role": "user", "content": "Hello"},
54
+
{"role": "assistant", "content": "Hi there"}
55
+
],
56
+
"context": "Optional context"
57
+
}
58
+
```
44
59
60
+
-**DELETE /sessions/{session_id}/memory**
61
+
Deletes all stored memory (messages, context, token count) for a session.
45
62
46
-
## API Reference
63
+
-**POST /sessions/{session_id}/search**
64
+
Performs a semantic search on the messages within a session.
65
+
_Request Body Example:_
66
+
```json
67
+
{
68
+
"text": "Search query text"
69
+
}
70
+
```
47
71
48
-
### API Docs
72
+
## MCP Server Interface
73
+
Redis Memory Server also offers an MCP (Model Context Protocol) server interface powered by FastMCP, providing tool-based memory operations:
49
74
50
-
API documentation is available at: http://localhost:8000/docs.
75
+
-**list_sessions**: Retrieve available memory sessions with optional pagination.
76
+
-**get_session_memory**: Fetch memory (messages and context) for a specific session.
77
+
-**add_memory**: Add messages and context to a session's memory.
78
+
-**delete_session_memory**: Remove all memory data for a session.
79
+
-**search_memory**: Perform semantic search across session messages.
80
+
-**memory_prompt**: Generate prompts enriched with memory context and long-term memories.
51
81
52
-
### Endpoint Preview
82
+
##Getting Started
53
83
54
-
#### List Sessions
55
-
```http
56
-
GET /sessions/
57
-
```
84
+
### Local Install
58
85
59
-
Query Parameters:
60
-
-`page` (int): Page number (default: 1)
61
-
-`size` (int): Items per page (default: 10)
62
-
-`namespace` (string, optional): Filter sessions by namespace
63
-
64
-
Response:
65
-
```json
66
-
[
67
-
"session-1",
68
-
"session-2"
69
-
]
70
-
```
86
+
1. Install the package and required dependencies:
87
+
```bash
88
+
pip install -e .
89
+
```
71
90
72
-
#### Get Memory
73
-
```http
74
-
GET /sessions/{session_id}/memory
75
-
```
91
+
2. Start both the REST API server and MCP server:
92
+
```bash
93
+
python -m redis_memory_server.main
76
94
77
-
Response:
78
-
```json
79
-
{
80
-
"messages": [
81
-
{
82
-
"role": "user",
83
-
"content": "Hello, how are you?",
84
-
"topics": ["greeting", "well-being"],
85
-
"entities": []
86
-
}
87
-
],
88
-
"context": "Optional context for the conversation",
89
-
"tokens": 123
90
-
}
91
-
```
95
+
### Docker Compose
92
96
93
-
#### Add Messages to Memory
94
-
```http
95
-
POST /sessions/{session_id}/memory
96
-
```
97
+
To start the API using Docker Compose, follow these steps:
97
98
98
-
Request Body:
99
-
```json
100
-
{
101
-
"messages": [
102
-
{
103
-
"role": "user",
104
-
"content": "Hello, how are you?"
105
-
}
106
-
],
107
-
"context": "Optional context for the conversation"
108
-
}
109
-
```
99
+
1. Ensure that Docker and Docker Compose are installed on your system.
110
100
111
-
Query Parameters:
112
-
-`namespace` (string, optional): Namespace for the session
101
+
2. Open a terminal in the project root directory (where the docker-compose.yml file is located).
113
102
114
-
Response:
115
-
```json
116
-
{
117
-
"status": "ok"
118
-
}
119
-
```
103
+
3. (Optional) Set up your environment variables (such as OPENAI_API_KEY and ANTHROPIC_API_KEY) either in a .env file or by modifying the docker-compose.yml as needed.
120
104
121
-
#### Delete Session
122
-
```http
123
-
DELETE /sessions/{session_id}/memory
124
-
```
105
+
4. Build and start the containers by running:
106
+
docker-compose up --build
125
107
126
-
Query Parameters:
127
-
-`namespace` (string, optional): Namespace for the session
108
+
5. Once the containers are up, the API will be available at http://localhost:8000. You can also access the interactive API documentation at http://localhost:8000/docs.
128
109
129
-
Response:
130
-
```json
131
-
{
132
-
"status": "ok"
133
-
}
134
-
```
110
+
6. To stop the containers, press Ctrl+C in the terminal and then run:
111
+
docker-compose down
135
112
136
113
## Configuration
137
114
@@ -152,40 +129,23 @@ You can configure the service using environment variables:
0 commit comments