diff --git a/memory_client.py b/memory_client.py new file mode 100644 index 0000000..4b74527 --- /dev/null +++ b/memory_client.py @@ -0,0 +1,43 @@ +from fastmcp import Client +import asyncio + + +async def main(): + # Connect to MCP server via stdio + client = Client("python memory_server.py") + + await client.connect() + + try: + # Save data in namespace "default" + result = await client.call_tool( + "save_with_namespace", + {"key": "username", "value": "Алексей", "namespace": "default"} + ) + print(f"Сохранено: {result}") + + # Save another key for pattern matching demo + result = await client.call_tool( + "save", + {"key": "default:user_name", "value": "Алексей"} + ) + + # Read data from namespace + result = await client.call_tool( + "get_by_namespace", + {"namespace": "default"} + ) + print(f"Данные namespace 'default':") + for item in result: + print(f" {item['key']}: {item['value']}") + + # Search by pattern + keys = await client.call_tool("list_keys", {"pattern": "*name"}) + print(f"Ключи с 'name': {keys}") + + finally: + await client.close() + + +if __name__ == "__main__": + asyncio.run(main())