mcp-server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-serverShow me recent customers from Canada"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Server - Customer & Order Analytics
A Model Context Protocol (MCP) server implementation that provides AI-powered tools for querying customer and order data. This FastAPI-based server enables LLM clients to access structured business data through three specialized tools for customer analytics and order management.
๐ Overview
This MCP server acts as a bridge between AI language models and business data, allowing LLMs to:
Count customer orders by month
Retrieve recent customers by country
Calculate customer lifetime value and spending patterns
The server follows the Model Context Protocol specification, making it compatible with various AI clients and frameworks that support MCP integration.
โจ Features
Core MCP Tools
Order Count by Customer & Month - Track customer ordering patterns over time
Recent Customers by Country - Discover new customers in specific markets
Customer Total Spend - Analyze customer lifetime value and spending behavior
Technical Features
FastAPI Framework - High-performance async API with automatic documentation
Pydantic Validation - Type-safe data models with automatic validation
JSON Data Backend - Simple file-based storage for customers and orders
Comprehensive Logging - Full request/response logging for debugging
Health Monitoring - Built-in health check endpoints
CORS Support - Cross-origin requests enabled for web clients
๐๏ธ Architecture
mcp-server/
โโโ main.py # FastAPI application entry point
โโโ requirements.txt # Python dependencies
โโโ data/ # JSON data files
โ โโโ customers.json # Customer records
โ โโโ orders.json # Order transactions
โโโ src/ # Source code
โ โโโ models/ # Data models and schemas
โ โ โโโ schemas.py # Pydantic models for validation
โ โ โโโ data_loader.py # Data loading utilities
โ โโโ tools/ # MCP tools implementation
โ โโโ mcp_tools.py # Tool implementations
โโโ tests/ # Test suite
โโโ llm_client/ # Example LLM client implementation
โโโ docs/ # Documentation๐ ๏ธ Available Tools
1. get_order_count_by_customer_and_month
Count orders for a specific customer in a given calendar month.
Input:
{
"customerName": "John Doe",
"isoMonth": "2025-03"
}Output:
{
"count": 2
}2. list_recent_customers_by_country
Fetch the newest N customers from a specific country.
Input:
{
"country": "USA",
"limit": 5
}Output:
{
"customers": [
{
"id": 1,
"name": "John Doe",
"country": "USA",
"joinedAt": "2025-01-15T10:30:00Z",
"totalSpend": 1250.50,
"orderCount": 3
}
]
}3. get_customer_total_spend
Calculate total spending and order statistics for a customer.
Input:
{
"customerName": "John Doe"
}Output:
{
"customerName": "John Doe",
"totalSpend": 1250.50,
"orderCount": 3,
"averageOrderValue": 416.83
}๐ฆ Quick Start
Prerequisites
Python 3.9+
pip or poetry for dependency management
Installation
Clone the repository:
git clone <repository-url>
cd mcp-serverInstall dependencies:
pip install -r requirements.txtStart the server:
python main.pyThe server will start on http://localhost:8000
Production Deployment
uvicorn main:app --host 0.0.0.0 --port 8000๐ก API Endpoints
Health Check
GET
/- Basic health checkGET
/health- Detailed health status
MCP Protocol Endpoints
GET
/tools/list- List available MCP toolsPOST
/tools/call- Execute a specific tool
Example Usage
List available tools:
curl http://localhost:8000/tools/listCall a tool:
curl -X POST http://localhost:8000/tools/call \
-H "Content-Type: application/json" \
-d '{
"name": "get_order_count_by_customer_and_month",
"arguments": {
"customerName": "John Doe",
"isoMonth": "2025-03"
}
}'๐งช Testing
Run the test suite:
pytest tests/Run with coverage:
pytest tests/ --cov=src --cov-report=html๐ง Configuration
Environment Variables
HOST- Server host (default: 0.0.0.0)PORT- Server port (default: 8000)LOG_LEVEL- Logging level (default: INFO)
Data Files
The server reads from JSON files in the data/ directory:
customers.json- Customer records with id, name, country, joinedAtorders.json- Order records with id, customerId, customerName, date, amount
๐ค Integration
LLM Client Example
This repository includes an example LLM client (llm_client/) that demonstrates how to integrate with the MCP server using Mistral AI. The client:
Connects to the MCP server
Uses Mistral AI for natural language processing
Automatically calls appropriate MCP tools based on user questions
Returns AI-generated answers with real data
Using with Other AI Frameworks
The server is compatible with any system that supports the Model Context Protocol, including:
Claude Desktop
Custom AI applications
Other MCP-compatible frameworks
๐ Documentation
Setup Guide - Detailed setup and usage instructions
Architecture - Technical architecture and design decisions
API Documentation - Interactive API docs (when server is running)
๐ก๏ธ Error Handling
The server provides comprehensive error handling:
400 Bad Request - Invalid input parameters
404 Not Found - Unknown tool names
500 Internal Server Error - Server-side errors
All errors follow the MCP protocol format with detailed error messages.
๐ Development
Adding New Tools
Define the tool schema in
src/tools/mcp_tools.pyImplement the tool logic
Add input validation using Pydantic models
Update the tool definitions list
Add comprehensive tests
Code Style
Follow PEP 8 guidelines
Use type hints throughout
Add docstrings for all public methods
Maintain test coverage above 80%
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/JoaoToledoSE/mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server