Skip to main content
Glama

add_file

Add files to a RAG system for document retrieval, supporting PDF, DOCX, TXT, MD, CSV, and JSON formats to enable semantic search and information access.

Instructions

Add a file to the RAG system for document retrieval

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesPath to the file to add to the RAG system

Implementation Reference

  • MCP tool handler for 'add_file' that calls ragService.addFile and formats the MCP response.
    private async handleAddFile(args: { filePath: string }) {
      const result = await this.ragService.addFile(args.filePath);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Input schema definition for the 'add_file' tool.
    inputSchema: {
      type: 'object',
      properties: {
        filePath: {
          type: 'string',
          description: 'Path to the file to add to the RAG system',
        },
      },
      required: ['filePath'],
    },
  • src/index.ts:34-47 (registration)
    Registration of the 'add_file' tool in the ListToolsRequestSchema handler.
    {
      name: 'add_file',
      description: 'Add a file to the RAG system for document retrieval',
      inputSchema: {
        type: 'object',
        properties: {
          filePath: {
            type: 'string',
            description: 'Path to the file to add to the RAG system',
          },
        },
        required: ['filePath'],
      },
    },
  • Core implementation of file addition: processes file into chunks and stores in vector database.
    async addFile(filePath: string): Promise<{
      success: boolean;
      chunks: number;
      message: string;
    }> {
      try {
        logger.info(`Adding file to RAG: ${filePath}`);
    
        // Check if file exists and is supported
        if (!await this.fileProcessor.isSupportedFile(filePath.split('/').pop() || '')) {
          throw new Error('Unsupported file type');
        }
    
        // Process file into chunks
        const chunks = await this.fileProcessor.processFile(filePath);
        
        if (chunks.length === 0) {
          throw new Error('No content could be extracted from the file');
        }
    
        // Add chunks to vector database
        await this.vectorDatabase.addDocuments(chunks);
    
        logger.info(`Successfully added file: ${filePath} (${chunks.length} chunks)`);
        
        return {
          success: true,
          chunks: chunks.length,
          message: `File added successfully with ${chunks.length} chunks`
        };
      } catch (error) {
        logger.error(`Error adding file: ${error}`);
        return {
          success: false,
          chunks: 0,
          message: `Failed to add file: ${error}`
        };
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions adding a file for retrieval, but lacks details on permissions needed, whether the operation is idempotent, error handling, or effects on existing data. For a mutation tool with zero annotation coverage, this is a significant gap.

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, clear sentence with no wasted words, making it efficient and front-loaded. It directly communicates the tool's purpose without unnecessary elaboration.

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?

Given the complexity of a mutation tool with no annotations and no output schema, the description is incomplete. It fails to address behavioral aspects like side effects, return values, or error conditions, leaving gaps for an AI agent to understand how to use it effectively.

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?

The schema description coverage is 100%, with the parameter 'filePath' well-documented in the schema. The description does not add any additional meaning beyond what the schema provides, such as file format requirements or path examples. 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 a file') and the target system ('to the RAG system for document retrieval'), which is specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'list_files' or 'remove_file' in terms of purpose, though the verb 'Add' implies creation versus listing/removal.

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, such as 'add_memory' or 'search_files', nor does it mention prerequisites like file format compatibility or system readiness. It only states what the tool does, not when or why to invoke it.

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/santis84/mcp-rag'

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