Skip to main content
Glama

MCP RAG

Um servidor MCP (Model Context Protocol) completo para RAG (Retrieval-Augmented Generation) com gerenciamento de arquivos e memória vetorial para agentes.

🚀 Características

  • 📄 Gerenciamento de Arquivos: Adicione, remova e pesquise documentos em diversos formatos (PDF, DOCX, TXT, MD, CSV, JSON)

  • 🧠 Memória Vetorial: Sistema separado para que agentes armazenem informações importantes para uso futuro

  • 🔍 Busca Semântica: Utiliza embeddings do Hugging Face para busca semântica avançada

  • 💾 Banco Vetorial Local: ChromaDB local para armazenamento eficiente de vetores e metadados

  • 🛠️ Script de Manutenção: CLI completo para gerenciamento e manutenção do sistema

  • 📚 Documentação Completa: HTML para GitHub Pages com guias de configuração

Related MCP server: ragi

📋 Pré-requisitos

  • Node.js 18+

  • npm ou yarn

  • Chave da API do Hugging Face

🛠️ Instalação

  1. Clone o repositório

    git clone https://github.com/seu-usuario/mcp-rag.git
    cd mcp-rag
  2. Instale as dependências

    npm install
  3. Configure as variáveis de ambiente

    cp .env.example .env

    Edite o arquivo .env e configure sua chave da API do Hugging Face:

    HUGGINGFACE_API_KEY=sua_chave_aqui
  4. Compile o projeto

    npm run build

🔧 Configuração

Cursor

Adicione a seguinte configuração no arquivo de configurações do MCP:

{
  "mcpServers": {
    "mcp-rag": {
      "command": "node",
      "args": ["dist/index.js"],
      "cwd": "/caminho/para/mcp-rag"
    }
  }
}

Claude Desktop

Adicione a configuração no arquivo claude_desktop_config.json:

{
  "mcpServers": {
    "mcp-rag": {
      "command": "node",
      "args": ["dist/index.js"],
      "cwd": "/caminho/para/mcp-rag"
    }
  }
}

VS Code

Configure no settings.json:

{
  "mcp.servers": {
    "mcp-rag": {
      "command": "node",
      "args": ["dist/index.js"],
      "cwd": "/caminho/para/mcp-rag"
    }
  }
}

🛠️ Script de Manutenção

O projeto inclui um CLI completo para manutenção:

# Adicionar arquivo
npm run maintenance add-file /caminho/para/arquivo.pdf

# Adicionar diretório
npm run maintenance add-dir /caminho/para/diretorio

# Buscar arquivos
npm run maintenance search-files "sua consulta"

# Listar arquivos
npm run maintenance list-files

# Gerenciar memória
npm run maintenance add-memory "conteúdo" "agent-id" "session-id"
npm run maintenance search-memory "sua consulta"

# Ver estatísticas
npm run maintenance stats

# Limpar dados
npm run maintenance clear all

🔍 Ferramentas MCP Disponíveis

Gerenciamento de Arquivos

  • add_file: Adiciona um arquivo ao sistema RAG

  • search_files: Busca documentos relevantes

  • remove_file: Remove um arquivo do sistema

  • list_files: Lista todos os arquivos no sistema

Gerenciamento de Memória

  • add_memory: Adiciona informação à memória do agente

  • search_memory: Busca na memória do agente

  • remove_memory: Remove uma entrada da memória

  • get_memory_by_agent: Obtém toda a memória de um agente

Utilitários

  • get_stats: Obtém estatísticas do sistema

  • clear_data: Limpa dados do sistema

  • test_connection: Testa a conexão com o serviço de embeddings

📊 Formatos Suportados

  • PDF: Documentos PDF com texto extraível

  • DOCX: Documentos do Microsoft Word

  • TXT: Arquivos de texto simples

  • MD: Arquivos Markdown

  • CSV: Arquivos de dados separados por vírgula

  • JSON: Arquivos de dados JSON

⚙️ Configurações

Variáveis de Ambiente

# MCP Configuration
MCP_SERVER_NAME=mcp-rag
MCP_SERVER_VERSION=1.0.0

# Hugging Face Configuration
HUGGINGFACE_API_KEY=your_huggingface_api_key_here
HUGGINGFACE_MODEL=sentence-transformers/all-MiniLM-L6-v2

