Personal RAG MCP Server

Personal RAG MCP Server

Enables storing and searching personal notes, documents, and snippets using semantic search and RAG capabilities across Claude Desktop, VS Code, and Open WebUI.

Category
访问服务器

README

Personal RAG MCP Server

A Model Context Protocol (MCP) server that provides personal knowledge base with RAG (Retrieval-Augmented Generation) capabilities. Share context across Claude Desktop, Claude Code, VS Code, and Open WebUI.

Features

  • Hybrid Storage: SQLite for full-text documents + Qdrant for semantic search
  • Rich Metadata: Comprehensive metadata capture for future extensibility
  • Dual Transport: stdio (for Claude Desktop/VS Code) + HTTP Streaming (for Open WebUI)
  • Forward-Compatible: Strategy pattern allows adding advanced RAG features without refactoring
  • Containerized: Runs in Docker, connects to existing Qdrant/Ollama/LiteLLM infrastructure

Architecture

User Input → MCP Tool
    ↓
[1] Generate embedding (Ollama)
    ↓
[2] Store full text + metadata in SQLite
    ↓
[3] Store vector in Qdrant
    ↓
Return confirmation

Search Query
    ↓
[1] Embed query (Ollama)
    ↓
[2] Search Qdrant (semantic search)
    ↓
[3] Retrieve full text from SQLite
    ↓
[4] Generate response (LiteLLM)
    ↓
Return answer + sources

MCP Tools

1. store_memory

Store notes, documents, or snippets in the knowledge base.

store_memory(
    text="Your content here",
    namespace="notes/personal",  # Hierarchical organization
    tags=["tag1", "tag2"],
    title="Optional Title",
    category="personal",  # work, personal, family
    content_type="note"  # note, document, snippet
)

2. search_memory

Semantic search across your knowledge base.

search_memory(
    query="What did I learn about X?",
    namespace="notes/personal",  # Optional filter
    limit=5,
    content_type="note"  # Optional filter
)

3. ask_with_context

Ask questions with RAG (retrieval + generation).

ask_with_context(
    question="What are my thoughts on X?",
    namespace="notes/personal",  # Optional filter
    limit=5  # Context chunks to retrieve
)

Project Structure

personal-rag-mcp/
├── Dockerfile
├── requirements.txt
├── README.md
├── config/
│   ├── pipeline.yaml          # RAG pipeline config
│   └── server.yaml            # Server config
├── personal_rag_mcp/
│   ├── server.py              # MCP server entry point
│   ├── storage/
│   │   ├── sqlite_store.py    # SQLite document storage
│   │   ├── qdrant_store.py    # Qdrant vector storage
│   │   └── schema.py          # Pydantic metadata models
│   ├── pipeline/
│   │   ├── retriever.py       # Retrieval strategies
│   │   ├── reranker.py        # Reranking strategies
│   │   ├── expander.py        # Query expansion
│   │   ├── generator.py       # LLM generation
│   │   └── pipeline.py        # RAG orchestration
│   └── utils/
│       ├── embeddings.py      # Ollama embedding client
│       └── chunking.py        # Text chunking
├── scripts/
│   ├── init_db.py             # Initialize database
│   └── backup.py              # Backup utility
└── tests/

Environment Variables

# Transport
TRANSPORT=http  # or stdio
PORT=8765

# Storage
SQLITE_PATH=/app/data/documents.db
QDRANT_URL=http://qdrant:6333

# AI Services
OLLAMA_URL=http://ollama:11434
LITELLM_URL=http://litellm:4000

Development

Setup

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

# Install dependencies
pip install -r requirements.txt

Run Locally (stdio)

export SQLITE_PATH=./data/documents.db
export QDRANT_URL=http://localhost:6333
export OLLAMA_URL=http://localhost:11434
export LITELLM_URL=http://localhost:4000

python -m personal_rag_mcp.server

Run Locally (HTTP)

export TRANSPORT=http
export PORT=8765

python -m personal_rag_mcp.server

Docker Deployment

Prerequisites

This MCP server depends on the following AI infrastructure services:

  • Qdrant (vector database) - Port 6333
  • Ollama (embeddings) - Port 11434
  • LiteLLM (LLM proxy) - Port 4000/8000

Example Docker Compose Integration

