mcp-server-ai-bot

mcp-server-ai-bot

An MCP server integrating Google Gemini LLM for intelligent customer service, providing chat, analytics, and tools for customer data interaction.

Category
Visit Server

README

๐Ÿค– AI Assistant Platform

A Model Context Protocol (MCP) server integrated with Google Gemini LLM for intelligent customer service assistance. This platform provides natural language chat capabilities and AI-powered customer data analysis and summarization.

Python 3.10+ FastAPI License: MIT

๐ŸŒŸ Features

  • ๐Ÿ”ง MCP Tool Integration: Standardized tool interface following Model Context Protocol
  • ๐Ÿค– AI-Powered Chat: Natural language interaction using Google Gemini 1.5 Flash
  • ๐Ÿ“Š Smart Analytics: AI-generated customer insights and summaries
  • ๐Ÿ”’ Secure API: Bearer token authentication for external API calls
  • ๐ŸŒ Professional Web Interface: Modern UI for customer service operations
  • ๐Ÿ“– Auto-Generated Docs: FastAPI automatic API documentation

๐Ÿ“ Project Structure

ai-assistant-platform/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ main.py                 # FastAPI application entry point
โ”‚   โ”œโ”€โ”€ server.py               # MCP server setup
โ”‚   โ”œโ”€โ”€ llm_agent.py            # Gemini LLM integration
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ config.py           # Configuration management
โ”‚   โ”œโ”€โ”€ tools/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ user_tools.py       # MCP tools implementation
โ”‚   โ””โ”€โ”€ static/
โ”‚       โ””โ”€โ”€ index.html          # Web interface
โ”œโ”€โ”€ .env                        # Environment variables (not in git)
โ”œโ”€โ”€ .env.example                # Environment template
โ”œโ”€โ”€ .gitignore                  # Git ignore rules
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ LICENSE                     # MIT License
โ””โ”€โ”€ README.md                   # This file

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10 or higher
  • pip package manager
  • Google Gemini API key (Get one here)
  • External API credentials (for customer data integration)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/ai-assistant-platform.git
    cd ai-assistant-platform
    
  2. Create and activate virtual environment

    Windows:

    python -m venv venv
    venv\Scripts\activate
    

    Linux/Mac:

    python -m venv venv
    source venv/bin/activate
    
  3. Install dependencies

    pip install -r requirements.txt
    
  4. Configure environment variables

    # Copy the example file
    cp .env.example .env
    
    # Edit .env with your actual credentials
    # On Windows: notepad .env
    # On Linux/Mac: nano .env
    

    Required environment variables:

    API_KEY=your_api_key_here
    API_URL=https://your-api-url.com
    GEMINI_API_KEY=your_gemini_api_key_here
    
  5. Run the server

    # Using uvicorn directly
    uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
    
    # OR using Python module
    python -m app.main
    
  6. Access the application

    • ๐Ÿ  Home/Health Check: http://localhost:8000/
    • ๐Ÿ“– API Documentation: http://localhost:8000/docs
    • ๐ŸŒ Web Interface: http://localhost:8000/ui
    • ๐Ÿ”ง List Tools: http://localhost:8000/tools

๐Ÿ“š API Endpoints

Core Endpoints

Method Endpoint Description
GET / Health check
GET /ui Web interface
GET /tools List available MCP tools
GET /config View current configuration
GET /docs Interactive API documentation

MCP Tool Endpoints

Method Endpoint Description
POST /test/get_user_details Test MCP tool with file number

Request Body:

{
  "file_number": "ABC123"
}

LLM Endpoints

Chat with LLM

POST /llm/chat

Natural language chat with optional customer context.

Request Body:

{
  "message": "What's my current balance?",
  "file_number": "ABC123"  // Optional
}

Response:

{
  "success": true,
  "response": "Based on your account, your current balance is $1,500.00..."
}

AI Summary

POST /llm/summarize

Generate AI-powered summary of customer account.

Request Body:

{
  "file_number": "ABC123"
}

Response:

{
  "success": true,
  "summary": "Account Summary for John Doe:\n\nCurrent Balance: $1,500.00..."
}

๐Ÿ”ง Configuration

All configuration is managed through environment variables in the .env file:

# API Configuration
API_KEY=your_api_key_here
API_URL=https://api.example.com
API_TIMEOUT=30

# LLM Configuration
GEMINI_API_KEY=your_gemini_key_here

# Server Configuration
SERVER_HOST=0.0.0.0
SERVER_PORT=8000
DEBUG=false

# MCP Configuration
MCP_SERVER_NAME=company-mcp-server
MCP_SERVER_VERSION=1.0.0

๐Ÿ—๏ธ Architecture

