A modern CLI tool for generating and extending production-ready Model Context Protocol (MCP) servers. Built with clean architecture and advanced MCP features, this tool creates servers that demonstrate all MCP capabilities through one cohesive example instead of scattered demos. Now with powerful component extension capabilities!
π¦ Available on npm:
mcp-server-generator
- 442kB of production-ready MCP server templates
π Complete Documentation: mcp-server-generator.com
See the MCP Server Generator in action! Watch how easy it is to create a production-ready MCP server:
Watch the complete workflow from project generation to testing with MCP Inspector
π Detailed guides and tutorials: mcp-server-generator.com
- Video Showcase
- Overview
- Quick Start
- Extending Existing Projects
- Features
- CLI Commands
- Generated Project Structure
- Usage Examples
- Development Scripts
- Development
- Architecture
- Contributing
- License
π For comprehensive documentation, examples, and guides, visit mcp-server-generator.com
- π― Unified Example: One comprehensive Data Analysis Assistant showcasing ALL MCP features
- ποΈ Clean Architecture: Modular design with proper separation of concerns
- π§ Advanced MCP Features: Elicitation, sampling, multiple analysis methodologies
- π MCP Inspector Integration: Built-in testing with visual and CLI modes
- π Production Ready: Comprehensive error handling, validation, and documentation
- π Educational: Learn MCP best practices through real-world implementation
- β Extensible: Add new components to existing projects with intelligent automation
Unlike other MCP generators that create scattered demo examples, this tool provides:
- π― One Unified Example: Data Analysis Assistant showcasing ALL MCP features
- ποΈ Clean Architecture: Maintainable, extensible, production-ready code
- π Educational Value: Learn MCP best practices through real implementation
- π§ͺ Integrated Testing: MCP Inspector ready-to-use with pre-configured scripts
- π Developer Experience: Convenient scripts, help system, instant feedback
- β Component Extension: Add tools, resources, prompts, services, transports, and utils to existing projects
Perfect for learning MCP development, building production servers, or as a foundation for custom implementations. Start with our comprehensive example, then extend with your own components!
π Complete Documentation: mcp-server-generator.com
π Quick Start Guide: Installation & Setup
π‘ Examples & Tutorials: Component Examples
# One-time usage (recommended)
npx mcp-server-generator my-project
# Global installation
npm install -g mcp-server-generator
mcp-server-generator my-project
# Create a comprehensive MCP server with Data Analysis Assistant
npx mcp-server-generator my-analysis-server
# Or specify custom options
npx mcp-server-generator my-analysis-server --transport both --skip-install
# Create and enter project
npx mcp-server-generator my-analysis-server
cd my-analysis-server
# 1οΈβ£ See everything at once
npm run quick:test # Shows all 8 tools, 9 resources, 3 prompts
# 2οΈβ£ Get help with all commands
npm run help # Complete command reference
# 3οΈβ£ Test with MCP Inspector (2 terminals)
# Terminal 1:
npm run dev:http:stateless
# Terminal 2:
npm run inspector:config -- --server my-analysis-server-http
Easily extend your MCP servers with new components using the powerful add
command:
# Add a new tool
npx mcp-server-generator add tool calculator
npx mcp-server-generator add tool file-manager --description "File management tool"
# Add a new resource
npx mcp-server-generator add resource user-data
npx mcp-server-generator add resource api-docs --author "Your Name"
# Add a new prompt
npx mcp-server-generator add prompt code-review
npx mcp-server-generator add prompt system-design --description "System design prompt"
# Add business logic services
npx mcp-server-generator add service email-sender
npx mcp-server-generator add service data-processor --description "Process data"
# Add custom transports
npx mcp-server-generator add transport websocket
npx mcp-server-generator add transport grpc --description "gRPC transport"
# Add utility functions
npx mcp-server-generator add util string-helpers
npx mcp-server-generator add util crypto-utils --description "Cryptography utilities"
See what components are already in your project:
# Navigate to your MCP project
cd my-mcp-project
# List all components
npx mcp-server-generator list
Each component type includes:
- π Interactive Configuration: Rich prompts for component-specific settings
- π§ Automatic Integration: Components are automatically registered and ready to use
- πΎ Backup & Rollback: Safe modifications with automatic backup creation
- β Validation: Name validation and conflict detection
- π Production-Ready Code: Generated components follow MCP best practices
- π― Type Safety: Full TypeScript support with proper typing
Type | Description | Examples |
---|---|---|
π οΈ Tool | Add functionality and actions | calculator , file-manager , data-validator |
π Resource | Add data and documentation | user-guide , api-docs , configuration |
π‘ Prompt | Add intelligent templates | code-review , analysis , summary |
βοΈ Service | Add business logic | email-sender , data-processor , auth-manager |
π Transport | Add communication layers | websocket , grpc , mqtt |
π§ Util | Add helper functions | string-helpers , crypto-utils , validators |
data-analysis
: Complete analysis with 5 methodologies, 6 sampling strategies, elicitation integrationserver-status
: Health monitoring and performance trackingstart-elicitation
: Begin interactive elicitation sessions for guided information gatheringcontinue-elicitation
: Continue active elicitation sessions with responsesget-elicitation-status
: Get status and summary of elicitation sessionsgenerate-sample
: Generate samples using 6 different sampling strategiesanalyze-sample
: Analyze sample quality and representativenessgenerate-synthetic-data
: Generate synthetic data based on source patterns
data-analysis
: Comprehensive guide to data analysis approaches and techniquessampling-guide
: Complete guide to data sampling techniques and strategieselicitation-workflows
: Interactive elicitation workflows for guided analysisanalysis-best-practices
: Industry best practices for effective data analysisserver-info
: Comprehensive server information and capabilitiesserver-config
: Current server configuration and runtime settingsapi-docs
: Complete API documentation for the MCP serversampling-strategies
: Documentation of available sampling strategiessampling-best-practices
: Guidelines for effective data sampling
research-analysis
: 8 research methodologies with flexible contexts and output formatsinteractive-exploration
: Generate interactive exploration questions for topicsguided-discovery
: Create guided discovery sessions for knowledge elicitation
- π§ Interactive Elicitation: Guided analysis with smart question generation
- π AI-Enhanced Sampling: 6 sampling strategies including AI-powered techniques
- ποΈ Modular Architecture: Clean separation of concerns with dependency injection
- π MCP Inspector Integration: Visual and CLI testing built-in
- β Component Extension: Add new tools, resources, prompts, services, transports, and utilities
- π§ Intelligent Integration: Automatic registry updates and import management
- πΎ Safe Modifications: Backup and rollback system for project changes
- π― Smart Validation: Component name validation and conflict detection
- Stdio Transport: Standard input/output for Claude Desktop and CLI tools
- HTTP Transport: RESTful API with Server-Sent Events for web integration
- Streamable HTTP: Modern protocol 2025-03-26 with session management
npx mcp-server-generator <project-name> [options]
Options:
<project-name>
: Name of the MCP server project (required)-t, --transport <type>
: Transport type (stdio
,http
,both
) - default:both
-d, --directory <path>
: Directory to create the project in--skip-install
: Skip installing dependencies--verbose
: Enable verbose logging--oauth
: Enable OAuth authentication for HTTP transport--no-dns-protection
: Disable DNS rebinding protection--stateless
: Enable stateless mode (no session persistence)
npx mcp-server-generator add <component-type> <component-name> [options]
Component Types:
tool
- Add functionality and tools to your MCP serverresource
- Add data and documentation resourcesprompt
- Add intelligent prompt templatesservice
- Add business logic and processing servicestransport
- Add custom communication transportsutil
- Add helper functions and utilities
Options:
<component-type>
: Type of component to add (required)<component-name>
: Name of the component (required)-d, --description <desc>
: Component description-a, --author <author>
: Component author--skip-validation
: Skip component name validation--verbose
: Enable verbose logging
npx mcp-server-generator list [options]
Options:
--verbose
: Enable verbose logging
Examples:
# Create a new project
npx mcp-server-generator my-server --transport both
# Add components to existing project
cd my-server
npx mcp-server-generator add tool calculator --description "Math calculator"
npx mcp-server-generator add resource user-guide --author "Team"
# List all components
npx mcp-server-generator list
my-analysis-server/
βββ src/
β βββ server.ts # Simplified main entry point (106 lines)
β βββ core/ # Core server logic
β β βββ config.ts # Configuration management
β β βββ mcp-server.ts # Core MCP server implementation
β β βββ server-factory.ts # Server instantiation
β βββ transports/ # Transport layer
β β βββ stdio-transport.ts # Stdio communication
β β βββ http-transport.ts # HTTP communication
β β βββ transport-manager.ts # Transport coordination
β βββ tools/ # Modular tool implementations
β β βββ index.ts # Tool registry
β β βββ data-analysis-tool.ts # Comprehensive analysis tool
β β βββ server-status-tool.ts # Monitoring tool
β βββ resources/ # Resource providers
β β βββ index.ts # Resource registry
β β βββ data-analysis-resource.ts # Analysis documentation
β β βββ server-info-resource.ts # Server information
β βββ prompts/ # Prompt templates
β β βββ index.ts # Prompt registry
β β βββ research-analysis-prompt.ts # Multi-methodology prompts
β βββ services/ # Business logic
β β βββ elicitation.ts # Interactive guidance
β β βββ sampling.ts # Data sampling
β β βββ example.ts # Example service
β βββ utils/ # Utilities
β βββ logger.ts # Logging system
β βββ health.ts # Health monitoring
βββ mcp-inspector.config.json # MCP Inspector configuration
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ README.md # Comprehensive documentation
# Test individual components
npm run test:tools # List data-analysis and server-status tools
npm run test:resources # Browse methodology guides and documentation
npm run test:prompts # Test research-analysis prompt
# Start different modes
npm run dev:stdio # For Claude Desktop integration
npm run dev:http # For API/web integration
npm run dev:http:oauth # With authentication
# Visual inspector (UI mode)
npm run inspector
# CLI-based testing
npm run inspector:cli
# Quick test (shows tool schema)
npm run test:tools
# Advanced test with actual data
npx @modelcontextprotocol/inspector --cli tsx src/server.ts \
--method tools/call \
--tool-name data-analysis \
--tool-arg 'data=[{"age":25,"score":85},{"age":30,"score":92}]' \
--tool-arg analysis_type=exploratory \
--tool-arg sampling_strategy=ai-representative \
--tool-arg enable_elicitation=true
# Test server status monitoring
npx @modelcontextprotocol/inspector --cli tsx src/server.ts \
--method tools/call \
--tool-name server-status \
--tool-arg 'include_details=true' \
--tool-arg 'format=json'
# Add a custom tool and test it immediately
npx mcp-server-generator add tool calculator --description "Math calculator"
npm run build
npm run test:tools # Your new tool will appear in the list
# Add a resource and verify it
npx mcp-server-generator add resource user-guide --description "User documentation"
npm run test:resources # New resource will be listed
# Add a prompt and test it
npx mcp-server-generator add prompt code-review --description "Code review prompt"
npm run test:prompts # New prompt will be available
# Test your extended server
npm run dev:stdio # Start with all components
npm run inspector:cli # Test all components interactively
# π Quick Start & Testing
npm run quick:test # Show ALL tools, resources & prompts at once
npm run help # Show all available commands
# π§ Development
npm run dev:stdio # Start with stdio transport (for Claude Desktop)
npm run dev:http # Start with HTTP transport
npm run dev:http:stateless # Start HTTP in stateless mode (best for inspector)
npm run dev:http:oauth # Start with OAuth enabled
# π MCP Inspector Integration (2 terminals)
# Terminal 1: npm run dev:http:stateless
# Terminal 2: npm run inspector:config -- --server your-project-http
# π Individual Testing
npm run test:tools # List available tools
npm run test:resources # List available resources
npm run test:prompts # List available prompts
# π Inspector Options
npm run inspector # Launch visual inspector (UI mode)
npm run inspector:cli # Command line testing
npm run inspector:config # Use configuration-based testing
# π Production
npm run build # Build TypeScript
npm run start:stdio # Production stdio
npm run start:http # Production HTTP
npm run start:http:stateless # Production HTTP stateless
This generator has been thoroughly tested and improved with:
- Zero TypeScript Errors: All 26+ compilation issues resolved
- Working Scripts: Every npm script tested and functional
- Clean Architecture: Proper separation of concerns with dependency injection
- Error Handling: Comprehensive validation and graceful error recovery
- One-Command Testing:
npm run quick:test
shows everything at once - Built-in Help:
npm run help
provides complete command reference - Smart Defaults: Optimized configurations for immediate use
- Inspector Integration: Seamless MCP Inspector setup with clear instructions
# Install dependencies
npm install
# Build the CLI tool
npm run build
# Test locally
npm link
mcp-server-generator test-analysis-server
Every generated project includes carefully selected dependencies:
Core MCP:
@modelcontextprotocol/sdk
: Official MCP TypeScript SDK@modelcontextprotocol/inspector
: Visual testing tool (dev dependency)zod
: Runtime type validation and schema definition
HTTP Transport:
express
: Web server frameworkcors
: Cross-origin resource sharing
Development & Quality:
typescript
: TypeScript compilertsx
: TypeScript execution engineeslint
: Code linting with TypeScript rulesjest
: Testing frameworkrimraf
: Clean builds
mcp-server-generator/
βββ bin/
β βββ create-mcp.js # CLI entry point
β βββ index.js # Alternative entry
βββ src/
β βββ cli/ # CLI implementation
β β βββ index.ts # Main CLI logic with add/list commands
β β βββ generator.ts # Project generation
β β βββ prompts.ts # User interaction
β β βββ validator.ts # Input validation
β β βββ add-component.ts # Component addition logic
β β βββ add-prompts.ts # Component configuration prompts
β βββ helpers/ # Helper utilities
β β βββ examples.ts # Example data
β β βββ install.ts # Dependency installation
β β βββ validate-pkg.ts # Package validation
β βββ types/ # TypeScript types (extended for components)
β βββ utils/ # Core utilities
β β βββ file-operations.ts # File system operations
β β βββ template-processor.ts # Template processing
β β βββ package-manager.ts # Package management
β β βββ project-detector.ts # Project detection & validation
β β βββ component-templates.ts # Dynamic component generation
β β βββ registry-updater.ts # Registry file management
β βββ templates/ # Template generation system
β βββ base/ # Base project files
β β βββ package.json.template
β β βββ README.md.template
β β βββ tsconfig.json.template
β βββ src/ # Source code templates
β βββ core/ # Core server modules
β βββ tools/ # Tool implementations
β βββ resources/ # Resource providers
β βββ prompts/ # Prompt templates
β βββ services/ # Business logic
β βββ transports/ # Transport handlers
β βββ utils/ # Utility modules
βββ lib/ # Built JavaScript (generated)
βββ package.json # CLI dependencies
The CLI now includes a powerful component extension system:
- Automatically detects valid MCP server projects
- Validates project structure and dependencies
- Checks for required files and registry structure
- Template-based component generation for each type
- Type-specific configuration and validation
- Production-ready code with proper TypeScript types
- Automatic import and export management
- Registry file updates (tools, resources, prompts)
- Component integration with existing architecture
- Backup creation before modifications
- Rollback capability on failures
- Conflict detection and prevention
Our template system generates production-ready MCP servers with:
- Modular Design: Each component has single responsibility
- Dependency Injection: Clean separation of concerns
- Registry Pattern: Easy extension and testing
- Factory Pattern: Centralized server creation
- One Comprehensive Example: Data Analysis Assistant showcasing ALL features
- No Scattered Demos: Everything integrated and cohesive
- Real-World Applicable: Practical use case developers can adapt
- Educational Value: Learn MCP best practices through implementation
- 5 Analysis Methodologies: exploratory, descriptive, diagnostic, predictive, prescriptive
- 6 Sampling Strategies: Including AI-enhanced techniques
- Interactive Elicitation: Smart question generation and guided workflows
- Multi-Methodology Prompts: 8 research approaches with flexible contexts
- MCP Inspector: Visual and CLI testing built-in
- Comprehensive Scripts: Ready-to-use testing commands
- Configuration Files: Pre-configured inspector settings
- Development Workflow: Immediate testing capability
- Multiple Transports: Stdio, HTTP, Streamable HTTP
- Session Management: Stateful and stateless modes
- Security: OAuth, CORS, DNS protection
- Monitoring: Health checks, status reporting, comprehensive logging
- Extensibility: Add new components without breaking existing functionality
- Type Safety: Full TypeScript support for all generated components
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature
- Make your changes and add tests
- Build and test:
npm run build && npm test
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Follow the unified architecture approach (no scattered examples)
- Maintain clean separation of concerns
- Add comprehensive tests for new features
- Update documentation for API changes
- Use conventional commit messages
- Main Documentation: mcp-server-generator.com
- API Reference: mcp-server-generator.com/docs/api/overview
- Contributing Guide: GitHub Contributing Guidelines
MIT License - see LICENSE file for details.
This project is inspired by and builds upon:
- Model Context Protocol - The protocol specification and community
- MCP TypeScript SDK - The official TypeScript SDK
- MCP Inspector - Visual testing tool for MCP servers
- create-next-app - CLI design patterns
- Neon's MCP Server - MCP server implementation patterns
MCP Server Generator - Generate and extend production-ready Model Context Protocol servers with comprehensive Data Analysis Assistant, component addition capabilities, and integrated testing.
Package Information:
- npm Package: mcp-server-generator
- GitHub: LinuxDevil/Create-MCP
- Size: 442 kB (155+ files)
- Commands:
mcp-server-generator
orcreate-mcp
New Features:
- β Component Addition:
mcp-server-generator add <type> <name>
- π Component Listing:
mcp-server-generator list
- π§ 6 Component Types: tools, resources, prompts, services, transports, utils
- π― Smart Integration: Automatic registry updates and type-safe generation
π Learn More:
- Complete Documentation: mcp-server-generator.com
- API Reference: mcp-server-generator.com/docs/api/overview
- Component Guide: mcp-server-generator.com/docs/components/overview
- CLI Reference: mcp-server-generator.com/docs/cli-commands