Connect your AI Search to an MCP client
Every AI Search instance can expose a built-in Model Context Protocol (MCP) ↗ endpoint. The endpoint provides a search tool over your indexed content, so any MCP client or agent, such as an AI assistant or IDE, can search your knowledge base without any code.
This guide creates an AI Search instance that indexes a documentation site, then exposes it as a search tool that any MCP client can call.
- Sign up for a Cloudflare account ↗.
- Install
Node.js↗.
Node.js version manager
Use a Node version manager like Volta ↗ or nvm ↗ to avoid permission issues and change Node.js versions. Wrangler, discussed later in this guide, requires a Node version of 16.17.0 or later.
To index a website, you also need a domain onboarded to your Cloudflare account. Otherwise, you can upload your own files to built-in storage.
If you already have an instance with indexed content, skip to step 2.
Create an instance with the Wrangler CLI. This example indexes a documentation site, using the Cloudflare Developer Docs at developers.cloudflare.com, so an assistant can answer questions from it. Connect the site as a website data source so AI Search crawls and indexes it automatically:
npx wrangler ai-search create docs-search --type web-crawler --source developers.cloudflare.comReplace developers.cloudflare.com with a domain you have onboarded to your Cloudflare account, since you can only crawl sites you own. To index content without crawling a site, run npx wrangler ai-search create docs-search --type builtin and upload files to built-in storage instead.
Check indexing progress:
npx wrangler ai-search stats docs-searchOnce indexing completes, your instance has content to expose over MCP.
Your instance's public endpoint serves the MCP endpoint.
-
Go to AI Search in the Cloudflare dashboard.
Go to AI Search -
Select your
docs-searchinstance. -
Go to Settings > Public Endpoint.
-
Turn on Enable Public Endpoint, then turn on the MCP endpoint.
-
Copy the endpoint host. Your MCP URL is that host followed by
/mcp:https://<INSTANCE_ID>.search.ai.cloudflare.com/mcp
An MCP client reads a tool's description to decide when to call it. Under Settings > Public Endpoint, set the Tool Description to explain what your content covers and the questions it answers. For example:
Search the Cloudflare Developer Documentation for product concepts,configuration, and API references. Use this when users ask how to buildor configure Cloudflare products.A specific description helps agents call your search tool at the right time. Refer to Public endpoint settings for the full configuration.
Add the MCP URL to your client as a remote MCP server. Many clients use an mcpServers configuration like the following:
{ "mcpServers": { "ai-search": { "url": "https://<INSTANCE_ID>.search.ai.cloudflare.com/mcp" } }}The exact configuration depends on your client. Some clients require a transport field on the server entry, such as "type": "http" for a remote HTTP server, so refer to your MCP client's documentation for how to add a remote server. Once connected, the client can call the search tool to retrieve relevant content from your instance.
To test the endpoint directly or build your own client, refer to MCP for the request format.
The public endpoint does not require authentication, so anyone with the URL can query your indexed content. To control access:
- Enable rate limiting under Settings > Public Endpoint.
- Restrict allowed origins with CORS rules.
- Only index content that is safe to expose publicly.
Refer to Public endpoint settings for details.