Files
task-69f8e929da860fb4533faa2a/README.md
T
2026-06-02 07:05:45 +00:00

50 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MCP Memory Server
This repository contains a simple **MCP (Model Context Protocol)** server that provides a persistent key/value store with optional namespace support. The server is built with **FastMCP** and exposes tools that can be called by other agents or CLI utilities.
## Features
- **Basic CRUD** operations: `save`, `get`, `delete`, `list_keys`.
- **Namespace support**: `save_with_namespace`, `get_by_namespace`, etc.
- Data is persisted to `memory_data.json` with timestamps.
- Simple client demo (`memory_client.py`).
## Installation
```bash
pip install -r requirements.txt
```
## Running the Server
```bash
python memory_server.py
```
The server will start listening via **stdio** transport.
## Running the Client Demo
```bash
python memory_client.py
```
You should see output similar to:
```
Сохранено: True
Данные namespace 'default':
default:username: Алексей
Ключи с 'name': ['default:username']
```
## How It Works
- The server uses a JSON file (`memory_data.json`) to store data. Each entry is a mapping of `namespace:key` to a dictionary containing `value` and `timestamp`.
- All tools are registered with `@mcp.tool()` and can be invoked by any MCP client.
- The client uses `fastmcp.Client` to connect via stdio and call the tools.
## Extending
You can add more tools or modify the storage backend (e.g., switch to a database) by extending the `MemoryServer` class.