MAS MCP 服务器
面向 Claude Code、Cursor、Codex 和任何 MCP 客户端的安卓 MCP 服务器
25 个工具,给你的 AI 客户端装上安卓上的眼睛和手:它能查看的截图、OCR 和模板匹配、点击、滑动和输入、宏运行,以及一个能从一句话生成宏的智能体。从一个远程端点驱动 Windows 或 Mac 上的 BlueStacks、LDPlayer、MuMu、MEmu 或任何兼容 adb 的模拟器、插到电脑上的手机,或者全天在线的安卓云手机。
托管服务器,用你的 MAS 密钥换取的令牌;然后是作为 stdio 服务器的免费本地连接器。
claude mcp add --transport http mas https://api.automationmacro.com/mcp --header "Authorization: Bearer $MAS_MCP_TOKEN" claude mcp add mas-local -- python -m masagent mcp 托管服务器写在 ~/.codex/config.toml 里,令牌放在环境变量中;本地连接器作为 stdio 命令。
[mcp_servers.mas]
url = "https://api.automationmacro.com/mcp"
bearer_token_env_var = "MAS_MCP_TOKEN" codex mcp add mas-local -- python -m masagent mcp 在 Grok 的 MCP 设置里添加一个远程 MCP 服务器,填入端点和 Authorization 请求头;本地连接器是一个 stdio 条目。
{ "mcpServers": { "mas": { "url": "https://api.automationmacro.com/mcp", "headers": { "Authorization": "Bearer <your token>" } } } } { "mcpServers": { "mas-local": { "command": "python", "args": ["-m", "masagent", "mcp"] } } } Hermes 使用标准的 mcpServers 结构:端点加 Authorization 请求头,或者把本地连接器作为命令。
{ "mcpServers": { "mas": { "url": "https://api.automationmacro.com/mcp", "headers": { "Authorization": "Bearer <your token>" } } } } { "mcpServers": { "mas-local": { "command": "python", "args": ["-m", "masagent", "mcp"] } } } Cursor、OpenCode、Gemini CLI 以及任何接受带请求头的远程 HTTP 服务器或 stdio 命令的客户端。第二段代码用你的密钥换取令牌。
{
"mcpServers": {
"mas": { "type": "http", "url": "https://api.automationmacro.com/mcp", "headers": { "Authorization": "Bearer <your token>" } },
"mas-local": { "command": "python", "args": ["-m", "masagent", "mcp"] }
}
} curl -s -X POST https://api.automationmacro.com/api/mcp/oauth/token -d grant_type=client_credentials -d client_secret=$MAS_API_KEY 它是什么
MAS 安卓 MCP 服务器做什么
MCP 是 AI 客户端调用外部工具的协议。这个服务器把一台安卓设备变成这些工具。你的客户端请求截图,得到一张它能查看的图片;询问屏幕上写了什么,得到带置信度和边框的 OCR 行;发送一张模板,得到它的位置;点击、滑动、输入和按键;打开和关闭应用。这是每个安卓 MCP 服务器都会做的部分,在模拟器、插上数据线的手机或云手机上的工作方式完全相同。
MAS 服务器还做设备服务器做不到的部分。它读取并运行你库里的宏,让 MAS Agent 探索一个应用并交回一个做好的 Python 宏,还暴露智能体学到的应用地图,以及作为 MCP 资源提供的完整 SDK 参考,让你的客户端能按规范写宏代码。这使它在设备层是一个安卓自动化 MCP 服务器,在其上的各层(宏、智能体、地图)是一个移动自动化 MCP 服务器。它不是 Android Studio 插件,也不是编程助手。它驱动设备。
托管服务器
全部 25 个工具,在你的云手机上
一个远程 HTTP 端点。租用云手机、驱动它、在服务器端运行宏、用智能体生成新宏、读取应用地图。什么都不用安装,你的电脑可以关机。
本地连接器,免费
13 个设备和视觉工具,在你的电脑上
一个你自己运行的 stdio 服务器。它驱动 adb 能看到的任何东西:Windows 或 macOS 上的 BlueStacks、LDPlayer、MuMu、MEmu,或者开启了 USB 调试的手机。屏幕、输入、OCR 和模板匹配。不需要账户。
模拟器
控制安卓模拟器:Windows 或 Mac 上的 BlueStacks、LDPlayer、MuMu、MEmu
本地连接器是一个面向你桌上已有模拟器的安卓模拟器 MCP 服务器。用 python -m masagent mcp 启动它,通过参数或 MAS_DEVICE 变量指定设备,或者让它使用 adb 列出的第一台设备。它只需要 PATH 里有 adb,别的什么都不需要,而且从不回连服务器。这就是大多数人在找的 MCP 安卓模拟器配置:一条命令、adb,搞定。MAS 应用的“连接”页面会一步步带你完成。
- BlueStacks
- LDPlayer
- MuMu
- MEmu
- Windows
- macOS
游戏是让基于无障碍树的服务器失效的场景:没有树可读。连接器基于像素工作,所以模型可以像操作设置界面一样通关一个游戏界面。
云手机
安卓云手机,什么都不用安装
托管服务器连接的是 MAS 为你运行的全天在线设备。lease_device 打开一个控制会话,返回每个设备工具都需要的租约 id;设置 auto_start,它会先启动已停止的设备。租约在每次调用时续期,闲置 10 分钟后过期,所以被遗忘的客户端不可能永远占着设备。run_macro 在设备上服务器端执行,author_macro 让 MAS Agent 在上面工作,两者都可以在你电脑关机时进行。
设备工具不按调用收费;它们作用于你账户拥有的云手机,每台 $80/月,含月度积分额度。查看云手机。
你自己的手机
给你桌上那部手机的安卓 ADB MCP 服务器
开启 USB 调试,插上手机,本地连接器就会把它和你的模拟器列在一起。每个屏幕、输入和视觉工具都能在它上面用:模型可以通过 MCP 控制安卓手机,就像控制模拟器一样,用你已经在用的客户端,手机上什么都不用装。
视觉
模型能看到的截图、OCR 和模板匹配
screenshot把屏幕作为图片内容返回,所以模型直接查看它,而不是从一棵树里猜。本地连接器会把长边缩放到 1280 px 并报告缩放比例。read_text对整个屏幕或一个区域运行 OCR,返回每一行以及置信度和边框,所以“点击‘领取’这个词”是一个坐标,而不是一个希望。find_image用 OpenCV 匹配你发送的模板,阈值由你控制,返回得分和要点击的中心点。
工具
全部 25 个工具
每个工具的名称及其参数。“本地和托管”工具在两个界面上都存在;其余的需要云手机。
Device control
Pick a device and drive it: the same taps, swipes and keys a person would use.
- List the devices your client can reach, with their state. On the hosted server that is your cloud devices; on the local connector, whatever adb can see.
list_devices本地和托管 - Open a control session on one of your cloud devices and get the lease_id every device tool needs. Can boot a stopped device first. Leases expire after ten idle minutes and renew on every call.
lease_device(device_id, auto_start) 托管 - End the control session. The device keeps running.
release_device(lease_id) 托管 - Tap the screen at device coordinates.
tap(x, y) 本地和托管 - Swipe between two points for scrolling and drags, with a chosen duration.
swipe(x1, y1, x2, y2, duration_ms) 本地和托管 - Type text into the focused input field.
type_text(text) 本地和托管 - Press BACK, HOME, ENTER, TAB, DEL or any KEYCODE_ name.
press_key(key) 本地和托管 - Launch an app by package name.
open_app(package) 本地和托管 - Force-stop an app by package name.
close_app(package) 本地和托管 - Report the package in the foreground.
current_app本地和托管 - Return the screen size in pixels, the coordinate space for tap and swipe.
screen_size本地和托管 - Pause for animations and loading screens, up to ten seconds per call.
wait(ms) 本地和托管
Vision
Let the model see the screen and locate things on it without guessing coordinates.
- Capture the screen and return it as an image the model can look at.
screenshot(lease_id) 本地和托管 - OCR the whole screen or one region into text lines, each with a confidence and a bounding box.
read_text(region) 本地和托管 - Locate a template image on screen with OpenCV matching and return the match score and tap coordinates.
find_image(template_base64, threshold) 本地和托管
Macros and runs
Your macro library, readable and runnable from the client. Runs execute server-side on a cloud device.
- List your saved macros with name, id and type, paged.
list_macros(page, page_size) 托管 - Read a macro's source: the entry script by default, plus the file listing, or any file you name.
get_macro_code(macro_id, file) 托管 - Start a saved macro on a cloud device, server-side, with optional argument overrides. Returns a run_id.
run_macro(macro_id, device_id, args) 托管 - The state of a run, from launching through running to finished or failed, with its message.
get_run(run_id) 托管 - Stop a running macro.
stop_run(run_id) 托管
Agent authoring
Hand a goal to MAS Agent and get a finished macro back, from any client.
- Ask MAS Agent to build a new macro on a cloud device from a plain-language goal. Runs for several minutes and spends AI credits. Returns a session_id.
author_macro(prompt, device_id, model) 托管 - Progress of an authoring session: state, summary, the macro id once it exists, and the transcript events after your cursor, including any question the agent asked.
get_agent_session(session_id, after_seq) 托管 - Answer the agent's pending question so it can continue.
answer_agent_session(session_id, qid, answers) 托管 - Stop a session early. Work done so far is saved.
stop_agent_session(session_id) 托管
App maps
What the agent has learned about an app, readable by your client.
- The learned menu map of an app: its screens and the proven routes between them.
get_map(package, profile) 托管
资源
服务器发布的文档,让客户端不用离开对话就能写宏代码。
mas://docs/sdk-referenceThe full mas SDK reference, so an external agent can write macro code in house style.mas://docs/house-libraryThe house library of helpers the agent and the studio use.
设置
一分钟接入
托管服务器使用 OAuth 客户端凭据:在应用的 API 密钥下创建一个密钥,选择它的权限范围,然后换取一个有效期 1 小时的访问令牌。把这个令牌作为 bearer 请求头发送。本地连接器不需要密钥。
curl -s -X POST https://api.automationmacro.com/api/mcp/oauth/token -d grant_type=client_credentials -d client_secret=$MAS_API_KEY Claude Code
托管服务器,使用上面的令牌;或者本地连接器,作为 stdio 命令:
claude mcp add --transport http mas https://api.automationmacro.com/mcp --header "Authorization: Bearer $MAS_MCP_TOKEN"
claude mcp add mas-local -- python -m masagent mcp Cursor
在 .cursor/mcp.json 里,一个带请求头的远程 HTTP 条目:
{
"mcpServers": {
"mas": {
"url": "https://api.automationmacro.com/mcp",
"headers": { "Authorization": "Bearer <your token>" }
}
}
} Codex CLI
在 ~/.codex/config.toml 里,令牌放在环境变量中:
[mcp_servers.mas]
url = "https://api.automationmacro.com/mcp"
bearer_token_env_var = "MAS_MCP_TOKEN" Hermes、OpenCode、Gemini CLI 和其他客户端
任何接受带请求头的远程 HTTP 服务器或能启动 stdio 命令的客户端。Claude Desktop 和 claude.ai 的连接器需要交互式登录,所以请使用一个添加请求头的本地桥接。
{
"mcpServers": {
"mas": { "type": "http", "url": "https://api.automationmacro.com/mcp", "headers": { "Authorization": "Bearer <your token>" } },
"mas-local": { "command": "python", "args": ["-m", "masagent", "mcp"] }
}
} 验证:让你的客户端列出设备,然后要一张截图。端点 https://api.automationmacro.com/mcp,协议 2025-06-18,发现文档在 /.well-known 下。
智能体,作为工具
author_macro:从 AI 探索到做好的 Python 宏
大多数安卓 MCP 服务器止步于设备。这一个把智能体交给你。author_macro 接收一个用普通语言描述的目标和一台云手机,启动一个 MAS Agent 会话:探索应用,从实时屏幕截取需要的模板图片和文字区域,编译出确定性的 Python 宏,并通过回放验证。get_agent_session 返回带游标的记录以及智能体提出的任何问题;answer_agent_session 回答它。做好的宏进入你的库,id 记录在会话里,随时可以 run_macro,之后每次运行都是零 AI 积分。查看 MAS Agent。
QA
安卓应用测试和 QA 工作流
把客户端指向模拟器或云手机上的测试版本,用 tap、type_text 和 press_key 驱动流程,用 read_text 或 find_image 逐屏断言。用 author_macro 走一遍流程,它就变成一个可以定时运行的可重复检查。它像用户一样通过屏幕测试应用;它不是单元测试框架。
安全
远程服务器、HTTP 传输、带权限范围的密钥,以及一个从不回连的连接器
托管服务器是单一端点上基于 HTTPS 的无状态 JSON-RPC。密钥在应用里创建,只显示一次,可以带过期日期,一键撤销;由它换取的令牌有效期 1 小时。每个密钥只携带你授予的权限范围:
-
devices:controllease a cloud device, see its screen, tap, type and manage apps -
macros:runlist and read macros, start, check and stop runs -
macros:authorstart, follow, answer and stop an agent authoring session -
maps:readread the learned map of an app
本地连接器自己不发起任何网络调用:它只和你电脑上的 adb 以及你的客户端通信,别的都不碰。
安卓 MCP 服务器常见问题
什么是安卓 MCP 服务器?
MCP(Model Context Protocol)是 Claude Code、Cursor 和 Codex 等 AI 客户端调用外部工具的方式。安卓 MCP 服务器把一台安卓设备作为工具暴露出来:截图、读取上面的文字、点击、滑动、输入、打开应用。MAS 服务器暴露 25 个工具,并加上单纯的设备服务器做不到的事:运行已保存的宏、让 MAS Agent 生成一个、读取它学到的应用地图。
如何把 Claude Code 连接到安卓模拟器?
对于你自己的模拟器,运行免费的本地连接器(python -m masagent mcp),把它作为 stdio 服务器添加到 Claude Code;它能驱动 adb 看到的任何设备。对于云手机,在应用里创建一个密钥,换取令牌,然后用 claude mcp add --transport http 和 bearer 请求头添加托管服务器。两段代码都在本页。
支持 BlueStacks、LDPlayer、MuMu、MEmu 吗?
支持。本地连接器和 adb devices 列出的任何东西通信,这覆盖了 Windows 或 macOS 上的 BlueStacks、LDPlayer、MuMu、MEmu 以及其他兼容 adb 的模拟器。它不绑定任何一个模拟器品牌。
Cursor 或 Codex 能通过 MCP 控制安卓模拟器吗?
能。Cursor 在 mcp.json 里把托管服务器作为带 Authorization 请求头的远程 HTTP 条目,把本地连接器作为 stdio 命令。Codex CLI 用 codex mcp add 添加托管服务器,bearer 令牌来自环境变量。两边出现的是同一套工具。
还有哪些 MCP 客户端可以用?
任何能用 bearer 请求头调用远程 HTTP MCP 服务器、或能启动 stdio 服务器的客户端:Claude Code、Cursor、Codex、Hermes、OpenCode、Gemini CLI 等。Claude Desktop 和 claude.ai 自定义连接器需要交互式登录流程,所以在 MAS 上它们通过一个添加请求头的本地桥接来连接。
需要安装 ADB 或 Android Studio 吗?
本地连接器底层使用 adb,所以 PATH 里必须有 adb;不需要 Android Studio。托管服务器什么都不用安装:云手机在服务器端驱动,你的客户端只是调用工具。
模型真的能看到屏幕吗?
能。screenshot 把屏幕作为图片返回,模型直接查看。read_text 运行 OCR,返回每一行以及置信度和边框;find_image 匹配你发送的模板,返回得分和点击坐标。不需要无障碍树,所以它在游戏上也能用。
可以控制插到电脑上的实体安卓手机吗?
可以,通过本地连接器。开启 USB 调试,插上手机,它就会像任何模拟器一样出现在 list_devices 里。屏幕、输入和视觉工具的工作方式完全一样。
它是远程 MCP 服务器还是本地运行?
都有。托管服务器是一个远程 HTTP 端点 https://api.automationmacro.com/mcp,为你的云手机提供全部 25 个工具。本地连接器是一个你在自己电脑上运行的免费 stdio 服务器,为模拟器和插上数据线的手机提供 13 个设备和视觉工具。宏运行、智能体生成和应用地图仅在托管端提供。
身份验证如何工作?
OAuth 客户端凭据。你在应用里创建一个密钥并选择它的权限范围;你的客户端在 https://api.automationmacro.com/api/mcp/oauth/token 用密钥换取一小时有效的访问令牌,并作为 bearer 令牌发送。密钥可以带过期日期,随时可以撤销。发现文档发布在 /.well-known 下。
author_macro 返回什么?需要多久?
它在云手机上启动一个 MAS Agent 会话,并立即返回会话 id。智能体会探索应用几分钟;get_agent_session 以游标方式流式返回记录,并显示它提出的任何问题,你用 answer_agent_session 回答。完成后,宏 id 在会话里,宏在你的库里,随时可以 run_macro。生成消耗 AI 积分;运行做好的宏零积分。查看 MAS Agent。
免费吗?云手机多少钱?
本地连接器免费。托管服务器是你 MAS 账户的一部分;它的设备工具作用于你拥有的云手机,每台 $80/月,含月度积分额度,设备工具不按调用收费。运行做好的宏零积分;智能体生成时按工作量消耗积分。查看价格。
可以在云手机上 24 小时运行而不开电脑吗?
可以。lease_device 在云手机上打开控制会话,还能启动已停止的设备;run_macro 在服务器端执行。你的电脑不需要一直开着,租约在每次调用时续期,闲置 10 分钟后过期。查看云手机。
可以用它做安卓应用测试和 QA 吗?
可以。把客户端指向测试版本,用 tap、type 和 press_key 驱动流程,用 read_text 或 find_image 逐屏断言,让 author_macro 把你走过一遍的流程变成可重复的检查。它像用户一样通过屏幕自动操作应用;它不是单元测试框架。