-NodeJS-MCP-Server-with-Tools-and-Resources

niharikakanakala/-NodeJS-MCP-Server-with-Tools-and-Resources

3.2

If you are the rightful owner of -NodeJS-MCP-Server-with-Tools-and-Resources 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.

The Model Context Protocol (MCP) is a standardized protocol for AI applications to interact with external tools and data sources.

Tools
  1. Calculator Tool

    Perform mathematical operations (add, subtract, multiply, divide).

  2. Data Retrieval Tool

    Get specific records by ID and type.

  3. Data Creation Tool

    Create new users, products, and orders.

๐Ÿ›ก๏ธ What is MCP?

The Model Context Protocol is a standardized way for AI applications to interact with external tools and data sources. This server enables:

๐Ÿค– AI Integration: Direct integration with Claude, ChatGPT, and other AI models

๐Ÿ”ง Tool Execution: AI can perform calculations and data operations

๐Ÿ“Š Data Access: AI can query and analyze your data

๐Ÿ”„ Context Preservation: Maintain state across AI interactions

๐ŸŒŸ Features

๐Ÿ› ๏ธ Tools (Executable Functions)

Calculator Tool: Perform mathematical operations (add, subtract, multiply, divide)
Data Retrieval Tool: Get specific records by ID and type
Data Creation Tool: Create new users, products, and orders
Advanced Validation: Input validation for all tool operations

๐Ÿ“ Resources (Data Access)

Users Resource: Access user data collection
Products Resource: Access product catalog
Orders Resource: Access order history
Settings Resource: Server configuration and system settings

๐Ÿ’พ Data Management

  In-Memory Data Store: Fast, efficient data storage using Maps
  CRUD Operations: Complete Create, Read, Update, Delete functionality
  Search Capabilities: Query data across all collections
  Statistics Generation: Real-time data analytics and metrics

๐Ÿ—๏ธ Architecture

MCP Server Components:

๐Ÿญ Factory Pattern โ†’ Server Creation & Configuration
๐Ÿ”ง Tools Handler โ†’ Executable Functions (calculate, get_data, create_data)
๐Ÿ“‚ Resources Handler โ†’ Data Access (users, products, orders, settings)
๐Ÿ’พ Data Service โ†’ CRUD Operations & In-Memory Storage
โœ… Validation Utilities โ†’ Input Validation & Error Handling
๐Ÿงช Test Suite โ†’ Comprehensive Testing Coverage

๐Ÿš€ Quick Start Prerequisites Node.js 16+ npm or yarn

Running the Server

npm start

Run tests

npm test

๐Ÿ“‹ API Endpoints

httpGET  /              # Welcome message
GET  /health        # Server health check
GET  /mcp/info      # MCP server information

Tools Endpoints

httpGET  /tools/list    # List available tools
POST /tools/call    # Execute a tool

Resources Endpoints

httpGET  /resources/list # List available resources
POST /resources/read # Read from a resource

๐Ÿ”’ Security Features

CORS Protection: Configurable cross-origin resource sharing
Helmet Integration: Security headers for enhanced protection
Input Validation: Comprehensive validation for all inputs
Error Handling: Proper error responses without data leakage
Request Size Limits: Protection against large payload attacks

๐Ÿš€ Performance Features

Factory Pattern: Efficient server instance creation
In-Memory Storage: Lightning-fast data operations
Async/Await: Non-blocking operations throughout
Singleton Services: Optimized memory usage
Modular Architecture: Easy to extend and maintain

๐Ÿ“ž Support

๐Ÿ“ง Issues: GitHub Issues

๐Ÿ“– Documentation: https://modelcontextprotocol.io/docs/concepts/architecture

๐Ÿ’ฌ Discussions: GitHub Discussions


โญ If this project helped you, please give it a star on GitHub!