@frontmcp/skills 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +135 -0
- package/catalog/TEMPLATE.md +49 -0
- package/catalog/adapters/create-adapter/SKILL.md +127 -0
- package/catalog/adapters/official-adapters/SKILL.md +136 -0
- package/catalog/auth/configure-auth/SKILL.md +250 -0
- package/catalog/auth/configure-auth/references/auth-modes.md +77 -0
- package/catalog/auth/configure-session/SKILL.md +201 -0
- package/catalog/config/configure-elicitation/SKILL.md +136 -0
- package/catalog/config/configure-http/SKILL.md +167 -0
- package/catalog/config/configure-throttle/SKILL.md +189 -0
- package/catalog/config/configure-throttle/references/guard-config.md +68 -0
- package/catalog/config/configure-transport/SKILL.md +151 -0
- package/catalog/config/configure-transport/references/protocol-presets.md +57 -0
- package/catalog/deployment/build-for-browser/SKILL.md +95 -0
- package/catalog/deployment/build-for-cli/SKILL.md +100 -0
- package/catalog/deployment/build-for-sdk/SKILL.md +218 -0
- package/catalog/deployment/deploy-to-cloudflare/SKILL.md +192 -0
- package/catalog/deployment/deploy-to-lambda/SKILL.md +304 -0
- package/catalog/deployment/deploy-to-node/SKILL.md +229 -0
- package/catalog/deployment/deploy-to-node/references/Dockerfile.example +45 -0
- package/catalog/deployment/deploy-to-vercel/SKILL.md +196 -0
- package/catalog/deployment/deploy-to-vercel/references/vercel.json.example +60 -0
- package/catalog/development/create-agent/SKILL.md +563 -0
- package/catalog/development/create-agent/references/llm-config.md +46 -0
- package/catalog/development/create-job/SKILL.md +566 -0
- package/catalog/development/create-prompt/SKILL.md +400 -0
- package/catalog/development/create-provider/SKILL.md +233 -0
- package/catalog/development/create-resource/SKILL.md +437 -0
- package/catalog/development/create-skill/SKILL.md +526 -0
- package/catalog/development/create-skill-with-tools/SKILL.md +579 -0
- package/catalog/development/create-tool/SKILL.md +418 -0
- package/catalog/development/create-tool/references/output-schema-types.md +56 -0
- package/catalog/development/create-tool/references/tool-annotations.md +34 -0
- package/catalog/development/create-workflow/SKILL.md +709 -0
- package/catalog/development/decorators-guide/SKILL.md +598 -0
- package/catalog/plugins/create-plugin/SKILL.md +336 -0
- package/catalog/plugins/create-plugin-hooks/SKILL.md +282 -0
- package/catalog/plugins/official-plugins/SKILL.md +667 -0
- package/catalog/setup/frontmcp-skills-usage/SKILL.md +200 -0
- package/catalog/setup/multi-app-composition/SKILL.md +358 -0
- package/catalog/setup/nx-workflow/SKILL.md +357 -0
- package/catalog/setup/project-structure-nx/SKILL.md +186 -0
- package/catalog/setup/project-structure-standalone/SKILL.md +153 -0
- package/catalog/setup/setup-project/SKILL.md +493 -0
- package/catalog/setup/setup-redis/SKILL.md +385 -0
- package/catalog/setup/setup-sqlite/SKILL.md +359 -0
- package/catalog/skills-manifest.json +414 -0
- package/catalog/testing/setup-testing/SKILL.md +539 -0
- package/catalog/testing/setup-testing/references/test-auth.md +88 -0
- package/catalog/testing/setup-testing/references/test-browser-build.md +57 -0
- package/catalog/testing/setup-testing/references/test-cli-binary.md +48 -0
- package/catalog/testing/setup-testing/references/test-direct-client.md +62 -0
- package/catalog/testing/setup-testing/references/test-e2e-handler.md +51 -0
- package/catalog/testing/setup-testing/references/test-tool-unit.md +41 -0
- package/package.json +34 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +16 -0
- package/src/index.js.map +1 -0
- package/src/loader.d.ts +46 -0
- package/src/loader.js +75 -0
- package/src/loader.js.map +1 -0
- package/src/manifest.d.ts +81 -0
- package/src/manifest.js +26 -0
- package/src/manifest.js.map +1 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deploy-to-lambda
|
|
3
|
+
description: Deploy a FrontMCP server to AWS Lambda with API Gateway. Use when deploying to AWS, setting up SAM or CDK, or configuring Lambda handlers.
|
|
4
|
+
tags:
|
|
5
|
+
- deployment
|
|
6
|
+
- lambda
|
|
7
|
+
- aws
|
|
8
|
+
- serverless
|
|
9
|
+
parameters:
|
|
10
|
+
- name: runtime
|
|
11
|
+
description: AWS Lambda runtime version
|
|
12
|
+
type: string
|
|
13
|
+
required: false
|
|
14
|
+
default: nodejs22.x
|
|
15
|
+
- name: memory
|
|
16
|
+
description: Lambda function memory in MB
|
|
17
|
+
type: number
|
|
18
|
+
required: false
|
|
19
|
+
default: 512
|
|
20
|
+
- name: timeout
|
|
21
|
+
description: Lambda function timeout in seconds
|
|
22
|
+
type: number
|
|
23
|
+
required: false
|
|
24
|
+
default: 30
|
|
25
|
+
- name: region
|
|
26
|
+
description: AWS region for deployment
|
|
27
|
+
type: string
|
|
28
|
+
required: false
|
|
29
|
+
default: us-east-1
|
|
30
|
+
examples:
|
|
31
|
+
- scenario: Deploy with SAM
|
|
32
|
+
parameters:
|
|
33
|
+
memory: 512
|
|
34
|
+
timeout: 30
|
|
35
|
+
region: us-east-1
|
|
36
|
+
expected-outcome: A FrontMCP server deployed as an AWS Lambda function behind API Gateway, managed by SAM.
|
|
37
|
+
- scenario: Deploy with CDK
|
|
38
|
+
parameters:
|
|
39
|
+
memory: 1024
|
|
40
|
+
timeout: 60
|
|
41
|
+
region: eu-west-1
|
|
42
|
+
expected-outcome: A FrontMCP server deployed via AWS CDK with API Gateway and Lambda.
|
|
43
|
+
compatibility: AWS CLI and SAM CLI required
|
|
44
|
+
license: Apache-2.0
|
|
45
|
+
visibility: both
|
|
46
|
+
priority: 10
|
|
47
|
+
metadata:
|
|
48
|
+
category: deployment
|
|
49
|
+
difficulty: advanced
|
|
50
|
+
platform: aws
|
|
51
|
+
docs: https://docs.agentfront.dev/frontmcp/deployment/serverless
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
# Deploy a FrontMCP Server to AWS Lambda
|
|
55
|
+
|
|
56
|
+
This skill walks you through deploying a FrontMCP server to AWS Lambda with API Gateway using SAM or CDK.
|
|
57
|
+
|
|
58
|
+
## Prerequisites
|
|
59
|
+
|
|
60
|
+
- AWS account with appropriate IAM permissions
|
|
61
|
+
- AWS CLI configured: `aws configure`
|
|
62
|
+
- SAM CLI installed: `brew install aws-sam-cli` (macOS) or see AWS docs
|
|
63
|
+
- Node.js 22 or later
|
|
64
|
+
- A FrontMCP project ready to build
|
|
65
|
+
|
|
66
|
+
## Step 1: Build for Lambda
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
frontmcp build --target lambda
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This produces a Lambda-compatible output with a single handler file optimized for cold-start performance, minimized bundle size with tree-shaking, and a `template.yaml` scaffold for SAM.
|
|
73
|
+
|
|
74
|
+
## Step 2: SAM Template
|
|
75
|
+
|
|
76
|
+
Create `template.yaml` in your project root:
|
|
77
|
+
|
|
78
|
+
```yaml
|
|
79
|
+
AWSTemplateFormatVersion: '2010-09-09'
|
|
80
|
+
Transform: AWS::Serverless-2016-10-31
|
|
81
|
+
Description: FrontMCP server on AWS Lambda
|
|
82
|
+
|
|
83
|
+
Globals:
|
|
84
|
+
Function:
|
|
85
|
+
Timeout: 30
|
|
86
|
+
Runtime: nodejs22.x
|
|
87
|
+
MemorySize: 512
|
|
88
|
+
Environment:
|
|
89
|
+
Variables:
|
|
90
|
+
NODE_ENV: production
|
|
91
|
+
LOG_LEVEL: info
|
|
92
|
+
|
|
93
|
+
Resources:
|
|
94
|
+
FrontMcpFunction:
|
|
95
|
+
Type: AWS::Serverless::Function
|
|
96
|
+
Properties:
|
|
97
|
+
Handler: dist/lambda.handler
|
|
98
|
+
CodeUri: .
|
|
99
|
+
Description: FrontMCP MCP server
|
|
100
|
+
Architectures:
|
|
101
|
+
- arm64
|
|
102
|
+
Events:
|
|
103
|
+
McpApi:
|
|
104
|
+
Type: HttpApi
|
|
105
|
+
Properties:
|
|
106
|
+
Path: /{proxy+}
|
|
107
|
+
Method: ANY
|
|
108
|
+
HealthCheck:
|
|
109
|
+
Type: HttpApi
|
|
110
|
+
Properties:
|
|
111
|
+
Path: /health
|
|
112
|
+
Method: GET
|
|
113
|
+
Environment:
|
|
114
|
+
Variables:
|
|
115
|
+
REDIS_URL: !If
|
|
116
|
+
- HasRedis
|
|
117
|
+
- !Ref RedisUrl
|
|
118
|
+
- ''
|
|
119
|
+
Policies:
|
|
120
|
+
- AWSLambdaBasicExecutionRole
|
|
121
|
+
|
|
122
|
+
FrontMcpLogGroup:
|
|
123
|
+
Type: AWS::Logs::LogGroup
|
|
124
|
+
Properties:
|
|
125
|
+
LogGroupName: !Sub /aws/lambda/${FrontMcpFunction}
|
|
126
|
+
RetentionInDays: 14
|
|
127
|
+
|
|
128
|
+
Conditions:
|
|
129
|
+
HasRedis: !Not [!Equals [!Ref RedisUrl, '']]
|
|
130
|
+
|
|
131
|
+
Parameters:
|
|
132
|
+
RedisUrl:
|
|
133
|
+
Type: String
|
|
134
|
+
Default: ''
|
|
135
|
+
Description: Redis connection URL for session storage
|
|
136
|
+
|
|
137
|
+
Outputs:
|
|
138
|
+
ApiEndpoint:
|
|
139
|
+
Description: API Gateway endpoint URL
|
|
140
|
+
Value: !Sub 'https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com'
|
|
141
|
+
FunctionArn:
|
|
142
|
+
Description: Lambda function ARN
|
|
143
|
+
Value: !GetAtt FrontMcpFunction.Arn
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Step 3: API Gateway
|
|
147
|
+
|
|
148
|
+
SAM automatically creates an HTTP API (API Gateway v2) from the `Events` block. The `/{proxy+}` route catches all paths and forwards them to FrontMCP's internal router.
|
|
149
|
+
|
|
150
|
+
For more control, define the API explicitly:
|
|
151
|
+
|
|
152
|
+
```yaml
|
|
153
|
+
Resources:
|
|
154
|
+
FrontMcpApi:
|
|
155
|
+
Type: AWS::Serverless::HttpApi
|
|
156
|
+
Properties:
|
|
157
|
+
StageName: prod
|
|
158
|
+
CorsConfiguration:
|
|
159
|
+
AllowOrigins:
|
|
160
|
+
- 'https://your-domain.com'
|
|
161
|
+
AllowMethods:
|
|
162
|
+
- GET
|
|
163
|
+
- POST
|
|
164
|
+
- OPTIONS
|
|
165
|
+
AllowHeaders:
|
|
166
|
+
- Content-Type
|
|
167
|
+
- Authorization
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Step 4: Handler Configuration
|
|
171
|
+
|
|
172
|
+
FrontMCP generates a Lambda handler at `dist/lambda.handler` during the build step. To customize the handler, create a `lambda.ts` entry point:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import { createLambdaHandler } from '@frontmcp/adapters/lambda';
|
|
176
|
+
import { AppModule } from './app.module';
|
|
177
|
+
|
|
178
|
+
export const handler = createLambdaHandler(AppModule, {
|
|
179
|
+
streaming: false,
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Step 5: Environment Variables
|
|
184
|
+
|
|
185
|
+
Configure environment variables in the SAM template or set them after deployment:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
aws lambda update-function-configuration \
|
|
189
|
+
--function-name FrontMcpFunction \
|
|
190
|
+
--environment "Variables={NODE_ENV=production,LOG_LEVEL=info,REDIS_URL=redis://your-redis:6379}"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
| Variable | Description | Required |
|
|
194
|
+
| ---------------------- | ----------------------------------- | ----------------- |
|
|
195
|
+
| `NODE_ENV` | Runtime environment | Yes |
|
|
196
|
+
| `REDIS_URL` | Redis/ElastiCache connection string | If using sessions |
|
|
197
|
+
| `LOG_LEVEL` | Logging verbosity | No |
|
|
198
|
+
| `FRONTMCP_AUTH_SECRET` | Secret for signing auth tokens | If using auth |
|
|
199
|
+
|
|
200
|
+
For sensitive values, use AWS Systems Manager Parameter Store or Secrets Manager:
|
|
201
|
+
|
|
202
|
+
```yaml
|
|
203
|
+
Environment:
|
|
204
|
+
Variables:
|
|
205
|
+
FRONTMCP_AUTH_SECRET: !Sub '{{resolve:ssm:/frontmcp/auth-secret}}'
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Step 6: Deploy
|
|
209
|
+
|
|
210
|
+
### First Deployment (Guided)
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
sam build
|
|
214
|
+
sam deploy --guided
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The guided deployment prompts for stack name, region, and parameter overrides. Answers are saved in `samconfig.toml` for subsequent deploys.
|
|
218
|
+
|
|
219
|
+
### Subsequent Deployments
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
sam build && sam deploy
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### CDK Alternative
|
|
226
|
+
|
|
227
|
+
If you prefer AWS CDK over SAM:
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
import * as cdk from 'aws-cdk-lib';
|
|
231
|
+
import * as lambda from 'aws-cdk-lib/aws-lambda';
|
|
232
|
+
import * as apigw from 'aws-cdk-lib/aws-apigatewayv2';
|
|
233
|
+
import * as integrations from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
234
|
+
|
|
235
|
+
const fn = new lambda.Function(this, 'FrontMcpHandler', {
|
|
236
|
+
runtime: lambda.Runtime.NODEJS_22_X,
|
|
237
|
+
handler: 'dist/lambda.handler',
|
|
238
|
+
code: lambda.Code.fromAsset('.'),
|
|
239
|
+
memorySize: 512,
|
|
240
|
+
timeout: cdk.Duration.seconds(30),
|
|
241
|
+
architecture: lambda.Architecture.ARM_64,
|
|
242
|
+
environment: {
|
|
243
|
+
NODE_ENV: 'production',
|
|
244
|
+
LOG_LEVEL: 'info',
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const api = new apigw.HttpApi(this, 'FrontMcpApi', {
|
|
249
|
+
defaultIntegration: new integrations.HttpLambdaIntegration('LambdaIntegration', fn),
|
|
250
|
+
});
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Deploy with:
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
cdk deploy
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Step 7: Verify
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
# Get the endpoint from stack outputs
|
|
263
|
+
aws cloudformation describe-stacks \
|
|
264
|
+
--stack-name frontmcp-prod \
|
|
265
|
+
--query "Stacks[0].Outputs[?OutputKey=='ApiEndpoint'].OutputValue" \
|
|
266
|
+
--output text
|
|
267
|
+
|
|
268
|
+
# Health check
|
|
269
|
+
curl https://abc123.execute-api.us-east-1.amazonaws.com/health
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Cold Start Mitigation
|
|
273
|
+
|
|
274
|
+
Lambda cold starts occur when a new execution environment is initialized. Strategies to reduce their impact:
|
|
275
|
+
|
|
276
|
+
1. **Provisioned Concurrency** -- pre-warms execution environments (incurs cost when idle):
|
|
277
|
+
|
|
278
|
+
```yaml
|
|
279
|
+
FrontMcpFunction:
|
|
280
|
+
Properties:
|
|
281
|
+
ProvisionedConcurrencyConfig:
|
|
282
|
+
ProvisionedConcurrentExecutions: 5
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
2. **Small bundles** -- the `frontmcp build --target lambda` output is already optimized, but audit your dependencies.
|
|
286
|
+
|
|
287
|
+
3. **ARM64 runtime** -- ARM functions initialize faster than x86. The template uses `arm64` by default.
|
|
288
|
+
|
|
289
|
+
4. **Higher memory** -- CPU scales proportionally with memory. 512 MB or 1024 MB is a good starting point.
|
|
290
|
+
|
|
291
|
+
### Typical Cold Start Times
|
|
292
|
+
|
|
293
|
+
| Memory | Cold Start (ARM64) | Cold Start (x86) |
|
|
294
|
+
| ------- | ------------------ | ---------------- |
|
|
295
|
+
| 256 MB | ~800ms | ~1000ms |
|
|
296
|
+
| 512 MB | ~500ms | ~700ms |
|
|
297
|
+
| 1024 MB | ~350ms | ~500ms |
|
|
298
|
+
|
|
299
|
+
## Troubleshooting
|
|
300
|
+
|
|
301
|
+
- **Timeout errors**: Increase `Timeout` in the SAM template. Check if the function is waiting on an unreachable resource.
|
|
302
|
+
- **502 Bad Gateway**: Check CloudWatch logs. Common causes: handler path mismatch, missing environment variables, unhandled exceptions.
|
|
303
|
+
- **Cold starts too slow**: Increase memory allocation, use ARM64, or enable provisioned concurrency.
|
|
304
|
+
- **Redis from Lambda**: Place the Lambda function in the same VPC as your ElastiCache cluster with appropriate security groups.
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deploy-to-node
|
|
3
|
+
description: Deploy a FrontMCP server as a standalone Node.js application with Docker. Use when deploying to a VPS, Docker, or bare metal server.
|
|
4
|
+
tags:
|
|
5
|
+
- deployment
|
|
6
|
+
- node
|
|
7
|
+
- docker
|
|
8
|
+
- production
|
|
9
|
+
parameters:
|
|
10
|
+
- name: port
|
|
11
|
+
description: The port number the server will listen on
|
|
12
|
+
type: number
|
|
13
|
+
required: false
|
|
14
|
+
default: 3000
|
|
15
|
+
examples:
|
|
16
|
+
- scenario: Deploy with Docker Compose
|
|
17
|
+
parameters:
|
|
18
|
+
port: 3000
|
|
19
|
+
expected-outcome: A FrontMCP server running inside a Docker container orchestrated by Docker Compose, with Redis for session storage and automatic restarts on failure.
|
|
20
|
+
- scenario: Deploy to bare metal with PM2
|
|
21
|
+
parameters:
|
|
22
|
+
port: 8080
|
|
23
|
+
expected-outcome: A FrontMCP server running directly on the host machine under PM2, listening on port 8080 with NGINX as a reverse proxy.
|
|
24
|
+
compatibility: Node.js 22+, Docker recommended
|
|
25
|
+
license: Apache-2.0
|
|
26
|
+
visibility: both
|
|
27
|
+
priority: 10
|
|
28
|
+
metadata:
|
|
29
|
+
category: deployment
|
|
30
|
+
difficulty: intermediate
|
|
31
|
+
docs: https://docs.agentfront.dev/frontmcp/deployment/production-build
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
# Deploy a FrontMCP Server to Node.js
|
|
35
|
+
|
|
36
|
+
This skill walks you through deploying a FrontMCP server as a standalone Node.js application, optionally containerized with Docker for production use.
|
|
37
|
+
|
|
38
|
+
## Prerequisites
|
|
39
|
+
|
|
40
|
+
- Node.js 22 or later
|
|
41
|
+
- Docker and Docker Compose (recommended for production)
|
|
42
|
+
- A FrontMCP project ready to build
|
|
43
|
+
|
|
44
|
+
## Step 1: Build the Server
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
frontmcp build --target node
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
This compiles your TypeScript source, bundles dependencies, and produces a production-ready output in `dist/`. The build output includes compiled JavaScript optimized for Node.js, a `package.json` with production dependencies only, and any static assets.
|
|
51
|
+
|
|
52
|
+
## Step 2: Dockerfile (Multi-Stage)
|
|
53
|
+
|
|
54
|
+
Create a multi-stage `Dockerfile` in your project root:
|
|
55
|
+
|
|
56
|
+
```dockerfile
|
|
57
|
+
# Stage 1: Build
|
|
58
|
+
FROM node:22-alpine AS builder
|
|
59
|
+
WORKDIR /app
|
|
60
|
+
COPY package.json yarn.lock ./
|
|
61
|
+
RUN yarn install --frozen-lockfile
|
|
62
|
+
COPY . .
|
|
63
|
+
RUN npx frontmcp build --target node
|
|
64
|
+
|
|
65
|
+
# Stage 2: Production
|
|
66
|
+
FROM node:22-alpine AS production
|
|
67
|
+
WORKDIR /app
|
|
68
|
+
ENV NODE_ENV=production
|
|
69
|
+
COPY --from=builder /app/dist ./dist
|
|
70
|
+
COPY --from=builder /app/package.json ./
|
|
71
|
+
RUN yarn install --frozen-lockfile --production && yarn cache clean
|
|
72
|
+
EXPOSE 3000
|
|
73
|
+
HEALTHCHECK --interval=30s --timeout=5s --retries=3 --start-period=10s \
|
|
74
|
+
CMD wget -qO- http://localhost:3000/health || exit 1
|
|
75
|
+
CMD ["node", "dist/main.js"]
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The first stage installs all dependencies and builds the project. The second stage copies only the compiled output and production dependencies into a slim image.
|
|
79
|
+
|
|
80
|
+
## Step 3: Docker Compose with Redis
|
|
81
|
+
|
|
82
|
+
Create a `docker-compose.yml` for a complete deployment with Redis:
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
version: '3.9'
|
|
86
|
+
|
|
87
|
+
services:
|
|
88
|
+
frontmcp:
|
|
89
|
+
build:
|
|
90
|
+
context: .
|
|
91
|
+
dockerfile: Dockerfile
|
|
92
|
+
ports:
|
|
93
|
+
- '${PORT:-3000}:3000'
|
|
94
|
+
environment:
|
|
95
|
+
- NODE_ENV=production
|
|
96
|
+
- PORT=3000
|
|
97
|
+
- REDIS_URL=redis://redis:6379
|
|
98
|
+
- LOG_LEVEL=info
|
|
99
|
+
depends_on:
|
|
100
|
+
redis:
|
|
101
|
+
condition: service_healthy
|
|
102
|
+
restart: unless-stopped
|
|
103
|
+
healthcheck:
|
|
104
|
+
test: ['CMD', 'wget', '-qO-', 'http://localhost:3000/health']
|
|
105
|
+
interval: 30s
|
|
106
|
+
timeout: 5s
|
|
107
|
+
retries: 3
|
|
108
|
+
start_period: 10s
|
|
109
|
+
|
|
110
|
+
redis:
|
|
111
|
+
image: redis:7-alpine
|
|
112
|
+
volumes:
|
|
113
|
+
- redis-data:/data
|
|
114
|
+
healthcheck:
|
|
115
|
+
test: ['CMD', 'redis-cli', 'ping']
|
|
116
|
+
interval: 10s
|
|
117
|
+
timeout: 3s
|
|
118
|
+
retries: 5
|
|
119
|
+
restart: unless-stopped
|
|
120
|
+
|
|
121
|
+
volumes:
|
|
122
|
+
redis-data:
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Deploy with:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
docker compose up -d
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Step 4: Environment Variables
|
|
132
|
+
|
|
133
|
+
Create a `.env` file or set variables in your deployment environment:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# Server
|
|
137
|
+
PORT=3000
|
|
138
|
+
NODE_ENV=production
|
|
139
|
+
HOST=0.0.0.0
|
|
140
|
+
|
|
141
|
+
# Redis (required for session storage in production)
|
|
142
|
+
REDIS_URL=redis://localhost:6379
|
|
143
|
+
|
|
144
|
+
# Logging
|
|
145
|
+
LOG_LEVEL=info
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
| Variable | Description | Default |
|
|
149
|
+
| ----------- | ----------------------------------- | ------------- |
|
|
150
|
+
| `PORT` | HTTP port for the server | `3000` |
|
|
151
|
+
| `NODE_ENV` | Runtime environment | `development` |
|
|
152
|
+
| `REDIS_URL` | Redis connection string for storage | (none) |
|
|
153
|
+
| `HOST` | Network interface to bind | `0.0.0.0` |
|
|
154
|
+
| `LOG_LEVEL` | Logging verbosity | `info` |
|
|
155
|
+
|
|
156
|
+
## Step 5: Health Checks
|
|
157
|
+
|
|
158
|
+
FrontMCP servers expose a `/health` endpoint by default:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
curl http://localhost:3000/health
|
|
162
|
+
# Response: { "status": "ok", "uptime": 12345 }
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
For Docker, the `HEALTHCHECK` directive in the Dockerfile and the `healthcheck` block in Compose handle this automatically. Point your load balancer or orchestrator at this endpoint for liveness checks.
|
|
166
|
+
|
|
167
|
+
## Step 6: PM2 for Bare Metal
|
|
168
|
+
|
|
169
|
+
When running without Docker, use PM2 as a process manager:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
# Install PM2 globally
|
|
173
|
+
npm install -g pm2
|
|
174
|
+
|
|
175
|
+
# Start the server with cluster mode (one instance per CPU core)
|
|
176
|
+
pm2 start dist/main.js --name frontmcp-server -i max
|
|
177
|
+
|
|
178
|
+
# Save the process list for auto-restart on reboot
|
|
179
|
+
pm2 save
|
|
180
|
+
pm2 startup
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
The `-i max` flag runs one instance per CPU core for optimal throughput.
|
|
184
|
+
|
|
185
|
+
## Step 7: NGINX Reverse Proxy
|
|
186
|
+
|
|
187
|
+
Place NGINX in front of the server for TLS termination:
|
|
188
|
+
|
|
189
|
+
```nginx
|
|
190
|
+
server {
|
|
191
|
+
listen 443 ssl;
|
|
192
|
+
server_name mcp.example.com;
|
|
193
|
+
|
|
194
|
+
ssl_certificate /etc/ssl/certs/mcp.example.com.pem;
|
|
195
|
+
ssl_certificate_key /etc/ssl/private/mcp.example.com.key;
|
|
196
|
+
|
|
197
|
+
location / {
|
|
198
|
+
proxy_pass http://127.0.0.1:3000;
|
|
199
|
+
proxy_set_header Host $host;
|
|
200
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
201
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
202
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Resource Limits
|
|
208
|
+
|
|
209
|
+
Set appropriate limits in Docker Compose for production:
|
|
210
|
+
|
|
211
|
+
```yaml
|
|
212
|
+
services:
|
|
213
|
+
frontmcp:
|
|
214
|
+
deploy:
|
|
215
|
+
resources:
|
|
216
|
+
limits:
|
|
217
|
+
memory: 512M
|
|
218
|
+
cpus: '1.0'
|
|
219
|
+
reservations:
|
|
220
|
+
memory: 256M
|
|
221
|
+
cpus: '0.5'
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Troubleshooting
|
|
225
|
+
|
|
226
|
+
- **Port already in use**: Change the `PORT` environment variable or stop the conflicting process.
|
|
227
|
+
- **Redis connection refused**: Verify Redis is running and `REDIS_URL` is correct. In Docker Compose, use the service name (`redis`) as the hostname.
|
|
228
|
+
- **Health check failing**: Increase `start_period` in the health check configuration to give the server more startup time.
|
|
229
|
+
- **Out of memory**: Increase the memory limit in Docker or use `NODE_OPTIONS="--max-old-space-size=1024" node dist/main.js`.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# ---- Build Stage ----
|
|
2
|
+
FROM node:22-alpine AS builder
|
|
3
|
+
|
|
4
|
+
WORKDIR /app
|
|
5
|
+
|
|
6
|
+
# Install dependencies first for better layer caching
|
|
7
|
+
COPY package.json yarn.lock ./
|
|
8
|
+
RUN yarn install --frozen-lockfile
|
|
9
|
+
|
|
10
|
+
# Copy source and build
|
|
11
|
+
COPY . .
|
|
12
|
+
RUN yarn frontmcp build --target node
|
|
13
|
+
|
|
14
|
+
# ---- Production Stage ----
|
|
15
|
+
FROM node:22-alpine AS production
|
|
16
|
+
|
|
17
|
+
WORKDIR /app
|
|
18
|
+
|
|
19
|
+
# Create non-root user for security
|
|
20
|
+
RUN addgroup -S frontmcp && adduser -S frontmcp -G frontmcp
|
|
21
|
+
|
|
22
|
+
# Copy only production artifacts
|
|
23
|
+
COPY --from=builder /app/dist ./dist
|
|
24
|
+
COPY --from=builder /app/package.json ./
|
|
25
|
+
COPY --from=builder /app/yarn.lock ./
|
|
26
|
+
|
|
27
|
+
# Install production dependencies only
|
|
28
|
+
RUN yarn install --frozen-lockfile --production && \
|
|
29
|
+
yarn cache clean
|
|
30
|
+
|
|
31
|
+
# Set ownership
|
|
32
|
+
RUN chown -R frontmcp:frontmcp /app
|
|
33
|
+
|
|
34
|
+
USER frontmcp
|
|
35
|
+
|
|
36
|
+
# Environment defaults
|
|
37
|
+
ENV NODE_ENV=production
|
|
38
|
+
ENV PORT=3000
|
|
39
|
+
|
|
40
|
+
EXPOSE 3000
|
|
41
|
+
|
|
42
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
43
|
+
CMD wget --no-verbose --tries=1 --spider http://localhost:3000/health || exit 1
|
|
44
|
+
|
|
45
|
+
CMD ["node", "dist/main.js"]
|