Skip to main content
Glama

AI Customer Support Bot - MCP Server

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

模型上下文协议 (MCP) 服务器使用 Cursor AI 和 Glama.ai 集成提供 AI 驱动的客户支持。

特征

  • 从 Glama.ai 获取实时上下文

  • 使用 Cursor AI 生成 AI 支持的响应

  • 批处理支持

  • 优先级排队

  • 速率限制

  • 用户交互跟踪

  • 健康监测

  • MCP 协议合规性

Related MCP server: MCP Starter

先决条件

  • Python 3.8+

  • PostgreSQL 数据库

  • Glama.ai API 密钥

  • 光标 AI API 密钥

安装

  1. 克隆存储库:

git clone <repository-url> cd <repository-name>
  1. 创建并激活虚拟环境:

python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
  1. 安装依赖项:

pip install -r requirements.txt
  1. 根据.env.example创建.env文件:

cp .env.example .env
  1. 使用您的凭证配置您的.env文件:

# API Keys GLAMA_API_KEY=your_glama_api_key_here CURSOR_API_KEY=your_cursor_api_key_here # Database DATABASE_URL=postgresql://user:password@localhost/customer_support_bot # API URLs GLAMA_API_URL=https://api.glama.ai/v1 # Security SECRET_KEY=your_secret_key_here # MCP Server Configuration SERVER_NAME="AI Customer Support Bot" SERVER_VERSION="1.0.0" API_PREFIX="/mcp" MAX_CONTEXT_RESULTS=5 # Rate Limiting RATE_LIMIT_REQUESTS=100 RATE_LIMIT_PERIOD=60 # Logging LOG_LEVEL=INFO
  1. 设置数据库:

# Create the database createdb customer_support_bot # Run migrations (if using Alembic) alembic upgrade head

运行服务器

启动服务器:

python app.py

该服务器将在http://localhost:8000可用

API 端点

1. 根端点

GET /

返回基本服务器信息。

2. MCP 版本

GET /mcp/version

返回支持的 MCP 协议版本。

3. 能力

GET /mcp/capabilities

返回服务器功能和支持的功能。

4. 处理请求

POST /mcp/process

使用上下文来处理单个查询。

示例请求:

curl -X POST http://localhost:8000/mcp/process \ -H "Content-Type: application/json" \ -H "X-MCP-Auth: your-auth-token" \ -H "X-MCP-Version: 1.0" \ -d '{ "query": "How do I reset my password?", "priority": "high", "mcp_version": "1.0" }'

5.批处理

POST /mcp/batch

在单个请求中处理多个查询。

示例请求:

curl -X POST http://localhost:8000/mcp/batch \ -H "Content-Type: application/json" \ -H "X-MCP-Auth: your-auth-token" \ -H "X-MCP-Version: 1.0" \ -d '{ "queries": [ "How do I reset my password?", "What are your business hours?", "How do I contact support?" ], "mcp_version": "1.0" }'

6. 健康检查

GET /mcp/health

检查服务器健康和服务状态。

速率限制

服务器使用以下默认值实现速率限制:

  • 每 60 秒 100 个请求

  • 速率限制信息包含在健康检查端点中

  • 速率限制超出响应包括重置时间

错误处理

服务器返回以下格式的结构化错误响应:

{ "code": "ERROR_CODE", "message": "Error description", "details": { "timestamp": "2024-02-14T12:00:00Z", "additional_info": "value" } }

常见错误代码:

  • RATE_LIMIT_EXCEEDED :超出速率限制

  • UNSUPPORTED_MCP_VERSION :不支持的 MCP 版本

  • PROCESSING_ERROR :处理请求时出错

  • CONTEXT_FETCH_ERROR :从 Glama.ai 获取上下文时出错

  • BATCH_PROCESSING_ERROR :处理批量请求时出错

发展

项目结构

. ├── app.py # Main application file ├── database.py # Database configuration ├── middleware.py # Middleware (rate limiting, validation) ├── models.py # Database models ├── mcp_config.py # MCP-specific configuration ├── requirements.txt # Python dependencies └── .env # Environment variables

添加新功能

  1. 使用新的配置选项更新mcp_config.py

  2. 如果需要,在models.py中添加新模型

  3. app.py中创建新的端点

  4. 更新功能端点以反映新功能

安全

  • 所有 MCP 端点都需要通过X-MCP-Auth标头进行身份验证

  • 实施速率限制以防止滥用

  • 数据库凭证应保持安全

  • API 密钥永远不应提交到版本控制

监控

服务器提供健康检查端点用于监控:

  • 服务状态

  • 速率限制使用情况

  • 互联服务

  • 处理时间

贡献

  1. 分叉存储库

  2. 创建功能分支

  3. 提交你的更改

  4. 推送到分支

  5. 创建拉取请求

验证徽章

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

支持

如需支持,请在存储库中创建问题或联系开发团队。

-
security - not tested
A
license - permissive license
-
quality - not tested

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ChiragPatankar/AI-Customer-Support-Bot--MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server