Data Flow

User Request โ†’ FastAPI โ†’ LLM Agent โ†’ MCP Tools โ†’ External API
                           โ†“
                    Gemini AI Processing
                           โ†“
                    AI-Enhanced Response

Components

  1. FastAPI Server (main.py): Handles HTTP requests and routing
  2. LLM Agent (llm_agent.py): Manages Gemini AI interactions
  3. MCP Server (server.py): Implements Model Context Protocol
  4. User Tools (user_tools.py): External API integration
  5. Configuration (config.py): Environment management

๐Ÿ’ก Usage Examples

Example 1: Get Customer Details

import requests

response = requests.post(
    "http://localhost:8000/test/get_user_details",
    json={"file_number": "CUST123"}
)
print(response.json())

Example 2: Chat with Context

import requests

response = requests.post(
    "http://localhost:8000/llm/chat",
    json={
        "message": "What payment options are available?",
        "file_number": "CUST123"
    }
)
print(response.json()["response"])

Example 3: Get AI Summary

import requests

response = requests.post(
    "http://localhost:8000/llm/summarize",
    json={"file_number": "CUST123"}
)
print(response.json()["summary"])

๐Ÿ”Œ MCP Client Integration

To use this server with an MCP client (like Claude Desktop):

{
  "mcpServers": {
    "company-mcp-server": {
      "command": "python",
      "args": [
        "/path/to/mcp-llm-server/app/main.py"
      ],
      "env": {
        "API_KEY": "your_api_key_here",
        "GEMINI_API_KEY": "your_gemini_key_here",
        "API_URL": "https://api.example.com"
      }
    }
  }
}

๐Ÿงช Testing

Using the Web Interface

  1. Open http://localhost:8000/ui
  2. Enter a file number (default: 14226904)
  3. Test different features:
    • MCP Tool Testing
    • LLM Chat
    • AI Summary

Using curl

# Test health check
curl http://localhost:8000/

# Test MCP tool
curl -X POST http://localhost:8000/test/get_user_details \
  -H "Content-Type: application/json" \
  -d '{"file_number": "14226904"}'

# Test LLM chat
curl -X POST http://localhost:8000/llm/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "What is the current balance?", "file_number": "14226904"}'

๐Ÿ› ๏ธ Development

Adding New MCP Tools

  1. Define the tool in app/tools/user_tools.py:

    async def new_tool(self, param: str) -> Dict[str, Any]:
        """Your tool implementation"""
        pass
    
  2. Register in app/server.py:

    @mcp_server.list_tools()
    async def list_tools() -> list[Tool]:
        return [
            Tool(name="new_tool", description="...", inputSchema={...})
        ]
    
  3. Add handler in app/server.py:

    @mcp_server.call_tool()
    async def call_tool(name: str, arguments: dict):
        if name == "new_tool":
            result = await user_tools.new_tool(arguments["param"])
    

Running in Development Mode

# Enable debug mode in .env
DEBUG=true

# Run with auto-reload
uvicorn app.main:app --reload --log-level debug

๐Ÿ“ฆ Dependencies

  • FastAPI: Modern web framework for building APIs
  • uvicorn: ASGI server for FastAPI
  • google-generativeai: Google Gemini AI SDK
  • httpx: Async HTTP client for external APIs
  • python-dotenv: Environment variable management
  • mcp: Model Context Protocol SDK

See requirements.txt for complete list with versions.

๐Ÿ”’ Security Best Practices

  1. Never commit .env file - Already in .gitignore
  2. Use environment variables for all secrets
  3. Rotate API keys regularly
  4. Use HTTPS in production
  5. Implement rate limiting for production use
  6. Validate all inputs before processing
  7. Log security events for monitoring

๐Ÿ“„ License

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

๐Ÿค Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ› Troubleshooting

Common Issues

Problem: Could not import module "main"

  • Solution: Use uvicorn app.main:app instead of uvicorn main:app

Problem: Server not accessible at http://0.0.0.0:8000

  • Solution: Use http://localhost:8000 or http://127.0.0.1:8000 in browser

Problem: API_KEY must be set in environment variables

  • Solution: Create .env file from .env.example and fill in your keys

Problem: Gemini API errors

  • Solution: Verify your GEMINI_API_KEY is valid and has sufficient quota

๐Ÿ“ž Support

For issues, questions, or contributions:

  • ๐Ÿ› Report bugs via GitHub Issues
  • ๐Ÿ’ฌ Discussions via GitHub Discussions
  • ๐Ÿ“ง Email: your.email@example.com

๐Ÿ™ Acknowledgments


Made with โค๏ธ for intelligent debt collection assistance

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured