Skip to main content
Glama
MamunCrafts

Statistics MCP Server

by MamunCrafts

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

Related MCP server: MCP Data Wrangler

๐Ÿ“Š 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!

A
license - permissive license
-
quality - not tested
D
maintenance

Maintenance

โ€“Maintainers
โ€“Response time
โ€“Release cycle
โ€“Releases (12mo)
Commit activity

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/MamunCrafts/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server