MCP with RAG Demo
About
This demonstration project shows how to implement a Model Context Protocol (MCP) server with Retrieval-Augmented Generation (RAG) capabilities. The demo allows AI models to interact with a knowledge base, search for information, and add new documents.
Details
- Author
- thinklytics
- Downloads
- 252
- Categories
- Knowledge Base
Jump to
- MCP server with tool and resource support
- RAG implementation with in-memory storage fallback
- Client example for interacting with the MCP server
- Support for both SSE (HTTP) and stdio communication modes
- Simple prompt templates for greetings
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
MCP with RAG DemoCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Install dependencies with pip install -r requirements.txt, then start the MCP server in either SSE mode (python server.py --sse) or stdio mode (python server.py --stdio). Run the client example with python client_example.py --sse http://localhost:8000 for SSE or python client_example.py --stdio --command python --args "server.py --stdio" for stdio. An OpenAI integration example is also available via python openai_example.py after setting the OPENAI_API_KEY environment variable.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"mcp with rag demo": {
"mcp-demo-thinklytics": {
"command": "python",
"args": [
"-m",
"venv",
"mcp-env"
]
}
}
}
}
McpServers
{
"mcp-demo-thinklytics": {
"command": "python",
"args": [
"-m",
"venv",
"mcp-env"
]
}
}
MCP with RAG Demo
This demonstration project shows how to implement a Model Context Protocol (MCP) server with Retrieval-Augmented Generation (RAG) capabilities. The demo allows AI models to interact with a knowledge base, search for information, and add new documents.
Features
- MCP server with tool and resource support
- RAG implementation (with fallback to in-memory storage)
- Client example for interacting with the MCP server
- Support for both SSE (HTTP) and stdio communication modes
- Simple prompt templates
Prerequisites
- Python 3.8+
- pip (Python package manager)
Installation
1. Clone the repository:
git clone <repository-url>
cd mcp-demo
2. Create a virtual environment:
python -m venv mcp-env
source mcp-env/bin/activate # On Windows: mcp-env\Scripts\activate
3. Install the required dependencies:
pip install -r requirements.txt
Project Structure
mcp-demo/
├── server.py # Main MCP server implementation
├── client_example.py # Example client to interact with the server
├── requirements.txt # Project dependencies
├── sample_data.txt # Sample data available as a resource
├── tools/
│ ├── __init__.py # Package initialization
│ └── rag_tools.py # RAG tools implementation
└── README.md # This readme file
Running the Demo
Step 1: Start the MCP Server
You can run the MCP server in two different modes:
Option A: SSE (HTTP) Mode
This mode allows the server to accept connections over HTTP using Server-Sent Events (SSE):
python server.py --sse
By default, the server will listen on 0.0.0.0:8000. You can customize the host and port:
python server.py --sse --host 127.0.0.1 --port 9000
Option B: stdio Mode
This mode allows the server to communicate through standard input/output:
python server.py --stdio
Step 2: Run the Client Example
After the server is up and running, open a new terminal window (keeping the server running in the first one):
Connecting to an SSE Server
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.


