Skip to main content
Glama

rag_add_document

Add documents to a RAG corpus for AI-powered search and retrieval within the AI Ops Hub, enabling secure access to local files, web pages, and notes for developer operational tasks.

Instructions

Добавить документ в RAG корпус

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uriYesURI документа
contentYesСодержимое документа
titleYesЗаголовок документа

Implementation Reference

  • Core implementation of the rag_add_document tool handler. Manages adding or updating documents in the RAG corpus by interacting with SQLiteClient for storage and embedding.
    async addDocument(uri: string, content: string, title: string): Promise<void> {
      try {
        console.log(`📄 Добавление документа: ${title} (${uri})`);
        
        // Получаем SQLiteClient из пула соединений
        const sqliteClient = await this.connectionPool.getSQLiteClient();
        
        // Проверяем, существует ли уже документ
        const existingDocResult = await sqliteClient.getDocument(uri);
        if (existingDocResult.isErr()) {
          throw new Error(`Ошибка проверки документа: ${existingDocResult.error.message}`);
        }
        
        const existingDoc = existingDocResult.value;
        if (existingDoc) {
          // Обновляем существующий документ
          const updateResult = await sqliteClient.updateDocument(uri, title, content);
          if (updateResult.isErr()) {
            throw new Error(`Ошибка обновления документа: ${updateResult.error.message}`);
          }
          console.log(`✅ Документ "${title}" обновлен в корпусе`);
        } else {
          // Добавляем новый документ
          const addResult = await sqliteClient.addDocument(uri, title, content);
          if (addResult.isErr()) {
            throw new Error(`Ошибка добавления документа: ${addResult.error.message}`);
          }
          const docId = addResult.value;
          console.log(`✅ Документ "${title}" добавлен в корпус (ID: ${docId})`);
        }
      } catch (error) {
        console.error('Ошибка добавления документа:', error);
        throw new Error(`Ошибка добавления документа: ${error}`);
      }
    }
  • Input schema and metadata for the rag_add_document tool, defined in the MCP server's list of tools.
    {
      name: 'rag_add_document',
      description: 'Добавить документ в RAG корпус',
      inputSchema: {
        type: 'object',
        properties: {
          uri: {
            type: 'string',
            description: 'URI документа',
          },
          content: {
            type: 'string',
            description: 'Содержимое документа',
          },
          title: {
            type: 'string',
            description: 'Заголовок документа',
          },
        },
        required: ['uri', 'content', 'title'],
      },
    },
  • src/server.ts:192-194 (registration)
    Registration and dispatch logic in the MCP CallToolRequest handler that routes rag_add_document calls to RAGService.addDocument.
    case 'rag_add_document':
      await this.ragService.addDocument(args.uri as string, args.content as string, args.title as string);
      return { content: 'Документ добавлен' };
  • Duplicate input schema for rag_add_document in the HTTP transport's tool list.
      name: 'rag_add_document',
      description: 'Добавить документ в RAG корпус',
      inputSchema: {
        type: 'object',
        properties: {
          uri: { type: 'string', description: 'URI документа' },
          content: { type: 'string', description: 'Содержимое документа' },
          title: { type: 'string', description: 'Заголовок документа' }
        },
        required: ['uri', 'content', 'title']
      }
    },
  • Dispatch logic for rag_add_document in the HTTP transport's call tool handler.
    case 'rag_add_document':
      await this.ragService.addDocument(args.uri, args.content, args.title);
      result = { message: 'Документ добавлен' };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action is to add a document, implying a write operation, but doesn't cover critical aspects like permissions needed, whether duplicates are allowed, error handling, or rate limits. This leaves significant gaps in understanding the tool's behavior.

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 Russian that directly states the tool's purpose without any wasted words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 write operation with no annotations and no output schema, the description is incomplete. It lacks details on what happens after adding (e.g., success confirmation, error messages, or how the document integrates into the corpus), which is crucial for an agent to use this tool 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 input schema has 100% description coverage, clearly documenting the three required parameters (uri, content, title). The description adds no additional meaning beyond this, such as explaining parameter relationships or constraints, so it meets the baseline for high schema coverage without compensating value.

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 ('документ в RAG корпус' - document to RAG corpus), making the purpose understandable. However, it doesn't distinguish this tool from potential sibling tools like 'rag_search' or 'file_write', which could also involve document operations, so it misses full differentiation.

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. It doesn't mention prerequisites, such as needing a RAG corpus setup, or compare it to siblings like 'rag_search' for retrieval or 'file_write' for storage, leaving the agent without contextual usage cues.

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/Galiusbro/MCP'

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