MCP Boilerplate
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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
Related MCP server: MCP Server Deployment Demo
π Quick Start
# Clone and install
git clone <your-repo-url>
cd mcp-boilerplate
npm install
# Build and run
npm run build
npm startπ Requirements
Node.js 18.x or higher
npm or yarn package manager
ποΈ Project Structure
mcp-boilerplate/
βββ src/
β βββ index.ts # Server entry point
β βββ server.ts # MCP server setup
β βββ tools/ # Tool implementations
β β βββ index.ts # Tool registry
β β βββ calculator.ts # Addition tool
β βββ schemas/ # Zod validation schemas
β β βββ index.ts # Schema exports
β β βββ calculator.ts # Calculator schemas
β βββ types/ # TypeScript definitions
β β βββ index.ts # Type exports
β β βββ tools.ts # Tool interfaces
β βββ utils/ # Utility functions
β βββ index.ts # Utility exports
β βββ errors.ts # Error handling
β βββ validation.ts # Validation helpers
βββ dist/ # Compiled JavaScript (generated)
βββ docs/ # Documentation and research
βββ package.json # Dependencies and scriptsπ οΈ 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:
npm run buildAdd to your Claude Desktop configuration (
claude_desktop_config.json):{ "mcpServers": { "mcp-boilerplate": { "command": "node", "args": ["/absolute/path/to/mcp-boilerplate/dist/index.js"], "env": { "NODE_ENV": "production" } } } }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 = 8Negative Numbers:
-2 + 7 = 5Decimal Numbers:
1.5 + 2.7 = 4.2Zero 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:
{
"name": "calculator_add",
"arguments": { "a": 5, "b": 3 }
}π Extending the Boilerplate
Adding a New Tool
Create the schema in
src/schemas/:export const MyToolSchema = z.object({ param1: z.string().min(1), }).strict(); export type MyToolInput = z.infer<typeof MyToolSchema>;Implement the tool in
src/tools/:export const myTool: ToolDefinition<MyToolInput> = { name: 'my_tool', description: 'Description of what the tool does', inputSchema: MyToolSchema, execute: async (params) => { // Tool implementation return { content: [{ type: 'text', text: 'Result' }] }; }, };Register the tool in
src/tools/index.ts:export const tools = { calculator_add: calculatorTool, my_tool: myTool, // Add your tool here } as const;Rebuild and test:
npm run build npm start
π Troubleshooting
Server Won't Start
Check Node.js version (requires 18.x+)
Run
npm run buildto compile TypeScriptCheck for port conflicts
Tool Not Found
Verify tool is registered in
src/tools/index.tsRebuild with
npm run buildCheck 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
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Related MCP Connectors
MCP server for progressive tool usage at any scale (see https://klavis.ai)
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yoβ¦
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceA minimal example server implementing the Model Context Protocol, providing addition and multiplication tools for learning and experimentation with MCP clients.1-
- FlicenseCqualityDmaintenanceA demonstration MCP server that provides a simple addition tool for learning how to create and deploy servers following the Model-Context-Protocol specification. Serves as a basic example for developers getting started with MCP server development.1-
- AlicenseNot gradedqualityNot gradedmaintenanceA demonstration MCP server that provides calculator tools for arithmetic operations, personalized greeting resources, and code review prompt templates. Enables users to perform basic math calculations, generate dynamic greetings, and access reusable code review templates through the Model Context Protocol.MIT
- FlicenseBqualityDmaintenanceA demonstration MCP server providing basic tools for returning greetings and performing mathematical addition. It serves as a practical workshop guide for setting up and configuring Model Context Protocol servers from scratch using Python.24-