Mobile automation iOS MCP server

Modern iOS automation server built with FastMCP 2.0 and clean architecture

License: MITPython 3.11+Platform: macOSFastMCPArchitecture

A production-ready iOS automation MCP server built with FastMCP 2.0, featuring clean modular architecture with complete platform segregation. Ready for cross-platform expansion with iOS-specific and shared components properly separated.

๐Ÿ“บ Demo Video

Mobile automation iOS MCP server Demo

๐ŸŽฌ Watch the Complete Demo: Mobile automation iOS MCP server in Action

โœจ Features

  • ๐Ÿš€ FastMCP 2.0 - Modern Python-first MCP implementation
  • ๐ŸŒ Cloud Deployment - Ready for Railway, Heroku, or other platforms
  • ๐Ÿ“ฑ Real iOS Automation - Appium + WebDriverAgent integration
  • ๐Ÿ—๏ธ Clean Modular Architecture - Complete platform segregation & SOLID principles
  • ๐Ÿ”„ Cross-Platform Ready - Shared utilities for future Android/other platforms
  • ๐ŸŽจ Beautiful Logging - Colored console output with emojis
  • ๐Ÿ”ง Type-Safe - Comprehensive type hints throughout
  • ๐Ÿ”Œ Extensible - Plugin-style tool system with modular configuration
  • ๐Ÿ“ฆ Zero Code Duplication - DRY principles with shared utilities

๐Ÿš€ Quick Start

Option 1: Remote Server (Recommended)

Use the hosted version on Railway - no local setup required:

{
  "mcpServers": {
    "ios-automation-railway": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://mcp-server-demo-production.up.railway.app/sse/"
      ]
    }
  }
}

Option 2: Local Development

  1. Prerequisites

    • macOS (required for iOS automation)
    • Python 3.11+
    • uv (recommended) or pip
    • Xcode with iOS Simulator
    • Node.js (for Appium)
  2. Installation

    git clone https://github.com/iHackSubhodip/mcp-server-demo.git
    cd mcp-server-demo
    
    # Using uv (recommended)
    uv sync
    
    # Or using pip (legacy)
    pip install -e .
    
  3. Claude Desktop Configuration

    {
      "mcpServers": {
        "ios-automation-local": {
          "command": "uv",
          "args": ["run", "python", "mobile-automation-mcp-server/fastmcp_server.py"],
          "cwd": "/path/to/mcp-server-demo"
        }
      }
    }
    

๐Ÿ—๏ธ Architecture

The Mobile automation iOS MCP server features a clean, modular architecture with complete platform segregation achieved through a comprehensive 6-phase refactoring. This design enables maximum maintainability, zero code duplication, and seamless cross-platform expansion.

โœจ Architecture Achievements

๐ŸŽฏ Complete Platform Segregation

  • Cross-platform utilities isolated in shared/ package
  • iOS-specific code contained in platforms/ios/ package
  • Clean separation of concerns across all components
  • Future-ready for Android in platforms/android/

๐Ÿ”„ DRY Principles Applied

  • Shared utilities: Logger, exceptions, command runner
  • Base configuration: AppiumConfig, ServerConfig for reuse
  • Platform configs: iOS-specific settings separate
  • Zero duplication between current/future platforms

๐Ÿ›ก๏ธ Maintainable & Extensible

  • Self-contained platforms: Each platform completely independent
  • Unified interface: Single configuration entry point
  • Backward compatible: All existing interfaces preserved
  • Professional structure: Enterprise-grade organization

Directory Structure

mobile-automation-mcp-server/
โ”œโ”€โ”€ fastmcp_server.py          # ๐Ÿš€ FastMCP 2.0 server (main entry)
โ”œโ”€โ”€ config/
โ”‚   โ””โ”€โ”€ settings.py           # ๐Ÿ”ง Unified configuration interface
โ”œโ”€โ”€ shared/                   # ๐ŸŒ Cross-platform utilities & config
โ”‚   โ”œโ”€โ”€ utils/               # ๐Ÿ› ๏ธ Platform-agnostic utilities  
โ”‚   โ”‚   โ”œโ”€โ”€ logger.py       # ๐Ÿ“ Colored logging with emojis
โ”‚   โ”‚   โ”œโ”€โ”€ exceptions.py   # โš ๏ธ Exception hierarchy
โ”‚   โ”‚   โ””โ”€โ”€ command_runner.py # ๐Ÿ’ป Shell command execution
โ”‚   โ””โ”€โ”€ config/             # โš™๏ธ Base configuration classes
โ”‚       โ””โ”€โ”€ base_settings.py # ๐Ÿ“‹ AppiumConfig, ServerConfig
โ”œโ”€โ”€ platforms/ios/          # ๐ŸŽ iOS-specific platform code
โ”‚   โ”œโ”€โ”€ automation/         # ๐Ÿค– iOS automation services
โ”‚   โ”‚   โ”œโ”€โ”€ appium_client.py # ๐Ÿ“ฑ iOS automation client
โ”‚   โ”‚   โ”œโ”€โ”€ screenshot_service.py # ๐Ÿ“ธ Screenshot handling
โ”‚   โ”‚   โ””โ”€โ”€ simulator_manager.py # ๐ŸŽฎ Simulator management
โ”‚   โ”œโ”€โ”€ tools/             # ๐Ÿ”จ iOS-specific MCP tools
โ”‚   โ”‚   โ”œโ”€โ”€ appium_tap_type_tool.py # โŒจ๏ธ Text field automation
โ”‚   โ”‚   โ”œโ”€โ”€ find_and_tap_tool.py    # ๐Ÿ‘† Advanced element finding
โ”‚   โ”‚   โ”œโ”€โ”€ launch_app_tool.py      # ๐Ÿš€ App launching
โ”‚   โ”‚   โ””โ”€โ”€ screenshot_tool.py      # ๐Ÿ“ท Screenshot capture
โ”‚   โ””โ”€โ”€ config/            # โš™๏ธ iOS-specific configuration
โ”‚       โ””โ”€โ”€ ios_settings.py # ๐ŸŽ iOSConfig (XCUITest, iPhone)
โ”œโ”€โ”€ screenshots/             # ๐Ÿ“ Screenshot storage
โ”œโ”€โ”€ Dockerfile              # ๐Ÿณ Container deployment
โ”œโ”€โ”€ Procfile                # ๐Ÿš‚ Railway deployment
โ””โ”€โ”€ pyproject.toml          # ๐Ÿ“ฆ Dependencies & project config

