Skip to main content
Glama
DynamicEndpoints

Document Extractor MCP Server

get_document

Retrieve full document content by ID from the Document Extractor MCP Server for accessing stored documentation with metadata preservation.

Instructions

Get a specific document by ID with full content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesDocument ID to retrieve

Implementation Reference

  • Registration and handler logic for the 'get_document' tool.
    const getDocumentTool = server.tool(
      'get_document',
      'Get a specific document by ID with full content',
      {
        id: z.string().min(1, 'Document ID is required').describe('Document ID to retrieve')
      },    async ({ id }) => {
        try {
          // Only authenticate when tool is actually invoked
          await authenticateWhenNeeded();
          
          const doc = await getDocument(id);
          
          return {
            content: [
              {
                type: 'text',
                text: `📄 **${doc.title}**\n\n` +
                      `**ID:** ${doc.id}\n` +
                      `**Source:** ${doc.metadata?.source || 'Unknown'}\n` +
                      `**Domain:** ${doc.metadata?.domain || 'Unknown'}\n` +
                      `**Word Count:** ${doc.metadata?.wordCount || 'Unknown'}\n` +
                      `**Created:** ${new Date(doc.created).toLocaleString()}\n` +
                      `${doc.updated ? `**Updated:** ${new Date(doc.updated).toLocaleString()}\n` : ''}` +
                      `**URL:** ${doc.metadata?.url || 'N/A'}\n` +
                      `${doc.metadata?.description ? `**Description:** ${doc.metadata.description}\n` : ''}` +
                      `\n**Content:**\n${doc.content}`
              }
            ]
          };
        } catch (error) {
          return {
            content: [
              {
                type: 'text',
                text: `❌ Error: ${error.message}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • The helper function `getDocument` that executes the core logic of retrieving a single document from PocketBase.
    async function getDocument(id) {
      try {
        await authenticateWhenNeeded();
        
        if (!DOCUMENTS_COLLECTION) {
          initializeConfig();
        }
        
        const doc = await pb.collection(DOCUMENTS_COLLECTION).getOne(id);
        
        debugLog('Document retrieved from PocketBase', { id });
        return doc;
      } catch (error) {
        debugLog('Error getting document', { error: error.message, id });
        throw new Error(`Failed to retrieve document: ${error.message}`);
      }
    }

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