niharikakanakala/-NodeJS-MCP-Server-with-Tools-and-Resources
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.
๐ก๏ธ 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!