Skip to main content
Glama
ikungsjl

MCP Knowledge Base Server

by ikungsjl

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);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('get') but doesn't disclose traits like read-only nature (implied by 'get'), authentication needs, rate limits, error handling, or return format. The description is minimal and lacks behavioral context beyond the basic operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence ('获取特定文档信息') that is front-loaded and wastes no words. It directly states the tool's purpose without unnecessary elaboration, making it highly concise and well-structured for its minimal content.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a read operation with one parameter) and lack of annotations and output schema, the description is incomplete. It doesn't explain what information is returned, potential errors, or how it differs from sibling tools. For a tool with no structured output or behavioral hints, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with 'document_id' clearly documented as '文档ID' (document ID). The description doesn't add any parameter semantics beyond what the schema provides, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description '获取特定文档信息' (Get specific document information) states the verb (get) and resource (document information), but it's vague about what 'information' includes and doesn't differentiate from sibling tools like 'list_documents' or 'query_knowledge_base'. It's a basic functional statement without specificity about scope or content.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, exclusions, or compare to siblings such as 'list_documents' for multiple documents or 'query_knowledge_base' for search-based retrieval. Usage is implied only by the name and description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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