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);