home / mcp / mcp boilerplate server
A powerful, production-ready MCP server implementing the Model Context Protocol with robust SSE transport, built-in tools, and comprehensive error handling. Seamlessly connect AI models to data sources with enterprise-grade stability and performance.
Configuration
View docs{
"mcpServers": {
"iamsrikanthnani-mcp-boilerplate": {
"url": "http://localhost:4005/sse?API_KEY={{your_api_key_here}}",
"headers": {
"PORT": "4005",
"API_KEY": "YOUR_API_KEY"
}
}
}
}You deploy and run a Model Context Protocol (MCP) server that exposes a standard SSE-based transport for connecting AI models to data sources and tools. This boilerplate provides authentication, logging, session management, and graceful shutdown, so you can quickly build and extend MCP servers for a variety of clients and use cases.
Connect your MCP client to the server using the SSE endpoint. You authenticate by passing your API key in the connection URL or via the configured transport. The server maintains sessions for multiple clients, streams keepalive messages to prevent timeouts, and provides a structured way to call tools you define on the server.
Prerequisites: you need Node.js and npm installed on your machine.
Clone or obtain the project files for the MCP boilerplate, then install dependencies and start the server.
npm installCreate a .env file with the following variables:
PORT=4005
API_KEY=your_api_keynpm run buildnpm run start:sseThis server uses a centralized configuration with API key protection and keeps logs at configurable levels. You can customize tool definitions and add your own tools to extend MCP capabilities.
Key runtime settings influence transport behavior and tool execution retries. You can adjust keepalive intervals, retry logic, and log levels to suit your environment.
The server includes an example tool named calculator that performs basic arithmetic operations.
// Example tool definition (conceptual)
{
name: "calculator",
description: "Performs add, subtract, multiply, divide",
inputSchema: { type: "object", properties: {}, required: [] },
handler: async () => {
// implementation
},
}If you encounter body timeout errors, try increasing stability by adjusting keepalive and ping settings, and ensure proxies do not terminate long-held connections.
You can extend the boilerplate by adding custom tools and wiring them into the tool registry. Follow the example structure to create handlers, define input schemas, and register new tools.
Environment variables that you may configure include PORT and API_KEY as shown in the development setup. You can add additional environment variables for your deployment as needed.
Performs basic arithmetic operations (add, subtract, multiply, divide)