Files
task-69f8e929da860fb4533faa2a/memory_client.py
T

34 lines
916 B
Python
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.
from __future__ import annotations
import asyncio
from fastmcp import Client
def unwrap(result):
return getattr(result, "data", result)
async def main():
async with Client("memory_server.py") as client:
result = await client.call_tool(
"save_with_namespace",
{"key": "username", "value": "\u0410\u043b\u0435\u043a\u0441\u0435\u0439", "namespace": "default"},
)
print(f"Сохранено: {unwrap(result)}")
result = await client.call_tool(
"get_by_namespace",
{"namespace": "default"},
)
print("Данные namespace 'default':")
for item in unwrap(result):
print(f" {item['key']}: {item['value']}")
keys = await client.call_tool("list_keys", {"pattern": "*name"})
print(f"Ключи с 'name': {unwrap(keys)}")
if __name__ == "__main__":
asyncio.run(main())