Skip to content

Commit 46c9e83

Browse files
committed
feat: Initialize create-mcp CLI project with essential files and configurations
- Added .gitignore to exclude node_modules, environment files, and build outputs. - Created index.js as the entry point for the CLI, logging the Node.js version. - Included package.json and package-lock.json for project dependencies and scripts. - Added README.md with project description, features, and usage instructions. - Configured TypeScript with tsconfig.json for strict type checking and module resolution. - Implemented core CLI functionality in src/ directory, including project generation and prompts. - Established templates for project structure and configuration files. - Included utility functions for logging, health checks, and package management. - Set up example services and health monitoring for the MCP server.
0 parents  commit 46c9e83

50 files changed

Lines changed: 11921 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.env
3+
lib/

README.md

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Create MCP CLI
2+
3+
A comprehensive CLI tool for generating Model Context Protocol (MCP) servers using TypeScript. This tool is modeled after Next.js's create-next-app and provides a complete development experience for building MCP servers.
4+
5+
## Features
6+
7+
- 🚀 **Quick Setup**: Generate a complete MCP server project with one command
8+
- 📦 **TypeScript First**: Full TypeScript support with proper configurations
9+
- 🔄 **Dual Transport**: Support for both Stdio and HTTP transports
10+
- 🛠️ **Ready-to-Use**: Includes working examples and proper project structure
11+
- 📚 **Well Documented**: Comprehensive documentation and examples
12+
- 🎯 **Production Ready**: Best practices and proper error handling
13+
14+
## Usage
15+
16+
```bash
17+
# Create a new MCP server project
18+
npx create-mcp my-mcp-server
19+
20+
# Or with specific transport
21+
npx create-mcp my-mcp-server --transport stdio
22+
npx create-mcp my-mcp-server --transport http
23+
npx create-mcp my-mcp-server --transport both
24+
```
25+
26+
## CLI Options
27+
28+
- `<project-name>`: Name of the MCP server project (required)
29+
- `-t, --transport <type>`: Transport type (`stdio`, `http`, `both`) - default: `both`
30+
- `-d, --directory <path>`: Directory to create the project in
31+
- `--skip-install`: Skip installing dependencies
32+
33+
## Generated Project Structure
34+
35+
```
36+
my-mcp-server/
37+
├── src/
38+
│ ├── services/
39+
│ │ └── example.ts # Example service with tools and resources
40+
│ ├── utils/
41+
│ │ └── index.ts # Utility functions
42+
│ └── server.ts # Main server with transport implementations
43+
├── dist/ # Built JavaScript files (after build)
44+
├── .env.local # Environment configuration
45+
├── package.json # Dependencies and scripts
46+
├── tsconfig.json # TypeScript configuration
47+
├── .gitignore # Git ignore rules
48+
└── README.md # Project documentation
49+
```
50+
51+
## Features of Generated Projects
52+
53+
### 🔧 Tools
54+
- `get_time`: Get current time in various formats
55+
- `calculate`: Perform basic mathematical calculations
56+
57+
### 📚 Resources
58+
- `example://config`: Server configuration and status
59+
- `example://stats`: Runtime statistics and metrics
60+
61+
### 🚀 Transport Support
62+
- **Stdio Transport**: Standard input/output communication for MCP clients
63+
- **HTTP Transport**: RESTful API with Server-Sent Events for web integration
64+
65+
### 📝 Scripts
66+
- `npm run dev`: Development mode with auto-reload
67+
- `npm run build`: Build TypeScript to JavaScript
68+
- `npm start`: Start the server (stdio transport)
69+
- `npm run start:http`: Start with HTTP transport
70+
- `npm run lint`: ESLint code checking
71+
- `npm test`: Run tests
72+
73+
## Development
74+
75+
### Building the CLI
76+
77+
```bash
78+
# Install dependencies
79+
npm install
80+
81+
# Build the CLI tool
82+
npm run build
83+
84+
# Test locally
85+
npm link
86+
create-mcp test-project
87+
```
88+
89+
### Project Dependencies
90+
91+
The generated projects include:
92+
93+
**Core Dependencies:**
94+
- `@modelcontextprotocol/sdk`: Official MCP TypeScript SDK
95+
- `dotenv`: Environment configuration
96+
- `zod`: Runtime type validation
97+
98+
**HTTP Transport (when selected):**
99+
- `express`: Web server framework
100+
- `cors`: Cross-origin resource sharing
101+
102+
**Development:**
103+
- `typescript`: TypeScript compiler
104+
- `tsx`: TypeScript execution engine
105+
- `eslint`: Code linting
106+
- `jest`: Testing framework
107+
108+
## Architecture
109+
110+
The CLI follows the create-next-app pattern:
111+
112+
### CLI Structure
113+
```
114+
create-mcp/
115+
├── bin/
116+
│ └── create-mcp.js # CLI entry point
117+
├── src/
118+
│ ├── index.ts # Main CLI logic
119+
│ ├── create-mcp.ts # Project creation logic
120+
│ ├── templates/ # Template generation
121+
│ │ ├── index.ts # Template orchestration
122+
│ │ ├── package-json.ts # Package.json generation
123+
│ │ ├── server-ts.ts # Server template
124+
│ │ └── ... # Other templates
125+
│ └── utils/ # Utility functions
126+
├── lib/ # Built JavaScript (generated)
127+
└── package.json # CLI dependencies
128+
```
129+
130+
### Template System
131+
132+
The template system generates complete, working MCP servers with:
133+
134+
1. **Modular Architecture**: Separate services and utilities
135+
2. **Transport Flexibility**: Support for stdio and HTTP
136+
3. **Type Safety**: Full TypeScript integration
137+
4. **Best Practices**: Error handling, validation, and documentation
138+
5. **Development Experience**: Hot reload, linting, and testing
139+
140+
## Example Usage
141+
142+
After creating a project:
143+
144+
```bash
145+
# Create and enter project
146+
npx create-mcp my-awesome-mcp
147+
cd my-awesome-mcp
148+
149+
# Start development
150+
npm run dev
151+
152+
# In another terminal, test the MCP server
153+
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | node dist/server.js
154+
```
155+
156+
## Contributing
157+
158+
1. Fork the repository
159+
2. Create your feature branch: `git checkout -b feature/amazing-feature`
160+
3. Make your changes and add tests
161+
4. Build and test: `npm run build && npm test`
162+
5. Commit your changes: `git commit -m 'Add amazing feature'`
163+
6. Push to the branch: `git push origin feature/amazing-feature`
164+
7. Open a Pull Request
165+
166+
## License
167+
168+
MIT License - see LICENSE file for details.
169+
170+
## Inspiration
171+
172+
This project is inspired by:
173+
- [create-next-app](https://github.com/vercel/next.js/tree/canary/packages/create-next-app)
174+
- [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
175+
- [Neon's MCP Server](https://github.com/neondatabase/mcp-server-neon)

bin/create-mcp.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env node
2+
3+
const { run } = require('../lib/index.js');
4+
5+
run().catch((error) => {
6+
console.error('Unexpected error:', error);
7+
process.exit(1);
8+
});

bin/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env node
2+
3+
// Binary entry point for create-mcp CLI
4+
require('../dist/cli/index.js');

index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// run `node index.js` in the terminal
2+
3+
console.log(`Hello Node.js v${process.versions.node}!`);

0 commit comments

Comments
 (0)