diff --git a/memory_client.py b/memory_client.py new file mode 100644 index 0000000..fedac3b --- /dev/null +++ b/memory_client.py @@ -0,0 +1,36 @@ +"""Client demo for MemoryServer. + +Run with: + python memory_client.py +""" + +import asyncio +from fastmcp import Client + +async def main(): + # Connect to the server via stdio. The server must be running in another terminal. + client = Client("python memory_server.py") + await client.connect() + try: + # Save a value in default namespace + res = await client.call_tool("save_with_namespace", { + "key": "username", + "value": "Алексей", + "namespace": "default", + }) + print(f"Сохранено: {res}") + + # Retrieve all items in default namespace + res = await client.call_tool("get_by_namespace", {"namespace": "default"}) + print("Данные namespace 'default':") + for item in res: + print(f" {item['key']}: {item['value']}") + + # List keys matching pattern + keys = await client.call_tool("list_keys", {"pattern": "*name"}) + print("Ключи с 'name':", keys) + finally: + await client.close() + +if __name__ == "__main__": + asyncio.run(main())