-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsmoke_mcp.py
More file actions
37 lines (30 loc) · 1.67 KB
/
Copy pathsmoke_mcp.py
File metadata and controls
37 lines (30 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3
"""End-to-end MCP smoke test: act as an MCP client against server.py, exercise the
real tools against the live redroid device."""
import asyncio, os
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
DIR = "/home/armani/projects/android-agent"
async def main():
env = dict(os.environ, ANDROID_SERIAL="localhost:5555")
params = StdioServerParameters(command=f"{DIR}/.venv/bin/python", args=[f"{DIR}/server.py"], env=env)
async with stdio_client(params) as (r, w):
async with ClientSession(r, w) as s:
await s.initialize()
tools = (await s.list_tools()).tools
print(f"TOOLS ({len(tools)}):", ", ".join(t.name for t in tools))
st = await s.call_tool("droid_status", {})
print("\n[droid_status]\n" + st.content[0].text)
shot = await s.call_tool("droid_screenshot", {})
kinds = [(c.type, len(getattr(c, "data", "") or "")) for c in shot.content]
print("\n[droid_screenshot] content:", kinds)
ui = await s.call_tool("droid_ui", {})
print("\n[droid_ui] (first 6 lines):")
print("\n".join(ui.content[0].text.splitlines()[:6]))
# ACT: open Settings, confirm the foreground app changed
print("\n[droid_launch settings]:", (await s.call_tool("droid_launch", {"app": "com.android.settings"})).content[0].text)
await asyncio.sleep(2)
st2 = await s.call_tool("droid_status", {})
cur = [l for l in st2.content[0].text.splitlines() if l.startswith("current_app")]
print("[after launch]", cur[0] if cur else "?")
asyncio.run(main())