RAG MCP Server
Enables Claude Desktop to search custom knowledge bases using retrieval-augmented generation via a simple MCP tool.
README
RAG MCP Server
A simple Model Context Protocol (MCP) server that provides RAG (Retrieval-Augmented Generation) capabilities to Claude Desktop. This allows Claude to search through your custom knowledge base!
š¤ What is MCP?
Model Context Protocol (MCP) is an open standard created by Anthropic that allows AI assistants like Claude to securely connect to external data sources and tools. Think of it as a way to give Claude superpowers by connecting it to your own data and APIs.
šÆ What Does This Server Do?
This MCP server exposes a search_rag tool that Claude Desktop can use to search through a knowledge base. In this example, it returns test data, but you can easily customize it to:
- Query your own vector database
- Search through your documents
- Connect to your RAG API
- Access any custom data source
š Quick Start
New to this? Check out QUICKSTART.md for a simplified step-by-step guide!
Prerequisites
- Python 3.10 or higher (Download Python)
- Claude Desktop (Download here)
- Basic familiarity with command line
Step 1: Clone or Download This Repository
git clone https://github.com/torkian/rag-mcp-server.git
cd rag-mcp-server
Step 2: Install Dependencies
pip install -r requirements.txt
Step 3: Test the Server
Make sure the server runs correctly:
python server.py
You should see the server start. Press Ctrl+C to stop it.
Step 4: Configure Claude Desktop
Find your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Open the file and add this configuration (replace /path/to/ with your actual path):
{
"mcpServers": {
"rag-server": {
"command": "python3",
"args": ["/absolute/path/to/rag-mcp-server/server.py"]
}
}
}
Important: Use the absolute path to server.py!
Finding Your Python Path
If python3 doesn't work, find your Python path:
# macOS/Linux
which python3
# Windows (Command Prompt)
where python
Use the full path in your config, for example:
{
"mcpServers": {
"rag-server": {
"command": "/usr/local/bin/python3",
"args": ["/Users/yourname/rag-mcp-server/server.py"]
}
}
}
Step 5: Restart Claude Desktop
- Completely quit Claude Desktop (don't just close the window)
- macOS: Press
Cmd+Qor go to Claude ā Quit - Windows: Right-click the system tray icon and select Quit
- macOS: Press
- Reopen Claude Desktop
- Look for the š icon at the bottom of the chat window - this means your MCP server is connected!
Step 6: Test It!
In Claude Desktop, try asking:
Use the search_rag tool to find information about Python
You should see Claude call your tool and return the test message!
š How to Customize
Option 1: Add Your Own Hardcoded Data
Edit server.py and modify the KNOWLEDGE_BASE list (lines 11-39):
KNOWLEDGE_BASE = [
{
"id": 1,
"title": "Your Document Title",
"content": "Your document content here..."
},
# Add more documents...
]
Then update the search_knowledge_base() function (line 45) to implement real search logic.
Option 2: Connect to Your API
Modify the search_knowledge_base() function to call your existing RAG API:
import httpx
def search_knowledge_base(query: str) -> list:
# Call your API
response = httpx.get(f"https://your-api.com/search?q={query}")
return response.json()
Option 3: Connect to a Vector Database
Install a vector database client and query it:
# Example with Pinecone
import pinecone
def search_knowledge_base(query: str) -> list:
# Query your vector database
results = index.query(query, top_k=5)
return results
š ļø Project Structure
rag-mcp-server/
āāā server.py # Main MCP server implementation
āāā requirements.txt # Python dependencies
āāā README.md # Full documentation (you are here!)
āāā QUICKSTART.md # Simplified quick start guide
āāā CONTRIBUTING.md # Contribution guidelines
āāā LICENSE # MIT License
āāā claude_desktop_config.example.json # Example config (copy and modify)
āāā .gitignore # Git ignore patterns
š§ Troubleshooting
The š icon doesn't appear
- Check the config file path - make sure you edited the correct file
- Verify absolute paths - use full paths, not relative paths like
./server.py - Check Python path - run
which python3(macOS/Linux) orwhere python(Windows) - View logs - Claude Desktop logs errors to:
- macOS:
~/Library/Logs/Claude/mcp*.log - Windows:
%APPDATA%\Claude\Logs\mcp*.log
- macOS:
Server shows as connected but tool doesn't work
- Restart Claude Desktop completely after any code changes
- Test the server manually:
It should start without errorspython server.py
Permission errors
Make the server executable:
chmod +x server.py
Import errors
Make sure dependencies are installed:
pip install -r requirements.txt
If using virtual environments, activate it first:
# Create virtual environment
python -m venv venv
# Activate it
# macOS/Linux:
source venv/bin/activate
# Windows:
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Then update your Claude Desktop config to use the virtual environment's Python:
{
"mcpServers": {
"rag-server": {
"command": "/absolute/path/to/venv/bin/python",
"args": ["/absolute/path/to/server.py"]
}
}
}
š Learn More
š¤ Contributing
Contributions are welcome! Feel free to:
- Open issues for bugs or feature requests
- Submit pull requests
- Share your customizations
š License
MIT License - feel free to use this in your own projects!
š” Example Use Cases
- Personal knowledge base: Search your notes, documents, or research
- Company documentation: Give Claude access to internal wikis or docs
- Database queries: Connect to SQL/NoSQL databases
- API integration: Bridge Claude with your existing APIs
- Custom tools: Add any functionality you need!
š How It Works
- Server starts: The Python server runs and waits for messages via stdin/stdout
- Claude connects: Claude Desktop reads the config and connects to your server
- Tool registration: The server tells Claude about the
search_ragtool - User asks: When you ask Claude to search, it calls the tool
- Server responds: Your server processes the request and returns results
- Claude uses results: Claude incorporates the results into its response
Built with ā¤ļø using the Model Context Protocol
Questions? Open an issue or check the MCP documentation!
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.