Skip to main content
Glama

get_document

Retrieve detailed information about a specific document by providing its unique ID using the MCP Knowledge Base Server. Access indexed content from formats like PDF, DOCX, TXT, and HTML for efficient document handling.

Instructions

获取特定文档信息

Input Schema

NameRequiredDescriptionDefault
document_idYes文档ID

Input Schema (JSON Schema)

{ "properties": { "document_id": { "description": "文档ID", "type": "string" } }, "required": [ "document_id" ], "type": "object" }

Implementation Reference

  • Handler for the 'get_document' tool. Extracts document_id from arguments, calls 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 ListTools response, defining name, description, and input schema requiring 'document_id'.
    { name: 'get_document', description: '获取特定文档信息', inputSchema: { type: 'object', properties: { document_id: { type: 'string', description: '文档ID' } }, required: ['document_id'] } },
  • Core helper method in KnowledgeBase class that retrieves and returns the Document by ID from the internal documents Map.
    async getDocument(id: string): Promise<Document | undefined> { return this.documents.get(id); }

Other Tools

Related Tools

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