Skip to main content
Glama
little2512

Word Document Reader MCP Server

by little2512

get_stored_document

Retrieve previously stored Word document content from cache using a memory key for quick access to analyzed data.

Instructions

获取已存储的文档内容

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
memoryKeyYes要获取的文档内存键名

Implementation Reference

  • Handler for the 'get_stored_document' tool. Retrieves the document from the NodeCache (documentCache) using the memoryKey and constructs a detailed response including text, tables, and image OCR content.
    case "get_stored_document": {
      const { memoryKey } = args;
      const doc = documentCache.get(memoryKey);
    
      if (!doc) {
        throw new Error(`未找到内存键为 "${memoryKey}" 的文档`);
      }
    
      let responseText = `文档内容 (内存键: ${memoryKey}):\n\n`;
      responseText += `文件路径: ${doc.filePath}\n`;
      responseText += `文档类型: ${doc.documentType}\n`;
      responseText += `处理时间: ${doc.timestamp}\n\n`;
    
      // 添加文本内容
      if (doc.text) {
        responseText += `【文本内容】\n${doc.text}\n\n`;
      }
    
      // 添加表格内容
      if (doc.tables && doc.tables.length > 0) {
        responseText += `【表格内容】(${doc.tables.length} 个)\n`;
        doc.tables.forEach((table, index) => {
          responseText += `\n表格${index + 1}:\n`;
          table.rows.forEach((row, rowIndex) => {
            responseText += `行${rowIndex + 1}: ${row.join(' | ')}\n`;
          });
        });
      }
    
      // 添加图片OCR内容
      if (doc.images && doc.images.length > 0) {
        responseText += `【图片OCR内容】(${doc.images.length} 个)\n`;
        doc.images.forEach((image, index) => {
          responseText += `\n图片${index + 1} (${image.filename}):\n${image.ocrText}\n`;
        });
      }
    
      return {
        content: [
          {
            type: "text",
            text: responseText
          }
        ]
      };
    }
  • server.js:579-592 (registration)
    Registration of the 'get_stored_document' tool in the ListTools response, including name, description, and input schema.
    {
      name: "get_stored_document",
      description: "获取已存储的文档内容",
      inputSchema: {
        type: "object",
        properties: {
          memoryKey: {
            type: "string",
            description: "要获取的文档内存键名"
          }
        },
        required: ["memoryKey"]
      }
    },
  • Basic handler for the 'get_stored_document' tool. Retrieves the document from either uiComponentMemory or documentMemory Map using the memoryKey and returns the content.
    case "get_stored_document": {
      const { memoryKey } = args;
    
      let doc = uiComponentMemory.get(memoryKey) || documentMemory.get(memoryKey);
    
      if (!doc) {
        throw new Error(`未找到内存键为 "${memoryKey}" 的文档`);
      }
    
      return {
        content: [
          {
            type: "text",
            text: `文档内容 (内存键: ${memoryKey}):\n\n${doc.content}`
          }
        ]
      };
    }
  • server-basic.js:76-87 (registration)
    Registration of the 'get_stored_document' tool in the basic server ListTools response, including input schema.
    name: "get_stored_document",
    description: "获取已存储的文档内容",
    inputSchema: {
      type: "object",
      properties: {
        memoryKey: {
          type: "string",
          description: "要获取的文档内存键名"
        }
      },
      required: ["memoryKey"]
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves content but doesn't describe what happens if the document doesn't exist (e.g., errors), whether it requires authentication, rate limits, or the format of returned content. For a read operation with zero annotation coverage, this leaves significant gaps in understanding behavior.

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

Conciseness4/5

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

The description is a single, efficient sentence in Chinese that directly states the tool's purpose. It's appropriately sized and front-loaded with the core action. There's no wasted text, though it could be slightly more informative without losing conciseness.

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 has no annotations and no output schema, the description is incomplete. It doesn't explain what 'stored' means in context (e.g., from a cache or database), what content is returned (e.g., text, binary), or error handling. For a tool with one parameter but rich behavioral unknowns, this minimal description is inadequate.

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 schema description coverage is 100%, with the single parameter 'memoryKey' documented as '要获取的文档内存键名' (the memory key name of the document to retrieve). The description doesn't add any meaning beyond this, such as explaining what a 'memoryKey' represents or providing examples. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 states the tool's purpose as '获取已存储的文档内容' (get stored document content), which clearly indicates it retrieves document content. However, it doesn't distinguish this from sibling tools like 'list_stored_documents' (which likely lists metadata) or 'read_word_document' (which may read from a different source). The verb+resource is clear but lacks sibling differentiation.

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 (e.g., needing a stored document), exclusions, or comparisons to siblings like 'search_documents' or 'read_word_document'. Without such context, the agent must infer usage from the name alone.

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/little2512/word-doc-mcp'

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