AI-Customer-Support-Bot--MCP-Server

ChiragPatankar/AI-Customer-Support-Bot--MCP-Server

3.3

If you are the rightful owner of AI-Customer-Support-Bot--MCP-Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

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

๐Ÿค– AI Customer Support Bot - MCP Server

Python FastAPI PostgreSQL MCP License

A modern, extensible MCP server framework for building AI-powered customer support systems

Features โ€ข Quick Start โ€ข API Reference โ€ข Architecture โ€ข Contributing


๐ŸŒŸ Overview

A Model Context Protocol (MCP) compliant server framework built with modern Python. Designed for developers who want to create intelligent customer support systems without vendor lock-in. Clean architecture, battle-tested patterns, and ready for any AI provider.

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)]

โœจ Features

๐Ÿ—๏ธ Clean Architecture
Layered design with clear separation of concerns

๐Ÿ“ก MCP Compliant
Full Model Context Protocol implementation

๐Ÿ”’ Production Ready
Auth, rate limiting, monitoring included

๐Ÿš€ High Performance
Built on FastAPI with async support

๐Ÿ”Œ AI Agnostic
Integrate any AI provider easily

๐Ÿ“Š Health Monitoring
Comprehensive metrics and diagnostics

๐Ÿ›ก๏ธ Secure by Default
Token auth and input validation

๐Ÿ“ฆ Batch Processing
Handle multiple queries efficiently

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+
  • PostgreSQL
  • Your favorite AI service (OpenAI, Anthropic, etc.)

Installation

# 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

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

Run

# Setup database
createdb customer_support_bot

# Start server
python app.py
# ๐Ÿš€ Server running at http://localhost:8000

๐Ÿ“ก API Reference

Core Endpoints

Health Check

GET /mcp/health

Process Single Query

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"
}

Batch Processing

POST /mcp/batch
Content-Type: application/json
X-MCP-Auth: your-token

{
  "queries": [
    "How do I reset my password?",
    "What are your business hours?"
  ]
}
Response Format

Success Response

{
  "status": "success",
  "data": {
    "response": "Generated AI response",
    "confidence": 0.95,
    "processing_time": "120ms"
  },
  "meta": {
    "request_id": "req_123456",
    "timestamp": "2024-02-14T12:00:00Z"
  }
}

Error Response

{
  "code": "RATE_LIMIT_EXCEEDED",
  "message": "Rate limit exceeded",
  "details": {
    "retry_after": 60,
    "timestamp": "2024-02-14T12:00:00Z"
  }
}

๐Ÿ—๏ธ Architecture

Project Structure

๐Ÿ“ฆ 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

Layer Responsibilities

LayerPurposeComponents
APIHTTP endpoints, validationFastAPI routes, Pydantic models
MiddlewareAuth, rate limiting, loggingToken validation, request throttling
ServiceBusiness logic, AI integrationContext management, AI orchestration
DataPersistence, modelsPostgreSQL, SQLAlchemy ORM

๐Ÿ”Œ Extending with AI Services

Add Your AI Provider

  1. Install your AI SDK:
pip install openai  # or anthropic, cohere, etc.
  1. Configure environment:
# Add to .env
AI_SERVICE_API_KEY=sk-your-api-key
AI_SERVICE_MODEL=gpt-4
  1. Implement service integration:
# In service layer
class AIService:
    async def generate_response(self, query: str, context: dict) -> str:
        # Your AI integration here
        return ai_response

๐Ÿ”ง Development

Running Tests

pytest tests/

Code Quality

# Format code
black .

# Lint
flake8

# Type checking
mypy .

Docker Support

# Coming soon - Docker containerization

๐Ÿ“Š Monitoring & Observability

Health Metrics

  • โœ… Service uptime
  • ๐Ÿ”— Database connectivity
  • ๐Ÿ“ˆ Request rates
  • โฑ๏ธ Response times
  • ๐Ÿ’พ Memory usage

Logging

# Structured logging included
{
  "timestamp": "2024-02-14T12:00:00Z",
  "level": "INFO",
  "message": "Query processed",
  "request_id": "req_123456",
  "processing_time": 120
}

๐Ÿ”’ Security

Built-in Security Features

  • ๐Ÿ” Token Authentication - Secure API access
  • ๐Ÿ›ก๏ธ Rate Limiting - DoS protection
  • โœ… Input Validation - SQL injection prevention
  • ๐Ÿ“ Audit Logging - Request tracking
  • ๐Ÿ”’ Environment Secrets - Secure config management

๐Ÿš€ Deployment

Environment Setup

# Production environment variables
DATABASE_URL=postgresql://prod-user:password@prod-host/db
RATE_LIMIT_REQUESTS=1000
LOG_LEVEL=WARNING

Scaling Considerations

  • Use connection pooling for database
  • Implement Redis for rate limiting in multi-instance setups
  • Add load balancer for high availability
  • Monitor with Prometheus/Grafana

๐Ÿค Contributing

We love contributions! Here's how to get started:

Development Setup

# 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

Contribution Guidelines

  • ๐Ÿ“ Write tests for new features
  • ๐Ÿ“š Update documentation
  • ๐ŸŽจ Follow existing code style
  • โœ… Ensure CI passes

MseeP.ai Security Assessment Badge

๐Ÿ“„ License

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


Built with โค๏ธ by Chirag Patankar

โญ Star this repo if you find it helpful! โญ

Report Bug โ€ข Request Feature โ€ข Documentation