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"]
    }

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