mcp_server

nfilho1989/mcp_server

3.1

If you are the rightful owner of mcp_server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Model Context Protocol (MCP) server is a crucial component in integrating various AI and data retrieval technologies, facilitating seamless communication and data exchange between systems.

MCP + Elasticsearch + LangChain Demo

Este projeto demonstra a integraΓ§Γ£o entre Model Context Protocol (MCP), Elasticsearch e LangChain para criar um sistema de RAG (Retrieval-Augmented Generation).

πŸš€ Como executar

1. Acessar o container

docker exec -it mcp-elasticsearch-server /bin/bash

2. Executar o aplicativo principal

cd /app
python src/init_app.py

3. OpΓ§Γ΅es disponΓ­veis

  1. Testar Elasticsearch: Verifica se a conexΓ£o e busca estΓ£o funcionando
  2. Iniciar servidor MCP: Inicia o servidor MCP (ainda nΓ£o conectado ao agente)
  3. Iniciar agente de IA: Chat interativo com o assistente
  4. Exemplo completo: DemonstraΓ§Γ£o de todas as funcionalidades
  5. Limpar dados: Remove todos os dados do Γ­ndice

πŸ“ Exemplos de perguntas para o agente

  • "Quais posts existem sobre usuΓ‘rios?"
  • "Me mostre os posts mais recentes"
  • "Quantos documentos existem por categoria?"
  • "Busque posts que mencionam email"
  • "Me dΓͺ detalhes do post com ID post_1"

πŸ› οΈ Instalando Ollama (para o modelo LLM gratuito)

Para usar o agente de IA, vocΓͺ precisa instalar o Ollama no container:

# Dentro do container
curl -fsSL https://ollama.ai/install.sh | sh

# Baixar o modelo Llama2 (ou mistral para algo menor)
ollama pull llama2
# ou
ollama pull mistral

# Iniciar o servidor Ollama em background
ollama serve &

πŸ“Š Arquitetura

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 β”‚     β”‚                  β”‚     β”‚               β”‚
β”‚  LangChain      │────▢│  MCP Server      │────▢│ Elasticsearch β”‚
β”‚  Agent          β”‚     β”‚                  β”‚     β”‚               β”‚
β”‚                 β”‚     β”‚                  β”‚     β”‚               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                                                 β”‚
        β”‚                                                 β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    Direct ES Access (for now)

πŸ”§ Estrutura do Projeto

/app/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ mcp_server/
β”‚   β”‚   β”œβ”€β”€ mcp_config.json
β”‚   β”‚   └── server.py
β”‚   β”œβ”€β”€ elasticsearch_client/
β”‚   β”‚   └── es_client.py
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   └── elasticsearch_agent.py
β”‚   └── init_app.py
β”œβ”€β”€ data/
β”œβ”€β”€ notebooks/
β”œβ”€β”€ requirements.txt
└── .env