Skip to main content
Glama

add_directory

Add all documents from a specified directory to the MCP Knowledge Base Server for indexing and question-based content retrieval.

Instructions

添加目录中的所有文档到知识库

Input Schema

NameRequiredDescriptionDefault
directory_pathYes目录路径

Input Schema (JSON Schema)

{ "properties": { "directory_path": { "description": "目录路径", "type": "string" } }, "required": [ "directory_path" ], "type": "object" }

Implementation Reference

  • Core implementation of the add_directory tool: processes all documents in the given directory using DocumentProcessor, adds them to the internal documents Map, saves the index, and returns the count of added documents.
    async addDirectory(dirPath: string): Promise<number> { const documents = await this.processor.processDirectory(dirPath); for (const doc of documents) { this.documents.set(doc.id, doc); } await this.saveIndex(); return documents.length; }
  • MCP server dispatch handler for 'add_directory' tool call: extracts directory_path from arguments, delegates to KnowledgeBase.addDirectory, and returns formatted success message with count.
    case 'add_directory': { const { directory_path } = args as { directory_path: string }; const count = await this.knowledgeBase.addDirectory(directory_path); return { content: [ { type: 'text', text: `已从目录 "${directory_path}" 添加了 ${count} 个文档到知识库` } ] }; }
  • Registration of the 'add_directory' tool in ListTools response, including name, description, and input schema definition.
    { name: 'add_directory', description: '添加目录中的所有文档到知识库', inputSchema: { type: 'object', properties: { directory_path: { type: 'string', description: '目录路径' } }, required: ['directory_path'] }
  • Input schema for add_directory tool: requires 'directory_path' string.
    { name: 'add_directory', description: '添加目录中的所有文档到知识库', inputSchema: { type: 'object', properties: { directory_path: { type: 'string', description: '目录路径' } }, required: ['directory_path'] }

Other Tools

Related Tools

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