Android模拟位置控制工具

一款用于在Android模拟器中模拟GPS位置的工具,支持地理编码和街道级路线规划,适用于QA测试和开发调试。

  • by Manabu-GT
  • TypeScript
  • 本地部署
  • 4 星标
  • 更新于
在 GitHub 查看 Manabu-GT/android-mock-location-mcp

使用说明

安卓模拟定位mcp

从任何MCP客户端模拟Android模拟器GPS。 通过内置的地理编码和街道级路由控制模拟器的位置以进行QA测试。

"Drive from downtown Denver to the airport with rush hour traffic"
"Simulate bad GPS signal for 30 seconds"
"Test the geofence at the nearest Whole Foods - bounce in and out 3 times"

为什么?

测试位置感知应用程序是痛苦的。你要么:

  • 在模拟器的扩展控件中手动键入坐标
  • 使用硬编码坐标编写复杂的ADB脚本
  • 使用笨重的GUI模拟位置应用程序

此MCP服务器允许您从Android Studio、Cursor、Claude Code、Codex等控制模拟器位置。说“开车去机场”,而不是复制粘贴坐标。

此服务器 控制Android模拟器的GPS 内置地理编码和街道级路由——它发送 geo fix 通过ADB直接向仿真器发送命令。

建筑

┌─────────────────────────────────────────────────────────┐
│  Developer Machine                                      │
│  ┌───────────────┐      ┌─────────────────────────────┐ │
│  │ Claude/Cursor │ ←──→ │ MCP Server                  │ │
│  │ or any MCP    │      │ • Geocoding + routing       │ │
│  │ client        │      │ • Route interpolation       │ │
│  └───────────────┘      │ • geo fix command            │ │
│                          └──────────┬──────────────────┘ │
└────────────────────────────────────┼────────────────────┘
                                     │ adb emu geo fix
                                     ▼
┌─────────────────────────────────────────────────────────┐
│  Android Emulator                                       │
│  GPS location set via geo fix                           │
└─────────────────────────────────────────────────────────┘

快速开始

1.配置您的MCP客户端

服务器由您的MCP客户端自动启动,您无需直接运行它。将其添加到客户端的配置中:

Claude Desktop

编辑 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)或 %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "android-mock-location-mcp": {
      "command": "npx",
      "args": ["-y", "android-mock-location-mcp"]
    }
  }
}
Cursor

前往设置→ MCP → 添加服务器:

{
  "command": "npx",
  "args": ["-y", "android-mock-location-mcp"]
}
Claude Code
claude mcp add android-mock-location-mcp -- npx -y android-mock-location-mcp

更新配置以使更改生效后,重新启动MCP客户端。

有关提供者选项(Google、Mapbox),请参阅 服务器配置.

2.启动模拟器

从Android Studio或命令行启动Android模拟器。无需特殊设置——服务器直接通过 geo fix 命令。

3.使用它

在您的MCP客户端中:

> Set location to Times Square New York
> Drive from here to SFO airport at 60 km/h

服务器将自动检测模拟器并开始设置位置。

可用工具

工具 说明
geo_set_location 设置为坐标或地名
geo_simulate_route 以指定速度沿路线移动(支持汽车/脚/自行车配置文件)
geo_simulate_multi_stop 有停留时间的多站路线(如送货路线)
geo_simulate_jitter 模拟GPS噪声(城市峡谷、漂移)
geo_test_geofence 测试地理围栏进入/退出/反弹
geo_replay_gpx_kml 重播GPX或KML曲目文件
geo_stop 停止任何活动模拟
geo_get_status 当前模拟位置状态
geo_get_location 获取模拟器的当前GPS位置(用作路线起点)
geo_list_devices 列出已连接的Android模拟器
geo_connect_device 连接到特定模拟器

有关完整的参数参考,请参阅 服务器/README.md.

提供程序配置

开箱即用 开放街道图 (免费,无API密钥)。为了获得更好的结果,请考虑使用 谷歌 或 地图框 供应商——他们提供更准确的地理编码、完整的路线配置文件支持(汽车/步行/自行车)和更高的费率限制。

提供商 优点 限制 获取API密钥
osm (默认) 免费,不需要API密钥 仅限车辆路线,1 req/sec地理编码限制 -
google 精确的地理编码,完整的汽车/脚/自行车路线 需要API密钥(具有免费层) 谷歌地图平台
mapbox 精确的地理编码,完整的汽车/步行/自行车路线 需要访问令牌(有免费等级) Mapbox访问令牌

有关环境变量、MCP客户端配置示例和提供程序详细信息,请参阅 服务器/README.md.

例子

# Basic location
"Set location to 37.7749, -122.4194"
"Move to Times Square"

# Route simulation
"Drive from SFO to downtown SF, simulate a commute with heavy traffic"
"Walk to the nearest Whole Foods"

# Multi-stop routes
"Simulate a delivery route: warehouse → Stop A (wait 30s) → Stop B (wait 30s) → depot"

# Track replay
"Replay this GPX file from my morning run at 2x speed"

# GPS testing
"Simulate bad GPS for 30 seconds, add urban canyon jitter with 50m radius"

# Geofence testing
"Test entering the nearest Starbucks geofence, bounce in and out of a 100m radius 5 times"

文档

文档 描述
服务器README 工具参考、提供者配置、开发
出版 npm发布工作流
贡献 开发设置

补充工具

此服务器专注于仿真器位置控制。其他需求:

  • 移动mcp --跨平台(iOS+Android)移动UI自动化
  • 安卓MCP -通过亚洲开发银行+辅助功能API实现轻量级Android设备控制

许可证

Apache 2.0——请参阅 许可证