search_documentation
Find specific information in Cloudflare documentation by entering a search query. This tool retrieves relevant content to assist with troubleshooting, implementation, or learning.
Instructions
Searches Cloudflare documentation and returns relevant content
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | Maximum number of results to return | |
| query | Yes | Search query |
Input Schema (JSON Schema)
{
"properties": {
"maxResults": {
"description": "Maximum number of results to return",
"type": "number"
},
"query": {
"description": "Search query",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- src/server.ts:232-290 (handler)Implementation of the search_documentation tool. Validates input, returns mock search results from Cloudflare documentation formatted as markdown.private async handleSearchDocumentation(args: any) { // Validate arguments if (typeof args !== 'object' || args === null || typeof args.query !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid arguments for search_documentation'); } const { query, maxResults = 3 } = args; try { // In a real implementation, you would: // 1. Use Cloudflare Browser Rendering to navigate to the docs // 2. Use the search functionality on the docs site // 3. Extract the search results // For this simulation, we'll return mock results const mockResults = [ { title: 'Browser Rendering API Overview', url: 'https://developers.cloudflare.com/browser-rendering/', snippet: 'Cloudflare Browser Rendering is a serverless headless browser service that allows execution of browser actions within Cloudflare Workers.', }, { title: 'REST API Reference', url: 'https://developers.cloudflare.com/browser-rendering/rest-api/', snippet: 'The REST API provides simple endpoints for common browser tasks like fetching content, taking screenshots, and generating PDFs.', }, { title: 'Workers Binding API Reference', url: 'https://developers.cloudflare.com/browser-rendering/workers-binding/', snippet: 'For more advanced use cases, you can use the Workers Binding API with Puppeteer to automate browser interactions.', }, ].slice(0, maxResults); // Format the results const formattedResults = mockResults.map(result => `## [${result.title}](${result.url})\n${result.snippet}\n` ).join('\n'); return { content: [ { type: 'text', text: `# Search Results for "${query}"\n\n${formattedResults}`, }, ], }; } catch (error) { console.error('Error searching documentation:', error); return { content: [ { type: 'text', text: `Error searching documentation: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
- src/server.ts:80-97 (registration)Registration of the search_documentation tool in the ListTools response, including its schema definition.{ name: 'search_documentation', description: 'Searches Cloudflare documentation and returns relevant content', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query', }, maxResults: { type: 'number', description: 'Maximum number of results to return', }, }, required: ['query'], }, },
- src/server.ts:83-96 (schema)Input schema definition for the search_documentation tool.inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query', }, maxResults: { type: 'number', description: 'Maximum number of results to return', }, }, required: ['query'], },