Skip to main content
Glama

AutoBot MCP

Python Version MCP License

一个基于 AutoBot API 的 MCP(Model Context Protocol)服务器实现,用于远程控制和自动化 Android 设备。

✨ 功能特点

AutoBot MCP 提供了全面的 Android 设备控制功能,包括:

📱 设备信息获取

  • 获取已安装应用列表

  • 获取设备详细信息(硬件、系统、内存、存储)

  • 获取屏幕信息和截图

  • 获取 UI 布局(JSON/XML 格式)

🎮 设备控制

  • 点击、长按、滑动等触摸操作

  • 文本输入和按键模拟

  • 手势操作(单指/多指)

  • 屏幕亮灭控制和录屏

  • 智能屏幕常亮(自动保持屏幕常亮,操作结束后恢复)

📲 应用管理

  • 启动和停止应用

  • 获取应用信息

  • 清除应用数据

📞 通信功能

  • 联系人管理(增删查)

  • 短信管理(收发)

  • 电话拨打和挂断

📁 文件操作

  • 文件列表和删除

  • 文件上传下载

🔧 系统操作

  • 执行 ADB Shell 命令

  • 剪切板操作

  • 脚本执行(AutoX.js)

Related MCP server: ADB MCP Server

🚀 快速开始

环境要求

  • Python: >= 3.12

  • uv: 最新版本的 Python 包管理器

  • Android 设备: 运行 AutoBot HTTP 服务

安装步骤

  1. 克隆仓库

git clone https://github.com/yourusername/autobot-mcp.git
cd autobot-mcp
  1. 安装依赖

uv sync
  1. 配置设备

创建配置文件(从示例复制):

cp config.yaml.example config.yaml

编辑 config.yaml,填入你的设备信息:

device:
  ip: "192.168.1.100"  # 替换为你的设备IP地址
  port: 18080          # 替换为你的设备端口

运行服务器

方式一:使用 autobot-mcp 命令

uv run autobot-mcp

方式二:直接运行 Python 脚本

uv run python main.py

方式三:激活虚拟环境后运行

# Windows
.venv\Scripts\activate

# Linux/Mac
source .venv/bin/activate

autobot-mcp
# 或者
python main.py

📖 使用示例

Claude Code

添加 AutoBot MCP 服务器:

在项目目录下执行:

claude mcp add --transport stdio autobot-mcp -- \
  uv run --directory /path/to/autobot-mcp autobot-mcp

说明:

  • --transport stdio:指定使用 stdio 传输方式

  • autobot-mcp:服务器名称(可自定义)

  • uv run autobot-mcp:启动命令,确保在项目目录下执行以正确加载 config.yaml

注意事项:

  • 确保已创建并配置 config.yaml 文件

  • 命令需要在项目根目录执行,以便找到配置文件

  • 如果使用虚拟环境,也可以使用 python main.py 作为启动命令

测试连接

使用 autobot-mcp 命令测试:

uv run autobot-mcp
# MCP 服务器将在 stdio 上运行,等待来自 MCP 客户端的连接

使用 Python 脚本测试:

uv run python -c "from main import hello; print(hello())"

Python API 使用

from main import mcp

# 设备已连接后,可以使用各种工具
# 获取设备信息
device_info = get_device_info()

# 启动应用
start_app("com.android.chrome")

# 点击屏幕
click(0.5, 0.5)  # 点击屏幕中心(百分比坐标)

# 获取截图
screenshot = get_screenshot()

🛠️ 可用工具函数

设备信息

  • get_packages() - 获取所有已安装应用

  • get_device_info() - 获取设备详细信息

  • get_screen_info() - 获取屏幕信息

  • get_screenshot() - 获取设备截图

  • get_uilayout() - 获取当前 UI 布局

  • hello() - 测试服务器连接

屏幕操作

  • click(x, y) - 点击屏幕(支持百分比和绝对坐标)

  • long_click(x, y) - 长按屏幕

  • swipe(x1, y1, x2, y2, duration) - 滑动操作

  • input_text(text) - 输入文本(支持多语言)

  • press_key(key_code) - 模拟按键

  • gesture(duration, points) - 单指手势

  • gestures(gestures_data) - 多指手势

应用管理

  • start_app(package_name) - 启动应用

  • stop_app(package_name) - 停止应用

  • get_package_action_intents(package_name) - 获取应用信息

  • clear_app_data(package_name) - 清除应用数据

