Skip to main content
Glama
ikungsjl

MCP Knowledge Base Server

by ikungsjl

list_documents

Retrieve all indexed documents from the knowledge base to browse available content for querying and analysis.

Instructions

列出知识库中的所有文档

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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
          }
        ]
      };
    }
  • 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: {}
      }
    },
  • 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());
    }

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/ikungsjl/mcp-knowledge-base'

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