mcpField
A
AI Customer Support Bot - MCP Server

AI Customer Support Bot - MCP Server

本地服务
github.com/ChiragPatankar数据与分析462 周前更新

关于 AI Customer Support Bot - MCP Server

这是一个用于构建 AI 客户支持系统的 Python MCP 框架,面向开发者。它提供可接入不同 AI 服务的分层架构,并包含 HTTP API、PostgreSQL 持久化、身份验证和批量查询处理。

主要功能

  1. 01分层服务架构
  2. 02AI 服务集成
  3. 03单条和批量查询接口
  4. 04令牌身份验证与速率限制
  5. 05PostgreSQL 持久化
  6. 06健康指标与诊断

适用场景

  1. 01构建 AI 客户支持服务
  2. 02批量处理客户支持问题
  3. 03通过令牌验证和速率限制保护支持接口

MCP 相关

项目将自身描述为符合 MCP 的服务端,并提供健康检查、单条查询处理和批量处理的 HTTP 接口。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

暂未收录安装方式

我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。

代码仓库

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

🤖 AI 客户支持机器人 - MCP 服务

Python FastAPI PostgreSQL MCP License

用于构建 AI 驱动的客户支持系统的现代化、可扩展 MCP 服务框架

功能 • 快速开始 • API 参考 • 架构 • 参与贡献


🌟 概述

一个使用现代 Python 构建、符合 Model Context Protocol(MCP) 规范的服务框架。专为希望创建智能客户支持系统、又不想被供应商锁定的开发者设计。架构清晰,采用经过实战检验的模式,可适配任何 AI 提供商。

graph TB
    Client[HTTP Client] --> API[API Server]
    API --> MW[Middleware Layer]
    MW --> SVC[Service Layer]
    SVC --> CTX[Context Manager]
    SVC --> AI[AI Integration]
    SVC --> DAL[Data Access Layer]
    DAL --> DB[(PostgreSQL)]

✨ 功能

🏗️ 清晰的架构
分层设计,职责划分明确

📡 符合 MCP 规范
完整实现 Model Context Protocol

🔒 适用于生产环境
内置身份验证、速率限制和监控

🚀 高性能
基于 FastAPI 构建,支持异步操作

🔌 不依赖特定 AI 服务
轻松集成任意 AI 提供商

📊 运行状况监控
全面的指标和诊断信息

🛡️ 默认安全
令牌身份验证和输入验证

📦 批处理
高效处理多个查询

🚀 快速开始

前提条件
  • Python 3.8+
  • PostgreSQL
  • 你喜欢的 AI 服务(OpenAI、Anthropic 等)
安装
# Clone and setup
git clone https://github.com/ChiragPatankar/AI-Customer-Support-Bot--MCP-Server.git
cd AI-Customer-Support-Bot--MCP-Server

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Setup environment
cp .env.example .env
# Edit .env with your configuration
配置
# .env file
DATABASE_URL=postgresql://user:password@localhost/customer_support_bot
SECRET_KEY=your-super-secret-key
RATE_LIMIT_REQUESTS=100
RATE_LIMIT_PERIOD=60
运行
# Setup database
createdb customer_support_bot

# Start server
python app.py
# 🚀 Server running at http://localhost:8000

📡 API 参考

核心端点
健康检查
GET /mcp/health
处理单个查询
POST /mcp/process
Content-Type: application/json
X-MCP-Auth: your-token
X-MCP-Version: 1.0

{
  "query": "How do I reset my password?",
  "priority": "high"
}
批处理
POST /mcp/batch
Content-Type: application/json
X-MCP-Auth: your-token

{
  "queries": [
    "How do I reset my password?",
    "What are your business hours?"
  ]
}
响应格式
成功响应
{
  "status": "success",
  "data": {
    "response": "Generated AI response",
    "confidence": 0.95,
    "processing_time": "120ms"
  },
  "meta": {
    "request_id": "req_123456",
    "timestamp": "2024-02-14T12:00:00Z"
  }
}
错误响应
{
  "code": "RATE_LIMIT_EXCEEDED",
  "message": "Rate limit exceeded",
  "details": {
    "retry_after": 60,
    "timestamp": "2024-02-14T12:00:00Z"
  }
}

🏗️ 架构

项目结构
📦 AI-Customer-Support-Bot--MCP-Server
├── 🚀 app.py              # FastAPI application
├── 🗄️  database.py         # Database configuration
├── 🛡️  middleware.py       # Auth & rate limiting
├── 📋 models.py          # ORM models
├── ⚙️  mcp_config.py      # MCP protocol config
├── 📄 requirements.txt   # Dependencies
└── 📝 .env.example      # Environment template
各层职责
层用途组件
APIHTTP 端点、验证FastAPI 路由、Pydantic 模型
中间件身份验证、速率限制、日志记录令牌验证、请求限流
服务业务逻辑、AI 集成上下文管理、AI 编排
数据持久化、模型PostgreSQL、SQLAlchemy ORM

🔌 扩展 AI 服务

添加你的 AI 提供商
  1. 安装 AI SDK:
pip install openai  # or anthropic, cohere, etc.
  1. 配置环境:
# Add to .env
AI_SERVICE_API_KEY=sk-your-api-key
AI_SERVICE_MODEL=gpt-4
  1. 实现服务集成:
# In service layer
class AIService:
    async def generate_response(self, query: str, context: dict) -> str:
        # Your AI integration here
        return ai_response

🔧 开发

运行测试
pytest tests/
代码质量
# Format code
black .

# Lint
flake8

# Type checking
mypy .
Docker 支持
# Coming soon - Docker containerization

📊 监控与可观测性

健康指标
  • ✅ 服务运行时间
  • 🔗 数据库连通性
  • 📈 请求速率
  • ⏱️ 响应时间
  • 💾 内存使用量
日志记录
# Structured logging included
{
  "timestamp": "2024-02-14T12:00:00Z",
  "level": "INFO",
  "message": "Query processed",
  "request_id": "req_123456",
  "processing_time": 120
}

🔒 安全

内置安全功能
  • 🔐 令牌身份验证 - 安全访问 API
  • 🛡️ 速率限制 - 防范 DoS 攻击
  • ✅ 输入验证 - 防止 SQL 注入
  • 📝 审计日志 - 跟踪请求
  • 🔒 环境密钥 - 安全管理配置

🚀 部署

环境设置
# Production environment variables
DATABASE_URL=postgresql://prod-user:password@prod-host/db
RATE_LIMIT_REQUESTS=1000
LOG_LEVEL=WARNING
扩展注意事项
  • 为数据库使用连接池
  • 在多实例部署中使用 Redis 实现速率限制
  • 添加负载均衡器以实现高可用性
  • 使用 Prometheus/Grafana 进行监控

🤝 参与贡献

欢迎贡献!以下是入门方法:

开发环境设置
# Fork the repo, then:
git clone https://github.com/your-username/AI-Customer-Support-Bot--MCP-Server.git
cd AI-Customer-Support-Bot--MCP-Server

# Create feature branch
git checkout -b feature/amazing-feature

# Make your changes
# ...

# Test your changes
pytest

# Submit PR
贡献指南
  • 📝 为新功能编写测试
  • 📚 更新文档
  • 🎨 遵循现有代码风格
  • ✅ 确保 CI 通过

MseeP.ai 安全评估徽章

📄 许可证

本项目采用 MIT 许可证授权,详情请参阅 LICENSE 文件。


由 Chirag Patankar 倾情打造 ❤️

⭐ 如果觉得这个仓库有帮助,请为它点星! ⭐

报告 Bug • 请求功能 • 文档

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。