Skip to content
Integrations

Haystack

Give Haystack agents tools that run Actors and read their results.

Give Haystack agents Scrape.ly tools: search the Store, run Actors, wait for their runs, and read the results. Agents connect to the hosted MCP server through the mcp-haystack integration, so there is no Scrape.ly package to install.

.bash
pip install mcp-haystack

Create an API token in the dashboard under Settings → API & Integrations and set it as SCRAPELY_TOKEN. The agent 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.

Give an agent Scrape.ly tools

Load the server's tools with MCPToolset and pass them to an Agent. token is sent as Authorization: Bearer with every request.

.python
import os

from haystack.components.agents import Agent
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack_integrations.tools.mcp import MCPToolset, StreamableHttpServerInfo

scrapely = MCPToolset(
    server_info=StreamableHttpServerInfo(
        url="https://mcp.scrape.ly",
        token=os.environ["SCRAPELY_TOKEN"],
        timeout=60,
    )
)

agent = Agent(
    chat_generator=OpenAIChatGenerator(),
    tools=scrapely,
    system_prompt="Find the right Actor in the Scrape.ly Store, run it, and report what its results show.",
    exit_conditions=["text"],
)

result = agent.run(
    messages=[
        ChatMessage.from_user(
            "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."
        )
    ]
)
print(result["messages"][-1].text)

Any Haystack chat generator works in place of OpenAIChatGenerator. See MCPToolset for more options.

What the agent can do

The agent gets the MCP server's default tools. The ones used most:

ToolWhat it does
search-actorsFind Actors in the Store by keywords.
fetch-actor-detailsRead an Actor's input schema, README, and pricing before running it.
call-actorRun an Actor with a JSON input, optionally with maxItems and maxTotalChargeUsd.
get-actor-runWait for a run and check its status.
get-actor-outputRead 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 agent skips the search.

Costs: runs started by the agent 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.