fix: memory_client.py — MCP-сервер для управления памятью агента
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
import asyncio
|
||||||
|
from fastmcp import Client
|
||||||
|
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
client = Client("python memory_server.py")
|
||||||
|
await client.connect()
|
||||||
|
try:
|
||||||
|
# Save a value in default namespace
|
||||||
|
saved = await client.call_tool(
|
||||||
|
"save_with_namespace",
|
||||||
|
{"key": "username", "value": "Алексей", "namespace": "default"},
|
||||||
|
)
|
||||||
|
print(f"Saved: {saved}")
|
||||||
|
|
||||||
|
# Retrieve all values from default namespace
|
||||||
|
data = await client.call_tool("get_by_namespace", {"namespace": "default"})
|
||||||
|
print("Namespace 'default' contents:")
|
||||||
|
for item in data:
|
||||||
|
print(f" {item['key']}: {item['value']} (ts={item['timestamp']})")
|
||||||
|
|
||||||
|
# List keys matching pattern
|
||||||
|
keys = await client.call_tool("list_keys", {"pattern": "*name"})
|
||||||
|
print(f"Keys matching '*name': {keys}")
|
||||||
|
|
||||||
|
finally:
|
||||||
|
await client.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
asyncio.run(main())
|
||||||
Reference in New Issue
Block a user