Skip to main content
Glama

rag_add_document

Add documents to a RAG corpus for AI-powered search and retrieval, enabling intelligent querying of local files, notes, and web content.

Instructions

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

Input Schema

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

Implementation Reference

  • Core handler function that implements the rag_add_document tool logic: checks if document exists, adds new or updates existing in the RAG SQLite database.
    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}`); } }
  • src/server.ts:62-83 (registration)
    Registers the rag_add_document tool in the MCP ListTools handler with name, description, and input schema.
    { 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'], }, },
  • MCP CallTool handler dispatch: calls RAGService.addDocument with parsed arguments and returns success message.
    case 'rag_add_document': await this.ragService.addDocument(args.uri as string, args.content as string, args.title as string); return { content: 'Документ добавлен' };
  • Input schema definition for rag_add_document tool parameters (uri, content, title).
    inputSchema: { type: 'object', properties: { uri: { type: 'string', description: 'URI документа', }, content: { type: 'string', description: 'Содержимое документа', }, title: { type: 'string', description: 'Заголовок документа', }, }, required: ['uri', 'content', 'title'], },
  • HTTP transport handler dispatch for rag_add_document: calls RAGService.addDocument.
    case 'rag_add_document': await this.ragService.addDocument(args.uri, args.content, args.title); result = { message: 'Документ добавлен' }; break;

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