Cloudflare Agents SDK Integration
Integrate Thordata MCP Server with Cloudflare Agents SDK to give AI agents access to real-time SERP data and structured search results.
How to integrate Cloudflare's Agents SDK with ThorData's Web MCP server to build AI agents on Cloudflare Workers, featuring over 60 MCP tools.
Hosted MCP
Get your API token
Go to SERP API-API Token to create an API token.
Copy your API Token (format as:
sk_7qBRe***************************)
Set up your Cloudflare environment
Please ensure you have Node.js 20 or later installed, then log in to Cloudflare:
npx wrangler loginInstall the Agents Starter template.
npx create-cloudflare@latest mcp-demo --template cloudflare/agents-starter
cd mcp-example
npm installConfigure environment variables
Copy the example .env file and add your OpenAI API key:
cp .dev.vars.example .dev.varsedit .dev.vars:
OPENAI_API_KEY=sk-...Connect ThorData MCP in your agent.
In src/server.ts,find the default, commented-out MCP connection onChatMessage:
// const mcpConnection = await this.mcp.connect(
// "https://path-to-mcp-server/mcp"
// );Replace it with the ThorData MCP connection:
// Connect to ThorData MCP server
const mcpConnection = await this.mcp.connect(
"https://mcp.thordata.net/API_TOKEN/mcp"
);
// Merge MCP tools with local tools
const allTools = {
...tools,
...this.mcp.getAITools()
};Testing to see if it works.
Please replace <API_TOKEN> with your actual ThorData API token.
Start the development server:
npm startOpen the application in your browser and ask customer service a question, for example:
Find the latest 3 news items about Cloudflare Agents and summarize them in bullets with links.You should be able to see agents using ThorData's web scraping tools to retrieve and aggregate real-time results:

Monitor usage
View your API usage in the ThorData SERP API usage logs.
Last updated
Was this helpful?