> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mobilerun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Server

> Connect AI agents and tools to Mobilerun using the Model Context Protocol.

Mobilerun provides a Model Context Protocol (MCP) server that enables AI agents, IDEs, and other MCP-compatible tools to interact with the Mobilerun API directly. All API endpoints are accessible through MCP.

## Overview

The MCP integration allows you to:

* Run mobile automation tasks from AI coding assistants
* Access all Mobilerun API functionality through MCP tools
* Integrate with any MCP-compatible client (Cursor, Claude Desktop, etc.)

## Configuration

There are two ways to connect to the Mobilerun MCP server:

### API Key Authentication

Use your [API key](/api-keys) for direct authentication. This method is ideal for automated workflows and server-side integrations.

```json theme={null}
{
  "mcpServers": {
    "mobilerun": {
      "url": "https://api.mobilerun.ai/v1/mcp",
      "transport": "http",
      "headers": {
        "Authorization": "Bearer dr_sk_YOUR_API_KEY"
      }
    }
  }
}
```

Replace `dr_sk_YOUR_API_KEY` with your actual API key from the [API Keys](/api-keys) tab.

### OAuth Authentication

Use OAuth for interactive authentication through the browser. This method is recommended for personal use in IDEs and desktop applications.

```json theme={null}
{
  "mcpServers": {
    "mobilerun": {
      "url": "https://cloud.mobilerun.ai/api/mcp/sse",
      "auth": {
        "type": "oauth2",
        "authorization_url": "https://cloud.mobilerun.ai/api/auth/oauth2/authorize",
        "token_url": "https://cloud.mobilerun.ai/api/auth/oauth2/token"
      }
    }
  }
}
```

With OAuth, you'll be prompted to sign in through your browser when the MCP client first connects.

## Available Tools

Once connected, the MCP server exposes tools for all Mobilerun operations:

| Tool Category   | Description                                  |
| --------------- | -------------------------------------------- |
| **Tasks**       | Create, run, monitor, and cancel agent tasks |
| **Devices**     | List devices and check availability          |
| **Apps**        | Browse and manage applications               |
| **Credentials** | Access stored credentials for tasks          |
| **Hooks**       | Manage webhook subscriptions                 |

## Client Setup

### Cursor

Add the MCP configuration to your Cursor settings:

1. Open Cursor Settings
2. Navigate to the MCP section
3. Add the Mobilerun server configuration
4. Restart Cursor to connect

### Claude Desktop

Add the configuration to your Claude Desktop `claude_desktop_config.json` file:

**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`

**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`

## Usage Example

Once configured, you can interact with Mobilerun directly through your AI assistant:

> "Run a task on Mobilerun to open the Settings app and take a screenshot"

The assistant will use the MCP tools to:

1. List available devices
2. Create and run the task
3. Return the results

## Choosing an Authentication Method

<CardGroup cols={2}>
  <Card title="API Key" icon="key">
    Best for automated systems, CI/CD pipelines, and server-side applications where you manage the credentials.
  </Card>

  <Card title="OAuth" icon="lock">
    Best for personal use in IDEs where you want to authenticate with your own account interactively.
  </Card>
</CardGroup>