系统操作

  • execute_adb_shell_command(command) - 执行 ADB 命令

  • turn_screen_on() - 亮屏

  • turn_screen_off() - 熄屏

  • start_screen_recording(limit) - 开始录屏

  • stop_screen_recording() - 停止录屏

通信功能

  • get_contacts(number) - 获取联系人

  • send_sms(phone_number, message) - 发送短信

  • call_phone(number) - 拨打电话

  • get_clipboard_text() - 获取剪切板内容

  • set_clipboard_text(text) - 设置剪切板内容

文件操作

  • list_files(path) - 列出文件

  • delete_file(path) - 删除文件

  • get_file_url(path) - 获取文件下载链接

📚 文档

🎯 坐标系统

AutoBot MCP 支持两种坐标系统:

  1. 绝对坐标:直接使用像素值,如 x=300, y=500

  2. 百分比坐标:使用 0-1 之间的浮点数,如 x=0.5, y=0.5(屏幕正中心)

推荐使用百分比坐标以提高跨设备兼容性。

⚠️ 注意事项

设备状态

  • 执行操作前确保设备处于亮屏和解锁状态

  • 参考文档了解屏幕状态检查方法

安全警告

  • delete_contact() 和 clear_app_data() 等操作不可恢复

  • exit_service() 会终止 AutoBot 服务

  • 执行脚本时注意权限和安全性

性能建议

  • 避免频繁调用 get_screenshot(),图像传输开销较大

  • 批量操作时考虑使用 ADB 命令

  • 使用百分比坐标提高兼容性

🔧 故障排除

连接失败

  • 检查设备 IP 地址和端口是否正确

  • 确保设备和电脑在同一网络

  • 确认 AutoBot 服务正在设备上运行

配置问题

  • 确保已创建 config.yaml 文件

  • 检查配置文件格式是否正确

操作无响应

  • 检查设备是否亮屏和解锁

  • 确认应用包名是否正确

  • 查看错误信息了解具体问题

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License

🔗 相关链接

Available Tools

53 tools
call_phoneC
Make a phone call (SIM card 1 only)
Args:
    number (str): Phone number to call
Returns:
    str: Success or error message

Inputs: number (required). Returns: result

clear_app_dataA
Clear application data for a package
Warning: This will delete all app data and cannot be undone
Args:
    package_name (str): Package name of the app
Returns:
    str: Success or error message

Inputs: package_name (required). Returns: result

clear_textB
Clear text in the current input field
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

clickB
Click at the specified coordinates on the screen
Args:
    x (float): X coordinate (can be absolute or relative 0-1)
    y (float): Y coordinate (can be absolute or relative 0-1)
Returns:
    str: Success or error message

Inputs: x (required), y (required). Returns: result

delete_contactA
Delete a contact or all contacts
Warning: Use with caution, especially when deleting all contacts
Args:
    number (str): Phone number of contact to delete, or "*" to delete all contacts (default)
Returns:
    str: Success or error message

Inputs: number. Returns: result

delete_fileA
Delete a file or directory
Warning: This will delete the file/directory and all its contents
Args:
    path (str): File or directory path to delete
Returns:
    str: Success or error message

Inputs: path (required). Returns: result

end_callB
End the current phone call
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

execute_adb_shell_commandA

Executes an ADB command and returns the output or an error. Args: command (str): The ADB shell command to execute Returns: str: The output of the ADB command

Inputs: command (required). Returns: result

execute_scriptB
Execute an AutoX.js script
Args:
    script (str): Script content to execute (optional)
    path (str): Local script path on device (optional, takes priority over script)
    delay (int): Delay before execution in milliseconds (default: 0)
    interval (int): Interval between loop iterations in milliseconds (default: 0)
    loop_times (int): Number of times to loop (default: 1, 0 for infinite)
Returns:
    str: Success or error message

Inputs: script, path, delay, interval, +1 more. Returns: result

exit_serviceA
Exit the AutoBot service
Warning: This will terminate the AutoBot server
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

gestureB
Execute a single-finger gesture
Args:
    duration (int): Duration of gesture in milliseconds
    points (list): List of points [{"x": 100, "y": 200}, {"x": 150, "y": 250}, ...]
Returns:
    str: Success or error message

Inputs: duration (required), points (required). Returns: result

gesturesB
Execute multi-finger gestures
Args:
    gestures_data (list): List of gesture objects, each with:
        - delay (int): Delay before starting this gesture
        - duration (int): Duration of gesture in milliseconds
        - points (list): List of points for the gesture
