1.4 KiB
1.4 KiB
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.jsonwith timestamps. - Simple client demo (
memory_client.py).
Installation
pip install -r requirements.txt
Running the Server
python memory_server.py
The server will start listening via stdio transport.
Running the Client Demo
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 ofnamespace:keyto a dictionary containingvalueandtimestamp. - All tools are registered with
@mcp.tool()and can be invoked by any MCP client. - The client uses
fastmcp.Clientto 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.