A comprehensive template for creating production-ready MCP (Model Context Protocol) servers from AI prompts. This template generates fully-featured TypeScript/Node.js projects with OpenAPI-to-MCP tool mapping, security best practices, and enterprise-grade architecture.
- Node.js 18+
- Docker (optional, for containerized deployment)
- Git
- AI model access (Claude, GPT-4, etc.) for prompt usage
-
Use the template to create a new project:
git clone https://github.com/markbsigler/MCP-Server-template.git cd MCP-Server-template -
Generate your MCP server using the
PROMPT.mdwith your preferred AI model -
Install and run:
npm install npm run dev
-
Test your MCP server:
curl http://localhost:3000/healthz
- π οΈ OpenAPI-to-MCP Tools: Automatic conversion of OpenAPI specs to MCP tools
- π Enterprise Security: JWT authentication, input validation, rate limiting
- ποΈ Production Architecture: Modular structure with handlers, middleware, and types
- π§ͺ Comprehensive Testing: Jest-based unit and integration tests with coverage
- π³ Container Ready: Multi-stage Docker builds with docker-compose
- π CI/CD Pipeline: GitHub Actions with security scanning and multi-platform builds
- π Monitoring: Health checks, structured logging, and metrics collection
- π Extensible: Plugin architecture and middleware system
- π Documentation: Auto-generated API docs and comprehensive examples
- MCP Protocol Compliance: Full
tools/list,tools/call, and notifications support - Streamable HTTP Transport: JSON-RPC 2.0 over HTTP with SSE support
- Security First: No token passthrough, secure session management
- Performance Optimized: Streaming responses and efficient resource usage
your-mcp-server/
βββ src/
β βββ handlers/ # MCP protocol handlers
β βββ middleware/ # Authentication, validation, CORS
β βββ types/ # TypeScript type definitions
β βββ utils/ # Helper functions and utilities
β βββ index.ts # Main server entry point
βββ tests/
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
β βββ __mocks__/ # Test mocks
βββ config/
β βββ openapi.json # OpenAPI specification
β βββ environments/ # Environment configurations
βββ docs/
β βββ api/ # Generated API documentation
β βββ architecture/ # Architecture diagrams
βββ .github/
β βββ workflows/ # GitHub Actions CI/CD
βββ docker/
β βββ Dockerfile # Multi-stage Docker build
β βββ docker-compose.yml
βββ package.json
βββ tsconfig.json
βββ README.md
-
Copy the entire
PROMPT.mdcontent -
Customize for your use case:
Generate an MCP server for [YOUR_USE_CASE] with the following additional requirements: - [Custom requirement 1] - [Custom requirement 2] [Paste PROMPT.md content here] -
Submit to your AI model (Claude, GPT-4, etc.)
The prompt supports several customization variables:
- Project Name: Modify the generated project name and structure
- OpenAPI Specification: Provide your own OpenAPI spec for custom tools
- Security Requirements: Add specific authentication or authorization needs
- Deployment Target: Specify cloud platform or container orchestration
- Integration Requirements: Add specific third-party service integrations
- Be Specific: Add detailed requirements for your use case
- Include Examples: Provide sample OpenAPI operations you want to support
- Specify Security: Define your authentication and authorization requirements
- Mention Integrations: List any third-party services you need to integrate
If you want to use this template to create a completely new MCP server project (without the original history and disconnected from this template), follow these steps:
git clone https://github.com/markbsigler/MCP-Server-template.git
cd MCP-Server-template
rm -rf .gitgit init
git add .
git commit -m "Initial commit"- Go to GitHub.com and click the + icon
- Select New repository
- Enter <newMCPrepo> as the repository name
- Choose public/private
- Don't check any initialization options (README, .gitignore, license)
- Click Create repository
git branch -M main
git remote add origin https://github.com/<username>/<newMCPrepo>.git
git push -u origin maincd ..
mv MCP-Server-template <newMCPrepo>
cd <newMCPrepo>Now you have your new MCP project ready to go - completely independent from the original template with a fresh git history!
-
REST API to MCP Tools
- OpenAPI spec with CRUD operations
- Automatic MCP tool generation
- JWT authentication with rate limiting
-
File Processing Service
- File upload/download operations
- Binary content handling
- Streaming responses
-
Data Analytics Platform
- Complex query operations
- Paginated responses
- Real-time data streaming
- API Gateway: Convert existing REST APIs to MCP tools
- Microservice Integration: Bridge microservices with MCP protocol
- AI Assistant Backend: Provide tools for AI assistants and agents
- Workflow Automation: Create tools for business process automation
We welcome contributions to improve this MCP Server template! Here's how you can help:
- Fork the repository to your GitHub account
- Clone your fork locally:
git clone https://github.com/<your-username>/MCP-Server-template.git cd MCP-Server-template
- Create a feature branch for your contribution:
git checkout -b feature/your-feature-name
We're looking for help with improving the PROMPT.md file:
- Additional MCP features: Expand the prompt to include more MCP protocol capabilities
- Security enhancements: Add more security best practices and implementation details
- Architecture improvements: Better project structure and organization patterns
- Tool implementation patterns: More comprehensive OpenAPI-to-MCP tool mapping examples
- Performance optimizations: Add performance considerations and monitoring requirements
- Testing strategies: Expand testing requirements and methodologies
- Documentation standards: Improve documentation generation and maintenance requirements
- Deployment scenarios: Add more container and cloud deployment patterns
- Integration examples: More comprehensive client and integration examples
- Error handling: Enhanced error handling and recovery patterns
- Commit your changes with clear, descriptive messages:
git add . git commit -m "feat: add new MCP tool for file processing"
- Push to your fork:
git push origin feature/your-feature-name
- Create a Pull Request on GitHub:
- Provide a clear description of your changes
- Reference any related issues
- Include screenshots or examples if applicable
- Keep PRs focused: One feature or fix per PR
- Write clear descriptions: Explain what changes you made and why
- Include tests: All new code should have corresponding tests
- Update documentation: Ensure README and other docs reflect your changes
- Follow conventional commits: Use clear, descriptive commit messages
- TypeScript: Use strict typing and follow existing patterns
- ESLint/Prettier: Code must pass linting and formatting checks
- Testing: Maintain or improve test coverage
- Security: Follow security best practices, especially for MCP tools
- Performance: Consider performance implications of changes
If you find a bug or have a feature request:
- Search existing issues to avoid duplicates
- Use issue templates when available
- Provide detailed information:
- Steps to reproduce (for bugs)
- Expected vs. actual behavior
- Environment details (Node.js version, OS, etc.)
- Relevant code snippets or logs
- Be respectful and constructive in all interactions
- Help others by answering questions and reviewing PRs
- Follow the code of conduct (if applicable)
- Stay focused on improving the template for everyone
If you have questions about contributing:
- Open a Discussion on GitHub
- Check existing Issues and Pull Requests
- Review the PROMPT.md file for technical details
Thank you for helping make this MCP Server template better for everyone!
Q: AI model generates incomplete code
- A: The prompt is comprehensive - try breaking it into smaller sections or use a model with larger context window
Q: Generated project won't start
- A: Check Node.js version (18+ required) and run
npm installto install dependencies
Q: OpenAPI tools not generating
- A: Verify your
config/openapi.jsonfile is valid JSON and follows OpenAPI 3.0+ specification
Q: Authentication issues
- A: Check JWT token configuration and ensure proper Bearer token format
Q: Docker build fails
- A: Ensure Docker is installed and running, check Dockerfile syntax
- Check the generated project's README for specific setup instructions
- Review the PROMPT.md for implementation details
- Open an issue with detailed error messages and environment info
- Initial release of MCP Server template
- Comprehensive PROMPT.md for AI code generation
- OpenAPI-to-MCP tools mapping
- Security best practices implementation
- Docker and CI/CD support
- Extensive documentation and examples
This project is licensed under the MIT License - see the LICENSE file for details.
When using this template:
- Retain the original LICENSE file
- Modify the copyright notice in generated projects
- Credit this template in your project documentation (optional but appreciated)
Generated projects may include:
- Express.js (MIT License)
- Jest (MIT License)
- TypeScript (Apache 2.0 License)
- Other npm packages with their respective licenses
Ready to build your MCP server? Use the PROMPT.md with your favorite AI model and create production-ready MCP servers in minutes! π