Returns:
    str: Success or error message

Inputs: gestures_data (required). Returns: result

get_clipboard_textB
Get clipboard text
Returns:
    str: Clipboard content or error message

Inputs: no named parameters. Returns: result

get_contactsB
Get all contacts or a specific contact by phone number
Args:
    number (str): Phone number to search for, or "*" to get all contacts (default)
Returns:
    str: Contact information as JSON

Inputs: number. Returns: result

get_device_idC
Get the device ID
Returns:
    str: Device ID

Inputs: no named parameters. Returns: result

get_device_infoC
Get detailed information about the device
Returns:
    str: Device information as a formatted string

Inputs: no named parameters. Returns: result

get_device_ipB
Get all IP addresses of the device
Returns:
    str: IP addresses as JSON

Inputs: no named parameters. Returns: result

get_device_nameB
Get the display name of the device
Returns:
    str: Device display name or error message

Inputs: no named parameters. Returns: result

get_file_urlC
Get the download URL for a file
Args:
    path (str): File path to download
Returns:
    str: Download URL or error message

Inputs: path (required). Returns: result

get_package_action_intentsB
Get all non-data actions from Activity Resolver Table for a package
Args:
    package_name (str): The name of the package to get actions for
Returns:
    list[str]: A list of all non-data actions from the Activity Resolver Table for the package

Inputs: package_name (required). Returns: result

get_packagesB
Get all installed packages on the device
Returns:
    str: A list of all installed packages on the device as a string

Inputs: no named parameters. Returns: result

get_screen_infoB
Get information about the screen (dimensions, rotation)
Returns:
    str: Screen information as a formatted string

Inputs: no named parameters. Returns: result

get_screen_rotationA
Get the screen rotation
Returns:
    str: Screen rotation as JSON (0=portrait, 1=landscape-90, 2=inverted, 3=landscape-270)

Inputs: no named parameters. Returns: result

get_screenshotB

Takes a screenshot of the device and returns it. Returns: Image: the screenshot

Inputs: no named parameters.

get_screen_xmlB
Get screen layout in XML format
Args:
    is_wait (bool): Whether to wait for layout (default: true)
Returns:
    str: Screen layout as XML

Inputs: is_wait. Returns: result

get_smsB
Get all SMS messages or messages from a specific number
Args:
    number (str): Phone number to get SMS from, or "*" to get all SMS (default)
Returns:
    str: SMS messages as JSON

Inputs: number. Returns: result

get_top_activityC
Get information about the current top activity
Returns:
    str: Top activity information as JSON

Inputs: no named parameters. Returns: result

get_uilayoutB
Retrieves information about clickable elements in the current UI.
Returns a formatted string containing details about each clickable elements,
including its text, content description, bounds, and center coordinates.

Returns:
    str: A formatted list of clickable elements with their properties

Inputs: no named parameters. Returns: result

get_versionA
Get the AutoBot version number
Returns:
    str: Version number

Inputs: no named parameters. Returns: result

helloA
Test connection to AutoBot server
Returns:
    str: Server response

Inputs: no named parameters. Returns: result

input_charA
Input ASCII characters using key simulation
Use this when input_text doesn't work in certain situations
Args:
    text (str): ASCII text to input
Returns:
    str: Success or error message

Inputs: text (required). Returns: result

input_textC
Input text on the device
Args:
    text (str): Text to input
Returns:
    str: Success or error message

Inputs: text (required). Returns: result

insert_contactB
Insert a new contact
Args:
    name (str): Contact name
    number (str): Contact phone number
Returns:
    str: Success or error message

Inputs: name (required), number (required). Returns: result

is_safe_modeA
Check if safe mode is enabled
Returns:
    str: Safe mode status (1=enabled, 0=disabled)

Inputs: no named parameters. Returns: result

list_filesB
List files in a directory
Args:
    path (str): Directory path to list (e.g., "/sdcard")
Returns:
    str: File list as JSON

Inputs: path (required). Returns: result

long_clickB
Long click at the specified coordinates on the screen
Args:
    x (float): X coordinate (can be absolute or relative 0-1)
    y (float): Y coordinate (can be absolute or relative 0-1)
Returns:
    str: Success or error message

Inputs: x (required), y (required). Returns: result

play_musicB
Play music from a URL
Warning: This may fail on Android 10 and below
Args:
    url (str): URL of the audio file to play
