summarize_content
Generate concise summaries of web content directly from URLs, optimizing for LLM context by specifying maximum summary length.
Instructions
Summarizes web content for more concise LLM context
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxLength | No | Maximum length of the summary | |
| url | Yes | URL to summarize |
Implementation Reference
- src/server.ts:353-411 (handler)Primary handler for executing the 'summarize_content' tool. Validates parameters, simulates content fetching and summarization, returns mock summary as text content.
private async handleSummarizeContent(args: any) { // Validate arguments if (typeof args !== 'object' || args === null || typeof args.url !== 'string') { throw new McpError(ErrorCode.InvalidParams, 'Invalid arguments for summarize_content'); } const { url, maxLength = 500 } = args; try { // In a real implementation, you would: // 1. Fetch the page content using Cloudflare Browser Rendering // 2. Process the content for LLM // 3. Call an LLM API to summarize the content // For this simulation, we'll return a mock summary const mockSummary = ` # Browser Rendering API Summary Cloudflare Browser Rendering is a serverless headless browser service for Cloudflare Workers that enables: 1. Rendering JavaScript-heavy websites 2. Taking screenshots and generating PDFs 3. Extracting structured data 4. Automating browser interactions It offers two main interfaces: - **REST API**: Simple endpoints for common tasks - **Workers Binding API**: Advanced integration with Puppeteer The service runs within Cloudflare's network, providing low-latency access to browser capabilities without managing infrastructure. `.trim(); // Truncate if necessary const truncatedSummary = mockSummary.length > maxLength ? mockSummary.substring(0, maxLength) + '...' : mockSummary; return { content: [ { type: 'text', text: truncatedSummary, }, ], }; } catch (error) { console.error('Error summarizing content:', error); return { content: [ { type: 'text', text: `Error summarizing content: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } } - src/server.ts:119-136 (registration)Registration of the 'summarize_content' tool in the ListToolsRequestSchema handler, including name, description, and input schema definition.
{ name: 'summarize_content', description: 'Summarizes web content for more concise LLM context', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to summarize', }, maxLength: { type: 'number', description: 'Maximum length of the summary', }, }, required: ['url'], }, }, - src/server.ts:122-135 (schema)Input schema definition for the 'summarize_content' tool, specifying required 'url' and optional 'maxLength' parameters.
inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'URL to summarize', }, maxLength: { type: 'number', description: 'Maximum length of the summary', }, }, required: ['url'], }, - src/content-processor.ts:134-161 (helper)Helper method in ContentProcessor class for summarizing content. Provides identical mock summary logic, though not directly called by the tool handler.
summarizeContent(content: string, maxLength: number = 500): string { // In a real implementation, you would call an LLM API here console.log('Simulating content summarization...'); // For this simulation, we'll return a mock summary const mockSummary = ` # Browser Rendering API Summary Cloudflare Browser Rendering is a serverless headless browser service for Cloudflare Workers that enables: 1. Rendering JavaScript-heavy websites 2. Taking screenshots and generating PDFs 3. Extracting structured data 4. Automating browser interactions It offers two main interfaces: - **REST API**: Simple endpoints for common tasks - **Workers Binding API**: Advanced integration with Puppeteer The service runs within Cloudflare's network, providing low-latency access to browser capabilities without managing infrastructure. `.trim(); // Truncate if necessary return mockSummary.length > maxLength ? mockSummary.substring(0, maxLength) + '...' : mockSummary; }