Skip to main content
Glama
cloudflare

mcp-server-cloudflare

Official
by cloudflare

search_cloudflare_documentation

Find answers about Cloudflare products and features by searching official documentation. Get relevant information on Workers, Zero Trust, CDN, AI tools, and other services.

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

  • Registration of the search_cloudflare_documentation tool, including inline handler that queries the 'docs-mcp-rag' autorag index via AI Search and formats results as XML.
    	server.tool(
    		'search_cloudflare_documentation',
    		`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.
    		`,
    		{
    			query: z.string(),
    		},
    		{
    			title: 'Search Cloudflare docs',
    			annotations: {
    				readOnlyHint: true,
    			},
    		},
    		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 }],
    			}
    		}
    	)
  • Registration of the search_cloudflare_documentation tool using Vectorize index for semantic search, with results formatted as XML.
    	server.tool(
    		'search_cloudflare_documentation',
    		`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.
    		`,
    		{
    			query: z.string(),
    		},
    		{
    			title: 'Search Cloudflare docs',
    			annotations: {
    				readOnlyHint: true,
    			},
    		},
    		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 }],
    			}
    		}
  • Registration of the search_cloudflare_documentation tool for the docs-autorag app, using autorag search and returning embedded resources.
    	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,
    			}
    		}
    	)
  • Helper function that performs the actual AI Search query to autorag index and processes the response into results.
    async function queryAiSearch(ai: Ai, query: string) {
    	const rawResponse = await doWithRetries(() =>
    		ai.autorag('docs-mcp-rag').search({
    			query,
    		})
    	)
    
    	// Parse and validate the response using Zod
    	const response = AiSearchResponseSchema.parse(rawResponse)
    
    	return response.data.map((item) => ({
    		similarity: item.score,
    		id: item.file_id,
    		url: sourceToUrl(item.filename),
    		title: extractTitle(item.filename),
    		text: item.content.map((c) => c.text).join('\n'),
    	}))
    }
Behavior3/5

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

The description adds behavioral context beyond annotations: it explains that 'Results are returned as semantically similar chunks to the query,' which clarifies the output format. Annotations only provide a title, so the description carries most of the burden. However, it doesn't mention rate limits, authentication needs, or other operational constraints that would be helpful.

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

Conciseness4/5

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

The description is appropriately sized and front-loaded: the first sentence states the core purpose, followed by usage guidelines and a behavioral note. The bulleted list is efficient for enumerating topics, though it could be slightly more concise. Every sentence adds value without redundancy.

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

Completeness3/5

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

Given the tool's complexity (a search function with no output schema and minimal annotations), the description is moderately complete. It covers purpose, usage, and output format, but lacks details on error handling, result structure beyond 'chunks,' or limitations. For a search tool, more context on result pagination or quality would be beneficial.

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

Parameters3/5

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

With 0% schema description coverage for the single 'query' parameter, the description doesn't add any specific parameter semantics beyond implying it should be a search query about Cloudflare topics. The schema already defines it as a required string, so the description doesn't compensate for the coverage gap with details like query format or examples.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Search the Cloudflare documentation.' It specifies the verb ('Search') and resource ('Cloudflare documentation'), making the function unambiguous. However, it doesn't explicitly differentiate from the sibling tool 'migrate_pages_to_workers_guide', which appears to be a specific guide rather than a general search function.

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 provides clear usage context: 'This tool should be used to answer any question about Cloudflare products or features,' followed by a comprehensive list of included topics. This gives strong guidance on when to use it. However, it doesn't explicitly state when NOT to use it or mention alternatives, though the sibling tool appears unrelated.

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