Skip to main content
Glama
DynamicEndpoints

Document Extractor MCP Server

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
NameRequiredDescriptionDefault
limitNoMaximum number of documents to return (default: 20, max: 100)
pageNoPage number for pagination (default: 1)

Implementation Reference

  • 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
          };
        }
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DynamicEndpoints/documentation-mcp-using-pocketbase'

If you have feedback or need assistance with the MCP directory API, please join our Discord server