import asyncio
from fastmcp import Client
import random
import time
from desmume.emulator import SCREEN_WIDTH, SCREEN_HEIGHT
client = Client("http://127.0.0.1:8000/mcp")
async def call_tool_press_key():
async with client:
result = await client.call_tool("press_key", {"key": "DOWN", "n": 10})
print(result)
# print(result.content)
obj = {
1: "RIGHT",
2: "DOWN",
3: "LEFT",
4: "UP",
}
async def call_tool_multiple_keys():
async with client:
result = await client.call_tool("press_multiple_keys", {"keys": [obj[random.randint(1, 4)] for _ in range(15)]})
print(result)
async def call_tool_load_state():
async with client:
result = await client.call_tool("load_state", {})
print(result)
async def call_tool_take_screenshot():
async with client:
result = await client.call_tool("take_screenshot_of_status", {})
print(result)
async def list_controls():
async with client:
result = await client.read_resource("resource://game_controls")
print(result)
async def call_tool_press_touch_screen():
print(f"Touch screen pressed at 48, 352")
async with client:
result = await client.call_tool("press_touch_screen", {"x": 48, "y": 352})
print(result)
# asyncio.run(call_tool_press_key())
# time.sleep(1)
# asyncio.run(call_tool_multiple_keys())
# time.sleep(1)
# asyncio.run(call_tool_take_screenshot())
# asyncio.run(call_tool_press_touch_screen())