MCP Boilerplate
A minimal, production-ready MCP (Model Context Protocol) server boilerplate with a simple addition calculator tool. Built with TypeScript, Zod validation, and comprehensive error handling.
✨ Features
- Simple Calculator Tool: Addition tool demonstrating MCP integration
- Type Safety: Full TypeScript support with strict type checking
- Input Validation: Zod schemas with security-first validation
- Error Handling: Comprehensive error handling with McpError
- Production Ready: Proper process management and graceful shutdown
- Extensible: Clean architecture for adding more tools
🚀 Quick Start
📋 Requirements
- Node.js 18.x or higher
- npm or yarn package manager
🏗️ Project Structure
🛠️ Available Scripts
npm run build
- Compile TypeScript to JavaScriptnpm run dev
- Watch mode compilationnpm start
- Start the MCP servernpm run lint
- Run ESLintnpm run lint:fix
- Fix linting issuesnpm run format
- Format code with Prettiernpm run clean
- Remove compiled files
🔧 Claude Desktop Integration
- Build the project:
- Add to your Claude Desktop configuration (
claude_desktop_config.json
): - Restart Claude Desktop
- Test the calculator tool:
- "Add 5 and 3"
- "What is 1.5 + 2.7?"
- "Calculate -2 plus 7"
🧪 Testing
The server has been tested with the following scenarios:
✅ Successful Operations
- Basic Addition:
5 + 3 = 8
- Negative Numbers:
-2 + 7 = 5
- Decimal Numbers:
1.5 + 2.7 = 4.2
- Zero Values:
0 + 5 = 5
✅ Error Handling
- Invalid Input: String inputs return validation errors
- Missing Parameters: Missing 'a' or 'b' parameters return required field errors
- Out of Bounds: Numbers outside safe range are rejected
🛡️ Security Features
- Input Validation: Comprehensive Zod schemas prevent malicious input
- Number Safety: Finite number validation prevents NaN/Infinity injection
- Bounds Checking: Reasonable limits prevent DoS attacks
- Error Sanitization: Production errors don't expose internal details
📊 Tool Reference
calculator_add
Adds two numbers together with comprehensive validation.
Parameters:
a
(number): First number to add (-10,000,000,000 to 10,000,000,000)b
(number): Second number to add (-10,000,000,000 to 10,000,000,000)
Returns:
- Success:
{ content: [{ type: 'text', text: 'a + b = result' }] }
- Error: MCP error with validation details
Example:
🔄 Extending the Boilerplate
Adding a New Tool
- Create the schema in
src/schemas/
: - Implement the tool in
src/tools/
: - Register the tool in
src/tools/index.ts
: - Rebuild and test:
🐛 Troubleshooting
Server Won't Start
- Check Node.js version (requires 18.x+)
- Run
npm run build
to compile TypeScript - Check for port conflicts
Tool Not Found
- Verify tool is registered in
src/tools/index.ts
- Rebuild with
npm run build
- Check tool name matches exactly
Validation Errors
- Check input parameter types match schema
- Verify required fields are provided
- Check number bounds (-1e10 to 1e10)
📝 License
MIT License - see LICENSE file for details.
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Built with TypeScript, MCP SDK v1.17.0, and Zod validation
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A minimal, production-ready MCP server with a simple addition calculator tool that demonstrates integration with the Model Context Protocol.
Related MCP Servers
- AsecurityFlicenseAqualityA simple Model Context Protocol server that provides standardized tool functionality, currently implementing a basic calculator for adding two numbers together.Last updated -2628JavaScript
- -securityFlicense-qualityA minimal example server implementing the Model Context Protocol, providing addition and multiplication tools for learning and experimentation with MCP clients.Last updated -Python
- AsecurityFlicenseAqualityA simple and extendable MCP server that currently provides basic addition functionality and can be easily extended by defining new tools with docstrings.Last updated -4Python
- AsecurityFlicenseAqualityA comprehensive learning project providing hands-on experience with Model Context Protocol (MCP) server development, featuring calculator and text utility tools for integration with Claude Desktop.Last updated -1JavaScript