Get the FREE Ultimate OpenClaw Setup Guide →

fastify -boilerplate

Production-ready MCP server boilerplate with Fastify, TypeScript, Docker, and modern tooling. Clone, customize, and deploy AI tools for Cursor IDE, Claude Desktop, and other MCP clients.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio jarodtaylor-fastify-mcp-server-boilerplate node dist/index.js \
  --env NODE_ENV="production"

How to use

This MCP server boilerplate provides a production-ready Fastify-based MCP server implemented with TypeScript. It leverages fastify-mcp for protocol handling, Biome for linting/formatting, tsup for fast bundling, and Docker for containerized deployments. The server exposes an MCP endpoint (default path /mcp) along with health metrics and request tracing, enabling robust session management and transport handling. Use the pre-configured scripts to develop, build, lint, format, and deploy, and customize tools and resources within src/mcp-server.ts as your MCP capabilities grow. You can test connectivity with an MCP client by pointing it at http://localhost:8080/mcp and validating health with http://localhost:8080/health. When integrating with clients like Cursor IDE or Claude, configure the MCP server entry (e.g., node dist/index.js) and environmental context to ensure proper startup and discovery of MCP capabilities.

How to install

Prerequisites:

  • Node.js (LTS) and npm/yarn installed
  • Git installed
  1. Clone the boilerplate repository
git clone https://github.com/your-username/fastify-mcp-server-boilerplate.git my-mcp-server
cd my-mcp-server
  1. Install dependencies
npm install
  1. Copy environment configuration
cp env.example .env
  1. Start development server with hot reload (dev script)
npm run dev
  1. Build for production (optional)
npm run build
  1. Run the built application
npm run start

Environment variables and configuration can be adjusted in the .env file or via a custom config file referenced in src/config.ts.

Additional notes

Tips and considerations:

  • The MCP endpoint defaults to /mcp; adjust MCP_ENDPOINT in environment variables if needed.
  • The health endpoint is available at /health and includes basic system metrics.
  • Environment-based configuration supports development and production modes; ensure NODE_ENV is set accordingly.
  • Docker deployment is supported with multi-stage builds and docker-compose configurations; use docker-compose up -d for production-like setups.
  • If you customize tools/resources in src/mcp-server.ts, follow the provided patterns to add new tools, resources, and handlers.
  • For development speed, Biome handles linting/formatting and can be customized via biome.json. Run npm run check to perform a full lint/format validation.
  • When deploying to production, ensure non-root container usage and proper port mappings (default 8080) are configured in your deployment environment.

Related MCP Servers

Sponsor this space

Reach thousands of developers