mcp-boilerplate
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.
claude mcp add --transport stdio iamsrikanthnani-mcp-boilerplate node dist/server.js \ --env HOST="localhost" \ --env PORT="4005" \ --env API_KEY="your_api_key"
How to use
This MCP server boilerplate implements the Model Context Protocol (MCP) over SSE (Server-Sent Events) and ships with a ready-to-extend structure. It includes an example tool called calculator that can perform basic arithmetic operations (add, subtract, multiply, divide). Clients connect via the /sse endpoint using an API key for authentication and can then invoke tools or receive streamed updates through MCP-compatible transports. The server supports session management, configurable keepalive/ping behavior, and structured logging. To get started, configure your environment variables (PORT, HOST, and API_KEY) and run the server. Once running, clients can connect to /sse, authenticate with the API key, and start sending tool requests or subscribe to tool events as per the MCP protocol. The README’s extension guide also shows how to add your own tools by editing the tool configurations and handlers in src/tools.*.
How to install
Prerequisites:
- Node.js and npm installed
- A TypeScript project setup (the boilerplate ships with tsconfig and src/ folders)
Setup steps:
- Install dependencies
npm install
- Create a .env file (optional but recommended) with API_KEY, PORT, and HOST values:
PORT=4005
API_KEY=your_api_key
HOST=localhost
- Build the project (transpile TypeScript to JavaScript)
npm run build
- Start the server (SSE mode as per the README examples)
npm run start:sse
Notes:
- You can customize the port and host by editing the environment variables or the config if needed.
- The server exposes endpoints such as /health, /sse, and /messages; ensure your client uses the /sse endpoint with the API_KEY parameter.
Additional notes
Tips and considerations:
- Ensure API_KEY is kept secure; it is required for all connections.
- If you encounter Body timeout errors, adjust keepaliveInterval and enable usePingEvents as described in the Troubleshooting SSE Timeouts section.
- When adding custom tools, follow the example in Extending the boilerplate by updating src/tools.ts, adding a ToolConfig with name, description, inputSchema, and handler.
- For production deployment, consider using a process manager (PM2) and/or Docker as described in your deployment workflow.
- The server supports graceful shutdown on SIGINT and SIGTERM; ensure your deployment environment forwards these signals correctly.
Related MCP Servers
flyto-core
The open-source execution engine for AI agents. 412 modules, MCP-native, triggers, queue, versioning, metering.
Pare
Dev tools, optimized for agents. Structured, token-efficient MCP servers for git, test runners, npm, Docker, and more.
awesome s
A curated list of excellent Model Context Protocol (MCP) servers.
mcp-chain-of-draft
Chain of Draft Server is a powerful AI-driven tool that helps developers make better decisions through systematic, iterative refinement of thoughts and designs. It integrates seamlessly with popular AI agents and provides a structured approach to reasoning, API design, architecture decisions, code reviews, and implementation planning.
mcp-gearbox-cli
💫 MCP CLI to help you get started with MCP servers faster
mcp-tidy
CLI tool to visualize and manage MCP server configurations in Claude Code. List servers, analyze usage statistics, and clean up unused servers