Create your own Commands and Run them on your Android without wasting time.
Lets you run Python scripts with or without included binaries on Android.
AutoPie is your own power tool-kit for android.
- Build from source yourself or get the prebuilt APK from the releases section.
- Install the APK and accept Play Protect Dialogs if any.
- Wait for the Python Binaries to get installed.
- Grant necessary permissions.
- AutoPie will try to download an init binary & configuration archive and extract it into the
AutoSec
directory. If it fails, you can download theautosec.tar.xz
file and extract to theAutoSec
folder. - Optional: Disable Battery Optimization for AutoPie.
- Open AutoPie App
- There are currently two types of commands.
Share Sheet Commands
,Folder Observer Commands
andCron Commands
. - Add your desired Commands in the AutoPie App by clicking on Add Button or Edit an already existing command.
AutoPie now comes with your own MCP server that you can use to automate your phone with AI Tools.
The server is easily extensible by adding your scripts to the /ExternalStorage/AutoSec/mcp_modules folder.
The scripts inside this folder will be included as tools in the MCP server.
You can add any kind of functionality on your phone with this by just writing a Python script.
The MCP tool scripts should be in this format.
import os
from typing import Dict, Any
from pydantic import BaseModel
class CreateFileInput(BaseModel):
filepath: str
content: str
class MCPTool:
path = "/create_file"
name = "create_text_file"
methods=["POST"]
async def run(self, input: CreateFileInput) -> Dict[str, Any]:
"""Creates a text file with the specified content."""
try:
# Create directory if it doesn't exist
os.makedirs(os.path.dirname(os.path.abspath(input.filepath)), exist_ok=True)
# Write content to file
with open(input.filepath, "w") as f:
f.write(input.content)
return {
"status": "success",
"message": f"File '{input.filepath}' created successfully"
}
except Exception as e:
return {
"status": "error",
"message": f"Failed to create file: {str(e)}"
}
- Check that the
AutoSec
folder containsobservers.json
for Folder Observation Automation,shares.json
for Share Sheet Configuration andcron.json
for Cron Configuration. And abin
folder with the binaries likeffmpeg
.
PLACEHOLDER | DESCRIPTION |
---|---|
${INPUT_FILE} | Use it to pass input file path or url in the command |
${INPUT_FILES} | If multiple files are needed as input to the command Example : magick combine two images |
${FILENAME} | Filename without path |
${DIRECTORY} | Parent Directory of file |
${FILENAME_NO_EXT} | Filename without path and extension |
${FILE_EXT} | File extension |
${RAND} | Random 4 digit number |
${HOST} | URL host (Only available if the input is a URL) |
USE | COMMAND |
---|---|
Ffmpeg Extract Audio from Video | -i ${INPUT_FILE} -b:a 192K -vn ${INPUT_FILE}.mp3 |
ImageMagick combine horizontal | ${INPUT_FILES} +append ${INPUT_FILE}-horiz-${RAND}.jpeg |
With AutoPie, you can define custom arguments called (extras) for commands.
This will show a card where you can input details to customize the behaviour of the command.
For Example,
Defining extra items such as options for codecs etc will look like this.
A repository where users can search and add pre-made AutoPie command snippets and install packages is in the works.
AutoPie binaries are just thin python wrappers around binaries like ffmpeg
magick
etc.
Using Shiv to package the binaries, dependencies and python files is strongly recommended.
This is an example for how to include the ffmpeg
binaries and libraries in a single file with shiv.
A more detailed docs is in WIP.
import subprocess
import sys
import os
import shlex
script_dir = os.path.dirname(__file__)
# Set the path to the ImageMagick binary and library directories
bin_path = os.path.join(script_dir, 'usr', 'bin')
lib_path = os.path.join(script_dir, 'usr', 'lib')
# Update PATH environment variable
os.environ['PATH'] = bin_path + os.pathsep + os.environ['PATH']
# Update LD_LIBRARY_PATH environment variable
os.environ['LD_LIBRARY_PATH'] = lib_path + os.pathsep + os.environ.get('LD_LIBRARY_PATH', '')
def main():
"""Console script for ffmpeg wrapper"""
input_command = sys.argv[1]
commands_list = shlex.split(input_command)
runner(commands_list)
def runner(commands_list: list[str]):
try:
commands_list= ["ffmpeg"] + commands_list
print(f"shlex command list: {commands_list}")
result = subprocess.run(commands_list)
if result.returncode == 0:
print(f"Successfully executed {commands_list}")
else:
print(f"Subprocess failed with exit code {result.returncode} : {commands_list}")
sys.exit(result.returncode)
except Exception as e:
print(f"Unexpected error: {e}")
sys.exit(e.returncode)
if __name__ == "__main__":
main()
You can build the app with prebuilt binaries by opening the project with Android Studio and then run build task.
- Set Environment Variable
ANDROID_NDK_ROOT
to your Android NDK installation folder. - Run the
./build-all.sh
script to build all dependencies and store them in the Assets folder.
- Supports only aarch64/arm-v8 as of now. It should run on most newer phones.
- Makes it easier to automate and run any task.
- Termux will be constrained in the future by Android Platform limitations.
- Needed to find an alternative method to Termux by including a whole Python installation in the APK itself that enables us to run scripts and binaries from anywhere on the storage.