Skip to main content
Glama
cloudflare

mcp-server-cloudflare

Official
by cloudflare

search_cloudflare_documentation

Search Cloudflare documentation for answers on products like Workers, Zero Trust, CDN, and more. Retrieve semantically relevant results tailored to your query for precise and actionable insights.

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 - AutoRAG, 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 'search_cloudflare_documentation' tool using AI Search (autorag). Includes input schema (query: string), handler that queries autorag('docs-mcp-rag'), formats results as XML, and returns as text content.
    '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 'search_cloudflare_documentation' tool using Vectorize. Includes input schema (query: string), handler that generates embeddings, queries Vectorize index, formats results as XML.
    '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 'search_cloudflare_documentation' tool in docs-autorag app using AutoRAG. Includes extended input schema (query, scoreThreshold, maxNumResults), handler that searches AutoRAG index and returns embedded resources.
    '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 queryAiSearch that performs the actual autorag search on 'docs-mcp-rag', parses response, converts to structured results with URL and title.
    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'), })) }

Other Tools

Related 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