midscene
midscene copied to clipboard
feat(mcp): simplify MCP tool architecture and unify platform tools
Summary
This PR refactors the MCP packages to use a simplified, consistent tool architecture across all platforms (Web, Android, iOS).
Key Changes
๐๏ธ Shared Infrastructure (@midscene/shared/mcp)
- Created
BaseMCPServerandBaseMidsceneToolsbase classes for code reuse - Implemented dynamic tool generation from
agent.getActionSpace() - Simplified common tools to only
take_screenshotandwait_for(removedassert) - Added unified tool generation pattern in
tool-generator.ts
๐ฆ Platform-Specific Packages
- @midscene/web-mcp (Renamed from @midscene/mcp): Web automation via Puppeteer & Bridge mode
- @midscene/android-mcp (New): Android-specific MCP server with
android_connecttool - @midscene/ios-mcp (New): iOS-specific MCP server with
ios_connecttool
๐ฏ Simplified Tool Architecture
Each platform now provides exactly 3 types of tools:
- ActionSpace tools (dynamic): Generated from
agent.getActionSpace()- Platform-specific interaction capabilities (Tap, Input, Scroll, etc.)
- Common tools (2 tools):
take_screenshot: Capture current page/screenwait_for: Wait until condition becomes true
- Platform connection (1 tool):
web_connect: Connect to web page (Puppeteer) or browser (Bridge mode)android_connect: Connect to Android device (optionaldeviceIdanduri)ios_connect: Connect to iOS device (optionaluri)
๐ง Recent Improvements
Bridge Mode Enhancement (d56be2d7):
- Improved bridge mode device initialization in
base-tools.ts - Enhanced wait_for error handling with try-catch blocks
- Better connection lifecycle management
Build & Type Fixes (0d4a3734):
- Fixed invalid
planTypeparameter in tool-generator.ts - Added missing
isErrorfield to wait_for tool response - Removed unused
@midscene/androiddependency from web-mcp - Added externals configuration to android-mcp and ios-mcp rslib configs
- Unified version handling using
__VERSION__constant across all MCP packages
๐งช Testing & Quality
- All MCP package tests passing (web-mcp: 22/22, android-mcp, ios-mcp)
- Build and lint checks passing
- Fixed test organization (moved from @midscene/mcp to @midscene/web-mcp)
Migration Notes
Tools have been consolidated:
- ~~
open_new~~ โweb_connect - ~~
android_list_devices~~ โ Removed (useandroid_connectwithout deviceId) - ~~
android_launch~~ โ Merged intoandroid_connect(useuriparameter) - ~~
ios_check_environment~~ โ Removed (just useios_connect) - ~~
assert~~ โ Removed from common tools
Package rename:
@midscene/mcpโ@midscene/web-mcp
Related Issues
Part of MCP architecture refactoring to support multiple platforms with consistent patterns. Addresses GitHub Copilot review comments for improved code quality and type safety.
๐ค Generated with Claude Code
Deploy Preview for midscene ready!
| Name | Link |
|---|---|
| Latest commit | cb1fe3377f0b54edfdc5787c152acd59a7d5bc84 |
| Latest deploy log | https://app.netlify.com/projects/midscene/deploys/6937863d3ab57b0008476428 |
| Deploy Preview | https://deploy-preview-1507--midscene.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify project configuration.