鸡尾酒RAG MCP服务器
使用RAG(检索增强生成)进行鸡尾酒推荐的MCP工具。
需求
- Python 3.11+
- uv包管理器 - https://docs.astral.sh/uv/getting-started/installation/
快速开始
- 获取Groq API密钥 (免费):https://console.groq.com/keys
- 设置:
# Clone the repository
git clone https://github.com/00200200/cocktails-rag-mcp.git
cd cocktails-rag-mcp
# Copy environment template
cp .env.example .env
# Edit .env and add your GROQ_API_KEY
nano .env
# Install dependencies
uv sync- 预下载型号(必填):
下载嵌入和重新链接模型:
uv run python -c "from src.rag.rag import RAG; RAG(); print('Models downloaed!')"- 为Claude Desktop安装:
### 自动(推荐)
uv run fastmcp install claude-desktop fastmcp.json --name cocktails --env-file .env### 手册
编辑配置文件:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json - 窗户: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"cocktails": {
"command": "uv",
"args": [
"run",
"--with","faiss-cpu",
"--with","fastmcp",
"--with","jq",
"--with","langchain",
"--with","langchain-community",
"--with","langchain-groq",
"--with","langchain-huggingface",
"--with","pandas",
"--with","python-dotenv",
"--with","sentence-transformers",
"fastmcp",
"run",
"/ABSOLUTE/PATH/TO/src/mcp/server.py:mcp"
],
"env": {
"GROQ_API_KEY": "your_groq_api_key_here"
}
}
}
}替换 /ABSOLUTE/PATH/TO/ 与您的项目路径和 GROQ_API_KEY 使用API密钥。
示例用法
局部测试
# Test RAG pipeline directly
uv run python -m src.rag.rag
# Test MCP server locally
uv run python src/mcp/server.py发展
代码格式化
# Format code with black
uv tool run black .
# Sort imports with isort
uv tool run isort .项目结构
RAG/
├── src/
│ ├── mcp/ # MCP server implementation (FastMCP)
│ ├── rag/ # RAG pipeline (retrieve, rerank, generate)
│ ├── db/ # FAISS vector database handler
│ └── data/ # Data loading utilities
├── data/ # Cocktail dataset
├── faiss_index/ # Generated FAISS index (auto-created on first run)
├── notebooks/ # EDA notebook
├── fastmcp.json # FastMCP configuration
├── pyproject.toml # Project dependencies
└── .env.example # Environment template技术栈
- MCP框架: FastMCP
- RAG框架: LangChain
- 嵌入: BAAI/bge-m3(当地经HuggingFace)
- 矢量数据库: FAISS(本地)
- 重新排名: BAAI/bge-ranker-v2-m3(当地通过HuggingFace)
- LLM Groq API(llama-3.1-8b-即时)
- 包管理器: 紫外线
