Sponsored by Deepsite.site

AI Customer Support Bot - MCP Server

Created By
ChiragPatankar8 months ago
Content

AI Customer Support Bot - MCP Server

A Model Context Protocol (MCP) server that provides AI-powered customer support using Cursor AI and Glama.ai integration.

Features

  • Real-time context fetching from Glama.ai
  • AI-powered response generation with Cursor AI
  • Batch processing support
  • Priority queuing
  • Rate limiting
  • User interaction tracking
  • Health monitoring
  • MCP protocol compliance

Prerequisites

  • Python 3.8+
  • PostgreSQL database
  • Glama.ai API key
  • Cursor AI API key

Installation

  1. Clone the repository:
git clone <repository-url>
cd <repository-name>
  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file based on .env.example:
cp .env.example .env
  1. Configure your .env file with your credentials:
# 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. Set up the database:
# Create the database
createdb customer_support_bot

# Run migrations (if using Alembic)
alembic upgrade head

Running the Server

Start the server:

python app.py

The server will be available at http://localhost:8000

API Endpoints

1. Root Endpoint

GET /

Returns basic server information.

2. MCP Version

GET /mcp/version

Returns supported MCP protocol versions.

3. Capabilities

GET /mcp/capabilities

Returns server capabilities and supported features.

4. Process Request

POST /mcp/process

Process a single query with context.

Example request:

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. Batch Processing

POST /mcp/batch

Process multiple queries in a single request.

Example request:

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. Health Check

GET /mcp/health

Check server health and service status.

Rate Limiting

The server implements rate limiting with the following defaults:

  • 100 requests per 60 seconds
  • Rate limit information is included in the health check endpoint
  • Rate limit exceeded responses include reset time

Error Handling

The server returns structured error responses in the following format:

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

Common error codes:

  • RATE_LIMIT_EXCEEDED: Rate limit exceeded
  • UNSUPPORTED_MCP_VERSION: Unsupported MCP version
  • PROCESSING_ERROR: Error processing request
  • CONTEXT_FETCH_ERROR: Error fetching context from Glama.ai
  • BATCH_PROCESSING_ERROR: Error processing batch request

Development

Project Structure

.
├── 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

Adding New Features

  1. Update mcp_config.py with new configuration options
  2. Add new models in models.py if needed
  3. Create new endpoints in app.py
  4. Update capabilities endpoint to reflect new features

Security

  • All MCP endpoints require authentication via X-MCP-Auth header
  • Rate limiting is implemented to prevent abuse
  • Database credentials should be kept secure
  • API keys should never be committed to version control

Monitoring

The server provides health check endpoints for monitoring:

  • Service status
  • Rate limit usage
  • Connected services
  • Processing times

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, please create an issue in the repository or contact the development team.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Playwright McpPlaywright MCP server
DeepChatYour AI Partner on Desktop
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Serper MCP ServerA Serper MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
WindsurfThe new purpose-built IDE to harness magic
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
ChatWiseThe second fastest AI chatbot™
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Tavily Mcp
Amap Maps高德地图官方 MCP Server
CursorThe AI Code Editor
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.