Statistics MCP Server

Statistics MCP Server

A Model Context Protocol (MCP) server that provides statistical analysis tools for sales and salary data.

Category
Visit Server

README

<p align="center"> <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a> </p>

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p> <p align="center"> <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a> <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a> <a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a> <a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a> <a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a> <a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a> <a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a> <a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a> <a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a> <a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a> </p> <!--Backers on Open Collective Sponsors on Open Collective-->

Statistics MCP Server

A Model Context Protocol (MCP) server that provides statistical analysis tools for sales and salary data. This server exposes business intelligence functions that can be used by AI assistants and other MCP-compatible clients.

๐Ÿš€ Features

  • Sales Analytics: Calculate total sales, find popular products, and analyze order patterns
  • Product Intelligence: Identify most ordered products and highest value orders
  • Salary Statistics: Compute salary metrics including averages, min/max values
  • MCP Compatible: Works with Claude Desktop and other MCP clients
  • TypeScript: Full type safety and modern development experience
  • NestJS Framework: Built with enterprise-grade Node.js framework

๐Ÿ“Š Available Tools

Tool Name Description Parameters
get_total_sales Calculate total sales amount from all orders None
get_popular_product Get the most frequently ordered product None
get_most_ordered_product Get product with highest total quantity None
get_highest_order_amount Get order with the highest total amount None
get_salary_statistics Get salary analytics (average, min, max) None

๐Ÿ—๏ธ Project Structure

mcp-server/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ statistics/
โ”‚   โ”‚   โ”œโ”€โ”€ statistics.service.ts    # Business logic and data operations
โ”‚   โ”‚   โ”œโ”€โ”€ statistics.controller.ts # REST API endpoints (NestJS)
โ”‚   โ”‚   โ”œโ”€โ”€ statistics.module.ts     # NestJS module configuration
โ”‚   โ”‚   โ””โ”€โ”€ statistics.types.ts      # TypeScript interfaces
โ”‚   โ”œโ”€โ”€ mcp/
โ”‚   โ”‚   โ””โ”€โ”€ mcp-server.ts           # MCP server implementation
โ”‚   โ”œโ”€โ”€ mcp-main.ts                 # MCP server entry point
โ”‚   โ”œโ”€โ”€ main.ts                     # NestJS application entry point
โ”‚   โ””โ”€โ”€ app.*                       # NestJS app configuration
โ”œโ”€โ”€ test/                           # E2E tests
โ”œโ”€โ”€ dist/                          # Compiled JavaScript output
โ”œโ”€โ”€ mcp-config.json                # MCP client configuration
โ”œโ”€โ”€ package.json                   # Dependencies and scripts
โ””โ”€โ”€ README.md                      # This file

๐Ÿ› ๏ธ Technology Stack

  • Runtime: Node.js
  • Language: TypeScript
  • Framework: NestJS
  • Protocol: Model Context Protocol (MCP)
  • Testing: Jest
  • Linting: ESLint

๐Ÿ“‹ Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn package manager

โšก Quick Start

1. Install Dependencies

npm install

2. Build the Project

npm run build

3. Start MCP Server

npm run start:mcp
# or directly:
node dist/mcp-main.js

4. Start NestJS Server (Alternative)

npm run start
# Development mode:
npm run start:dev

๐Ÿ”ง Configuration

MCP Client Configuration

Add this configuration to your MCP client (e.g., Claude Desktop):

{
  "mcpServers": {
    "statistics-server": {
      "command": "node",
      "args": ["/home/mamun/official/mcp-server/dist/mcp-main.js"],
      "env": {}
    }
  }
}

For Claude Desktop

Add to ~/.config/claude-desktop/claude_desktop_config.json (Linux):

{
  "mcpServers": {
    "statistics-server": {
      "command": "node",
      "args": ["/home/mamun/official/mcp-server/dist/mcp-main.js"],
      "env": {}
    }
  }
}

๐Ÿงช Testing

Run Unit Tests

npm run test

Run E2E Tests

npm run test:e2e

Test with MCP Inspector

npx @modelcontextprotocol/inspector dist/mcp-main.js

๐Ÿ“ก API Endpoints (NestJS)

The server also provides REST API endpoints:

Method Endpoint Description
GET /statistics/total-sales Get total sales amount
GET /statistics/popular-product Get most popular product
GET /statistics/most-ordered-product Get most ordered product
GET /statistics/highest-order-amount Get highest order amount
GET /statistics/salary-statistics Get salary statistics

Example API Usage

# Start the NestJS server
npm run start

# Make API requests
curl http://localhost:3000/statistics/total-sales
curl http://localhost:3000/statistics/popular-product

๐Ÿ”„ MCP Protocol Flow

1. AI Client connects to MCP server
2. Client requests available tools
3. Server responds with tool definitions
4. Client calls a specific tool (e.g., "get_total_sales")
5. Server executes the corresponding service method
6. Server returns structured result
7. AI uses the result in its response to user

๐Ÿ“Š Sample Data

The server includes sample data for demonstration:

Products

  • Laptop ($999.99)
  • Mouse ($24.99)
  • Keyboard ($79.99)
  • Monitor ($299.99)
  • Headphones ($149.99)

Orders

  • Multiple orders with different products and quantities
  • Total sales calculation across all orders

Salaries

  • Sample employee salary data for statistical analysis

๐Ÿš€ Development

Development Mode

npm run start:dev

Build for Production

npm run build
npm run start:prod

Linting

npm run lint
npm run lint:fix

๐Ÿ”ง Available Scripts

Script Description
npm run build Compile TypeScript to JavaScript
npm run start Start the NestJS application
npm run start:dev Start in development mode with hot reload
npm run start:debug Start in debug mode
npm run start:prod Start in production mode
npm run start:mcp Start the MCP server
npm run lint Run ESLint
npm run test Run unit tests
npm run test:watch Run tests in watch mode
npm run test:e2e Run end-to-end tests

๐Ÿ† Best Practices Implemented

  1. Separation of Concerns: Business logic in services, MCP logic in dedicated server
  2. Type Safety: Full TypeScript implementation with proper interfaces
  3. Error Handling: Comprehensive error handling in MCP tools
  4. Validation: Input validation for all operations
  5. Documentation: Clear documentation and examples
  6. Testing: Unit and E2E test setup
  7. Code Quality: ESLint configuration for consistent code style

๐Ÿค Contributing

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

๐Ÿ“ License

This project is licensed under the MIT License.

๐Ÿ“ž Support

For questions and support:

๐ŸŽฏ What You've Learned

By studying this project, you now understand:

  • โœ… MCP Basics: What MCP is and how it works
  • โœ… Server Architecture: How to structure an MCP server project
  • โœ… Tool Implementation: How to expose business logic as MCP tools
  • โœ… Client Integration: How AI clients connect and use your tools
  • โœ… TypeScript Development: Modern TypeScript with NestJS
  • โœ… Testing: How to test MCP servers
  • โœ… Deployment: How to build and deploy MCP servers

๐Ÿš€ Next Steps

  1. Add Authentication: Implement security for your MCP server
  2. Database Integration: Connect to real databases instead of sample data
  3. More Tools: Add additional statistical analysis tools
  4. Resources: Implement MCP resources for file/data access
  5. Prompts: Add MCP prompts for AI interaction templates
  6. Production Deployment: Deploy to cloud platforms
  7. Monitoring: Add logging and monitoring capabilities

Happy coding! ๐ŸŽ‰

This MCP server demonstrates a complete implementation from zero to hero. Use it as a foundation for building your own MCP servers!

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