Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execute_adb_command commands #3

Closed
edgan opened this issue Mar 24, 2025 · 1 comment
Closed

execute_adb_command commands #3

edgan opened this issue Mar 24, 2025 · 1 comment

Comments

@edgan
Copy link
Contributor

edgan commented Mar 24, 2025

Are you only giving a very rough template of what to do to the model? It is like it is completely guessing the commands. I would expect there to at least be suggested command line program to use, and ideally a way to prevalidate the what is installed.

As is this seems like a great way to both waste Cursor requests, and time.

The am and shell commands should be prefixed with adb. monkey should be monkeyrunner. We should also have a way to explicitly tell the model what are valid commands. So it doesn't try to try to do something replace adb with monkey.

In general the code should be more like:

@mcp.tool()
def execute_adb_command(command: str) -> str:
    """Executes an ADB command and returns the output.
    Args:
        command (str): The ADB command to execute
    Returns:
        str: The output of the ADB command
    """
   
    result = deviceManager.execute_adb_command(command)
    return result

Examples from Claude 3.7 thinking:

}
  "command": "shell am start -n me.ccrama.redditslide/me.ccrama.redditslide.Activities.MainActivity"
}
{
  "command": "monkey -p me.ccrama.redditslide -c android.intent.category.LAUNCHER 1"
}
}
  "command": "am start -n me.ccrama.redditslide/me.ccrama.redditslide.Activities.MainActivity"
}
{
  "command": "monkey -p me.ccrama.redditslide -c android.intent.category.LAUNCHER 1"
}
@minhalvp
Copy link
Owner

minhalvp commented Mar 24, 2025

Thank you for raising this issue. I see the confusion and it's actually my fault for not naming the function more clearly.

Let me clarify how the execute_adb_command function works in adbdevicemanager.py:

def execute_adb_command(self, command: str) -> str:
    """Executes an ADB command and returns the output."""
    if command.startswith("adb shell "):
        command = command[10:]
    elif command.startswith("adb "):
        command = command[4:]
    result = self.device.shell(command)
    return result

This function actually:

  1. Takes any command string (with or without "adb" prefixes)
  2. Strips the "adb shell" or "adb" prefix if present
  3. Uses the ppadb client's device.shell() method to execute the command directly

The examples you pointed out from Claude's thinking are actually being processed correctly - whether or not they include the "adb" prefix, they get properly executed on the device.

I'll make sure to rename the function to execute_adb_shell_command

@edgan edgan closed this as completed Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants