Skip to main content
Glama

get_document

Retrieve specific document information from a knowledge base by providing its document ID. This tool accesses indexed documents in formats like PDF, DOCX, TXT, and HTML for content reference and analysis.

Instructions

获取特定文档信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idYes文档ID

Implementation Reference

  • The main handler for the 'get_document' tool. It extracts document_id from arguments, retrieves the document using knowledgeBase.getDocument, handles not found case, and returns formatted document information including title, ID, type, path, dates, and content preview.
    case 'get_document': { const { document_id } = args as { document_id: string }; const document = await this.knowledgeBase.getDocument(document_id); if (!document) { return { content: [ { type: 'text', text: `未找到ID为 "${document_id}" 的文档` } ] }; } const resultText = `文档信息:\n\n标题: ${document.title}\nID: ${document.id}\n类型: ${document.fileType}\n路径: ${document.filePath}\n创建时间: ${document.createdAt.toLocaleString()}\n更新时间: ${document.updatedAt.toLocaleString()}\n\n内容预览:\n${document.content.substring(0, 500)}...`; return { content: [ { type: 'text', text: resultText } ] }; }
  • Registration of the 'get_document' tool in the list of tools returned by ListToolsRequestHandler, including name, description, and input schema.
    { name: 'get_document', description: '获取特定文档信息', inputSchema: { type: 'object', properties: { document_id: { type: 'string', description: '文档ID' } }, required: ['document_id'] } },
  • Input schema definition for the 'get_document' tool, specifying document_id as required string.
    inputSchema: { type: 'object', properties: { document_id: { type: 'string', description: '文档ID' } }, required: ['document_id'] }
  • Core helper function in KnowledgeBase class that retrieves a Document by ID from the internal documents Map.
    async getDocument(id: string): Promise<Document | undefined> { return this.documents.get(id); }

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/ikungsjl/mcp-knowledge-base'

If you have feedback or need assistance with the MCP directory API, please join our Discord server