Skip to content

Commit e9bb89c

Browse files
feat: Enhance frontmcp cli commands (#118)
* feat: Enhance 'create' command with interactive prompts and Docker support * feat: Add end-to-end testing script and Verdaccio configuration for CLI * refactor: Simplify argument parsing tests and enhance chdir mock implementation * feat: Enhance type safety by defining PackageJson interface and improving error handling * feat: Preserve user scripts in 'create' command and streamline script merging
1 parent 49a9f11 commit e9bb89c

File tree

15 files changed

+2323
-179
lines changed

15 files changed

+2323
-179
lines changed

docs/draft/docs/deployment/local-dev-server.mdx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ Creates a folder and scaffolds everything for you.
2929

3030
</CodeGroup>
3131

32+
<Info>
33+
The `create` command is interactive by default. Use `--yes` for non-interactive mode with defaults (Docker target, Redis via Docker Compose, GitHub Actions enabled).
34+
</Info>
35+
3236
### Option B — Existing project
3337

3438
Install and initialize in your current repo:
@@ -59,6 +63,31 @@ After `create` or `init`, your `package.json` will include:
5963
- `frontmcp inspector` — launches **@modelcontextprotocol/inspector** with zero setup
6064
- `frontmcp doctor` — verifies Node/npm versions and project configuration
6165

66+
### Docker scripts (Docker target only)
67+
68+
If you created your project with the Docker target (`--target node`), you'll also have:
69+
70+
```json
71+
{
72+
"scripts": {
73+
"docker:up": "docker compose -f ci/docker-compose.yml up",
74+
"docker:down": "docker compose -f ci/docker-compose.yml down",
75+
"docker:build": "docker compose -f ci/docker-compose.yml build"
76+
}
77+
}
78+
```
79+
80+
```bash
81+
# Start the full stack (app + Redis if configured)
82+
npm run docker:up
83+
84+
# Stop containers
85+
npm run docker:down
86+
87+
# Rebuild the Docker image
88+
npm run docker:build
89+
```
90+
6291
---
6392

6493
## Recommended tsconfig

docs/draft/docs/deployment/redis-setup.mdx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,22 @@ FrontMCP uses Redis for caching, session storage, and distributed state manageme
1818

1919
### Option 1: Docker Compose (Recommended)
2020

21-
Projects created with `frontmcp create` include a `docker-compose.yml`:
21+
Projects created with `frontmcp create --target node` include Docker files in the `ci/` folder:
2222

2323
```bash
2424
# Start Redis
25-
docker compose up redis -d
25+
docker compose -f ci/docker-compose.yml up redis -d
2626

2727
# Verify Redis is running
28-
docker compose exec redis redis-cli ping
28+
docker compose -f ci/docker-compose.yml exec redis redis-cli ping
29+
30+
# Start the full stack (app + Redis)
31+
docker compose -f ci/docker-compose.yml up
2932
```
3033

3134
<Tip>
3235
When running inside Docker, use `redis` (the service name) as `REDIS_HOST`, not `localhost`.
33-
Projects created with `frontmcp create` include a `.env.docker` file with Docker-specific values.
36+
Projects created with `frontmcp create` include a `ci/.env.docker` file with Docker-specific values.
3437
</Tip>
3538

3639
### Option 2: Local Installation

docs/draft/docs/deployment/serverless.mdx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,28 @@ Deploy your FrontMCP server to serverless platforms like Vercel, AWS Lambda, and
1111
| Platform | Status | Module Format | Config File |
1212
|----------|--------|---------------|-------------|
1313
| Vercel | Stable | ESM | `vercel.json` |
14-
| AWS Lambda | Stable | ESM | User-managed |
14+
| AWS Lambda | Stable | ESM | `ci/template.yaml` (SAM) |
1515
| Cloudflare Workers | Experimental | CommonJS | `wrangler.toml` |
1616

1717
## Quick Start
1818

19+
<Tip>
20+
**New project?** Use `frontmcp create` with the `--target` flag to scaffold a serverless-ready project:
21+
22+
```bash
23+
# Vercel project
24+
npx frontmcp create my-app --target vercel
25+
26+
# AWS Lambda project (generates SAM template)
27+
npx frontmcp create my-app --target lambda
28+
29+
# Cloudflare Workers project
30+
npx frontmcp create my-app --target cloudflare
31+
```
32+
33+
This generates the platform config files (`vercel.json`, `ci/template.yaml`, or `wrangler.toml`) automatically.
34+
</Tip>
35+
1936
<Tabs>
2037
<Tab title="Vercel">
2138
```bash
@@ -118,6 +135,13 @@ npm install @codegenie/serverless-express
118135

119136
### Setup
120137

138+
<Tip>
139+
Projects created with `frontmcp create --target lambda` include a SAM template at `ci/template.yaml` and a deploy script:
140+
```bash
141+
npm run deploy # Runs: cd ci && sam build && sam deploy
142+
```
143+
</Tip>
144+
121145
1. Build your project:
122146
```bash
123147
frontmcp build --adapter lambda
@@ -201,6 +225,13 @@ with streaming, certain middleware, and some response methods.
201225
For production Cloudflare deployments, consider using [Hono](https://hono.dev/) or native Workers APIs.
202226
</Warning>
203227

228+
<Tip>
229+
Projects created with `frontmcp create --target cloudflare` include a `wrangler.toml` and a deploy script:
230+
```bash
231+
npm run deploy # Runs: wrangler deploy
232+
```
233+
</Tip>
234+
204235
### Limitations
205236

206237
- Basic request/response handling only

docs/draft/docs/getting-started/installation.mdx

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ icon: arrow-down-to-line
1717

1818
## Option A — Create a new project
1919

20-
Use the built-in project generator. It **requires** a project name and will create a new folder under your current directory.
20+
Use the built-in project generator. It will create a new folder under your current directory.
2121

2222
<CodeGroup>
2323
```bash universal
@@ -34,11 +34,55 @@ Use the built-in project generator. It **requires** a project name and will crea
3434

3535
</CodeGroup>
3636

37+
The `create` command is **interactive** by default:
38+
39+
```
40+
? Project name: my-app
41+
? Deployment target:
42+
> Node.js (Docker)
43+
Vercel (Serverless)
44+
AWS Lambda
45+
Cloudflare Workers
46+
? Redis setup: (Docker target only)
47+
> Docker Compose
48+
Existing Redis
49+
None
50+
? Enable GitHub Actions CI/CD? (Y/n)
51+
```
52+
53+
Use `--yes` (or `-y`) to skip prompts and use defaults.
54+
55+
### CLI Flags
56+
57+
| Flag | Description | Default |
58+
|------|-------------|---------|
59+
| `--yes, -y` | Use defaults (non-interactive) | - |
60+
| `--target <type>` | Deployment: `node`, `vercel`, `lambda`, `cloudflare` | `node` |
61+
| `--redis <setup>` | Redis: `docker`, `existing`, `none` | `docker` |
62+
| `--cicd / --no-cicd` | Enable GitHub Actions | `--cicd` |
63+
64+
**Examples:**
65+
```bash
66+
# Interactive mode (default)
67+
npx frontmcp create my-app
68+
69+
# Non-interactive with defaults
70+
npx frontmcp create my-app --yes
71+
72+
# Vercel target with CI/CD
73+
npx frontmcp create my-app --target vercel
74+
75+
# Docker without Redis
76+
npx frontmcp create my-app --target node --redis none --no-cicd
77+
```
78+
3779
This will:
3880

3981
- scaffold a FrontMCP project in `./my-app`
4082
- configure `tsconfig.json` for decorators and modern ESM
4183
- generate a `package.json` with helpful scripts
84+
- create deployment configuration for your target (Dockerfile, vercel.json, etc.)
85+
- generate GitHub Actions workflows (if enabled)
4286
- install required dev dependencies (e.g. TypeScript, tsx, zod, reflect-metadata)
4387

4488
---

docs/draft/docs/getting-started/quickstart.mdx

Lines changed: 84 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,23 @@ yarn dev
4343

4444
</CodeGroup>
4545

46+
<Info>
47+
The `create` command is **interactive** by default. It will ask you about:
48+
- **Deployment target**: Node.js (Docker), Vercel, AWS Lambda, or Cloudflare Workers
49+
- **Redis setup**: Docker Compose, existing Redis, or none (Docker target only)
50+
- **GitHub Actions**: Enable CI/CD workflows
51+
52+
Use `--yes` (or `-y`) to skip prompts and use defaults.
53+
</Info>
54+
4655
The CLI creates a complete project structure with:
4756

4857
- ✅ TypeScript configured
4958
- ✅ Sample server, app, and tool
5059
- ✅ Development scripts ready
5160
- ✅ Hot-reload enabled
61+
- ✅ Deployment configuration for your target platform
62+
- ✅ GitHub Actions CI/CD (optional)
5263

5364
<Check>Your server is now running at `http://localhost:3000`!</Check>
5465

@@ -89,16 +100,68 @@ The `init` command:
89100

90101
After creating your project, you'll have:
91102

92-
```
93-
my-mcp-server/
94-
├── src/
95-
│ ├── main.ts # Server entry point
96-
│ ├── hello.app.ts # App definition
97-
│ └── tools/
98-
│ └── greet.tool.ts # Sample tool
99-
├── package.json
100-
└── tsconfig.json
101-
```
103+
<Tabs>
104+
<Tab title="Docker (default)">
105+
```
106+
my-mcp-server/
107+
├── ci/
108+
│ ├── Dockerfile
109+
│ ├── docker-compose.yml
110+
│ └── .env.docker
111+
├── .github/workflows/ # If CI/CD enabled
112+
│ ├── ci.yml
113+
│ ├── e2e.yml
114+
│ └── deploy.yml
115+
├── src/
116+
│ ├── main.ts
117+
│ ├── hello.app.ts
118+
│ └── tools/
119+
│ └── greet.tool.ts
120+
├── package.json
121+
└── tsconfig.json
122+
```
123+
</Tab>
124+
<Tab title="Vercel">
125+
```
126+
my-mcp-server/
127+
├── vercel.json
128+
├── src/
129+
│ ├── main.ts
130+
│ ├── hello.app.ts
131+
│ └── tools/
132+
│ └── greet.tool.ts
133+
├── package.json
134+
└── tsconfig.json
135+
```
136+
</Tab>
137+
<Tab title="Lambda">
138+
```
139+
my-mcp-server/
140+
├── ci/
141+
│ └── template.yaml # AWS SAM template
142+
├── src/
143+
│ ├── main.ts
144+
│ ├── hello.app.ts
145+
│ └── tools/
146+
│ └── greet.tool.ts
147+
├── package.json
148+
└── tsconfig.json
149+
```
150+
</Tab>
151+
<Tab title="Cloudflare">
152+
```
153+
my-mcp-server/
154+
├── wrangler.toml
155+
├── src/
156+
│ ├── main.ts
157+
│ ├── hello.app.ts
158+
│ └── tools/
159+
│ └── greet.tool.ts
160+
├── package.json
161+
└── tsconfig.json
162+
```
163+
</Tab>
164+
</Tabs>
102165

103166
### Server Configuration
104167

@@ -298,13 +361,23 @@ npm run doctor
298361

299362
| Command | Description |
300363
| ---------------------------- | -------------------------------- |
301-
| `npx frontmcp create <name>` | Create a new FrontMCP project |
364+
| `npx frontmcp create <name>` | Create a new FrontMCP project (interactive) |
365+
| `npx frontmcp create <name> --yes` | Create with defaults (non-interactive) |
302366
| `npx frontmcp init` | Add FrontMCP to existing project |
303367
| `npm run dev` | Start with hot-reload |
304368
| `npm run build` | Compile to production |
305369
| `npm run inspect` | Open MCP Inspector |
306370
| `npm run doctor` | Verify setup |
307371

372+
### Create Command Flags
373+
374+
| Flag | Description |
375+
| ---- | ----------- |
376+
| `--yes, -y` | Use defaults (non-interactive mode) |
377+
| `--target <type>` | Deployment target: `node`, `vercel`, `lambda`, `cloudflare` |
378+
| `--redis <setup>` | Redis setup: `docker`, `existing`, `none` |
379+
| `--cicd / --no-cicd` | Enable/disable GitHub Actions CI/CD |
380+
308381
---
309382

310383
## Troubleshooting

0 commit comments

Comments
 (0)