RAG MCP Server

RAG MCP Server

Enables Claude Desktop to search custom knowledge bases using retrieval-augmented generation via a simple MCP tool.

Category
Visit Server

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

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

  1. Completely quit Claude Desktop (don't just close the window)
    • macOS: Press Cmd+Q or go to Claude → Quit
    • Windows: Right-click the system tray icon and select Quit
  2. Reopen Claude Desktop
  3. 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

  1. Check the config file path - make sure you edited the correct file
  2. Verify absolute paths - use full paths, not relative paths like ./server.py
  3. Check Python path - run which python3 (macOS/Linux) or where python (Windows)
  4. View logs - Claude Desktop logs errors to:
    • macOS: ~/Library/Logs/Claude/mcp*.log
    • Windows: %APPDATA%\Claude\Logs\mcp*.log

Server shows as connected but tool doesn't work

  1. Restart Claude Desktop completely after any code changes
  2. Test the server manually:
    python server.py
    
    It should start without errors

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

  1. Server starts: The Python server runs and waits for messages via stdin/stdout
  2. Claude connects: Claude Desktop reads the config and connects to your server
  3. Tool registration: The server tells Claude about the search_rag tool
  4. User asks: When you ask Claude to search, it calls the tool
  5. Server responds: Your server processes the request and returns results
  6. 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

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Exa Search

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.

Official
Featured