get-document-by-id
Retrieve complete documents by ID to access specific knowledge content from structured domains for reference in answering questions.
Instructions
Retrieve full document by ID.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"id": "<id>"
},
"name": "get-document-by-id"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Document ID to retrieve |
Implementation Reference
- src/index.ts:337-356 (handler)The main handler for the 'get-document-by-id' tool. Extracts the document ID from arguments, retrieves the document using DocumentRepository.getDocumentById, and returns formatted markdown content or a 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 }; } - src/index.ts:239-252 (registration)Tool registration in the ListTools handler, including name, description, and input schema definition.
{ 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:242-251 (schema)Input schema for the 'get-document-by-id' tool, defining the required 'id' parameter as a number.
inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Document ID to retrieve' } }, required: ['id'] } - Helper method in DocumentRepository that retrieves and returns the KnowledgeDocument by ID from the internal documents Map, or null if not found.
getDocumentById(id: number): KnowledgeDocument | null { this.ensureInitialized(); return this.documents.get(id) || null; }