From 178a716b9455f3e21ea7917cda8f7b5d4dd13617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=B4=D0=B5=D0=BB=D0=B8=D0=BD=D0=B0=20=D0=A1=D0=B0?= =?UTF-8?q?=D1=82=D1=82=D0=B0=D1=80=D0=BE=D0=B2=D0=B0?= Date: Tue, 2 Jun 2026 06:04:34 +0000 Subject: [PATCH] Created main.py --- main.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..93d5774 --- /dev/null +++ b/main.py @@ -0,0 +1,47 @@ +from fastmcp import MCP +import json, os, time + +# Simple in-memory store with JSON persistence +DATA_FILE = "data.json" +store = {} +if os.path.exists(DATA_FILE): + with open(DATA_FILE) as f: + store = json.load(f) + +@MCP.tool() +def save(key: str, value: str): + store[key] = {"value": value, "timestamp": time.time()} + with open(DATA_FILE, "w") as f: + json.dump(store, f) + return f"Saved {key}" + +@MCP.tool() +def get(key: str): + return store.get(key, {}).get("value", None) + +@MCP.tool() +def delete(key: str): + if key in store: + del store[key] + with open(DATA_FILE, "w") as f: + json.dump(store, f) + return f"Deleted {key}" + return f"{key} not found" + +@MCP.tool() +def list_keys(): + return list(store.keys()) + +# Namespace helpers +@MCP.tool() +def save_with_namespace(namespace: str, key: str, value: str): + full = f"{namespace}:{key}" + return save(full, value) + +@MCP.tool() +def get_by_namespace(namespace: str, key: str): + full = f"{namespace}:{key}" + return get(full) + +if __name__ == "__main__": + MCP.run() \ No newline at end of file