๐ŸŽฏ Benefits Achieved

Aspect Before Refactoring After Refactoring
Structure Mixed iOS/shared code Clean platform segregation
Maintainability Monolithic Modular & self-contained
Extensibility iOS-only Cross-platform ready
Code Reuse Duplication likely Shared utilities for all platforms
Configuration Single settings file Modular config hierarchy
Organization Flat structure Professional enterprise structure

๐Ÿ”ง Available Tools

take_screenshot

Capture iOS simulator screenshots

{
  "filename": "optional_name.png",
  "device_id": "booted"
}

launch_app

Launch iOS applications

{
  "bundle_id": "com.apple.mobilesafari",
  "device_id": "booted"
}

find_and_tap

Find and tap UI elements with smart automation

{
  "accessibility_id": "submitButton",
  "take_screenshot": true,
  "dismiss_after_screenshot": false
}

appium_tap_and_type

Enhanced text input with element finding

{
  "text": "Hello World!",
  "element_type": "textField",
  "timeout": 10
}

list_simulators

List available iOS simulators

{}

get_server_status

Check server and Appium status

{}

๐Ÿ› ๏ธ Development

Local Development Commands

# Run FastMCP server locally (with uv)
uv run python mobile-automation-mcp-server/fastmcp_server.py

# Install dependencies (if needed)
uv sync

# Development mode (with dev dependencies)
uv sync --dev

Appium Setup

# Install Appium
npm install -g appium
appium driver install xcuitest

# Start Appium server
appium server --port 4723

Architecture Development

# The modular structure makes development easier:

# Work on shared utilities (affects all platforms)
cd shared/utils/

# Work on iOS-specific features  
cd platforms/ios/

# Work on configuration
cd config/

# Add new platforms (future)
mkdir platforms/android/

๐ŸŒ Cloud Deployment

This server is deployed on Railway and accessible via:

  • HTTP Endpoint: https://mcp-server-demo-production.up.railway.app/
  • SSE Endpoint: https://mcp-server-demo-production.up.railway.app/sse/

The cloud deployment simulates iOS automation responses for demonstration purposes.

๐Ÿ“Š Key Improvements

Feature Traditional MCP FastMCP 2.0 + Clean Architecture
Setup Complex configuration Simple Python decorators
Architecture Monolithic Modular platform segregation
Code Reuse Manual duplication Shared utilities package
Type Safety Manual validation Built-in Pydantic models
Error Handling Basic try-catch Rich context and logging
Deployment Local only Cloud-ready with Railway
Extensibility Hard to extend Easy platform addition
Maintainability Complex Clean separation of concerns

๐Ÿ” Troubleshooting

Simulator Issues

# List available simulators
xcrun simctl list devices

# Boot a simulator
xcrun simctl boot "iPhone 16 Pro"

Appium Connection

# Check Appium status
curl http://localhost:4723/status

# Restart Appium
pkill -f appium && appium server --port 4723

๐Ÿ“ Dependencies

Core dependencies managed via pyproject.toml:

  • fastmcp>=2.9.2 - FastMCP 2.0 framework
  • mcp>=1.0.0 - Traditional MCP protocol
  • aiohttp>=3.9.0 - HTTP client for automation
  • appium-python-client>=3.0.0 - iOS automation
  • pydantic>=2.4.0 - Data validation

Install with:

# Using uv (recommended)
uv sync

# Or using pip
pip install -e .

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Follow the clean architecture patterns:
    • Shared utilities go in shared/
    • Platform-specific code goes in platforms/{platform}/
    • Configuration follows the modular hierarchy
  4. Add comprehensive error handling
  5. Submit a pull request

๐Ÿš€ Future Expansion

Thanks to the clean architecture, adding new platforms is straightforward:

# Add Android platform (example)
mkdir -p platforms/android/{automation,tools,config}

# Reuse shared utilities
from shared.utils import get_logger, AutomationMCPError
from shared.config import AppiumConfig, ServerConfig

# Create Android-specific config
from platforms.android.config import AndroidConfig

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

MCP Server ยท Populars

MCP Server ยท New