list_documents
Retrieve a list of all documents indexed in the MCP Knowledge Base Server, enabling quick access to stored PDF, DOCX, TXT, and HTML files for processing or querying.
Instructions
列出知识库中的所有文档
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"type": "object"
}
Implementation Reference
- src/mcp-server.ts:98-105 (registration)Registration of the 'list_documents' tool in the ListTools response, including name, description, and empty input schema.{ name: 'list_documents', description: '列出知识库中的所有文档', inputSchema: { type: 'object', properties: {} } },
- src/mcp-server.ts:218-237 (handler)Handler implementation for the 'list_documents' tool. Retrieves all documents from the KnowledgeBase and formats a detailed list as text response.case 'list_documents': { const documents = await this.knowledgeBase.getAllDocuments(); let resultText = `知识库中共有 ${documents.length} 个文档:\n\n`; documents.forEach((doc, index) => { resultText += `${index + 1}. ${doc.title} (ID: ${doc.id})\n`; resultText += ` 类型: ${doc.fileType}\n`; resultText += ` 路径: ${doc.filePath}\n`; resultText += ` 创建时间: ${doc.createdAt.toLocaleString()}\n\n`; }); return { content: [ { type: 'text', text: resultText } ] }; }