list_stored_documents
Retrieve stored Word documents by type to access and manage your document library efficiently.
Instructions
列出所有已存储的文档
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| documentType | No | 筛选特定类型的文档 |
Implementation Reference
- server.js:851-875 (handler)The main handler for the 'list_stored_documents' tool. It retrieves all keys from the documentCache (NodeCache), fetches each document, filters by documentType if specified, formats a detailed list including memoryKey, filePath, type, timestamp, content length, tables, and images count, and returns it as formatted text content.case "list_stored_documents": { const { documentType } = args; const docs = []; const keys = documentCache.keys(); for (const key of keys) { const doc = documentCache.get(key); if (!documentType || doc.documentType === documentType) { docs.push(doc); } } const docList = docs.map(doc => `- 内存键: ${doc.memoryKey}\n 文件路径: ${doc.filePath}\n 文档类型: ${doc.documentType}\n 存储时间: ${doc.timestamp}\n 内容长度: ${doc.text?.length || 0} 字符\n 表格数: ${doc.tables?.length || 0}\n 图片数: ${doc.images?.length || 0}` ).join('\n\n'); return { content: [ { type: "text", text: `已存储的文档 (${docs.length} 个):\n\n${docList || "暂无存储的文档"}` } ] }; }
- server.js:565-578 (registration)Tool registration in the ListToolsRequestSchema handler, defining the tool's name, description, and input schema allowing optional 'documentType' filter.{ name: "list_stored_documents", description: "列出所有已存储的文档", inputSchema: { type: "object", properties: { documentType: { type: "string", description: "筛选特定类型的文档", enum: ["ui-component", "api-doc", "common-doc", "other"] } } } },
- server-basic.js:170-200 (handler)Simpler handler implementation in the basic server version, listing documents from both uiComponentMemory and documentMemory Maps, handling ui-component specially, and formatting basic list info.case "list_stored_documents": { const { documentType } = args; let docs = []; if (!documentType || documentType === "ui-component") { for (const [key, doc] of uiComponentMemory.entries()) { docs.push({ ...doc, memoryKey: key, storage: "ui-component" }); } } if (!documentType || documentType !== "ui-component") { for (const [key, doc] of documentMemory.entries()) { if (!documentType || doc.documentType === documentType) { docs.push({ ...doc, memoryKey: key, storage: "document" }); } } } const docList = docs.map(doc => `- 内存键: ${doc.memoryKey}\n 文件路径: ${doc.filePath}\n 文档类型: ${doc.documentType}\n 存储时间: ${doc.timestamp}\n 内容长度: ${doc.content.length} 字符` ).join('\n\n'); return { content: [ { type: "text", text: `已存储的文档 (${docs.length} 个):\n\n${docList || "暂无存储的文档"}` } ] }; }
- server-basic.js:61-74 (registration)Tool registration in the basic server's ListToolsRequestSchema handler, with similar schema.{ name: "list_stored_documents", description: "列出所有已存储到内存的文档", inputSchema: { type: "object", properties: { documentType: { type: "string", description: "筛选特定类型的文档", enum: ["ui-component", "api-doc", "common-doc", "other"] } } } },