Skip to main content
Glama
ikungsjl

MCP Knowledge Base Server

by ikungsjl

add_directory

Add documents from a specified directory to the knowledge base for indexing and querying. Supports multiple file formats including PDF, DOCX, TXT, and HTML.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
directory_pathYes目录路径

Implementation Reference

  • Registration of the 'add_directory' MCP tool, including name, description, and input schema.
    {
      name: 'add_directory',
      description: '添加目录中的所有文档到知识库',
      inputSchema: {
        type: 'object',
        properties: {
          directory_path: {
            type: 'string',
            description: '目录路径'
          }
        },
        required: ['directory_path']
      }
  • JSON schema defining the input parameters for the add_directory tool (directory_path: string).
    inputSchema: {
      type: 'object',
      properties: {
        directory_path: {
          type: 'string',
          description: '目录路径'
        }
      },
      required: ['directory_path']
  • MCP server handler for 'add_directory' tool: parses arguments, delegates to KnowledgeBase.addDirectory, returns formatted success message with document 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} 个文档到知识库`
          }
        ]
      };
    }
  • Core handler logic in KnowledgeBase class: processes all documents in directory using DocumentProcessor, stores them in memory map, persists index to disk, returns number 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;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states the action but doesn't describe what happens during processing (e.g., file format support, error handling, overwrite behavior, or whether this is a batch operation). For a tool that modifies the knowledge base, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence in Chinese that directly states the tool's function. There's zero wasted language, and it's appropriately front-loaded with the core action. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool that modifies the knowledge base (implied by 'add'), with no annotations and no output schema, the description is incomplete. It doesn't address what happens to existing documents, what formats are supported, whether this is recursive, or what the return value might be. Given the complexity of batch document addition, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'directory_path' already documented in the schema. The description doesn't add any additional meaning about the parameter beyond what the schema provides (it doesn't specify format requirements, path examples, or constraints). Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('添加' - add) and resource ('目录中的所有文档到知识库' - all documents in a directory to the knowledge base). It distinguishes from sibling tools like add_document (which likely adds individual documents) by specifying bulk addition from a directory. However, it doesn't explicitly mention the scope difference compared to add_document.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like add_document. There's no mention of prerequisites, constraints, or comparative scenarios. The agent must infer usage from the tool name and description alone without explicit direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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