Returns:
    str: Success or error message

Inputs: url (required). Returns: result

pressA
Long press at specified coordinates for a specific duration
Args:
    x (float): X coordinate (can be absolute or relative 0-1)
    y (float): Y coordinate (can be absolute or relative 0-1)
    duration (int): Duration of press in milliseconds (default: 1000)
Returns:
    str: Success or error message

Inputs: x (required), y (required), duration. Returns: result

press_keyB
Press a key on the device
Args:
    key_code (int): Key code to press (e.g., 3 for HOME, 4 for BACK)
Returns:
    str: Success or error message

Inputs: key_code (required). Returns: result

send_smsC
Send an SMS message
Args:
    phone_number (str): Recipient phone number
    message (str): Message content
Returns:
    str: Success or error message

Inputs: phone_number (required), message (required). Returns: result

set_clipboard_textC
Set clipboard text
Args:
    text (str): Text to set in clipboard
Returns:
    str: Success or error message

Inputs: text (required). Returns: result

set_device_nameA
Set a display name for the device
Note: This doesn't change the system device name, only the AutoBot display name
Args:
    name (str): Display name for the device
Returns:
    str: Success or error message

Inputs: name (required). Returns: result

start_appB
Start an application by package name
Args:
    package_name (str): Package name of the application to start
Returns:
    str: Success or error message

Inputs: package_name (required). Returns: result

start_screen_recordingB
Start screen recording
Args:
    limit (int): Maximum recording duration in seconds (default: 180)
Returns:
    str: Success or error message

Inputs: limit. Returns: result

stop_all_scriptsB
Stop all running AutoX.js scripts
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

stop_appA
Stop an application by package name
Args:
    package_name (str): Package name of the application to stop
Returns:
    str: Success or error message

Inputs: package_name (required). Returns: result

stop_musicA
Stop playing music
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

stop_screen_recordingC
Stop screen recording
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

swipeB
Swipe from one point to another on the screen
Args:
    x1 (float): Start X coordinate (can be absolute or relative 0-1)
    y1 (float): Start Y coordinate (can be absolute or relative 0-1)
    x2 (float): End X coordinate (can be absolute or relative 0-1)
    y2 (float): End Y coordinate (can be absolute or relative 0-1)
    duration (int): Duration of the swipe in milliseconds (default: 500)
Returns:
    str: Success or error message

Inputs: x1 (required), y1 (required), x2 (required), y2 (required), +1 more. Returns: result

turn_safe_mode_offB
Turn off safe mode
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

turn_safe_mode_onB
Turn on safe mode
In safe mode, AutoBot cannot access screen layout (JSON/XML) or receive notifications
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

turn_screen_offA
Turn off the screen (device remains active for control/casting)
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

turn_screen_onB
Turn on the screen
Returns:
    str: Success or error message

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 53 tools

    Disambiguation4/5

    Most tools have distinct purposes, such as call_phone for calls, click for tapping, and get_screenshot for capturing images. However, some overlap exists, like click, long_click, and press all involving screen interactions, which could cause confusion despite their nuanced differences in duration or action.

    Naming Consistency5/5

    Tool names consistently follow a verb_noun pattern throughout, such as call_phone, clear_app_data, and get_device_info. There are no deviations in naming conventions, making the set predictable and easy to parse.

    Tool Count2/5

    With 53 tools, the count is excessive for an automation server, leading to potential overwhelm and redundancy. While the domain is broad, many tools could be consolidated or omitted without losing functionality, indicating poor scoping.

    Completeness5/5

    The toolset comprehensively covers mobile device automation, including UI interactions, file management, app control, system info, and communication features. There are no obvious gaps; agents can perform full workflows from setup to cleanup without dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables AI agents to control and automate Android devices through natural language, supporting actions like app management, UI interactions, and device monitoring.
      60
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that provides Android Debug Bridge functionality for automating Android devices, enabling remote device management, screen operations, app management, file operations, and shell command execution.
      20
      9 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables control and automation of Android devices using uiautomator2 and ADB. It supports UI interactions, app management, and shell command execution through the Model Context Protocol.
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables programmatic control of Android devices via ADB, supporting UI automation, app management, screen capture with OCR, and file transfers through the Model Context Protocol. It allows MCP-compatible clients like Claude Desktop and Cursor to interact directly with physical or emulated Android devices.
      3
      Apache 2.0