mcp-sqlite-memory-bank 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_sqlite_memory_bank/__init__.py +112 -0
- mcp_sqlite_memory_bank/py.typed +0 -0
- mcp_sqlite_memory_bank/server.py +1015 -0
- mcp_sqlite_memory_bank/types.py +165 -0
- mcp_sqlite_memory_bank/utils.py +195 -0
- mcp_sqlite_memory_bank-0.1.0.dist-info/METADATA +696 -0
- mcp_sqlite_memory_bank-0.1.0.dist-info/RECORD +10 -0
- mcp_sqlite_memory_bank-0.1.0.dist-info/WHEEL +5 -0
- mcp_sqlite_memory_bank-0.1.0.dist-info/licenses/LICENSE +21 -0
- mcp_sqlite_memory_bank-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,696 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: mcp_sqlite_memory_bank
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: A dynamic, agent/LLM-friendly SQLite memory bank for MCP servers.
|
5
|
+
Home-page: https://github.com/yourusername/mcp_sqlite_memory_bank
|
6
|
+
Author: Robert Meisner
|
7
|
+
Author-email: Robert Meisner <your-email@example.com>
|
8
|
+
License-Expression: MIT
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Classifier: Operating System :: OS Independent
|
11
|
+
Requires-Python: >=3.8
|
12
|
+
Description-Content-Type: text/markdown
|
13
|
+
License-File: LICENSE
|
14
|
+
Requires-Dist: fastapi>=0.100.0
|
15
|
+
Requires-Dist: uvicorn>=0.22.0
|
16
|
+
Requires-Dist: pydantic>=1.10.0
|
17
|
+
Provides-Extra: test
|
18
|
+
Requires-Dist: pytest; extra == "test"
|
19
|
+
Dynamic: license-file
|
20
|
+
|
21
|
+
# mcp_sqlite_memory_bank
|
22
|
+
|
23
|
+

|
24
|
+

|
25
|
+

