Build with the Vercel AI SDK
The Vercel AI SDK talks to Polypad through its MCP client: one client, one URL, and all 21 Polypad tools become ordinary AI SDK tools your agent can call from generateText or streamText. No signup, no API key, no approval — the same open tier as the rest of the API. This page is the whole guide: install, connect, run the 5-minute check.
1 · Install
You need Node 18 or newer and a model key (this example uses Anthropic; any AI SDK provider works).
npm install ai @ai-sdk/mcp @ai-sdk/anthropic
On older AI SDK versions the same client is called experimental_createMCPClient and comes from the ai package instead of @ai-sdk/mcp. The rest of the example is identical.
2 · Connect and run
The client turns the remote MCP server into AI SDK tools. The model decides which tools to call; the prepare tools never move money — they return an unsigned transaction, a plain summary, and a signing link, and the user signs on polypad.family/sign. The signing page then checks the result and, when the agent passed a returnUrl, offers a link back to the agent's flow. How that loop works is on the sign loop page.
import { generateText, stopWhen, isStepCount } from "ai";
import { createMCPClient } from "@ai-sdk/mcp";
import { anthropic } from "@ai-sdk/anthropic";
// No Polypad account, no API key: the MCP server is open.
const mcp = await createMCPClient({
transport: {
type: "http",
url: "https://polypad.family/api/mcp",
},
});
const tools = await mcp.tools(); // all 21 polypad_* tools
try {
const { text } = await generateText({
model: anthropic("claude-sonnet-4-5"),
tools,
// At most 5 rounds of tool calls per request.
stopWhen: isStepCount(5),
prompt:
"List the newest tokens on Polypad, quote 0.01 ETH of POLYDASH, " +
"and prepare minting 1 share of the Polyfund for wallet " +
"0x1111111111111111111111111111111111111111. " +
"Show the signing link for the mint.",
});
console.log(text);
} finally {
await mcp.close();
}The http transport is the one for a remote server; the stdio transport is for servers running on your own machine. Close the client when the request finishes — in a server route, that is the end of the handler.
3 · The 5-minute check
Run the script above and check three things. Each one proves a different part of the wiring, and all three together mean your agent is live on Polypad:
- The agent lists tokens. The answer names real tokens from polypad_list_tokens — a read, no signature, no cost.
- The agent quotes a trade. The answer for 0.01 ETH of POLYDASH shows an expected output and a minimum after slippage, from polypad_quote_trade. A quote is a reading, not a promise: the price can move before signing.
- The agent prepares a mint. The answer includes a signing link for minting 1 share of the Polyfund (0.01 ETH a share) from polypad_prepare_fund_mint. Open it: the page rebuilds the mint for your connected wallet and shows the same summary. Nothing moves until you sign — close the page and nothing happened.
The wallet address in the example (0x1111…1111) is a placeholder. In real use the agent does not pass an address on every call: connect once on polypad.family/sign?connect=1, store the token, and pass it as walletToken instead — the SDKs do this for you, and the sign loop page explains how the token works. The per-call address is still there as the fallback.
What to build next
The same wiring runs a token launch (polypad_prepare_token_launch) or a tokenized fund (polypad_prepare_fund_create) from a script — that is the path Forge uses to launch a token a day; see the case studies. Every tool, with inputs and copy-paste examples, is in the tool reference, and the limits are on the rules of the road page. Contracts are unaudited.