npm package: @godrix/create-mcp-server
Description: CLI to create MCP (Model Context Protocol) servers with TypeScript. Provides a base structure with examples of tools, resources, and prompts.
Author: Carlos Godri
Latest version: 1.0.1

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

```bash
npx @godrix/create-mcp-server my-mcp-server
```

This will:
1. Create a new directory with your project name
2. Set up the complete MCP server structure
3. Configure all necessary files
4. Install dependencies
5. 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 documentation
```

### Features
- **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
```bash
npm install -g @godrix/create-mcp-server
```

Then use it anywhere:
```bash
create-mcp-server my-mcp-server
```

### One-time Usage
```bash
npx @godrix/create-mcp-server my-mcp-server
```

## Usage

### Basic Usage
```bash
npx @godrix/create-mcp-server my-mcp-server
```

### Interactive 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:

```bash
cd my-mcp-server
npm install
npm run dev
```

## Configuration

### Environment Variables
The CLI creates a `.env` file with your configuration:

```env
API_URL=https://api.example.com
API_KEY=your_api_key_here
READ_ONLY=false
```

### MCP Configuration
Use the generated `mcp.example.json` as a template for your LLM configuration:

```json
{
  "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
1. Create a new controller in `src/controllers/tools/`
2. Implement the necessary methods
3. Register the controller in `server.ts`

### Adding New Resources
1. Create a new controller in `src/controllers/resources/`
2. Implement the necessary methods
3. Register the controller in `server.ts`

### Adding New Prompts
1. Create a new controller in `src/controllers/prompts/`
2. Implement the necessary methods
3. Register the controller in `server.ts`

## Examples

### Create a Simple MCP Server
```bash
npx @godrix/create-mcp-server simple-mcp
```

### Create a Custom MCP Server
```bash
npx @godrix/create-mcp-server my-custom-mcp
# Follow the interactive prompts
```

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/new-feature`)
3. Commit your changes (`git commit -m 'Add new feature'`)
4. Push to the branch (`git push origin feature/new-feature`)
5. Open a Pull Request

## License

MIT