Skip to content
AgentSearch

How to Add Web Search to Dify (MCP)

Dify is an open-source platform for building LLM apps: workflows, chatflows and agents, built in a visual editor and served over an API. Its models only know what they were trained on, so anything recent (a release from last week, today's prices, a fresh error message) needs a tool that can reach the live web. Dify can import tools from any MCP server that speaks HTTP. This guide adds Dify web search with AgentSearch's hosted MCP server: one URL, nothing to install.

Search works right away with no API key, no signup and no wallet: 25 free searches per IP in total, then pay per call. The 25 is a lifetime allowance, not a daily one, and it never resets.

What we actually ran (November 28, 2026): a self-hosted Dify 1.20.0 (the latest release) from the official Docker Compose setup, with a throwaway admin account and no real model key. We added AgentSearch's hosted MCP server, and Dify imported its six tools. Then we ran two real free searches through Dify: one from a Tool node in a Workflow app, and one from an Agent app (the classic function-calling kind) whose model was a local stand-in that only asks for a tool call. Both came back with live results. We didn't test Dify Cloud, the newer Agent app type, or a real model. Where this post describes those, it says so and links Dify's docs.

Why MCP over HTTP (and not npx)

Most AgentSearch guides start a local MCP server with npx. Dify can't do that: Dify's docs say only MCP servers with HTTP transport are supported. That's why this guide uses the hosted server instead:

https://relay.agentsearchhq.com/mcp

It speaks the MCP Streamable HTTP transport, needs no sign-in and keeps no session. It's the same hosted endpoint described in our free remote MCP server post.

What the agent gets (and what it costs)

Dify listed these six tools after adding the server:

agentsearch_web_search     agentsearch_news_search
agentsearch_extract        agentsearch_search_and_read
agentsearch_render         agentsearch_screenshot

For research inside an app, these three matter most:

Tool What it does Free on the hosted server Paid price
agentsearch_web_search Live web search, 1 to 5 results with title, URL and a text snippet 25 searches per IP in total (never resets) $0.003 per call
agentsearch_extract Any public URL as clean markdown Free trial: 5 a day per IP $0.002 per call
agentsearch_search_and_read Search plus the page text of the top hits, in one call 10 calls per IP in total $0.005 per call

News search also has 10 free calls per IP in total, then costs $0.003 per call. Render (for JavaScript-heavy pages) has a free trial of 3 calls a day. The hosted server only uses the free allowances. Paid prices apply to the direct x402 API at api.agentsearchhq.com, covered below. There's no account and no API key at any tier.

Before you start

  • Dify 1.6 or later, self-hosted or Dify Cloud. MCP tools arrived in 1.6. We tested a self-hosted 1.20.0.
  • A model that supports tool calling if you want an agent to decide when to search. A Workflow Tool node needs no model at all.
  • Network access from your Dify server to relay.agentsearchhq.com on port 443.

Step 1: Add the MCP server

  1. Open Tools (in recent versions, Integrations → Tools, per Dify's docs) and choose the MCP tab.
  2. Click Add MCP Server (HTTP).
  3. Fill in the form:
    • Server URL: https://relay.agentsearchhq.com/mcp
    • Name & Icon: AgentSearch
    • Server Identifier: agentsearch
  4. Leave Headers empty. The server needs no authentication, so no token goes there.
  5. Click Add & Authorize.

With no sign-in to complete, Dify connected right away, marked the server as authorized and fetched the six tools. Listing tools doesn't use any of your free searches.

Pick the identifier carefully. Dify's form allows lowercase letters, numbers, underscores and hyphens, up to 24 characters. Apps refer to the server by this identifier, not by its name. Per Dify's docs, if you change it later, apps that use its tools stop working until you re-add the tools. Exported apps (DSL files) also carry the identifier, so a workspace that imports one needs a server with the same identifier.

The form's Timeout and SSE Read Timeout fields can stay at their defaults. We used a 30 second timeout, and our searches came back in about a second.

Step 2a: Use it in a Workflow or Chatflow (Tool node)

A Tool node runs the search every time the workflow reaches it, with no model involved. Add a node, pick Tools → AgentSearch → agentsearch_web_search, and set:

  • query: a variable, for example the user's input from the start node.
  • max_results: a number from 1 to 5.

Here's the gotcha we hit. The tool returns its results as JSON text, and Dify noticed that and parsed it. The node's json output held the results, and its text output was empty. Our first End node pointed at text and returned nothing, even though the search worked. Point the next node (an LLM node, a Code node or the End node) at the Tool node's json variable instead.

Here's what our Tool node returned for Dify MCP tool HTTP server with max_results: 3 (trimmed):

{
  "query": "Dify MCP tool HTTP server",
  "result_count": 3,
  "results": [
    {
      "title": "Dify Tools - Dify Docs",
      "url": "https://docs.dify.ai/en/cloud/use-dify/workspace/tools",
      "domain": "docs.dify.ai"
    },
    {
      "title": "MCP Server - Dify Docs",
      "url": "https://docs.dify.ai/en/cloud/use-dify/publish/publish-mcp",
      "domain": "docs.dify.ai"
    },
    {
      "title": "Tools MCP Server (HTTP) · langgenius dify · Discussion #26545",
      "url": "https://github.com/langgenius/dify/discussions/26545",
      "domain": "github.com"
    }
  ]
}

Each result also has a text snippet, a publish date when known and a trust score. Results are snippets, not whole pages. When the workflow needs full pages, add a second Tool node with agentsearch_extract, or use agentsearch_search_and_read to get both in one call.

In an Agent app, open the Tools section, click Add, and pick the AgentSearch tools you want. We added only agentsearch_web_search. Per Dify's docs, the same tools also work inside Agent nodes in workflows and in the newer Agent app type. We tested the classic Agent app with the Function Calling strategy.

The model saw the tool under its plain name, agentsearch_web_search, with the server's own description and parameters (query and max_results). When our stand-in model asked for a search, Dify called the hosted server and passed the full JSON result back to the model as the tool result. Unlike the Tool node, the agent gets the JSON as text, so there's no json versus text issue here.

A system prompt that tells the model when to search helps:

When a question depends on recent or changing information, use agentsearch_web_search
first, then answer from the results and cite the URLs.

Going past the free tier

The hosted server is free-only. When your IP has used its 25 searches, the tool returns an error with the paid options instead of failing silently.

Paid calls go to AgentSearch's direct x402 API at api.agentsearchhq.com. Each call is paid in USDC on Base, with no account, no API key and no minimum: search $0.003, news $0.003, extract $0.002 and search-and-read $0.005 (live prices on November 28, 2026). You're only charged when a usable answer comes back. The catch for Dify: x402 needs a client that signs a small payment for each call, and Dify's tool types (MCP, OpenAPI custom tools) don't do that. So paid traffic has to come from code that holds a wallet, such as a backend service your app calls. The x402 docs show how, and x402 pay-per-call APIs for AI agents explains the model. Use a new, dedicated wallet with a few dollars of USDC, never your main one.

Gotchas we hit

Dify can't run stdio servers. Configs that start a server with npx or uvx don't work in Dify's MCP form. It needs a URL. Use https://relay.agentsearchhq.com/mcp.

The Tool node's text output was empty. Dify parsed the JSON result into the json output. Use json downstream.

The identifier is the contract. Apps and exported DSL files point at the server identifier, so choose it once (agentsearch) and keep it.

The free allowance is per IP, and on Dify Cloud that IP isn't yours. The hosted server counts the 25 free searches against the address the requests come from. On a self-hosted Dify, that's your server's outgoing address. On Dify Cloud, the calls come from Dify's servers, so the allowance applies to an address shared with other users and may already be used up. We only tested self-hosted.

Troubleshooting

The server shows no tools. Check that the URL ends in /mcp and that your Dify server can reach relay.agentsearchhq.com over HTTPS. Self-hosted Dify sends outbound requests through its SSRF proxy container, so a proxy or firewall rule there can block it. Then use the server's option to fetch its tools again.

The search ran but the answer is empty. In a workflow, the next node probably reads the Tool node's text output. Switch it to json.

The agent never calls the tool. Make sure the model supports tool calling, that the tool is added and enabled in the app, and that the prompt says when to search.

An error mentions the free allowance or HTTP 429. You've used the free calls for your IP: the 25 lifetime searches, the 10 lifetime search-and-read or news calls, or the daily extract (5) or render (3) trial. See the paid section above.

Tools stopped working after editing the server. You probably changed the server identifier. Change it back, or re-add the tools in each app.

FAQ

Does Dify web search need an API key?

Not with this setup. AgentSearch's hosted MCP server gives you 25 free searches per IP in total with no key, account or wallet. You still need whatever key your model provider uses.

Does Dify support MCP servers?

Yes, MCP servers with HTTP transport, since Dify 1.6. Add them under Tools, on the MCP tab, with Add MCP Server (HTTP). Local stdio servers started with npx aren't supported.

Can I use AgentSearch in a Dify workflow without an agent?

Yes. A Tool node calls agentsearch_web_search directly, with no model involved. Read the results from the node's json output.

Does it work on Dify Cloud?

It should, because Dify Cloud supports HTTP MCP servers, but we only tested self-hosted Dify. On Dify Cloud the free allowance applies to Dify's outgoing address, not yours, so it may already be used up.

Is it safe to let the agent read web pages?

Treat everything the tools return as untrusted input, because a page can contain text written to steer an AI. Don't let page text trigger actions your app wouldn't take otherwise.

Next steps

Add https://relay.agentsearchhq.com/mcp as an MCP server in Dify, drop agentsearch_web_search into a workflow or an agent, and ask about something that changed last week. You get 25 free searches per IP in total with no key, then $0.003 per paid search.

More from the blog

Service pages: Web Search API · Web Extract API · Search + Read API · Web Render API