Skip to content

Does not work, adb always has #10

Description

@Manamama

Advanced adb and Droid user here.

@above-hp2-silver:~/Downloads/GitHub/android-mcp-server$ cat test1.py 

import subprocess
import json
import threading
import time

cmd = [
    "python3",
    "/home/user/.local/lib/python3.10/site-packages/android-mcp-server/server.py"
]

p = subprocess.Popen(
    cmd,
    stdin=subprocess.PIPE,
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    text=True
)

request = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "get_packages",
    "params": []  # empty list as you found required
}

print(">>> Sending request:", request)
p.stdin.write(json.dumps(request) + "\n")
p.stdin.flush()

def read_output(stream, label):
    for line in iter(stream.readline, ''):
        print(f"{label}: {line.strip()}")

stdout_thread = threading.Thread(target=read_output, args=(p.stdout, "STDOUT"))
stderr_thread = threading.Thread(target=read_output, args=(p.stderr, "STDERR"))
stdout_thread.start()
stderr_thread.start()

# Wait max 10 seconds for response
time.sleep(10)

if p.poll() is None:
    print("Process still running after 10s, terminating")
    p.terminate()
else:
    print("Process exited")

stdout_thread.join(timeout=1)
stderr_thread.join(timeout=1)


user@above-hp2-silver:~/Downloads/GitHub/android-mcp-server$ 

test shows nothing:


user@above-hp2-silver:~/Downloads/GitHub/android-mcp-server$ python test1.py 
>>> Sending request: {'jsonrpc': '2.0', 'id': 1, 'method': 'get_packages', 'params': []}



Process still running after 10s, terminating
user@above-hp2-silver:~/Downloads/GitHub/android-mcp-server$ 

vs:

 $ adb -s 192.168.44.1:5555 shell pm list packages | head
package:com.shix.qhipc
package:com.google.android.networkstack.tethering
package:com.ilixa.mirror
package:org.jitsi.meet
package:com.mediatek.gba
package:com.mediatek.ims
package:com.ajeic.LearnJapaneseNumbers
package:com.asana.app
package:com.android.cts.priv.ctsshim
package:com.extreamsd.usbmidimonitor

Yes, config file is fine etc. Tests mostly passed and:

python /home/user/.local/lib/python3.10/site-packages/android-mcp-server/server.py 
Loaded config from config.yaml
Configured device: 192.168.44.1:5555

The mcp client (e.g. Gemini CLI) debug logs show nothing, either.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions