list_documents
Retrieve stored documentation from PocketBase with pagination controls to manage and access extracted content efficiently.
Instructions
List stored documents from PocketBase with pagination
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of documents to return (default: 20, max: 100) | |
| page | No | Page number for pagination (default: 1) |
Implementation Reference
- src/index.js:841-895 (handler)The "list_documents" tool is defined and implemented within the createServer function in src/index.js. It accepts pagination parameters (limit, page) and uses the getDocuments helper to fetch and display documents from PocketBase.
const listDocumentsTool = server.tool( 'list_documents', 'List stored documents from PocketBase with pagination', { limit: z.number().min(1).max(100).optional().default(20).describe('Maximum number of documents to return (default: 20, max: 100)'), page: z.number().min(1).optional().default(1).describe('Page number for pagination (default: 1)') }, async ({ limit = 20, page = 1 }) => { try { // Only authenticate when tool is actually invoked await authenticateWhenNeeded(); const result = await getDocuments(limit, page); if (result.items.length === 0) { return { content: [ { type: 'text', text: '📚 No documents found in the database.' } ] }; } const documentList = result.items.map(doc => `**${doc.title}** (ID: ${doc.id})\n` + `Source: ${doc.metadata?.source || 'Unknown'}\n` + `Domain: ${doc.metadata?.domain || 'Unknown'}\n` + `Created: ${new Date(doc.created).toLocaleString()}\n` + `${doc.updated ? `Updated: ${new Date(doc.updated).toLocaleString()}\n` : ''}` + `${doc.metadata?.url ? `URL: ${doc.metadata.url}\n` : ''}` ).join('\n---\n'); return { content: [ { type: 'text', text: `📚 Found ${result.items.length} documents (Page ${page} of ${Math.ceil(result.totalItems / limit)}):\n` + `Total: ${result.totalItems} documents\n\n${documentList}` } ] }; } catch (error) { return { content: [ { type: 'text', text: `❌ Error: ${error.message}` } ], isError: true }; } } );