Add memory_client.py
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import asyncio
|
||||
from fastmcp import Client
|
||||
|
||||
async def main():
|
||||
# Connect to the server via stdio transport
|
||||
# The server should be started separately: python memory_server.py
|
||||
client = Client("stdio")
|
||||
# Wait for server to be ready
|
||||
await client.wait_for_ready()
|
||||
|
||||
# Test save
|
||||
result = await client.call_tool("save", key="foo", value={"bar": 1})
|
||||
print("save result:", result)
|
||||
# Test get
|
||||
result = await client.call_tool("get", key="foo")
|
||||
print("get result:", result)
|
||||
# Test list_keys
|
||||
result = await client.call_tool("list_keys", pattern="*")
|
||||
print("list_keys result:", result)
|
||||
# Test delete
|
||||
result = await client.call_tool("delete", key="foo")
|
||||
print("delete result:", result)
|
||||
# Test namespace
|
||||
await client.call_tool("save_with_namespace", key="baz", value="qux", namespace="ns1")
|
||||
result = await client.call_tool("get_by_namespace", namespace="ns1")
|
||||
print("get_by_namespace result:", result)
|
||||
|
||||
client.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user