@godrix/create-mcp-server
v1.0.1
Published
CLI to create MCP (Model Context Protocol) servers with TypeScript. Provides a base structure with examples of tools, resources, and prompts.
Maintainers
Readme
Create MCP Server
A CLI tool to create MCP (Model Context Protocol) servers with TypeScript. This tool provides a base structure with examples of tools, resources, and prompts to facilitate the development of custom MCP servers.
Quick Start
Create a new MCP server with one command:
npx @godrix/create-mcp-server my-mcp-serverThis will:
- Create a new directory with your project name
- Set up the complete MCP server structure
- Configure all necessary files
- Install dependencies
- Provide you with next steps
What's Included
Project Structure
my-mcp-server/
├── src/
│ ├── controllers/
│ │ ├── tools/
│ │ │ └── ExampleToolsController.ts # Example controller for tools
│ │ ├── resources/
│ │ │ └── ExampleResourcesController.ts # Example controller for resources
│ │ └── prompts/
│ │ └── ExamplePromptsController.ts # Example controller for prompts with argsSchema
│ ├── model/
│ │ ├── Error.ts # Error model
│ │ ├── ExampleData.ts # Example data model
│ │ ├── User.ts # User model
│ │ └── index.ts # Model exports
│ ├── services/
│ │ └── ExampleApiService.ts # Example API service
│ ├── utils/
│ │ ├── apiResponseHandler.ts # API response handler
│ │ ├── env.ts # Environment configuration
│ │ └── request.ts # Base HTTP request class
│ └── server.ts # Main server file
├── package.json # Project configuration
├── tsconfig.json # TypeScript configuration
├── .gitignore # Git ignore rules
├── .env # Environment variables
├── env.example # Environment variables example
├── mcp.example.json # MCP configuration example
└── README.md # Project documentationFeatures
- Tools: Example tools for API interaction
- Resources: Example resources for data access
- Prompts: Example prompts with argsSchema
- TypeScript: Full TypeScript support
- Error Handling: Standardized error handling
- Environment: Configurable environment variables
Installation
Global Installation
npm install -g @godrix/create-mcp-serverThen use it anywhere:
create-mcp-server my-mcp-serverOne-time Usage
npx @godrix/create-mcp-server my-mcp-serverUsage
Basic Usage
npx @godrix/create-mcp-server my-mcp-serverInteractive Setup
The CLI will ask you for:
- Project description
- Author name
- Version
- API URL (optional)
- API Key (optional)
Options
- If the directory already exists, it will ask if you want to overwrite it
- All configuration is done interactively
Development
After creating your project:
cd my-mcp-server
npm install
npm run devConfiguration
Environment Variables
The CLI creates a .env file with your configuration:
API_URL=https://api.example.com
API_KEY=your_api_key_here
READ_ONLY=falseMCP Configuration
Use the generated mcp.example.json as a template for your LLM configuration:
{
"servers": [
{
"name": "my-mcp-server",
"command": "npx",
"args": ["my-mcp-server", "-y"],
"envs": {
"API_URL": "https://api.example.com",
"API_KEY": "your_api_key_here",
"READ_ONLY": "false"
}
}
]
}Customization
Adding New Tools
- Create a new controller in
src/controllers/tools/ - Implement the necessary methods
- Register the controller in
server.ts
Adding New Resources
- Create a new controller in
src/controllers/resources/ - Implement the necessary methods
- Register the controller in
server.ts
Adding New Prompts
- Create a new controller in
src/controllers/prompts/ - Implement the necessary methods
- Register the controller in
server.ts
Examples
Create a Simple MCP Server
npx @godrix/create-mcp-server simple-mcpCreate a Custom MCP Server
npx @godrix/create-mcp-server my-custom-mcp
# Follow the interactive promptsContributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -m 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Open a Pull Request
License
MIT
