Skip to main content
RAGLight supports the Model Context Protocol (MCP), allowing your RAG pipeline to act as an agent that can query external databases, fetch live data, or execute code.

MCP Configuration

In this example, we connect the RAG agent to a local MCP server running on port 8001.
agentic_rag.py
from raglight.rag.simple_agentic_rag_api import AgenticRAGPipeline
from raglight.config.agentic_rag_config import AgenticRAGConfig
from raglight.config.vector_store_config import VectorStoreConfig
from raglight.config.settings import Settings
from raglight.models.data_source_model import FolderSource

Settings.setup_logging()

# 1. Vector store configuration
vector_store_config = VectorStoreConfig(
    embedding_model=Settings.DEFAULT_EMBEDDINGS_MODEL,
    provider=Settings.HUGGINGFACE,
    database=Settings.CHROMA,
    persist_directory="./defaultDb",
    collection_name=Settings.DEFAULT_COLLECTION_NAME,
)

# 2. MCP server connection (SSE transport)
mcp_servers = [
    {"url": "http://127.0.0.1:8001/sse"}
]

# 3. Configure Agentic RAG with MCP tools
config = AgenticRAGConfig(
    provider=Settings.OPENAI,
    model="gpt-4o",
    k=10,
    max_steps=4,
    mcp_config=mcp_servers,
    knowledge_base=[FolderSource(path="./company_data")],
)

# 4. Build and run
agent = AgenticRAGPipeline(config, vector_store_config)
agent.build()

# The agent now has access to both your documents AND the MCP tools
response = agent.generate(
    "Check the database for user 'Alice' and summarize her recent support tickets from the docs."
)
print(response)