Skip to main content

Model Context Protocol server for Mahoraga - AI-powered mobile automation agent

Project description

Mahoraga MCP - AI-Powered Mobile Automation

A Model Context Protocol (MCP) server for mobile automation testing with Mahoraga. Control Android devices and run automated tests directly from Claude Code or any MCP-compatible client using natural language.

Features

  • ๐Ÿค– AI-Powered Automation: Control your Android device using plain English
  • ๐Ÿ“ฑ Device Connection: Works with emulators and physical devices
  • โš™๏ธ Flexible Configuration: Customize AI model, temperature, vision, reasoning, and more
  • ๐Ÿ”„ Real-Time Execution: Live progress streaming during task execution
  • ๐ŸŽฏ Suite Execution: Run multiple tasks in sequence with retry logic
  • ๐Ÿ“Š Usage Tracking: Monitor API costs and token usage
  • ๐Ÿ” Secure: API key authentication via Mahoraga platform

Installation

pip install mahoraga-mcp

All dependencies (including ADB tools, LLM frameworks, and image processing) are automatically installed.

Quick Start

1. Get Your API Key

  1. Visit mahoraga.app (or your deployment URL)
  2. Sign in with Google
  3. Go to Dashboard โ†’ API Keys
  4. Create a new API key

2. Configure Claude Code

Add this to your MCP settings file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Linux: ~/.config/claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "mahoraga": {
      "command": "mahoraga-mcp"
    }
  }
}

Important: Restart Claude Code after adding the configuration.

3. Start Automating

Open Claude Code and try:

"Setup Mahoraga and connect to my Android device"
"Configure with my API key: mhg_xxxx..."
"Execute task: Open Settings and enable WiFi"

Available Tools

1. build

Setup and verify all dependencies.

Example:

Can you run the build tool to setup my system for Mahoraga?

2. connect

Connect to an Android device or emulator.

Parameters:

  • device_serial (optional): Device serial number

Example:

Connect to my Android device

3. configure

Configure agent execution parameters.

Parameters:

  • mahoraga_api_key: Your Mahoraga API key from the web portal
  • model: LLM model (e.g., "anthropic/claude-sonnet-4", "openai/gpt-4o")
  • temperature: 0-2 (default: 0.2)
  • max_steps: Maximum execution steps (default: 15)
  • vision: Enable screenshots (default: false)
  • reasoning: Enable multi-step planning (default: false)
  • reflection: Enable self-improvement (default: false)
  • debug: Verbose logging (default: false)

Example:

Configure Mahoraga with my API key mhg_xxx, use Claude Sonnet 4, and enable vision

4. execute

Run an automation task on the device.

Parameters:

  • task: Natural language task description

Example:

Execute task: Open Settings and navigate to WiFi settings

5. runsuite

Execute multiple tasks in sequence with retry logic.

Parameters:

  • suite_name: Name of the test suite
  • tasks: Array of tasks with retry and failure handling options

Example:

Run a test suite with these tasks: [
  {"prompt": "Open Settings", "type": "setup"},
  {"prompt": "Enable WiFi", "type": "test", "retries": 2},
  {"prompt": "Close Settings", "type": "teardown"}
]

6. usage

View API usage statistics and costs.

Example:

Show me my Mahoraga usage statistics

Complete Workflow Example

User: "Setup Mahoraga on my machine"
โ†’ Runs build tool
โ†’ Returns: All dependencies installed โœ“

User: "Connect to my Android emulator"
โ†’ Runs connect tool
โ†’ Returns: Connected to emulator-5554 โœ“

User: "Configure to use Claude Sonnet 4 with vision and my API key is mhg_xxx..."
โ†’ Runs configure tool
โ†’ Returns: Configuration set โœ“

User: "Execute task: Open Instagram and go to my profile"
โ†’ Runs execute tool with live streaming
โ†’ Returns: Task completed โœ“

User: "Show me my usage statistics"
โ†’ Runs usage tool
โ†’ Returns: Total cost: $0.15, 10 executions โœ“

Requirements

  • Python 3.11+ - Required for the MCP server
  • Android Device - Emulator or physical device with USB debugging enabled
  • Mahoraga API Key - Get from mahoraga.app

Dependencies automatically installed:

  • Android Debug Bridge (ADB) - via adbutils
  • Mahoraga Portal APK - via apkutils
  • LLM frameworks - via llama-index
  • Image processing - via pillow

Architecture

mahoraga-mcp/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ server.py            # Main MCP server entry point
โ”‚   โ”œโ”€โ”€ backend_client.py    # API communication with Mahoraga platform
โ”‚   โ”œโ”€โ”€ llm_wrapper.py       # LLM integration layer
โ”‚   โ”œโ”€โ”€ state.py             # Session state management
โ”‚   โ”œโ”€โ”€ usage_tracker.py     # Usage and cost tracking
โ”‚   โ””โ”€โ”€ tools/
โ”‚       โ”œโ”€โ”€ build.py         # Dependency checker and installer
โ”‚       โ”œโ”€โ”€ connect.py       # Device connectivity
โ”‚       โ”œโ”€โ”€ configure.py     # Agent configuration
โ”‚       โ”œโ”€โ”€ execute.py       # Task execution
โ”‚       โ”œโ”€โ”€ runsuite.py      # Suite execution
โ”‚       โ””โ”€โ”€ usage.py         # Usage statistics
โ””โ”€โ”€ pyproject.toml

Troubleshooting

"No devices found"

  • Start Android emulator via Android Studio > AVD Manager
  • Connect physical device with USB debugging enabled
  • For WiFi debugging: adb tcpip 5555 && adb connect <device-ip>:5555

"Portal not ready"

  • The connect tool automatically installs the Portal APK
  • If it fails, manually enable the Mahoraga Portal accessibility service in Settings > Accessibility

"Invalid API key"

  • Make sure you've run configure with a valid API key from mahoraga.app
  • API keys start with mhg_ prefix
  • Check your API key hasn't been revoked in the web portal

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mahoraga_mcp-0.1.0.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mahoraga_mcp-0.1.0-py3-none-any.whl (32.7 kB view details)

Uploaded Python 3

File details

Details for the file mahoraga_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: mahoraga_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for mahoraga_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bd5a7b013898e96a3a8e71ae1397a45c674d860cae207f0d54058ede71b5108c
MD5 18325160d3cf62a7999f9ae2039f6456
BLAKE2b-256 82f1703cb9deed072886d32deb7cef9f10491292098ab706414ed30aaabd3a27

See more details on using hashes here.

File details

Details for the file mahoraga_mcp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mahoraga_mcp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for mahoraga_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 444cc453808203b084ba382d177a7150f451216342a68878c3df8e7b919c6b2f
MD5 606b1c817c9db57da4656947af65e8c5
BLAKE2b-256 81dc41f4df1d7f48fd3027a032acbf81d593b3bba0aa2ad92cc85afd5742fbff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page