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

# Vercel AI SDK

> Give AI SDK agents a browser with the Notte MCP server

<Tip>
  STOP. Do not read past this section until you have read and followed [/quickstart.md](/quickstart.md).

  Goal: produce a reliable SDK automation script. The intended authoring flow is generate then edit, not write browser automation from scratch.

  Do not hand-write SDK code with element IDs, selectors, or form fields from memory. Element IDs, selectors, and field mappings must come from a live `observe()` call, CLI `notte page observe` output, or generated workflow code. Guessed browser targets fail on real pages.

  Use the Notte skill and CLI to inspect the live site, validate actions/selectors, handle auth/session state, and export workflow code with `notte sessions workflow-code` before using SDK docs or SDK code.

  SDK reference pages are for understanding, running, or editing generated workflow code. They are not the starting point for manually authoring the initial browser automation. SDK-first code is guesswork on real-world pages with dynamic selectors, auth state, CAPTCHAs, and anti-bot behavior.
</Tip>

The [Vercel AI SDK](https://ai-sdk.dev/) can load tools from an MCP server and pass them straight into `generateText` or `streamText`. Point its MCP client at the [Notte MCP server](/mcp-server) and your TypeScript agent gets a browser.

## Prerequisites

* A Notte API key ([get one here](https://console.notte.cc))
* A provider key for the model you call

## 1. Install the SDKs

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

## 2. Attach the Notte MCP server

<CodeGroup>
  ```typescript notte-ai-sdk.ts theme={null}
  import { anthropic } from "@ai-sdk/anthropic";
  import { createMCPClient } from "@ai-sdk/mcp";
  import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
  import { generateText, stepCountIs } from "ai";

  const mcp = await createMCPClient({
    transport: new StreamableHTTPClientTransport(new URL("https://api.notte.cc/mcp/"), {
      requestInit: {
        headers: { Authorization: `Bearer ${process.env.NOTTE_API_KEY}` },
      },
    }),
  });

  const tools = await mcp.tools();

  const result = await generateText({
    model: anthropic("claude-sonnet-4-5-20250929"),
    tools,
    stopWhen: stepCountIs(6),
    prompt: "What is the main heading on https://example.com?",
  });

  console.log(result.text);

  await mcp.close();
  ```
</CodeGroup>

Set the following environment variables in your `.env` file:

```bash theme={null}
NOTTE_API_KEY=your-notte-api-key
ANTHROPIC_API_KEY=your-anthropic-api-key
```

<Note>
  The MCP client lives in `@ai-sdk/mcp`. Older guides import `experimental_createMCPClient` from `ai` itself, which no longer exports it.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="MCP Server" icon="plug" href="/mcp-server">
    Every tool the Notte MCP server exposes
  </Card>

  <Card title="Connect with Puppeteer" icon="p" href="/features/sessions/puppeteer">
    Drive a Notte session from Node.js over CDP
  </Card>

  <Card title="Browser Agents" icon="robot" href="/concepts/agents">
    Hand a whole task to a Notte agent
  </Card>

  <Card title="Fetch" icon="download" href="/concepts/scraping">
    Pull structured data out of a page
  </Card>
</CardGroup>
