Vercel AI SDK
Use Scrape.ly tools with generateText and streamText.
Use Scrape.ly as tools in the Vercel AI SDK: the model can search the Store, run Actors, wait for their runs, and read the results. The SDK connects to the hosted MCP server, so there is no Scrape.ly package to install.
npm install ai @ai-sdk/mcpCreate an API token in the dashboard under Settings → API & Integrations and set it as SCRAPELY_TOKEN. The model can do anything the token can, including starting paid runs, so give it a scoped key: actors:run, runs:read, and datasets:read, with a Max charge per day. See API keys & permissions.
Use the tools with generateText
Create an MCP client for the server, pass its tools to generateText, and close the client when you are done. stopWhen lets the model call several tools in a row (find an Actor, run it, read the results) before it answers.
import { createMCPClient } from '@ai-sdk/mcp';
import { generateText, isStepCount } from 'ai';
const scrapely = await createMCPClient({
transport: {
type: 'http',
url: 'https://mcp.scrape.ly',
headers: { Authorization: `Bearer ${process.env.SCRAPELY_TOKEN}` },
},
});
try {
const { text } = await generateText({
model: 'anthropic/claude-sonnet-5.5',
tools: await scrapely.tools(),
stopWhen: isStepCount(10),
prompt:
"Find an Actor that scrapes Google Maps, run it for 'coffee shops in Berlin' with at most 20 results, " +
'and list the name, rating, and address of each place.',
});
console.log(text);
} finally {
await scrapely.close();
}Any model the AI SDK supports works. With streamText, close the client when the stream finishes (in onFinish) instead of in finally.
What the model can do
The model gets the MCP server's default tools. The ones used most:
| Tool | What it does |
|---|---|
search-actors | Find Actors in the Store by keywords. |
fetch-actor-details | Read an Actor's input schema, README, and pricing before running it. |
call-actor | Run an Actor with a JSON input, optionally with maxItems and maxTotalChargeUsd. |
get-actor-run | Wait for a run and check its status. |
get-actor-output | Read a run's results, paged and kept compact. |
The full list, including saved inputs and automations, is on the MCP server page. To run one Actor you already know, name it in the prompt, for example Run username/actor-name, so the model skips the search.
Costs: runs started by the model are billed like any run. Put the limits in the prompt (such as "at most 20 results"), and keep a Max charge per day on the key.