Token导航 LogoToken导航TokenDH.com
CAP RAG MCP logo
搜索检索stdio官方级别未说明来源级核验

CAP RAG MCP

MCP Server

CapAmerica RAG MCP Server是一个结合检索增强生成(RAG)和模型上下文协议(MCP)的智能产品目录API,提供基于对话AI的产品搜索和定价功能。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
Python搜索文档处理

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

jayanta8509

提供方

jayanta8509

最后核验

2026/5/17 20:21

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

python -m venv venv

详细介绍

CapAmerica RAG MCP服务器

CapAmerica头戴式耳机的智能产品目录API,将Retrieval-AugedGeneration(RAG)与Model Context Protocol(MCP)和FastAPI相结合,用于无缝对话式人工智能驱动的产品搜索和定价。

🧢 概述

CapAmerica RAG MCP服务器提供了一个复杂的人工智能产品目录系统,该系统:

  • 保持对话记忆 每个用户会话
  • 利用实时MCP工具 用于产品数据访问
  • 支持自然语言查询 用于产品发现
  • 提供准确的定价 批量订单的计算
  • 管理超过27种真帽产品 详细规格

📁 项目结构

CAP_RAG_MCP/
├── app.py                 # FastAPI web server with memory support
├── client.py              # LangChain MCP client with conversation memory
├── rag.py                 # Gradio interface for interactive testing
├── mcp_functions.py       # MCP server with product catalog tools
├── products.csv           # Real CapAmerica product database
├── .env                   # Environment variables (OPENAI_API_KEY)
├── requirements.txt       # Python dependencies
└── README.md             # This documentation

🚀 特性

💬 对话记忆

  • 用户特定线程:每个 user_id 获得自己的对话线索
  • 上下文持久性:后续问题记住之前的背景
  • 内存管理:每个用户的对话清晰
  • LangGraph内存保护程序:强大的内存后端

🛍️ 产品目录工具

  1. get_product_info(product_id) -详细的产品规格
  2. search_products(keyword) -按款式/功能查找产品
  3. get_product_pricing(product_id, embroidery_type, quantity) -精确的定价计算
  4. get_all_products() -完整的目录访问

📊 真实产品数据

  • 27+盖子产品:高性能帽子,卡车网眼布,羊毛混纺,运动风格
  • 实际定价:每台9.00美元至27.00美元(24至2500多个数量)
  • 颜色选项:每件产品有20+种颜色变化
  • 刺绣选项:平面和3D刺绣定价
  • 尺寸范围:XS至XXL,OSFM选项

🔧 API终点

发布 /chat/agent

使用对话记忆支持提问。

请求格式:

{
    "user_id": "xyz",
    "query": "What's the price for 48 units of i7041?",
    "use_agent": true
}

响应格式:

{
    "response": "The price for 48 units of i7041 with flat embroidery is $15.75 per unit...",
    "status_code": 200,
    "query": "What's the price for 48 units of i7041?",
    "user_id": "xyz",
    "timestamp": 1699123456.789
}

获取 /health

显示服务状态和可用功能的健康检查端点。

删除 /chat/{user_id}

为特定用户清除对话记忆。

📦 安装和设置

1.环境设置

# Create virtual environment
python -m venv venv

# Activate environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

2.环境配置

创建 .env 文件:

OPENAI_API_KEY=your_openai_api_key_here

3.启动服务

启动MCP服务器(后台)

python mcp_functions.py

启动FastAPI服务器

python app.py

API将在以下网址提供: http://localhost:8021

启动Gradio界面(可选)

python rag.py

访问交互式web界面: http://localhost:7860

🧠 用法示例

基本产品查询

# Find specific product
curl -X POST "http://localhost:8021/chat/agent" \
     -H "Content-Type: application/json" \
     -d '{
       "user_id": "customer_123",
       "query": "Show me details for product i7041"
     }'

搜索和发现

# Find products by style
curl -X POST "http://localhost:8021/chat/agent" \
     -H "Content-Type: application/json" \
     -d '{
       "user_id": "customer_123",
       "query": "What trucker style caps do you have?"
     }'

定价计算

# Get specific pricing
curl -X POST "http://localhost:8021/chat/agent" \
     -H "Content-Type: application/json" \
     -d '{
       "user_id": "customer_123",
       "query": "What'\''s the price for 144 units of i8501 with 3D embroidery?"
     }'

内存驱动的对话

# First question
curl -X POST "http://localhost:8021/chat/agent" \
     -H "Content-Type: application/json" \
     -d '{
       "user_id": "customer_456",
       "query": "Show me caps with UV protection"
     }'

# Follow-up question (remembers context)
curl -X POST "http://localhost:8021/chat/agent" \
     -H "Content-Type: application/json" \
     -d '{
       "user_id": "customer_456",
       "query": "What about the moisture wicking ones you mentioned?"
     }'