|
26
|
+
|
27
|
+
## Overview
|
28
|
+
|
29
|
+
**mcp_sqlite_memory_bank** is a dynamic, agent- and LLM-friendly SQLite memory bank designed for Model Context Protocol (MCP) servers and modern AI agent platforms.
|
30
|
+
|
31
|
+
This project provides a robust, discoverable API for creating, exploring, and managing SQLite tables and knowledge graphs. It enables Claude, Anthropic, Github Copilot, Claude Desktop, VS Code, Cursor, and other LLM-powered tools to interact with structured data in a safe, explicit, and extensible way.
|
32
|
+
|
33
|
+
**Key Use Cases:**
|
34
|
+
- Build and query knowledge graphs for semantic search and reasoning
|
35
|
+
- Store, retrieve, and organize notes or structured data for LLM agents
|
36
|
+
- Enable natural language workflows for database management and exploration
|
37
|
+
- Integrate with FastMCP, Claude Desktop, and other agent platforms for seamless tool discovery
|
38
|
+
|
39
|
+
**Why mcp_sqlite_memory_bank?**
|
40
|
+
- Explicit, discoverable APIs for LLMs and agents
|
41
|
+
- Safe, parameterized queries and schema management
|
42
|
+
- Designed for extensibility and open source collaboration
|
43
|
+
|
44
|
+
---
|
45
|
+
|
46
|
+
## Features
|
47
|
+
|
48
|
+
- **Dynamic Table Management:** Create, list, describe, rename, and drop tables at runtime
|
49
|
+
- **CRUD Operations:** Insert, read, update, and delete rows in any table
|
50
|
+
- **Safe SQL:** Run parameterized SELECT queries with input validation
|
51
|
+
- **Knowledge Graph Tools:** Built-in support for node/edge schemas and property graphs
|
52
|
+
- **Agent/LLM Integration:** Explicit, tool-based APIs for easy discovery and automation
|
53
|
+
- **Open Source:** MIT licensed, fully tested, and ready for community use
|
54
|
+
|
55
|
+
---
|
56
|
+
|
57
|
+
|
58
|
+
## Tools & API Reference
|
59
|
+
|
60
|
+
All tools are designed for explicit, discoverable use by LLMs, agents, and developers. Each function is available as a direct Python import and as an MCP tool.
|
61
|
+
|
62
|
+
### Table Management Tools
|
63
|
+
|
64
|
+
| Tool | Description | Required Parameters | Optional Parameters |
|
65
|
+
|------|-------------|---------------------|---------------------|
|
66
|
+
| `create_table` | Create new table with custom schema | `table_name` (str), `columns` (list[dict]) | None |
|
67
|
+
| `drop_table` | Delete a table | `table_name` (str) | None |
|
68
|
+
| `rename_table` | Rename an existing table | `old_name` (str), `new_name` (str) | None |
|
69
|
+
| `list_tables` | List all tables | None | None |
|
70
|
+
| `describe_table` | Get schema details | `table_name` (str) | None |
|
71
|
+
| `list_all_columns` | List all columns for all tables | None | None |
|
72
|
+
|
73
|
+
### Data Management Tools
|
74
|
+
|
75
|
+
| Tool | Description | Required Parameters | Optional Parameters |
|
76
|
+
|------|-------------|---------------------|---------------------|
|
77
|
+
| `create_row` | Insert row into table | `table_name` (str), `data` (dict) | None |
|
78
|
+
| `read_rows` | Read rows from table | `table_name` (str) | `where` (dict), `limit` (int) |
|
79
|
+
| `update_rows` | Update existing rows | `table_name` (str), `data` (dict), `where` (dict) | None |
|
80
|
+
| `delete_rows` | Delete rows from table | `table_name` (str), `where` (dict) | None |
|
81
|
+
| `run_select_query` | Run safe SELECT query | `table_name` (str) | `columns` (list[str]), `where` (dict), `limit` (int) |
|
82
|
+
|
83
|
+
Each tool validates inputs and returns consistent response formats with success/error indicators and appropriate data payloads.
|
84
|
+
|
85
|
+
---
|
86
|
+
|
87
|
+
## Installation & Transport Options
|
88
|
+
|
89
|
+
**Requirements:**
|
90
|
+
- Python 3.8 or higher (required packages specified in pyproject.toml)
|
91
|
+
- FastAPI, Uvicorn (for server mode)
|
92
|
+
- Supported OS: Windows, macOS, Linux
|
93
|
+
|
94
|
+
### Option 1: Install from PyPI (Recommended)
|
95
|
+
```bash
|
96
|
+
pip install mcp_sqlite_memory_bank
|
97
|
+
```
|
98
|
+
|
99
|
+
### Option 2: Clone and Install from Source (For Contributors)
|
100
|
+
```bash
|
101
|
+
git clone https://github.com/yourusername/mcp_sqlite_memory_bank.git
|
102
|
+
cd mcp_sqlite_memory_bank
|
103
|
+
pip install -e .
|
104
|
+
```
|
105
|
+
|
106
|
+
### Option 3: Run via NPX-style Command
|
107
|
+
```bash
|
108
|
+
python -m pip install --user pipx
|
109
|
+
pipx run mcp_sqlite_memory_bank
|
110
|
+
```
|
111
|
+
|
112
|
+
### Option 4: Run via UVX
|
113
|
+
```bash
|
114
|
+
# Install UVX if you don't have it
|
115
|
+
curl -fsSL https://uvx.zip/install.sh | bash
|
116
|
+
|
117
|
+
# Run directly without installation
|
118
|
+
uvx run mcp_sqlite_memory_bank
|
119
|
+
|
120
|
+
# Or, specify a version
|
121
|
+
uvx run mcp_sqlite_memory_bank@1.0.0
|
122
|
+
```
|
123
|
+
|
124
|
+
### Option 5: Docker (Containerized)
|
125
|
+
```bash
|
126
|
+
# Pull the image
|
127
|
+
docker pull yourusername/mcp_sqlite_memory_bank:latest
|
128
|
+
|
129
|
+
# Run with stdio transport (for Claude Desktop)
|
130
|
+
docker run -i --rm \
|
131
|
+
--mount type=bind,src=/path/to/data/dir,dst=/data \
|
132
|
+
yourusername/mcp_sqlite_memory_bank:latest stdio
|
133
|
+
|
134
|
+
# Run with HTTP transport (for API access)
|
135
|
+
docker run -p 8000:8000 --rm \
|
136
|
+
--mount type=bind,src=/path/to/data/dir,dst=/data \
|
137
|
+
yourusername/mcp_sqlite_memory_bank:latest http
|
138
|
+
```
|
139
|
+
|
140
|
+
### Transport Options
|
141
|
+
|
142
|
+
SQLite Memory Bank currently supports:
|
143
|
+
|
144
|
+
- **stdio** (default): For direct integration with Claude Desktop and other MCP clients
|
145
|
+
|
146
|
+
Planned transport options (not yet implemented):
|
147
|
+
- **http**: For web access and API usage
|
148
|
+
- **streamable-http**: For the latest MCP specification
|
149
|
+
|
150
|
+
Run with the default transport:
|
151
|
+
```bash
|
152
|
+
python -m mcp_sqlite_memory_bank.server
|
153
|
+
```
|
154
|
+
|
155
|
+
---
|
156
|
+
|
157
|
+
## Setup and Configuration
|
158
|
+
|
159
|
+
You can configure the database path and other options via environment variables or a `.env` file in your project root.
|
160
|
+
|
161
|
+
**Environment Variables:**
|
162
|
+
- `DB_PATH`: Path to the SQLite database file (default: `./test.db`)
|
163
|
+
- Any other options supported by the server (see API docs)
|
164
|
+
|
165
|
+
**Example `.env`:**
|
166
|
+
```env
|
167
|
+
DB_PATH=./test.db
|
168
|
+
```
|
169
|
+
|
170
|
+
---
|
171
|
+
|
172
|
+
## Integration with Editors & Agent Platforms
|
173
|
+
|
174
|
+
### VS Code Integration
|
175
|
+
|
176
|
+
#### Quick Install
|
177
|
+
[Install with Python Module in VS Code](https://insiders.vscode.dev/redirect/mcp/install?name=sqlite-memory&config=%7B%22command%22%3A%22python%22%2C%22args%22%3A%5B%22-m%22%2C%22mcp_sqlite_memory_bank%22%5D%7D)
|
178
|
+
|
179
|
+
[Install with Docker in VS Code](https://insiders.vscode.dev/redirect/mcp/install?name=sqlite-memory&config=%7B%22command%22%3A%22docker%22%2C%22args%22%3A%5B%22run%22%2C%22-i%22%2C%22--rm%22%2C%22--mount%22%2C%22type%3Dbind%2Csrc%3D%24%7BworkspaceFolder%7D%2Cdst%3D%2Fdata%22%2C%22yourusername%2Fmcp_sqlite_memory_bank%3Alatest%22%5D%7D)
|
180
|
+
|
181
|
+
#### Manual Configuration
|
182
|
+
|
183
|
+
Add or update `.vscode/mcp.json` in your project root:
|
184
|
+
```jsonc
|
185
|
+
{
|
186
|
+
"servers": {
|
187
|
+
"SQLite_Memory": {
|
188
|
+
"type": "stdio",
|
189
|
+
"command": "python",
|
190
|
+
"args": ["-m", "mcp_sqlite_memory_bank.server"],
|
191
|
+
"env": {
|
192
|
+
"DB_PATH": "${workspaceFolder}/data/memory.db"
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}
|
197
|
+
```
|
198
|
+
|
199
|
+
## FastMCP Integration (Planned)
|
200
|
+
|
201
|
+
```bash
|
202
|
+
# Coming soon - not yet implemented
|
203
|
+
fastmcp install mcp_sqlite_memory_bank/server.py --name "SQLite Memory Bank"
|
204
|
+
```
|
205
|
+
|
206
|
+
### Claude Desktop Integration
|
207
|
+
|
208
|
+
Add to your `claude_desktop_config.json`:
|
209
|
+
|
210
|
+
```jsonc
|
211
|
+
{
|
212
|
+
"mcpServers": {
|
213
|
+
"sqlite_memory": {
|
214
|
+
"command": "python",
|
215
|
+
"args": ["-m", "mcp_sqlite_memory_bank.server"],
|
216
|
+
"env": {
|
217
|
+
"DB_PATH": "/path/to/your/memory.db"
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
222
|
+
```
|
223
|
+
|
224
|
+
#### Docker Option for Claude Desktop
|
225
|
+
|
226
|
+
```jsonc
|
227
|
+
{
|
228
|
+
"mcpServers": {
|
229
|
+
"sqlite_memory": {
|
230
|
+
"command": "docker",
|
231
|
+
"args": [
|
232
|
+
"run",
|
233
|
+
"-i",
|
234
|
+
"--rm",
|
235
|
+
"--mount", "type=bind,src=/path/to/data/dir,dst=/data",
|
236
|
+
"yourusername/mcp_sqlite_memory_bank:latest"
|
237
|
+
],
|
238
|
+
"env": {
|
239
|
+
"DB_PATH": "/data/memory.db"
|
240
|
+
}
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
```
|
245
|
+
|
246
|
+
- Open your project in VS Code, Cursor, or Claude Desktop. The MCP server will be auto-discovered by Copilot Chat, Cursor, Claude, or any compatible agent.
|
247
|
+
- Use natural language to create tables, store notes, or build knowledge graphs.
|
248
|
+
|
249
|
+
---
|
250
|
+
|
251
|
+
## Running the Server
|
252
|
+
|
253
|
+
### Transport Options
|
254
|
+
|
255
|
+
SQLite Memory Bank currently supports stdio transport only:
|
256
|
+
|
257
|
+
**Stdio Transport (Default - for Claude Desktop):**
|
258
|
+
```bash
|
259
|
+
python -m mcp_sqlite_memory_bank.server
|
260
|
+
```
|
261
|
+
|
262
|
+
**HTTP Transport (REST API - Planned):**
|
263
|
+
```bash
|
264
|
+
# Coming soon - not yet implemented
|
265
|
+
python -m mcp_sqlite_memory_bank.server http --port 8000
|
266
|
+
```
|
267
|
+
|
268
|
+
**Streamable HTTP Transport (Latest MCP Spec - Planned):**
|
269
|
+
```bash
|
270
|
+
# Coming soon - not yet implemented
|
271
|
+
python -m mcp_sqlite_memory_bank.server streamable-http --port 8000
|
272
|
+
```
|
273
|
+
|
274
|
+
**With the example runner:**
|
275
|
+
```bash
|
276
|
+
python examples/run_server.py
|
277
|
+
```
|
278
|
+
|
279
|
+
**With FastMCP (Planned):**
|
280
|
+
```bash
|
281
|
+
# Coming soon - not yet implemented
|
282
|
+
fastmcp install mcp_sqlite_memory_bank/server.py --name "SQLite Memory Bank"
|
283
|
+
```
|
284
|
+
|
285
|
+
---
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
## Resources
|
290
|
+
|
291
|
+
The server exposes all tools as MCP resources and supports knowledge graph schemas (nodes, edges, properties).
|
292
|
+
|
293
|
+
**Agent & Copilot Usage:**
|
294
|
+
- See [API documentation](docs/api.md) for:
|
295
|
+
- Agent & Copilot usage scenarios (natural language prompt → tool mapping)
|
296
|
+
- Accessibility and security notes
|
297
|
+
- See [Memory usage instructions](examples/memory_instructions.md) for:
|
298
|
+
- Implementing persistent memory for LLM agents
|
299
|
+
- Schema design and best practices for memory management
|
300
|
+
|
301
|
+
**Example Agent Prompt:**
|
302
|
+
> "Create a table called 'tasks' with columns 'id' (integer, primary key) and 'description' (text)."
|
303
|
+
|
304
|
+
This will trigger the `create_table` tool with the appropriate arguments. See the API docs for more agent prompt examples.
|
305
|
+
|
306
|
+
---
|
307
|
+
|
308
|
+
## Usage Examples
|
309
|
+
|
310
|
+
### Quickstart: Basic Table
|
311
|
+
```python
|
312
|
+
from mcp_sqlite_memory_bank import create_table, create_row, read_rows
|
313
|
+
|
314
|
+
create_table(
|
315
|
+
"notes",
|
316
|
+
[
|
317
|
+
{"name": "id", "type": "INTEGER PRIMARY KEY AUTOINCREMENT"},
|
318
|
+
{"name": "content", "type": "TEXT"}
|
319
|
+
]
|
320
|
+
)
|
321
|
+
create_row("notes", {"content": "Hello, memory bank!"})
|
322
|
+
rows = read_rows("notes")
|
323
|
+
print(rows)
|
324
|
+
```
|
325
|
+
|
326
|
+
### Knowledge Graph (Nodes & Edges)
|
327
|
+
```python
|
328
|
+
# Basic implementation example for creating knowledge graphs
|
329
|
+
from mcp_sqlite_memory_bank import create_table, create_row, read_rows
|
330
|
+
|
331
|
+
create_table("nodes", [
|
332
|
+
{"name": "id", "type": "INTEGER PRIMARY KEY AUTOINCREMENT"},
|
333
|
+
{"name": "label", "type": "TEXT"}
|
334
|
+
])
|
335
|
+
create_table("edges", [
|
336
|
+
{"name": "id", "type": "INTEGER PRIMARY KEY AUTOINCREMENT"},
|
337
|
+
{"name": "source", "type": "INTEGER"},
|
338
|
+
{"name": "target", "type": "INTEGER"},
|
339
|
+
{"name": "type", "type": "TEXT"}
|
340
|
+
])
|
341
|
+
n1 = create_row("nodes", {"label": "Person"})
|
342
|
+
n2 = create_row("nodes", {"label": "Company"})
|
343
|
+
create_row("edges", {"source": n1["id"], "target": n2["id"], "type": "works_at"})
|
344
|
+
print(read_rows("nodes"))
|
345
|
+
print(read_rows("edges"))
|
346
|
+
```
|
347
|
+
|
348
|
+
### LLM Agent Memory Implementation
|
349
|
+
|
350
|
+
Here's an example of how a Python application might implement memory schemas, but remember that LLMs would interact with these capabilities through MCP tools and natural language:
|
351
|
+
|
352
|
+
```python
|
353
|
+
# Initialize memory schema
|
354
|
+
def initialize_agent_memory():
|
355
|
+
tables = list_tables()
|
356
|
+
|
357
|
+
# Create tables if they don't exist yet
|
358
|
+
if 'user_preferences' not in tables['tables']:
|
359
|
+
create_table('user_preferences', [
|
360
|
+
{"name": "id", "type": "INTEGER PRIMARY KEY AUTOINCREMENT"},
|
361
|
+
{"name": "preference_type", "type": "TEXT NOT NULL"},
|
362
|
+
{"name": "preference_value", "type": "TEXT NOT NULL"},
|
363
|
+
{"name": "context", "type": "TEXT"}
|
364
|
+
])
|
365
|
+
|
366
|
+
# Store a user preference
|
367
|
+
def remember_preference(pref_type, pref_value, context=None):
|
368
|
+
# Check if this preference already exists
|
369
|
+
existing = read_rows('user_preferences', {'preference_type': pref_type})
|
370
|
+
|
371
|
+
if existing['rows']:
|
372
|
+
# Update existing preference
|
373
|
+
update_rows('user_preferences',
|
374
|
+
{'preference_value': pref_value, 'context': context},
|
375
|
+
{'id': existing['rows'][0]['id']})
|
376
|
+
else:
|
377
|
+
# Create new preference
|
378
|
+
create_row('user_preferences', {
|
379
|
+
'preference_type': pref_type,
|
380
|
+
'preference_value': pref_value,
|
381
|
+
'context': context
|
382
|
+
})
|
383
|
+
|
384
|
+
# Retrieve user preferences
|
385
|
+
preferences = read_rows('user_preferences')
|
386
|
+
print(f"Remembered {len(preferences['rows'])} user preferences")
|
387
|
+
```
|
388
|
+
|
389
|
+
An LLM would accomplish the same tasks with natural language commands like:
|
390
|
+
|
391
|
+
```
|
392
|
+
Create a table called 'user_preferences' with columns for id (auto-incrementing primary key),
|
393
|
+
preference_type (required text), preference_value (required text), and context (optional text).
|
394
|
+
|
395
|
+
Add a row to user_preferences with preference_type="code_style" and preference_value="tabs" and context="User prefers tabs over spaces"
|
396
|
+
|
397
|
+
Find all rows in the user_preferences table
|
398
|
+
```
|
399
|
+
|
400
|
+
For a complete agent memory implementation example, see [examples/agent_memory_example.py](examples/agent_memory_example.py) and the detailed [memory usage instructions](examples/memory_instructions.md).
|
401
|
+
|
402
|
+
---
|
403
|
+
|
404
|
+
|
405
|
+
## Running Tests
|
406
|
+
|
407
|
+
If you are using the `src/` layout, set the Python path so tests can import the package:
|
408
|
+
|
409
|
+
**On Windows (PowerShell):**
|
410
|
+
```powershell
|
411
|
+
$env:PYTHONPATH = 'src'
|
412
|
+
pytest
|
413
|
+
```
|
414
|
+
**On Linux/macOS:**
|
415
|
+
```bash
|
416
|
+
PYTHONPATH=src pytest
|
417
|
+
```
|
418
|
+
Or, use:
|
419
|
+
```bash
|
420
|
+
pytest --import-mode=importlib
|
421
|
+
```
|
422
|
+
|
423
|
+
---
|
424
|
+
|
425
|
+
|
426
|
+
## Support & Contact
|
427
|
+
|
428
|
+
- [GitHub Issues](https://github.com/yourusername/mcp_sqlite_memory_bank/issues) — Bug reports & feature requests
|
429
|
+
- [GitHub Discussions](https://github.com/yourusername/mcp_sqlite_memory_bank/discussions) — Q&A and community support
|
430
|
+
- Email: your@email.com
|
431
|
+
|
432
|
+
---
|
433
|
+
|
434
|
+
## Contributing
|
435
|
+
|
436
|
+
Pull requests, issues, and suggestions are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
437
|
+
|
438
|
+
See [docs/api.md](docs/api.md) for a full API reference and [examples/run_server.py](examples/run_server.py) for a server example.
|
439
|
+
|
440
|
+
---
|
441
|
+
|
442
|
+
## License
|
443
|
+
|
444
|
+
MIT
|
445
|
+
|
446
|
+
---
|
447
|
+
|
448
|
+
## LLM Agent Memory Implementation
|
449
|
+
|
450
|
+
The SQLite Memory Bank provides a powerful foundation for implementing persistent memory in LLM agents, enabling them to maintain context across conversation sessions and provide more coherent, personalized assistance.
|
451
|
+
|
452
|
+
### Memory Management for LLM Agents
|
453
|
+
|
454
|
+
LLM agents can leverage the SQLite Memory Bank to store and retrieve:
|
455
|
+
|
456
|
+
1. **User Preferences & Context**
|
457
|
+
- Coding style preferences
|
458
|
+
- Project-specific terminology
|
459
|
+
- Recurring tasks and workflows
|
460
|
+
|
461
|
+
2. **Technical Knowledge**
|
462
|
+
- Project architecture
|
463
|
+
- Design decisions and rationales
|
464
|
+
- Documentation snippets
|
465
|
+
|
466
|
+
3. **Conversation History**
|
467
|
+
- Previous interactions
|
468
|
+
- Incomplete tasks
|
469
|
+
- Follow-up items
|
470
|
+
|
471
|
+
### Memory Schema Example
|
472
|
+
|
473
|
+
When LLMs use SQLite Memory Bank, they interact with it through MCP tools rather than direct Python code. Here's how an LLM might create memory schemas through natural language commands:
|
474
|
+
|
475
|
+
```
|
476
|
+
Create a table called 'project_structure' with columns:
|
477
|
+
- id (integer, auto-incrementing primary key)
|
478
|
+
- category (required text)
|
479
|
+
- title (required text)
|
480
|
+
- content (required text)
|
481
|
+
- timestamp (text with default current timestamp)
|
482
|
+
|
483
|
+
Create a table called 'technical_decisions' with columns:
|
484
|
+
- id (integer, auto-incrementing primary key)
|
485
|
+
- decision_name (required text)
|
486
|
+
- chosen_approach (required text)
|
487
|
+
- alternatives (text)
|
488
|
+
- rationale (required text)
|
489
|
+
- timestamp (text with default current timestamp)
|
490
|
+
```
|
491
|
+
|
492
|
+
Behind the scenes, these natural language requests invoke the appropriate MCP tools (like `create_table`), without the LLM needing to write Python code directly.
|
493
|
+
|
494
|
+
The Python implementation shown below is what developers would use when integrating with the SQLite Memory Bank programmatically:
|
495
|
+
|
496
|
+
```python
|
497
|
+
# Initialize memory tables (run once at the start of each session)
|
498
|
+
def initialize_memory():
|
499
|
+
# Check if tables exist
|
500
|
+
tables = list_tables()
|
501
|
+
|
502
|
+
# Create project structure table if needed
|
503
|
+
if 'project_structure' not in tables['tables']:
|
504
|
+
create_table('project_structure', [
|
505
|
+
{"name": "id", "type": "INTEGER PRIMARY KEY AUTOINCREMENT"},
|
506
|
+
{"name": "category", "type": "TEXT NOT NULL"},
|
507
|
+
{"name": "title", "type": "TEXT NOT NULL"},
|
508
|
+
{"name": "content", "type": "TEXT NOT NULL"},
|
509
|
+
{"name": "timestamp", "type": "TEXT DEFAULT CURRENT_TIMESTAMP"}
|
510
|
+
])
|
511
|
+
|
512
|
+
# Create technical decisions table if needed
|
513
|
+
if 'technical_decisions' not in tables['tables']:
|
514
|
+
create_table('technical_decisions', [
|
515
|
+
{"name": "id", "type": "INTEGER PRIMARY KEY AUTOINCREMENT"},
|
516
|
+
{"name": "decision_name", "type": "TEXT NOT NULL"},
|
517
|
+
{"name": "chosen_approach", "type": "TEXT NOT NULL"},
|
518
|
+
{"name": "alternatives", "type": "TEXT"},
|
519
|
+
{"name": "rationale", "type": "TEXT NOT NULL"},
|
520
|
+
{"name": "timestamp", "type": "TEXT DEFAULT CURRENT_TIMESTAMP"}
|
521
|
+
])
|
522
|
+
```
|
523
|
+
|
524
|
+
### Store and Retrieve Agent Memory
|
525
|
+
|
526
|
+
LLMs can store and retrieve memory through natural language commands that map to MCP tools:
|
527
|
+
|
528
|
+
```
|
529
|
+
Store in project_structure where category is "architecture" and title is "API Design":
|
530
|
+
Content: "The project uses a RESTful API design with explicit endpoint naming."
|
531
|
+
|
532
|
+
Find all entries in project_structure where category is "architecture"
|
533
|
+
```
|
534
|
+
|
535
|
+
For developers integrating programmatically, here's how the implementation might look:
|
536
|
+
|
537
|
+
```python
|
538
|
+
# Store project information
|
539
|
+
def remember_project_structure(category, title, content):
|
540
|
+
# Check if this information already exists
|
541
|
+
existing = read_rows('project_structure', {
|
542
|
+
'category': category,
|
543
|
+
'title': title
|
544
|
+
})
|
545
|
+
|
546
|
+
if existing:
|
547
|
+
# Update existing record
|
548
|
+
update_rows('project_structure',
|
549
|
+
{'content': content},
|
550
|
+
{'id': existing[0]['id']})
|
551
|
+
return existing[0]['id']
|
552
|
+
else:
|
553
|
+
# Create new record
|
554
|
+
result = create_row('project_structure', {
|
555
|
+
'category': category,
|
556
|
+
'title': title,
|
557
|
+
'content': content
|
558
|
+
})
|
559
|
+
return result['id']
|
560
|
+
|
561
|
+
# Retrieve relevant project information
|
562
|
+
def recall_project_structure(category=None):
|
563
|
+
if category:
|
564
|
+
return read_rows('project_structure', {'category': category})
|
565
|
+
else:
|
566
|
+
return read_rows('project_structure')
|
567
|
+
```
|
568
|
+
|
569
|
+
### Best Practices for Agent Memory
|
570
|
+
|
571
|
+
1. **Initialize memory tables** at the start of each session
|
572
|
+
2. **Check before writing** to avoid duplicate information
|
573
|
+
3. **Use specific queries** to retrieve only relevant context
|
574
|
+
4. **Update existing records** instead of creating duplicates
|
575
|
+
5. **Verify critical information** was saved correctly
|
576
|
+
|
577
|
+
For detailed implementation guidelines, see the [memory usage instructions](examples/memory_instructions.md).
|
578
|
+
|
579
|
+
---
|
580
|
+
|
581
|
+
## Advanced Features
|
582
|
+
|
583
|
+
> **Note:** The following features are all planned for future releases and are not currently implemented.
|
584
|
+
|
585
|
+
### Progress Reporting for Long Operations (Planned)
|
586
|
+
|
587
|
+
For operations that may take significant time, SQLite Memory Bank will provide progress updates:
|
588
|
+
|
589
|
+
```python
|
590
|
+
# Example of a planned feature - not yet implemented
|
591
|
+
result = run_complex_query('large_table', complex_filter,
|
592
|
+
with_progress=True, timeout=30)
|
593
|
+
```
|
594
|
+
|
595
|
+
Progress notifications will be sent to the client with percentage complete and estimated time remaining.
|
596
|
+
|
597
|
+
### Memory Snapshots (Planned)
|
598
|
+
|
599
|
+
Create point-in-time snapshots of your database state:
|
600
|
+
|
601
|
+
```python
|
602
|
+
# Example of planned feature - not yet implemented
|
603
|
+
# Create a named snapshot
|
604
|
+
create_memory_snapshot('before_major_update')
|
605
|
+
|
606
|
+
# Later restore to that point
|
607
|
+
restore_memory_snapshot('before_major_update')
|
608
|
+
|
609
|
+
# List all available snapshots
|
610
|
+
list_memory_snapshots()
|
611
|
+
```
|
612
|
+
|
613
|
+
### Memory Federation (Planned Feature)
|
614
|
+
|
615
|
+
Connect multiple memory banks for distributed storage:
|
616
|
+
|
617
|
+
```python
|
618
|
+
# Example of planned feature - not yet implemented
|
619
|
+
# Register external memory bank
|
620
|
+
register_external_memory('project_knowledge', 'http://other-server:8000/mcp')
|
621
|
+
|
622
|
+
# Query across federated memory
|
623
|
+
federated_results = query_federated_memory('technical_decisions',
|
624
|
+
['local', 'project_knowledge'])
|
625
|
+
```
|
626
|
+
|
627
|
+
## Security Considerations
|
628
|
+
|
629
|
+
### Access Controls
|
630
|
+
|
631
|
+
By default, SQLite Memory Bank operates with full read/write access to the database. For security-sensitive deployments:
|
632
|
+
|
633
|
+
- Use Docker with read-only mounts for specific directories
|
634
|
+
- Configure environment variables for access levels:
|
635
|
+
- `SQLITE_MEMORY_ACCESS=read_only` for read-only mode (planned)
|
636
|
+
- `SQLITE_MEMORY_ACCESS=schema_only` to prevent data modification (planned)
|
637
|
+
- `SQLITE_MEMORY_ALLOWED_TABLES` to restrict access to specific tables (planned)
|
638
|
+
|
639
|
+
### Encryption (Planned Feature)
|
640
|
+
|
641
|
+
For sensitive data, enable encryption:
|
642
|
+
|
643
|
+
```bash
|
644
|
+
# Coming soon - not yet implemented
|
645
|
+
python -m mcp_sqlite_memory_bank --encrypt --password-file /path/to/key
|
646
|
+
```
|
647
|
+
|
648
|
+
### Performance Optimization (Planned)
|
649
|
+
|
650
|
+
For large datasets, these features will be added:
|
651
|
+
|
652
|
+
- Enable WAL mode with `DB_WAL_MODE=1`
|
653
|
+
- Set appropriate cache size with `DB_CACHE_SIZE=10000`
|
654
|
+
- Use the `create_index` tool to optimize frequent queries
|
655
|
+
- Consider `DB_MEMORY_TEMP=1` for in-memory temporary tables
|
656
|
+
|
657
|
+
## Extending SQLite Memory Bank
|
658
|
+
|
659
|
+
The following extension features are planned for future releases:
|
660
|
+
|
661
|
+
### Custom Schema Validators (Planned Feature)
|
662
|
+
|
663
|
+
Create schema validators to ensure data consistency:
|
664
|
+
|
665
|
+
```python
|
666
|
+
# Example of planned feature - not yet implemented
|
667
|
+
from mcp_sqlite_memory_bank import register_schema_validator
|
668
|
+
|
669
|
+
def validate_user_schema(columns):
|
670
|
+
required_fields = ['username', 'email']
|
671
|
+
for field in required_fields:
|
672
|
+
if not any(col['name'] == field for col in columns):
|
673
|
+
return False, f"Missing required field: {field}"
|
674
|
+
return True, "Schema valid"
|
675
|
+
|
676
|
+
register_schema_validator('users', validate_user_schema)
|
677
|
+
```
|
678
|
+
|
679
|
+
### Custom Data Processors (Planned Feature)
|
680
|
+
|
681
|
+
Register processors to transform data on read/write:
|
682
|
+
|
683
|
+
```python
|
684
|
+
# Example of planned feature - not yet implemented
|
685
|
+
from mcp_sqlite_memory_bank import register_data_processor
|
686
|
+
|
687
|
+
def process_pii_data(row, operation):
|
688
|
+
if operation == 'write' and 'email' in row:
|
689
|
+
# Hash or encrypt PII data
|
690
|
+
row['email'] = hash_email(row['email'])
|
691
|
+
return row
|
692
|
+
|
693
|
+
register_data_processor('users', process_pii_data)
|
694
|
+
```
|
695
|
+
|
696
|
+
---
|
@@ -0,0 +1,10 @@
|
|
1
|
+
mcp_sqlite_memory_bank/__init__.py,sha256=HnroBjHNJqCQ3kqaHgfYrZhHipSmNFWpAIYH2or0fi0,2322
|
2
|
+
mcp_sqlite_memory_bank/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
mcp_sqlite_memory_bank/server.py,sha256=kbdpF8axXj7X2Rj7NwDiGIAjOluZ-1d5uJHcuyoxksU,37839
|
4
|
+
mcp_sqlite_memory_bank/types.py,sha256=gGteXWPKMKkOLlSe3CEpqEm-X-rEePCwfbXUaoY4YYU,4431
|
5
|
+
mcp_sqlite_memory_bank/utils.py,sha256=dkgx7-GHruZhzWemOWXgUpZwD_UZo_a7a7zP9bB5YXU,6476
|
6
|
+
mcp_sqlite_memory_bank-0.1.0.dist-info/licenses/LICENSE,sha256=KPr7eFgCJqQIjeSAcwRafbjcgm-10zkrJ7MFoTOGJQg,1092
|
7
|
+
mcp_sqlite_memory_bank-0.1.0.dist-info/METADATA,sha256=e6rI8BM-pPb-6HTqrNQUu2EbAQC0AqGe6ejec2z-z8U,22875
|
8
|
+
mcp_sqlite_memory_bank-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
+
mcp_sqlite_memory_bank-0.1.0.dist-info/top_level.txt,sha256=xQ8MTGECpWMR-9DV4H8mMqaSoZqE-C8EvpOg9E2U1wM,23
|
10
|
+
mcp_sqlite_memory_bank-0.1.0.dist-info/RECORD,,
|