Skip to main content
Glama
cloudflare

mcp-server-cloudflare

Official
by cloudflare

search_cloudflare_documentation

Search the Cloudflare documentation for answers about Workers, CDN, Zero Trust, and other products and features.

Instructions

Search the Cloudflare documentation.

	This tool should be used to answer any question about Cloudflare products or features, including:
	- Workers, Pages, R2, Images, Stream, D1, Durable Objects, KV, Workflows, Hyperdrive, Queues
	- AI Search, Workers AI, Vectorize, AI Gateway, Browser Rendering
	- Zero Trust, Access, Tunnel, Gateway, Browser Isolation, WARP, DDOS, Magic Transit, Magic WAN
	- CDN, Cache, DNS, Zaraz, Argo, Rulesets, Terraform, Account and Billing

	Results are returned as semantically similar chunks to the query.
	

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • Handler for search_cloudflare_documentation using AI autorag search. Calls agent.env.AI.autorag(name).search() and returns results as embedded resources.
    async (params) => {
    	// we don't need "rewrite query" OR aiSearch because an LLM writes the query and formats the output for us.
    	const result = await agent.env.AI.autorag(agent.env.AUTORAG_NAME).search({
    		query: params.query,
    		ranking_options: params.scoreThreshold
    			? {
    					score_threshold: params.scoreThreshold,
    				}
    			: undefined,
    		max_num_results: params.maxNumResults,
    	})
    
    	const resources: EmbeddedResource[] = result.data.map((result) => {
    		const content = result.content.reduce((acc, contentPart) => {
    			return acc + contentPart.text
    		}, '')
    		return {
    			type: 'resource',
    			resource: {
    				uri: `docs://${result.filename}`,
    				mimeType: mime.getType(result.filename) ?? 'text/plain',
    				text: content,
    			},
    		}
    	})
    
    	return {
    		content: resources,
    	}
    }
  • Handler for search_cloudflare_documentation using AI Search. Calls queryAiSearch() helper which uses ai.autorag('docs-mcp-rag').search(), returns results as XML text.
    		async ({ query }) => {
    			const results = await queryAiSearch(env.AI, query)
    			const resultsAsXml = results
    				.map((result) => {
    					return `<result>
    <url>${result.url}</url>
    <title>${result.title}</title>
    <text>
    ${result.text}
    </text>
    </result>`
    				})
    				.join('\n')
    			return {
    				content: [{ type: 'text', text: resultsAsXml }],
    			}
    		}
  • Handler for search_cloudflare_documentation using Vectorize. Calls queryVectorize() which generates embeddings via Gemma model and queries Vectorize index, returns results as XML text.
    		async ({ query }) => {
    			const results = await queryVectorize(env.AI, env.VECTORIZE, query, TOP_K)
    			const resultsAsXml = results
    				.map((result) => {
    					return `<result>
    <url>${result.url}</url>
    <title>${result.title}</title>
    <text>
    ${result.text}
    </text>
    </result>`
    				})
    				.join('\n')
    			return {
    				content: [{ type: 'text', text: resultsAsXml }],
    			}
    		}
  • Input schema for the docs-autorag variant with query (string), scoreThreshold (optional 0-1), and maxNumResults (optional, default 10).
    		{
    			// partially pulled from autorag query optimization example
    			query: z.string().describe(`Search query. The query should:
    1. Identify the core concepts and intent
    2. Add relevant synonyms and related terms
    3. Remove irrelevant filler words
    4. Structure the query to emphasize key terms
    5. Include technical or domain-specific terminology if applicable`),
    			scoreThreshold: z
    				.number()
    				.min(0)
    				.max(1)
    				.optional()
    				.describe('A score threshold (0-1) for which matches should be included.'),
    			maxNumResults: z
    				.number()
    				.default(10)
    				.optional()
    				.describe('The maximum number of results to return.'),
    		},
  • Registration of the search_cloudflare_documentation tool in the docs-autorag app via agent.server.tool().
    export function registerDocsTools(agent: CloudflareDocumentationMCP) {
    	// Register the worker logs analysis tool by worker name
    	agent.server.tool(
    		'search_cloudflare_documentation',
    		`Search the Cloudflare documentation.
    
    		You should use this tool when:
    		- A user asks questions about Cloudflare products (Workers, Developer Platform, Zero Trust, CDN, etc)
    		- A user requests information about a Cloudflare feature
    		- You are unsure of how to use some Cloudflare functionality
    		- You are writing Cloudflare Workers code and need to look up Workers-specific documentation
    
    		This tool returns a number of results from a vector database. These are embedded as resources in the response and are plaintext documents in a variety of formats.
    		`,
    		{
    			// partially pulled from autorag query optimization example
    			query: z.string().describe(`Search query. The query should:
    1. Identify the core concepts and intent
    2. Add relevant synonyms and related terms
    3. Remove irrelevant filler words
    4. Structure the query to emphasize key terms
    5. Include technical or domain-specific terminology if applicable`),
    			scoreThreshold: z
    				.number()
    				.min(0)
    				.max(1)
    				.optional()
    				.describe('A score threshold (0-1) for which matches should be included.'),
    			maxNumResults: z
    				.number()
    				.default(10)
    				.optional()
    				.describe('The maximum number of results to return.'),
    		},
    		async (params) => {
    			// we don't need "rewrite query" OR aiSearch because an LLM writes the query and formats the output for us.
    			const result = await agent.env.AI.autorag(agent.env.AUTORAG_NAME).search({
    				query: params.query,
    				ranking_options: params.scoreThreshold
    					? {
    							score_threshold: params.scoreThreshold,
    						}
    					: undefined,
    				max_num_results: params.maxNumResults,
    			})
    
    			const resources: EmbeddedResource[] = result.data.map((result) => {
    				const content = result.content.reduce((acc, contentPart) => {
    					return acc + contentPart.text
    				}, '')
    				return {
    					type: 'resource',
    					resource: {
    						uri: `docs://${result.filename}`,
    						mimeType: mime.getType(result.filename) ?? 'text/plain',
    						text: content,
    					},
    				}
    			})
    
    			return {
    				content: resources,
    			}
    		}
    	)
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations beyond a title, the description adds 'Results are returned as semantically similar chunks', which is a key behavioral detail. However, it lacks information about result count, pagination, or error handling, which would be helpful for a search tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is only two sentences, immediately states the action, and uses a clear list of covered topics. Every sentence adds value, and there is no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter, no output schema), the description adequately covers purpose, scope, and result format. However, it could mention potential limitations or result count to improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% and the description does not elaborate on the single 'query' parameter beyond its name. It provides no format hints, constraints, or examples, forcing the agent to infer that it is a natural language query.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Search') and specific resource ('Cloudflare documentation'), and lists covered product categories, making it distinct from the only sibling tool which is a specific migration guide.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states that the tool should be used for any question about Cloudflare products, implying its broad applicability. However, it does not provide explicit when-not-to-use guidance or alternatives, though the sibling is clearly different.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cloudflare/mcp-server-cloudflare'

If you have feedback or need assistance with the MCP directory API, please join our Discord server