MCP-RAG Server
Manages environment variables and sensitive configuration through .env files for secure API key storage.
Enables version control for contributing features through forking, branching, committing, and pull requests.
Supports Jupyter notebook functionality through ipykernel, allowing interactive development and testing.
Integrates with OpenAI API for generating completions, enabling RAG capabilities with various models including GPT-4.
Provides type-safety and validation through Pydantic models for robust data handling and configuration.
Built on Python 3.12+ with support for virtual environments and package management.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP-RAG Serversearch for information about RAG implementation best practices"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP-RAG: Model Context Protocol with RAG π
A powerful and efficient RAG (Retrieval-Augmented Generation) implementation using GroundX and OpenAI, built with Modern Context Processing (MCP).
π Features
Advanced RAG Implementation: Utilizes GroundX for high-accuracy document retrieval
Model Context Protocol: Seamless integration with MCP for enhanced context handling
Type-Safe: Built with Pydantic for robust type checking and validation
Flexible Configuration: Easy-to-customize settings through environment variables
Document Ingestion: Support for PDF document ingestion and processing
Intelligent Search: Semantic search capabilities with scoring
Related MCP server: PDF Knowledgebase MCP Server
π οΈ Prerequisites
Python 3.12 or higher
OpenAI API key
GroundX API key
MCP CLI tools
π¦ Installation
Clone the repository:
git clone <repository-url>
cd mcp-ragCreate and activate a virtual environment:
uv sync
source .venv/bin/activate # On Windows, use `.venv\Scripts\activate`βοΈ Configuration
Copy the example environment file:
cp .env.example .envConfigure your environment variables in
.env:
GROUNDX_API_KEY="your-groundx-api-key"
OPENAI_API_KEY="your-openai-api-key"
BUCKET_ID="your-bucket-id"π Usage
Starting the Server
Run the inspect server using:
mcp dev server.pyDocument Ingestion
To ingest new documents:
from server import ingest_documents
result = ingest_documents("path/to/your/document.pdf")
print(result)Performing Searches
Basic search query:
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}")With custom configuration:
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)π Dependencies
groundx(β₯2.3.0): Core RAG functionalityopenai(β₯1.75.0): OpenAI API integrationmcp[cli](β₯1.6.0): Modern Context Processing toolsipykernel(β₯6.29.5): Jupyter notebook support
π Security
Never commit your
.envfile containing API keysUse environment variables for all sensitive information
Regularly rotate your API keys
Monitor API usage for any unauthorized access
π€ Contributing
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add some amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Available Tools
3 toolsingest_documentsB
Ingest documents from a local file into the knowledge base.
Args:
local_file_path: The path to the local file containing the documents to ingest.
Returns:
str: A message indicating the documents have been ingested.
| Name | Required | Description | Default |
|---|---|---|---|
| local_file_path | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('ingest') and return value, but lacks details on permissions, side effects (e.g., overwriting), rate limits, or error handling. This is inadequate for a mutation tool with zero annotation coverage.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and concise, with a clear purpose statement followed by Args and Returns sections. Each sentence adds value, though the return description could be more specific (e.g., success/failure indicators).
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (a mutation with no annotations or output schema), the description is minimally adequate. It covers purpose and parameters but lacks behavioral details and output specifics. The absence of annotations increases the burden, leaving gaps in understanding the tool's full behavior.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description adds meaningful context for the single parameter 'local_file_path' by explaining it's 'the path to the local file containing the documents to ingest.' With schema description coverage at 0%, this compensates well, though it doesn't specify format constraints (e.g., absolute vs. relative paths).
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Ingest documents from a local file into the knowledge base.' It specifies the verb ('ingest'), resource ('documents'), and source ('local file'), but doesn't explicitly differentiate from sibling tools like 'process_search_query' or 'search_doc_for_rag_context', which appear to be for querying rather than ingestion.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., file format requirements), exclusions, or compare it to sibling tools. The agent must infer usage from the purpose alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
process_search_queryB
Process a search query using GroundX and OpenAI.
Args:
query: The search query string
config: Optional SearchConfig object for customization
Returns:
SearchResponse object containing the query, score, and result
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| config | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the technologies (GroundX and OpenAI) but doesn't explain what 'process' entailsβwhether it's a read-only search, requires API keys, has rate limits, or affects data. The description lacks critical behavioral context for a tool that likely involves external API calls.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is well-structured and concise, with zero wasted words. It starts with the core purpose, then lists parameters and returns in a clear, bullet-like format. Every sentence adds value, making it easy for an agent to parse quickly.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity (2 parameters, no output schema, no annotations), the description is partially complete. It covers the purpose and parameters but lacks behavioral details, usage context, and output explanation. It's adequate as a baseline but has clear gaps, especially for a tool that likely involves external processing.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description adds meaningful semantics beyond the input schema. It explains that 'query' is a 'search query string' and 'config' is an 'Optional SearchConfig object for customization,' which clarifies their roles. Since schema description coverage is 0%, this compensates well, though it doesn't detail the SearchConfig properties like 'openai_api_key' or 'bucket_id'.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Process a search query using GroundX and OpenAI.' It specifies the verb ('process') and resource ('search query'), and mentions the technologies involved. However, it doesn't explicitly differentiate from sibling tools like 'search_doc_for_rag_context' or 'ingest_documents', which prevents a perfect score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. There's no mention of sibling tools, specific use cases, or prerequisites. The agent must infer usage from the tool name and description alone, which is insufficient for optimal tool selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
search_doc_for_rag_contextC
Searches and retrieves relevant context from a knowledge base,
based on the user's query.
Args:
query: The search query supplied by the user.
Returns:
str: Relevant text content that can be used by the LLM to answer the query.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'searches and retrieves' but doesn't cover critical aspects like whether this is a read-only operation, potential rate limits, authentication requirements, or how results are formatted (e.g., pagination, ranking). For a search tool with zero annotation coverage, this is a significant gap in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is appropriately sized with three sentences: purpose, parameter explanation, and return value. It's front-loaded with the core functionality and avoids unnecessary fluff. However, the structure could be slightly improved by integrating the 'Args' and 'Returns' sections more seamlessly into the flow.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's complexity (search/retrieval operation), lack of annotations, and no output schema, the description is incomplete. It doesn't explain behavioral traits, usage context, or return format details (beyond stating it returns a string). For a tool that likely involves data retrieval and potential constraints, more comprehensive information is needed.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description includes an 'Args' section that documents the single parameter 'query' as 'The search query supplied by the user.' With 0% schema description coverage, this adds essential meaning beyond the bare schema. However, it doesn't provide details on query syntax, length limits, or special characters, leaving some semantic gaps. The baseline is 3 since the description compensates partially but not fully.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'Searches and retrieves relevant context from a knowledge base, based on the user's query.' It specifies the verb ('searches and retrieves'), resource ('relevant context from a knowledge base'), and scope ('based on the user's query'). However, it doesn't explicitly differentiate from sibling tools like 'process_search_query' or 'ingest_documents', which prevents a perfect score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'process_search_query' or 'ingest_documents', nor does it specify prerequisites, constraints, or appropriate contexts for usage. This leaves the agent without direction on tool selection.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.1.0- First observed
ingest_documents - First observed
process_search_query - First observed
search_doc_for_rag_context
TDQS
Scored across 3 tools
The tools have significant overlap and unclear boundaries. Both 'process_search_query' and 'search_doc_for_rag_context' appear to handle search queries with similar inputs (query strings) and similar purposes (retrieving relevant information). While 'process_search_query' mentions GroundX and OpenAI integration and returns a structured SearchResponse, while 'search_doc_for_rag_context' returns plain text for RAG context, their core functionality is too similar, likely causing agent confusion about which to use for search tasks.
The naming is mostly consistent with a verb_noun pattern ('ingest_documents', 'process_search_query', 'search_doc_for_rag_context'), though 'search_doc_for_rag_context' is slightly verbose and includes an abbreviation (RAG). All use snake_case, and the verbs ('ingest', 'process', 'search') are appropriate for their actions, with only minor deviations from perfect consistency.
With only 3 tools, the count feels thin for a RAG server's scope, which typically involves more operations like document management (e.g., delete, list), query customization, or knowledge base maintenance. While the tools cover basic ingestion and search, the limited number may restrict agent workflows and indicate an incomplete surface, though it's not extreme.
There are significant gaps in the tool surface for a RAG server. Core operations are missing: no tools to list, update, or delete documents from the knowledge base, and no way to manage the knowledge base itself (e.g., clear or reset). The search functionality is duplicated rather than expanded, and there's no support for advanced RAG features like chunking or metadata handling, which will likely cause agent failures in complex tasks.
Maintenance
Related MCP Connectors
The Needle MCP server enables semantic search on documents stored in files like PDFs, DOCX, and XLSX by connecting AI applications to external data sources. It provides capabilities to create and manage document collections, perform natural language searches on stored content, and retrieve relevant information without requiring exact keyword matches.
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoβ¦
The CustomGPT.ai MCP server is a fully managed, RAG-powered endpoint that connects large language models with private knowledge bases and external data sources. It provides tools for retrieval-augmented generation queries (send_message), data ingestion (upload_file), and source listing, enabling AI agents to query private documents like PDFs with high accuracy and real-time citations.
MCP server unifying ERPs, CRMs, APIs and knowledge base for Claude, ChatGPT and Gemini.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceImplements Retrieval-Augmented Generation (RAG) using GroundX and OpenAI, allowing users to ingest documents and perform semantic searches with advanced context handling through Modern Context Processing (MCP).5-
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables intelligent document search and retrieval from PDF collections, providing semantic search capabilities powered by OpenAI embeddings and ChromaDB vector storage.13MIT
- AlicenseNot gradedqualityNot gradedmaintenanceA Python server that enables retrieval-augmented generation through semantic, question/answer, and style search modalities using PostgreSQL and pgvector for embedding storage and retrieval.2Apache 2.0
- AlicenseNot gradedqualityDmaintenanceA local RAG server that enables document indexing and sentence window retrieval across multiple file formats like PDF, MD, and DOCX. It supports both local Hugging Face models and OpenAI embeddings for efficient context-aware querying through the Model Context Protocol.GPL 3.0