
mcp example
一个基于 NestJS 的 TypeScript 启动项目,用于构建高效、可扩展的服务器端应用程序。
Repository Info
About This Server
一个基于 NestJS 的 TypeScript 启动项目,用于构建高效、可扩展的服务器端应用程序。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
Create MCP Server
🚀 A CLI tool to quickly generate new MCP (Model Context Protocol) servers using NestJS.
Quick Start
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-server
Interactive Setup
The 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!
What You Get
Every generated MCP server includes:
🎯 Core Features
- 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
🛠️ Development Tools
- 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
🏗️ Production Ready
- 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
📊 Generated Project Structure
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
Usage Examples
Basic Usage
npx create-mcp-server weather-server
With Interactive Prompts
npx create-mcp-server
# Follow the interactive prompts
Command Line Arguments
npx create-mcp-server my-server
# Then provide additional details interactively
After Generation
Once 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
MCP Client Configuration
STDIN Transport
{
"mcpServers": {
"my-awesome-server": {
"command": "node",
"args": ["/path/to/my-awesome-server/dist/mcp-stdin.js"],
"env": {}
}
}
}
SSE Transport
{
"mcpServers": {
"my-awesome-server": {
"url": "http://localhost:3352/mcp"
}
}
}
Available Scripts
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
Requirements
- Node.js: 18 or higher
- Package Manager: pnpm (recommended), npm, or yarn
- OS: macOS, Linux, or Windows
Features Out of the Box
🔧 MCP Tools
- Example greeting tool with progress reporting
- Easy-to-extend tool system
- Automatic tool registration
📚 MCP Resources
- Resource management system
- Example user information resources
- Type-safe resource definitions
🧪 Testing
- Unit test examples
- E2E test suite
- MCP-specific test utilities
- Performance and stress tests
🐳 Docker
- Multi-stage Dockerfile
- Development and production configurations
- Docker Compose support
📝 Documentation
- Comprehensive README
- CLAUDE.md for AI assistant guidance
- Inline code documentation
- Architecture diagrams
Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
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-project
Troubleshooting
Common Issues
Template directory not found
# Reinstall the package
npm uninstall -g create-mcp-server
npm install -g create-mcp-server
Permission errors
# Use npx instead of global installation
npx create-mcp-server my-project
Project already exists
# Choose a different name or remove the existing directory
rm -rf existing-project
npx create-mcp-server new-project-name
License
MIT © [Your Name]
Related Projects
- Model Context Protocol
- NestJS
- @rekog/mcp-nest
Quick Start
Clone the repository
git clone https://github.com/andreymaznyak/mcp-exampleInstall dependencies
cd mcp-example
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.