MCP Rag

An MCP server providing retrieval-augmented generation with document ingestion and semantic search using GroundX and OpenAI.
  • python

5

GitHub Stars

python

Language

6 months ago

First Indexed

2 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "sourangshupal-mcp-rag": {
      "command": "mcp",
      "args": [
        "dev",
        "server.py"
      ],
      "env": {
        "BUCKET_ID": "YOUR_BUCKET_ID",
        "OPENAI_API_KEY": "YOUR_OPENAI_API_KEY",
        "GROUNDX_API_KEY": "YOUR_GROUNDX_API_KEY"
      }
    }
  }
}

You run an MCP server that powers Retrieval-Augmented Generation (RAG) by integrating GroundX and OpenAI, with strong type safety and flexible configuration. This server lets you ingest PDFs and other documents, then perform semantic searches that leverage both retrieved context and generative capabilities to produce accurate, context-aware results.

How to use

Start the MCP server using the standard dev command, then ingest documents and run searches. Begin by launching the server, then add documents you want to query against, and finally perform semantic searches that return relevant results with scores and context.

Typical usage flow to accomplish common tasks:

You can customize how queries are processed by supplying a configuration object that adjusts the model and bucket used for storage. This lets you control the completion model and data routing for your searches.

How to install

Follow these concrete steps to set up the MCP Rag server locally.

Prerequisites: Python 3.12 or higher, OpenAI API key, GroundX API key, and MCP CLI tools.

Clone the project and enter the directory.

git clone <repository-url>
cd mcp-rag

Create and activate a virtual environment.

uv sync
source .venv/bin/activate

Set up environment variables for sensitive keys and identifiers.

GROUNDX_API_KEY="your-groundx-api-key"
OPENAI_API_KEY="your-openai-api-key"
BUCKET_ID="your-bucket-id"

Copy the example environment file and fill in your values.

c p .env.example .env

Start the MCP development server.

mcp dev server.py

Ingest documents by calling the ingestion function from your server module.

from server import ingest_documents

result = ingest_documents("path/to/your/document.pdf")
print(result)

Perform searches with or without a custom configuration.

from server import process_search_query

response = process_search_query("your search query here")
print(f"Query: {response.query}")
print(f"Score: {response.score}")
print(f"Result: {response.result}")

To use a custom configuration for the search, supply a SearchConfig object that specifies the model and bucket to use.

from server import process_search_query, SearchConfig

config = SearchConfig(
    completion_model="gpt-4",
    bucket_id="custom-bucket-id"
)
response = process_search_query("your query", config)

Additional content

Configuration and security practices help keep your setup robust. Do not commit your .env file with API keys. Use environment variables for sensitive information and rotate keys regularly. Monitor usage to detect unauthorized access.

Available tools

ingest_documents

Ingests documents (e.g., PDFs) into the MCP Rag server so they can be searched and contextually retrieved.

process_search_query

Executes a search against the ingested documents and returns a structured response with query, score, and result.

SearchConfig

Configuration object to customize search behavior, including the model and target bucket.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational