fetch
Extract specific content from ebooks using epub URLs to retrieve targeted book passages for research or reference purposes.
Instructions
Fetch specific content from a book using epub:// URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | epub:// URL from search results |
Implementation Reference
- server.js:988-1001 (registration)Registration of the 'fetch' tool in the tools list, including name, description, and input schema.{ name: 'fetch', description: 'Fetch specific content from a book using epub:// URL', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'epub:// URL from search results' } }, required: ['url'] } },
- server.js:991-1000 (schema)Input schema for the 'fetch' tool defining the expected 'url' parameter.inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'epub:// URL from search results' } }, required: ['url'] }
- server.js:1108-1111 (handler)Handler for the 'fetch' tool call; currently a placeholder that returns an error indicating implementation is pending.case 'fetch': // Implementation would be similar to original this.sendError(id, -32601, 'Fetch tool implementation pending'); break;
- server.js:437-446 (helper)Helper function to create epub:// URLs used by the 'fetch' tool.createEpubUrl(author, title, id, startLine = '', endLine = '') { const encAuthor = encodeURIComponent(author); const encTitle = encodeURIComponent(title); let url = `epub://${encAuthor}/${encTitle}@${id}`; if (startLine && endLine) { url += `#${startLine}:${endLine}`; } return url; }
- server.js:448-466 (helper)Helper function to parse epub:// URLs for the 'fetch' tool implementation.parseEpubUrl(url) { url = url.replace(/^epub:\/\//, ''); const idMatch = url.match(/@(\d+)/); if (!idMatch) { throw new Error('Invalid epub URL format'); } const bookId = idMatch[1]; let startLine = ''; let endLine = ''; const rangeMatch = url.match(/#(\d+):(\d+)$/); if (rangeMatch) { startLine = rangeMatch[1]; endLine = rangeMatch[2]; } return { bookId, startLine, endLine }; }