add memory_client.py
This commit is contained in:
+2
-27
@@ -1,28 +1,3 @@
|
|||||||
from fastmcp import Client
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from fastmcp import Client
|
||||||
async def main():
|
async def main():c?
|
||||||
client = Client("python memory_server.py")
|
|
||||||
await client.connect()
|
|
||||||
try:
|
|
||||||
result = await client.call_tool(
|
|
||||||
"save_with_namespace",
|
|
||||||
{"key": "username", "value": "Алексей", "namespace": "default"}
|
|
||||||
)
|
|
||||||
print(f"Сохранено: {result}")
|
|
||||||
|
|
||||||
result = await client.call_tool(
|
|
||||||
"get_by_namespace",
|
|
||||||
{"namespace": "default"}
|
|
||||||
)
|
|
||||||
print("Данные namespace 'default':")
|
|
||||||
for item in result:
|
|
||||||
print(f" {item['key']}: {item['value']}")
|
|
||||||
|
|
||||||
keys = await client.call_tool("list_keys", {"pattern": "*name"})
|
|
||||||
print(f"Ключи с 'name': {keys}")
|
|
||||||
finally:
|
|
||||||
await client.close()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
asyncio.run(main())
|
|
||||||
Reference in New Issue
Block a user