services:
  # Required: Qdrant vector database
  qdrant:
    image: qdrant/qdrant:latest
    container_name: qdrant
    ports:
      - "6333:6333"
    volumes:
      - qdrant-data:/qdrant/storage
    restart: unless-stopped

  # Required: Ollama for embeddings
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    ports:
      - "11434:11434"
    volumes:
      - ollama-data:/root/.ollama
    restart: unless-stopped

  # Required: LiteLLM proxy for LLM access
  litellm-proxy:
    image: ghcr.io/berriai/litellm:main-latest
    container_name: litellm-proxy
    ports:
      - "4080:8000"
    volumes:
      - ./litellm_config.yaml:/app/config.yaml
    environment:
      - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
      - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
      - AWS_REGION=${AWS_REGION}
      - OLLAMA_API_BASE=http://ollama:11434
    entrypoint: ["litellm", "--config", "/app/config.yaml", "--port", "8000"]
    depends_on:
      - ollama
    restart: unless-stopped

  # Personal RAG MCP Server
  personal-rag-mcp:
    build: ./personal-rag-mcp
    container_name: personal-rag-mcp
    ports:
      - "8765:8765"
    environment:
      - TRANSPORT=http
      - PORT=8765
      - QDRANT_URL=http://qdrant:6333
      - OLLAMA_URL=http://ollama:11434
      - LITELLM_URL=http://litellm-proxy:8000
      - OPENAI_API_KEY=${LITELLM_API_KEY}  # LiteLLM auth
      - SQLITE_PATH=/app/data/documents.db
    volumes:
      - personal-rag-data:/app/data
      - ./config/personal-rag:/app/config:ro
    depends_on:
      - qdrant
      - ollama
      - litellm-proxy
    restart: unless-stopped

volumes:
  qdrant-data:
  ollama-data:
  personal-rag-data:

LiteLLM Configuration Example

The MCP server uses LiteLLM as a unified proxy, which means you can use any LLM provider:

  • Local: Ollama (llama3, deepseek, qwen, etc.)
  • Cloud: OpenAI, Anthropic Claude, Google Gemini, Cohere
  • AWS Bedrock: Claude, Llama, Mistral, etc.
  • Azure OpenAI: GPT-4, GPT-3.5
  • 100+ other providers: See LiteLLM docs

Simply configure your preferred models in litellm_config.yaml:

model_list:
  # Local Ollama models (no API key needed)
  - model_name: deepseek-r1-1.5b
    litellm_params:
      model: ollama/deepseek-r1:1.5b
      api_base: http://ollama:11434

  # AWS Bedrock models
  - model_name: bedrock-claude-3-5-sonnet-v2
    litellm_params:
      model: bedrock/us.anthropic.claude-3-5-sonnet-20241022-v2:0
      aws_access_key_id: os.environ/AWS_ACCESS_KEY_ID
      aws_secret_access_key: os.environ/AWS_SECRET_ACCESS_KEY
      aws_region_name: us-east-2

  # OpenAI models
  - model_name: gpt-4o
    litellm_params:
      model: openai/gpt-4o
      api_key: os.environ/OPENAI_API_KEY

  # Anthropic Claude
  - model_name: claude-3-5-sonnet
    litellm_params:
      model: anthropic/claude-3-5-sonnet-20241022
      api_key: os.environ/ANTHROPIC_API_KEY

  # Embedding model (for semantic search)
  - model_name: nomic-embed-text
    litellm_params:
      model: ollama/nomic-embed-text
      api_base: http://ollama:11434

general_settings:
  master_key: sk-1234  # Set LITELLM_API_KEY in .env

The server defaults to using whatever model is configured in LiteLLM. You can easily switch between local and cloud models without changing the MCP server code.

Environment File (.env)

# LiteLLM API Key
LITELLM_API_KEY=sk-1234

# AWS Credentials (optional, for Bedrock models)
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-2

First-Time Setup

  1. Pull required Ollama models:

    docker exec ollama ollama pull nomic-embed-text
    docker exec ollama ollama pull deepseek-r1:1.5b
    
  2. Verify services are running:

    curl http://localhost:6333/collections  # Qdrant
    curl http://localhost:11434/api/tags     # Ollama
    curl -H "Authorization: Bearer sk-1234" http://localhost:4080/v1/models  # LiteLLM
    
  3. Test the MCP server:

    docker exec personal-rag-mcp python /app/scripts/test_e2e.py
    

For complete infrastructure setup, see the parent repository.

Roadmap

Phase 1 (Current)

  • ✅ Hybrid SQLite + Qdrant storage
  • ✅ Basic RAG pipeline (vector retrieval)
  • ✅ MCP tools (store, search, ask)
  • ✅ Dual transport (stdio + HTTP)

Phase 2 (Future)

  • [ ] Advanced RAG features (reranking, hybrid search, query expansion)
  • [ ] Bulk document ingestion (PDF, DOCX parsing)
  • [ ] Conversation history capture
  • [ ] Multi-user support with authentication

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选