AI SDK
Use the Vercel AI SDK to connect your AI application to OpenAffiliate via MCP.
TypeScript
import { createMCPClient } from "@ai-sdk/mcp";
import { generateText } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
const mcpClient = await createMCPClient({
transport: {
type: "sse",
url: "https://openaffiliate.dev/api/mcp",
},
});
const tools = await mcpClient.tools();
const { text } = await generateText({
model: anthropic("claude-sonnet-4.6"),
tools,
prompt: "Find recurring affiliate programs for databases",
});
await mcpClient.close();