Skip to main content

Overview

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

Installation

npm install ai @ai-sdk/openai

Quick Start

Connect to StackOne MCP and use tools in your Next.js/Node.js app:
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

STACKONE_API_KEY=<stackone_api_key>

Resources

Next Steps