Skip to main content
Glama
DynamicEndpoints

Document Extractor MCP Server

connection_status

Check PocketBase connection status and configuration to verify the Document Extractor MCP Server's database connectivity for content storage and retrieval.

Instructions

Check the current PocketBase connection status and configuration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The connection_status tool handler in src/index.js, which checks the current PocketBase connection status and configuration.
    const connectionStatusTool = server.tool(
      'connection_status',
      'Check the current PocketBase connection status and configuration',
      {},
      async () => {
        try {
          // LAZY LOADING: Only initialize config when tool is actually invoked
          initializeConfig();
          
          // Get current environment settings (without revealing password)
          const pocketbaseUrl = process.env.POCKETBASE_URL || 'Not configured';
          const pocketbaseEmail = process.env.POCKETBASE_EMAIL || 'Not configured';
          const collection = DOCUMENTS_COLLECTION || 'documents';
          
          let connectionStatus = 'Not tested';
          let serverInfo = {};
          let authInfo = {};
          let errorDetails = '';
          
          // Test connection if credentials are available
          if (pocketbaseUrl !== 'Not configured' && pocketbaseEmail !== 'Not configured') {
            try {
              await authenticateWhenNeeded();
              connectionStatus = '✅ Connected';
              
              // Get server info
              if (pb && pb.authStore.isValid) {
                authInfo = {
                  email: pb.authStore.record?.email || 'Unknown',
                  id: pb.authStore.record?.id || 'Unknown',
                  avatar: pb.authStore.record?.avatar || 'None',
                  created: pb.authStore.record?.created ? new Date(pb.authStore.record.created).toLocaleString() : 'Unknown',
                  tokenValid: pb.authStore.isValid,
                  recordType: 'superuser'
                };
                
                // Try to get some basic server stats
                try {
                  const collections = await pb.collections.getList(1, 5);
                  const healthCheck = await pb.health.check();
                  
                  serverInfo.totalCollections = collections.totalItems;
                  serverInfo.sampleCollections = collections.items.map(c => c.name).slice(0, 3);
                  serverInfo.health = healthCheck?.message || 'Healthy';
                  serverInfo.version = healthCheck?.version || 'Unknown';
                } catch (e) {
                  serverInfo.error = 'Could not fetch server statistics: ' + e.message;
                }
                
                // Check if documents collection exists
                try {
                  const docsCollection = await pb.collections.getOne(collection);
                  serverInfo.documentsCollection = {
                    exists: true,
                    id: docsCollection.id,
                    created: new Date(docsCollection.created).toLocaleString(),
                    fieldsCount: docsCollection.schema?.length || 0
                  };
                } catch (e) {
                  serverInfo.documentsCollection = {
                    exists: false,
                    error: 'Collection not found - use "ensure_collection" tool to create it'
                  };
                }
              }
            } catch (error) {
              connectionStatus = `❌ Connection failed: ${error.message}`;
              errorDetails = `\n**Error Details:** ${error.message}`;
              
              if (error.message.includes('credentials not configured')) {
                errorDetails += '\n**Solution:** Use the "authenticate" tool to set up your credentials.';
              } else if (error.message.includes('Invalid credentials')) {
                errorDetails += '\n**Solution:** Check your email and password, then use the "authenticate" tool.';
              } else if (error.message.includes('Cannot connect')) {
                errorDetails += '\n**Solution:** Verify PocketBase server URL and ensure it\'s running.';
              }
            }
          }
          
          // Build status report
          let statusReport = `🔌 **PocketBase Connection Status**\n\n` +
                            `**Configuration:**\n` +
                            `- Server URL: ${pocketbaseUrl}\n` +
                            `- Admin Email: ${pocketbaseEmail}\n` +
                            `- Password: ${process.env.POCKETBASE_PASSWORD ? '✅ Configured' : '❌ Not configured'}\n` +
                            `- Default Collection: ${collection}\n\n` +
                            `**Connection Status:** ${connectionStatus}`;
          
          if (errorDetails) {
            statusReport += errorDetails;
          }
          
          if (authInfo.email) {
            statusReport += `\n\n**Authentication Details:**\n` +
                           `- Email: ${authInfo.email}\n` +
                           `- Admin ID: ${authInfo.id}\n` +
                           `- Account Created: ${authInfo.created}\n` +
                           `- Avatar: ${authInfo.avatar}\n` +
                           `- Token Valid: ${authInfo.tokenValid}\n` +
                           `- Account Type: ${authInfo.recordType}`;
          }
          
          if (serverInfo.totalCollections) {
            statusReport += `\n\n**Server Statistics:**\n` +
                           `- Server Health: ${serverInfo.health}\n` +
                           `- Total Collections: ${serverInfo.totalCollections}\n` +
                           `- Sample Collections: ${serverInfo.sampleCollections?.join(', ') || 'None'}`;
            
            if (serverInfo.documentsCollection) {
              const docCol = serverInfo.documentsCollection;
              statusReport += `\n\n**Documents Collection:**\n` +
                             `- Exists: ${docCol.exists ? 'Yes' : 'No'}`;
              if (docCol.exists) {
                statusReport += `\n- Collection ID: ${docCol.id}\n` +
                               `- Created: ${docCol.created}\n` +
                               `- Schema Fields: ${docCol.fieldsCount}`;
              } else {
                statusReport += `\n- Status: ${docCol.error}`;
              }
            }
          }
          
          if (serverInfo.error) {
            statusReport += `\n\n**Server Info:** ${serverInfo.error}`;
          }
          
          statusReport += `\n\n**Available Tools:**\n` +
                         `- \`authenticate\`: Test/update PocketBase credentials\n` +
                         `- \`ensure_collection\`: Create documents collection if needed\n` +
                         `- \`collection_info\`: Get detailed collection statistics\n` +
                         `- \`extract_document\`: Extract and store documents from URLs\n` +
                         `- \`list_documents\`: List stored documents with pagination\n` +
                         `- \`search_documents\`: Search document content\n` +
                         `- \`get_document\`: Retrieve specific document by ID\n` +
                         `- \`delete_document\`: Remove a document from storage`;
          
          return {
            content: [
              {
                type: 'text',
                text: statusReport
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `❌ Error checking connection status: ${error.message}\n\n` +
                      `**Troubleshooting:**\n` +
                      `- Use the 'authenticate' tool to set up your PocketBase credentials\n` +
                      `- Verify your PocketBase server is running and accessible\n` +
                      `- Check the server URL format (include http:// or https://)`
              }
            ],
            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