get-document-by-id
Fetch a complete document using its unique ID to access detailed information within the Knowledge Retrieval Server, ensuring accurate and relevant data retrieval for structured knowledge domains.
Instructions
Retrieve full document by ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Document ID to retrieve |
Implementation Reference
- src/index.ts:239-252 (registration)Tool registration including name, description, and input schema for 'get-document-by-id' in the listTools handler.{ name: 'get-document-by-id', description: 'Retrieve full document by ID.', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Document ID to retrieve' } }, required: ['id'] } },
- src/index.ts:337-356 (handler)Main tool handler that extracts ID from arguments, calls repository.getDocumentById, and returns formatted document content or not found message.case 'get-document-by-id': { const { id } = args as { id: number }; const document = repository.getDocumentById(id); if (!document) { const content: TextContent[] = [{ type: 'text', text: `Document with ID ${id} not found.` }]; return { content }; } const content: TextContent[] = [{ type: 'text', text: `# ${document.title}\n\n${document.content}` }]; return { content }; }
- Helper method in DocumentRepository that retrieves the document by ID from the internal documents Map.getDocumentById(id: number): KnowledgeDocument | null { this.ensureInitialized(); return this.documents.get(id) || null; }