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
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Document ID to retrieve |
Implementation Reference
- src/index.js:954-995 (handler)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 }; } } ); - src/index.js:623-639 (helper)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}`); } }