# ChromaDB Configuration
CHROMA_PERSIST_DIRECTORY=./data/chroma
CHROMA_COLLECTION_FILES=rag_files
CHROMA_COLLECTION_MEMORY=agent_memory

# File Processing Configuration
MAX_FILE_SIZE_MB=50
SUPPORTED_EXTENSIONS=.pdf,.docx,.txt,.md,.csv,.json

# Vector Configuration
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
EMBEDDING_DIMENSION=384

# Logging
LOG_LEVEL=info

🚀 Uso

Iniciando o Servidor

npm start

Desenvolvimento

npm run dev

Testes

npm test

📚 Documentação

A documentação completa está disponível em HTML para GitHub Pages em docs/index.html. Ela inclui:

  • Guias de instalação e configuração

  • Instruções para Cursor, Claude Desktop e VS Code

  • Exemplos de uso

  • Solução de problemas

  • Referência completa das ferramentas

🤝 Contribuição

  1. Fork o projeto

  2. Crie uma branch para sua feature (git checkout -b feature/AmazingFeature)

  3. Commit suas mudanças (git commit -m 'Add some AmazingFeature')

  4. Push para a branch (git push origin feature/AmazingFeature)

  5. Abra um Pull Request

📄 Licença

Este projeto está licenciado sob a Licença MIT - veja o arquivo LICENSE para detalhes.

🙏 Agradecimentos

📞 Suporte

Se você encontrar problemas ou tiver dúvidas:

  1. Verifique a documentação HTML

  2. Abra uma issue

  3. Consulte a seção de solução de problemas na documentação


Desenvolvido com ❤️ para a comunidade de IA

Available Tools

11 tools
add_fileC

Add a file to the RAG system for document retrieval

Inputs: filePath (required).

add_memoryC

Add information to the agent memory system

Inputs: agentId (required), content (required), sessionId (required), category, +2 more.

clear_dataC

Clear data from the RAG system

Inputs: type (required).

get_memory_by_agentC

Get all memory entries for a specific agent

Inputs: agentId (required).

get_statsC

Get statistics about the RAG system

Inputs: no named parameters.

list_filesB

List all files in the RAG system

Inputs: no named parameters.

remove_fileC

Remove a file from the RAG system

Inputs: filePath (required).

remove_memoryC

Remove a memory entry from the agent memory system

Inputs: memoryId (required).

search_filesC

Search for relevant documents in the RAG system

Inputs: query (required), limit, threshold.

search_memoryC

Search for relevant information in agent memory

Inputs: query (required), agentId, limit, threshold.

test_connectionB

Test the connection to the embedding service

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.3/5.0

    Scored across 11 tools

    Disambiguation4/5

    Most tools have distinct purposes, but there is some overlap between 'add_file' and 'add_memory' as both involve adding data, though to different systems (RAG vs. memory). Similarly, 'search_files' and 'search_memory' are distinct but conceptually similar operations. The descriptions help clarify the boundaries, but an agent might occasionally confuse these pairs.

    Naming Consistency5/5

    All tool names follow a consistent verb_noun pattern with snake_case, such as 'add_file', 'clear_data', 'get_stats', and 'search_memory'. This uniformity makes the set predictable and easy to understand, with no deviations in style or convention.

    Tool Count5/5

    With 11 tools, the count is well-scoped for a RAG and memory management system. It covers core operations like adding, removing, listing, and searching for both files and memory, along with utility functions like clearing data and testing connections, without being excessive or sparse.

    Completeness4/5

    The tool set provides comprehensive coverage for RAG and memory operations, including CRUD-like actions for files and memory entries, search capabilities, and system management. A minor gap is the lack of tools for updating existing files or memory entries, which might require workarounds, but core workflows are well-supported.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server implementation that provides tools for retrieving and processing documentation through vector search, enabling AI assistants to augment their responses with relevant documentation context. Uses Ollama or OpenAI to generate embeddings. Docker files included
      34 npm
      30
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Local-first RAG indexing and semantic search MCP server. Enables document retrieval and context-aware queries using local embedding models.
      3
      15 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An MCP server that indexes documents and serves relevant context to LLMs via Retrieval Augmented Generation (RAG).
      36
      MIT