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

# Vercel AI SDK

> Connect StackOne MCP to Vercel AI SDK for TypeScript/JavaScript applications with native MCP client support.

## Overview

Vercel AI SDK v4.2+ includes native MCP support via `experimental_createMCPClient`, enabling direct integration with StackOne's MCP server.

[Official Docs](https://ai-sdk.dev/docs/reference/ai-sdk-core/create-mcp-client)

## Installation

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

## Quick start

Connect to StackOne MCP and use tools in your Next.js/Node.js app:

```typescript theme={null}
import { anthropic } from "@ai-sdk/anthropic";
import { generateText, stepCountIs } from "ai";
import { experimental_createMCPClient } from "@ai-sdk/mcp";

// Connect to StackOne MCP server
const mcp = await experimental_createMCPClient({
	transport: {
		type: "http",
		url: "https://api.stackone.com/mcp",
		headers: {
			Authorization: `Basic ${Buffer.from(`${process.env.STACKONE_API_KEY}:`).toString("base64")}`,
			"x-account-id": "<stackone_account_id>",
		},
	},
});

// Get StackOne tools
const tools = await mcp.tools();

// Use with any AI SDK provider
const result = await generateText({
	model: anthropic("claude-haiku-4-5-20251001"),
	tools,
	prompt: "List all employees", // update the prompt based on what you want your agent to do
	stopWhen: stepCountIs(2),
});

console.log(result.text);
```

## Environment variables

```bash theme={null}
STACKONE_API_KEY=<stackone_api_key>
```

## Resources

* [Vercel AI SDK MCP Documentation](https://ai-sdk.dev/docs/reference/ai-sdk-core/create-mcp-client)
* [Vercel AI SDK Core Docs](https://ai-sdk.dev/docs/ai-sdk-core)
* [MCP Cookbook](https://ai-sdk.dev/cookbook/node/mcp-tools)
* [StackOne Authentication](/embed/call-actions/mcp#calling-actions)

## Optimize and secure

With your agent connected, use StackOne's platform features to optimize performance and secure every call.

<CardGroup cols={3}>
  <Card title="Search & Execute" icon="magnifying-glass" href="/optimize/search-and-execute">
    Reduce context and save tokens.
  </Card>

  <Card title="Data Sync" icon="arrows-rotate" href="/optimize/data-sync">
    Reduce latency and enable semantic search.
  </Card>

  <Card title="Defender" icon="shield-halved" href="/secure/defender">
    Block prompt injections before they reach your agent.
  </Card>
</CardGroup>
