> ## 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.

# Vercel AI SDK

> Connect Vercel AI SDK agents to Mobilerun phones using MCP.

The Vercel AI SDK helps applications build model-powered agents. Its MCP client can provide Mobilerun phone tools to an agent.

## Setup

1. [Set up a phone](https://docs.mobilerun.ai/devices.md), install `@ai-sdk/mcp`, `ai`, and your model provider package, and create a Mobilerun [API key](https://docs.mobilerun.ai/api-keys.md).

   ```bash theme={null}
   npm install ai @ai-sdk/mcp
   ```

2. Connect the MCP client in your server-side TypeScript application:

```typescript theme={null}
import { createMCPClient } from '@ai-sdk/mcp';

const client = await createMCPClient({
  transport: {
    type: 'http',
    url: 'https://cloud.mobilerun.ai/api/mcp',
    headers: { Authorization: `Bearer ${process.env.MOBILERUN_API_KEY}` },
  },
});
try {
  const tools = await client.tools();
  // Pass tools to your AI SDK model call while the client is open.
} finally {
  await client.close();
}
```

3. Set `MOBILERUN_API_KEY` and model credentials in the server process environment. Keep the key server-side and configure action approvals.

## First task

> List my Mobilerun devices and take a screenshot of the ready device.

See [MCP Server](https://docs.mobilerun.ai/mcp-server.md) for available tools.

See the [AI SDK MCP documentation](https://ai-sdk.dev/docs/ai-sdk-core/mcp-tools) for model calls.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.