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

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

3.1

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
3
Resources
0
Prompts
0

🛡️ 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!