π A CLI tool to quickly generate new MCP (Model Context Protocol) servers using NestJS.
Create a new MCP server in seconds:
# Using npx (recommended)
npx create-mcp-server my-awesome-server
# Or install globally
npm install -g create-mcp-server
create-mcp-server my-awesome-serverThe CLI provides an interactive setup process:
npx create-mcp-server
π Welcome to MCP Server Generator!
This tool will help you create a new MCP server with NestJS.
π Project name (e.g., my-mcp-server): my-awesome-server
π·οΈ MCP Server display name (my-awesome-server): My Awesome Server
π Server description (optional): A powerful MCP server for awesome tasks
π€ Author name (optional): Your Name
ποΈ Creating MCP server: my-awesome-server
β
MCP server created successfully!Every generated MCP server includes:
- NestJS Framework: Modern TypeScript framework with dependency injection
- MCP Integration: Built-in support for Model Context Protocol via
@rekog/mcp-nest - Dual Transport: Both SSE (Server-Sent Events) and STDIN transports
- TypeScript: Full TypeScript support with strict typing
- Hot Reload: Development mode with watch support
- Testing Suite: Unit tests, E2E tests, and MCP-specific tests
- Code Quality: ESLint, Prettier, and TypeScript checking
- Docker Support: Complete containerization setup
- Health Checks: Built-in health monitoring endpoints
- Security: Helmet, rate limiting, and input validation
- Error Handling: Global exception filters and logging
- Configuration: Environment-based configuration management
my-awesome-server/
βββ src/
β βββ app.module.ts # Root module with MCP configuration
β βββ main.ts # HTTP/SSE entry point
β βββ mcp-stdin.ts # STDIN entry point
β βββ tools/ # MCP tools implementation
β β βββ greeting.tool.ts # Example greeting tool
β β βββ tools.module.ts # Tools module
β βββ common/ # Shared utilities
β β βββ dto/ # Data transfer objects
β β βββ filters/ # Exception filters
β β βββ guards/ # Route guards
β β βββ interceptors/ # Request/response interceptors
β β βββ middleware/ # Custom middleware
β β βββ pipes/ # Validation pipes
β β βββ types/ # TypeScript types
β βββ config/ # Configuration management
β βββ health/ # Health check endpoints
βββ test/ # Comprehensive test suite
βββ Dockerfile # Docker configuration
βββ CLAUDE.md # AI assistant guidance
βββ README.md # Project documentation
npx create-mcp-server weather-servernpx create-mcp-server
# Follow the interactive promptsnpx create-mcp-server my-server
# Then provide additional details interactivelyOnce your MCP server is created:
cd my-awesome-server
# Install dependencies
pnpm install
# Start development
pnpm run start:dev
# Test MCP functionality
pnpm run dev:mcp
# Run tests
pnpm run test:e2e{
"mcpServers": {
"my-awesome-server": {
"command": "node",
"args": ["/path/to/my-awesome-server/dist/mcp-stdin.js"],
"env": {}
}
}
}{
"mcpServers": {
"my-awesome-server": {
"url": "http://localhost:3352/mcp"
}
}
}Each generated project includes these scripts:
# Development
pnpm run start:dev # Start with hot reload
pnpm run start:debug # Start with debugging
# Building
pnpm run build # Build the project
pnpm run start:prod # Run production build
# Testing
pnpm run test # Unit tests
pnpm run test:e2e # End-to-end tests
pnpm run test:cov # Coverage report
# Code Quality
pnpm run lint # ESLint with auto-fix
pnpm run format # Prettier formatting
pnpm run typecheck # TypeScript checking
# MCP Specific
pnpm run start:mcp # Start MCP server via STDIN
pnpm run dev:mcp # Build and start MCP server
# Docker
pnpm run docker:build # Build Docker image
pnpm run docker:run # Run in Docker- Node.js: 18 or higher
- Package Manager: pnpm (recommended), npm, or yarn
- OS: macOS, Linux, or Windows
- Example greeting tool with progress reporting
- Easy-to-extend tool system
- Automatic tool registration
- Resource management system
- Example user information resources
- Type-safe resource definitions
- Unit test examples
- E2E test suite
- MCP-specific test utilities
- Performance and stress tests
- Multi-stage Dockerfile
- Development and production configurations
- Docker Compose support
- Comprehensive README
- CLAUDE.md for AI assistant guidance
- Inline code documentation
- Architecture diagrams
We welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/your-username/create-mcp-server.git
cd create-mcp-server
pnpm install
# Test the CLI locally
node bin/create-mcp-server.js test-projectTemplate directory not found
# Reinstall the package
npm uninstall -g create-mcp-server
npm install -g create-mcp-serverPermission errors
# Use npx instead of global installation
npx create-mcp-server my-projectProject already exists
# Choose a different name or remove the existing directory
rm -rf existing-project
npx create-mcp-server new-project-nameMIT Β© [Your Name]