🔧 MCP工具参考

get_product_info(product_id)

# Returns detailed product information
{
    "product_id": "i7041",
    "title": "Lightweight Aerated Performance Cap",
    "features": "Medium profile six panel structured cap...",
    "sizing": "XS / OSFM",
    "pricing": {
        "flat_embroidery": {"24": 17.5, "48": 15.75, ...},
        "3d_embroidery": {"24": 22.25, "48": 20.75, ...}
    },
    "available_colors": ["Black", "Gray", "Maroon", "Navy", ...]
}

搜索产品(关键字)

# Returns matching products
{
    "keyword": "trucker",
    "matches": 8,
    "products": [
        {
            "product_id": "i8501",
            "title": "Performance Trucker Mesh Back Cap",
            "features": "Mid profile six panel structured..."
        }
    ]
}

get_product_price(product_id,刺绣y_type,数量)

# Returns calculated pricing
{
    "product_id": "i7041",
    "product_title": "Lightweight Aerated Performance Cap",
    "embroidery_type": "flat",
    "quantity": 48,
    "unit_price": 15.75,
    "total_cost": 756.0,
    "currency": "USD"
}

🏗️ 建筑

内存层

  • LangGraph内存保护程序:持久对话存储
  • 基于线程的隔离:每个用户都有独立的对话线程
  • 可配置的保留:每个用户轻松管理内存

MCP集成

  • 多服务器MCPClient:连接到产品目录MCP服务器
  • 动态刀具加载:自动加载可用的MCP工具
  • 错误处理:强大的错误恢复和用户反馈

AI层

  • LangChain:AI框架集成
  • OpenAI GPT-4o-mini:高级语言模型
  • 重新代理:具有推理能力的工具使用代理

API层

  • 快速API:高性能异步web框架
  • CORS支持:跨源请求处理
  • 自动文档:OpenAPI/Swagger /docs

📊 产品目录统计

  • 产品总数:27款以上真正的CapAmerica帽子型号
  • 价格范围:每单位9.00-27.00美元
  • 数量层次:24、48、96、144、576、2500多个单位
  • 颜色选项:每种产品有20+种变化
  • 刺绣类型:平面和3D刺绣
  • 尺寸范围:XS、S、M、L、XL、XXL、OSFM
  • 帽子样式:性能、卡车司机、运动型、羊毛混纺、按扣、遮阳板

🔍 对话流程示例

[
    {
        "user_id": "outdoor_event_co",
        "query": "What caps do you recommend for outdoor sports events?",
        "response": "For outdoor sports events, I recommend performance caps with UV protection and moisture wicking features. Let me show you some options..."
    },
    {
        "user_id": "outdoor_event_co",
        "query": "What about the trucker style ones?",
        "response": "Great choice! The trucker mesh caps are perfect for outdoor events. We have the Performance Trucker (i8501) and Premium Trucker (i8502) with excellent ventilation..."
    },
    {
        "user_id": "outdoor_event_co",
        "query": "What's the pricing for 96 units of the i8501?",
        "response": "For 96 units of the Performance Trucker Mesh Back Cap (i8501), the pricing is $18.75 per unit with flat embroidery, or $21.75 per unit with 3D embroidery..."
    }
]

🛠️ 发展

添加新的MCP工具

  1. 在中定义工具功能 mcp_functions.py 随着 @mcp.tool() 装饰器
  2. 更新工具文档和示例
  3. AI代理可以自动使用工具

扩展内存功能

  • 内存配置 client.py: get_user_config(user_id)
  • 对话管理: clear_conversation(user_id)
  • 通过以下方式进行线程隔离 thread_id 参数

API增强功能

  • 在中添加新端点 app.py
  • 扩展请求/响应模型
  • 更新自动生成的OpenAPI文档

🐛 故障排除

常见问题

  1. MCP服务器连接

- 确保 mcp_functions.py 正在后台运行 - 检查stdio传输连接

  1. 内存不工作

- 验证user_id在请求之间是否一致 - 检查MemorySaver配置

  1. 缺少环境变量

- 集 OPENAI_API_KEY.env 文件 - 验证API密钥的有效性

  1. 产品数据问题

- 确保 products.csv 存在且可访问 - 检查CSV格式和所需列

调试模式

启用详细日志记录:

import logging
logging.basicConfig(level=logging.DEBUG)

📄 许可证

该项目是CapAmerica头饰目录系统的一部分,包含专有产品数据和定价信息。

🤝 支持

有关产品目录的技术支持或问题,请参阅CapAmerica产品文档或联系开发团队。

______________________________________________________________________

内置于❤️ 使用LangChain、FastAPI和模型上下文协议

目录标签

目录标签

Python搜索文档处理智能产品目录本地部署对话AI产品搜索定价计算FastAPI

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP