Skip to content

LinuxDevil/Create-MCP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MCP Server Generator

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!

npm version Downloads License: MIT

πŸ“¦ Available on npm: mcp-server-generator - 442kB of production-ready MCP server templates
πŸ“š Complete Documentation: mcp-server-generator.com

🎬 Video Showcase

See the MCP Server Generator in action! Watch how easy it is to create a production-ready MCP server:

Watch Demo Video

Watch the complete workflow from project generation to testing with MCP Inspector

πŸ“– Detailed guides and tutorials: mcp-server-generator.com

πŸ“‹ Table of Contents

πŸ“š For comprehensive documentation, examples, and guides, visit mcp-server-generator.com

Overview

✨ Modern Architecture

  • 🎯 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

🌟 What Makes This Different

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

Quick Start

Installation

# One-time usage (recommended)
npx mcp-server-generator my-project

# Global installation
npm install -g mcp-server-generator
mcp-server-generator my-project

Basic Usage

# 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

Immediate Testing

# 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

Extending Existing Projects

βž• Add Components to Existing Projects

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"

πŸ” List Existing Components

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

βš™οΈ Smart Component Generation

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

πŸ› οΈ Component Types

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

Features

πŸ”§ Comprehensive Tools (8 powerful tools)

  • data-analysis: Complete analysis with 5 methodologies, 6 sampling strategies, elicitation integration
  • server-status: Health monitoring and performance tracking
  • start-elicitation: Begin interactive elicitation sessions for guided information gathering
  • continue-elicitation: Continue active elicitation sessions with responses
  • get-elicitation-status: Get status and summary of elicitation sessions
  • generate-sample: Generate samples using 6 different sampling strategies
  • analyze-sample: Analyze sample quality and representativeness
  • generate-synthetic-data: Generate synthetic data based on source patterns

πŸ“‹ Rich Resources (9 comprehensive resources)

  • data-analysis: Comprehensive guide to data analysis approaches and techniques
  • sampling-guide: Complete guide to data sampling techniques and strategies
  • elicitation-workflows: Interactive elicitation workflows for guided analysis
  • analysis-best-practices: Industry best practices for effective data analysis
  • server-info: Comprehensive server information and capabilities
  • server-config: Current server configuration and runtime settings
  • api-docs: Complete API documentation for the MCP server
  • sampling-strategies: Documentation of available sampling strategies
  • sampling-best-practices: Guidelines for effective data sampling

πŸ’‘ Flexible Prompts (3 intelligent prompts)

  • research-analysis: 8 research methodologies with flexible contexts and output formats
  • interactive-exploration: Generate interactive exploration questions for topics
  • guided-discovery: Create guided discovery sessions for knowledge elicitation

✨ Advanced Features

  • 🧠 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

πŸš€ Transport Support

  • 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

CLI Commands

πŸš€ Create New Projects

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)

βž• Add Components to Existing Projects

npx mcp-server-generator add <component-type> <component-name> [options]

Component Types:

  • tool - Add functionality and tools to your MCP server
  • resource - Add data and documentation resources
  • prompt - Add intelligent prompt templates
  • service - Add business logic and processing services
  • transport - Add custom communication transports
  • util - 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

πŸ“‹ List Project Components

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

Generated Project Structure

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

Usage Examples

πŸš€ Quick Start Testing

# 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

πŸ§ͺ Testing the Data Analysis Tool

# 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'

βž• Adding and Testing New Components

# 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

Development Scripts

πŸ“ Available Scripts (for generated projects)

# πŸš€ 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

πŸŽ‰ Enhanced Developer Experience

This generator has been thoroughly tested and improved with:

βœ… Production-Ready Quality

  • 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

πŸš€ Instant Productivity

  • 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

Development

Building the CLI

# Install dependencies
npm install

# Build the CLI tool
npm run build

# Test locally
npm link
mcp-server-generator test-analysis-server

Generated Project Dependencies

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 framework
  • cors: Cross-origin resource sharing

Development & Quality:

  • typescript: TypeScript compiler
  • tsx: TypeScript execution engine
  • eslint: Code linting with TypeScript rules
  • jest: Testing framework
  • rimraf: Clean builds

Architecture

CLI Structure

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

Component Extension System

The CLI now includes a powerful component extension system:

πŸ” Project Detection

  • Automatically detects valid MCP server projects
  • Validates project structure and dependencies
  • Checks for required files and registry structure

πŸ—οΈ Dynamic Component Generation

  • Template-based component generation for each type
  • Type-specific configuration and validation
  • Production-ready code with proper TypeScript types

πŸ”§ Registry Management

  • Automatic import and export management
  • Registry file updates (tools, resources, prompts)
  • Component integration with existing architecture

πŸ’Ύ Safe Operations

  • Backup creation before modifications
  • Rollback capability on failures
  • Conflict detection and prevention

Advanced Template System

Our template system generates production-ready MCP servers with:

πŸ—οΈ Clean Architecture

  • Modular Design: Each component has single responsibility
  • Dependency Injection: Clean separation of concerns
  • Registry Pattern: Easy extension and testing
  • Factory Pattern: Centralized server creation

🎯 Unified Examples

  • 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

πŸ”§ Advanced MCP Features

  • 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

πŸ” Integrated Testing

  • 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

πŸš€ Production Features

  • 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

Contributing

  1. Fork the repository
  2. Create your feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Build and test: npm run build && npm test
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

Development Guidelines

  • 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

Documentation

License

MIT License - see LICENSE file for details.

Acknowledgments

This project is inspired by and builds upon:


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:

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: