getWorkbookContent
Extracts and formats Christian Life and Ministry workbook content from RTF files, converting them into clean plain text with proper structure after users select a specific week.
Instructions
STEP 2: Get the actual CLM workbook content after user chooses a week. Use this tool AFTER getWorkbookLinks when user specifies which week they want (e.g., "May 5-11" or "June 30-July 6"). Takes the RTF URL from Step 1 results, downloads the RTF file, parses it to clean plain text, and returns the formatted workbook content with proper line breaks and structure.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The RTF file URL from getWorkbookLinks results (e.g., "https://cfp2.jw-cdn.org/a/...") |
Implementation Reference
- src/tools/workbook-tools.js:37-54 (handler)Core handler function that downloads RTF content from the provided URL, parses it to plain text, and returns structured result with metadata.export async function getWorkbookContent(url) { const rtfData = await downloadRtfContent(url); try { // Parse RTF to plain text const parsedText = parseRTF(rtfData.content); return { url: rtfData.url, contentType: rtfData.contentType, originalSize: rtfData.size, parsedText: parsedText, parsedSize: parsedText.length }; } catch (error) { throw new Error(`Failed to parse RTF content: ${error.message}`); } }
- src/tools/workbook-tools.js:87-100 (schema)Input schema and metadata definition for the getWorkbookContent tool, part of the workbookTools array.{ name: 'getWorkbookContent', description: 'STEP 2: Get the actual CLM workbook content after user chooses a week. Use this tool AFTER getWorkbookLinks when user specifies which week they want (e.g., "May 5-11" or "June 30-July 6"). Takes the RTF URL from Step 1 results, downloads the RTF file, parses it to clean plain text, and returns the formatted workbook content with proper line breaks and structure.', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'The RTF file URL from getWorkbookLinks results (e.g., "https://cfp2.jw-cdn.org/a/...")' } }, required: ['url'] } }
- src/index.js:33-41 (registration)Spreads workbookTools (containing getWorkbookContent schema) into the server's allTools array for tool listing (ListToolsRequestHandler).const allTools = [ captionsTool, ...workbookTools, ...watchtowerTools, searchBibleBooksTool, getBibleVerseTool, getVerseWithStudyTool, getBibleVerseURLTool ];
- src/index.js:44-49 (registration)Registers handleWorkbookTools (which dispatches getWorkbookContent) into the server's toolHandlers array for tool execution (CallToolRequestHandler).const toolHandlers = [ handleCaptionsTool, handleWorkbookTools, handleWatchtowerTools, handleScriptureTools ];
- src/tools/workbook-tools.js:132-170 (handler)Tool dispatcher logic within handleWorkbookTools that validates input, calls getWorkbookContent, formats response for MCP, and handles errors.// Handle getWorkbookContent tool if (request.params.name === 'getWorkbookContent') { try { const { url } = request.params.arguments; if (!url) { return { content: [ { type: 'text', text: 'Error: URL parameter is required', }, ], isError: true, }; } const result = await getWorkbookContent(url); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error: ${error.message}`, }, ], isError: true, }; } }