list_documents
Retrieve all indexed documents from the knowledge base to browse available content for querying and analysis.
Instructions
列出知识库中的所有文档
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_documents"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp-server.ts:218-237 (handler)The main handler for the 'list_documents' tool. It fetches all documents from the KnowledgeBase using getAllDocuments() and formats a detailed list including document ID, title, file type, path, and creation time into a 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 } ] }; } - src/mcp-server.ts:98-105 (schema)Tool schema definition for 'list_documents', including name, description, and empty input schema (no parameters required). This is part of the tools list returned in ListToolsRequest.
{ name: 'list_documents', description: '列出知识库中的所有文档', inputSchema: { type: 'object', properties: {} } }, - src/knowledge-base.ts:166-168 (helper)Helper method in KnowledgeBase class that returns an array of all stored documents, used by the list_documents tool handler.
async getAllDocuments(): Promise<Document[]> { return Array.from(this.documents.values()); }