@172ai/containers-mcp-server 1.0.27 → 1.2.0
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/dist/server.d.ts +20 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +599 -1
- package/dist/server.js.map +1 -1
- package/dist/services/buildService.d.ts.map +1 -1
- package/dist/services/buildService.js +26 -2
- package/dist/services/buildService.js.map +1 -1
- package/dist/services/containerService.d.ts.map +1 -1
- package/dist/services/containerService.js +16 -2
- package/dist/services/containerService.js.map +1 -1
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/enhancedErrorHandler.d.ts +114 -0
- package/dist/utils/enhancedErrorHandler.d.ts.map +1 -0
- package/dist/utils/enhancedErrorHandler.js +469 -0
- package/dist/utils/enhancedErrorHandler.js.map +1 -0
- package/package.json +2 -2
package/dist/server.d.ts
CHANGED
|
@@ -16,6 +16,10 @@ declare class ContainerMCPServer {
|
|
|
16
16
|
* Set up container management tools
|
|
17
17
|
*/
|
|
18
18
|
private setupContainerTools;
|
|
19
|
+
/**
|
|
20
|
+
* Get container development workflow prompts
|
|
21
|
+
*/
|
|
22
|
+
private getContainerWorkflowPrompts;
|
|
19
23
|
/**
|
|
20
24
|
* Get all available tools
|
|
21
25
|
*/
|
|
@@ -68,6 +72,22 @@ declare class ContainerMCPServer {
|
|
|
68
72
|
private handleGetExecutionHistory;
|
|
69
73
|
private handleGetCostEstimate;
|
|
70
74
|
private handleGetExtensionCostEstimate;
|
|
75
|
+
/**
|
|
76
|
+
* Get container development workflow content
|
|
77
|
+
*/
|
|
78
|
+
private getContainerDevelopmentWorkflowContent;
|
|
79
|
+
/**
|
|
80
|
+
* Get container debugging workflow content
|
|
81
|
+
*/
|
|
82
|
+
private getContainerDebuggingWorkflowContent;
|
|
83
|
+
/**
|
|
84
|
+
* Get container deployment workflow content
|
|
85
|
+
*/
|
|
86
|
+
private getContainerDeploymentWorkflowContent;
|
|
87
|
+
/**
|
|
88
|
+
* Get container best practices content
|
|
89
|
+
*/
|
|
90
|
+
private getContainerBestPracticesContent;
|
|
71
91
|
/**
|
|
72
92
|
* Start the MCP server
|
|
73
93
|
*/
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAwBA;;;;;GAKG;AACH,cAAM,kBAAkB;IACtB,OAAO,CAAC,MAAM,CAAS;;IAcvB;;OAEG;IACH,OAAO,CAAC,UAAU;IAiBlB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAyH3B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IAkFnC;;OAEG;IACH,OAAO,CAAC,WAAW;IAspBnB;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAI3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;YAoBZ,oBAAoB;YAmBpB,kBAAkB;YAoBlB,qBAAqB;YAerB,qBAAqB;YAcrB,qBAAqB;YAYrB,mBAAmB;YAcnB,oBAAoB;YAepB,oBAAoB;YAmBpB,gBAAgB;YAmBhB,kBAAkB;YAclB,wBAAwB;YAkBxB,oBAAoB;YAiBpB,gBAAgB;YAgBhB,gBAAgB;YAgBhB,gBAAgB;YAYhB,sBAAsB;YAmBtB,mBAAmB;YAmBnB,wBAAwB;YAkBxB,oBAAoB;YAmBpB,mBAAmB;YAcnB,wBAAwB;YAuBxB,oBAAoB;YAwBpB,0BAA0B;YAmB1B,sBAAsB;YAiBtB,qBAAqB;YAcrB,yBAAyB;YAuBzB,qBAAqB;YAyBrB,8BAA8B;IAwB5C;;OAEG;IACH,OAAO,CAAC,sCAAsC;IA0F9C;;OAEG;IACH,OAAO,CAAC,oCAAoC;IAgG5C;;OAEG;IACH,OAAO,CAAC,qCAAqC;IA8H7C;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAqLxC;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAyB7B;AAID,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -57,9 +57,25 @@ class ContainerMCPServer {
|
|
|
57
57
|
// Handle prompts/list requests
|
|
58
58
|
this.server.setRequestHandler(types_js_1.ListPromptsRequestSchema, async () => {
|
|
59
59
|
return {
|
|
60
|
-
prompts:
|
|
60
|
+
prompts: this.getContainerWorkflowPrompts(),
|
|
61
61
|
};
|
|
62
62
|
});
|
|
63
|
+
// Handle prompts/get requests
|
|
64
|
+
this.server.setRequestHandler(types_js_1.GetPromptRequestSchema, async (request) => {
|
|
65
|
+
const { name, arguments: args } = request.params;
|
|
66
|
+
switch (name) {
|
|
67
|
+
case 'container_development_workflow':
|
|
68
|
+
return this.getContainerDevelopmentWorkflowContent(args);
|
|
69
|
+
case 'container_debugging_workflow':
|
|
70
|
+
return this.getContainerDebuggingWorkflowContent(args);
|
|
71
|
+
case 'container_deployment_workflow':
|
|
72
|
+
return this.getContainerDeploymentWorkflowContent(args);
|
|
73
|
+
case 'container_best_practices':
|
|
74
|
+
return this.getContainerBestPracticesContent();
|
|
75
|
+
default:
|
|
76
|
+
throw errorHandler_js_1.ErrorHandler.createValidationError(`Unknown prompt: ${name}`);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
63
79
|
// Handle resources/list requests
|
|
64
80
|
this.server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => {
|
|
65
81
|
return {
|
|
@@ -145,6 +161,90 @@ class ContainerMCPServer {
|
|
|
145
161
|
}
|
|
146
162
|
});
|
|
147
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Get container development workflow prompts
|
|
166
|
+
*/
|
|
167
|
+
getContainerWorkflowPrompts() {
|
|
168
|
+
return [
|
|
169
|
+
{
|
|
170
|
+
name: "container_development_workflow",
|
|
171
|
+
title: "Complete Container Development Workflow",
|
|
172
|
+
description: "Step-by-step guide for creating, building, and deploying containers from customer requirements",
|
|
173
|
+
arguments: [
|
|
174
|
+
{
|
|
175
|
+
name: "customer_request",
|
|
176
|
+
description: "The customer's requirements for the container application",
|
|
177
|
+
required: true
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "application_type",
|
|
181
|
+
description: "Type of application (web app, API service, worker, CLI tool, etc.)",
|
|
182
|
+
required: false
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "programming_language",
|
|
186
|
+
description: "Preferred programming language (if any)",
|
|
187
|
+
required: false
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
name: "framework",
|
|
191
|
+
description: "Preferred framework or technology stack (if any)",
|
|
192
|
+
required: false
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: "container_debugging_workflow",
|
|
198
|
+
title: "Container Build & Runtime Debugging",
|
|
199
|
+
description: "Troubleshooting guide for container build failures and runtime errors",
|
|
200
|
+
arguments: [
|
|
201
|
+
{
|
|
202
|
+
name: "container_id",
|
|
203
|
+
description: "ID of the container experiencing issues",
|
|
204
|
+
required: true
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "error_type",
|
|
208
|
+
description: "Type of error (build_failure, runtime_error, deployment_error)",
|
|
209
|
+
required: true
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: "error_message",
|
|
213
|
+
description: "The specific error message or log output",
|
|
214
|
+
required: false
|
|
215
|
+
}
|
|
216
|
+
]
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: "container_deployment_workflow",
|
|
220
|
+
title: "Container Deployment & Monitoring",
|
|
221
|
+
description: "Best practices for deploying containers and monitoring their execution",
|
|
222
|
+
arguments: [
|
|
223
|
+
{
|
|
224
|
+
name: "container_id",
|
|
225
|
+
description: "ID of the container to deploy",
|
|
226
|
+
required: true
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: "deployment_environment",
|
|
230
|
+
description: "Target deployment environment (development, staging, production)",
|
|
231
|
+
required: false
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "resource_requirements",
|
|
235
|
+
description: "Expected CPU, memory, and duration requirements",
|
|
236
|
+
required: false
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: "container_best_practices",
|
|
242
|
+
title: "Container Development Best Practices",
|
|
243
|
+
description: "Guidelines and recommendations for creating high-quality, secure containers",
|
|
244
|
+
arguments: []
|
|
245
|
+
}
|
|
246
|
+
];
|
|
247
|
+
}
|
|
148
248
|
/**
|
|
149
249
|
* Get all available tools
|
|
150
250
|
*/
|
|
@@ -1305,6 +1405,504 @@ class ContainerMCPServer {
|
|
|
1305
1405
|
],
|
|
1306
1406
|
};
|
|
1307
1407
|
}
|
|
1408
|
+
/**
|
|
1409
|
+
* Get container development workflow content
|
|
1410
|
+
*/
|
|
1411
|
+
getContainerDevelopmentWorkflowContent(args) {
|
|
1412
|
+
const { customer_request, application_type, programming_language, framework } = args;
|
|
1413
|
+
return {
|
|
1414
|
+
messages: [
|
|
1415
|
+
{
|
|
1416
|
+
role: 'user',
|
|
1417
|
+
content: {
|
|
1418
|
+
type: 'text',
|
|
1419
|
+
text: `I need to create a container application. Here are the requirements:
|
|
1420
|
+
|
|
1421
|
+
**Customer Request:** ${customer_request}
|
|
1422
|
+
${application_type ? `**Application Type:** ${application_type}\n` : ''}${programming_language ? `**Programming Language:** ${programming_language}\n` : ''}${framework ? `**Framework/Stack:** ${framework}\n` : ''}
|
|
1423
|
+
|
|
1424
|
+
Please follow this comprehensive workflow to create, build, and deploy the container:
|
|
1425
|
+
|
|
1426
|
+
## Phase 1: Code Development & Local Files
|
|
1427
|
+
1. **Analyze Requirements**: Break down the customer request into specific features and technical requirements
|
|
1428
|
+
2. **Create Application Architecture**: Design the application structure and identify needed components
|
|
1429
|
+
3. **Write Application Code**: Create all necessary code files locally
|
|
1430
|
+
4. **Create Dockerfile**: Write an optimized, multi-stage Dockerfile following best practices
|
|
1431
|
+
5. **Prepare Supporting Files**: Create configuration files, requirements files, and documentation
|
|
1432
|
+
|
|
1433
|
+
## Phase 2: Container Creation & Setup
|
|
1434
|
+
6. **Create Container**: Use \`create_container\` tool with:
|
|
1435
|
+
- Descriptive name based on the application purpose
|
|
1436
|
+
- Short description (1-2 sentences)
|
|
1437
|
+
- Long description in Markdown with features, usage, and deployment notes
|
|
1438
|
+
- Relevant tags for discoverability
|
|
1439
|
+
- Appropriate capabilities based on application needs
|
|
1440
|
+
- Set private/public visibility as appropriate
|
|
1441
|
+
|
|
1442
|
+
7. **Upload Application Files**: Use \`upload_file\` tool to add all code files:
|
|
1443
|
+
- Upload Dockerfile first
|
|
1444
|
+
- Upload application code in logical order (main files first)
|
|
1445
|
+
- Upload configuration and support files
|
|
1446
|
+
- Verify uploads with \`list_container_files\`
|
|
1447
|
+
|
|
1448
|
+
8. **Configure Environment Variables**: Add environment variables one-by-one using \`update_container\`:
|
|
1449
|
+
- Database connections
|
|
1450
|
+
- API keys and secrets (use placeholders)
|
|
1451
|
+
- Configuration settings
|
|
1452
|
+
- Port numbers and service endpoints
|
|
1453
|
+
|
|
1454
|
+
## Phase 3: Build Process
|
|
1455
|
+
9. **Initiate Build**: Use \`build_container\` tool to start the container build
|
|
1456
|
+
10. **Monitor Build Progress**: Check build status every 15 seconds using \`get_build_status\`
|
|
1457
|
+
11. **Handle Build Errors**: If build fails:
|
|
1458
|
+
- Get detailed error logs with \`get_build_logs\`
|
|
1459
|
+
- Analyze error messages and identify issues
|
|
1460
|
+
- Update problematic files using \`update_file\`
|
|
1461
|
+
- Delete and re-upload fixed files if needed
|
|
1462
|
+
- Restart build process
|
|
1463
|
+
- Repeat until build succeeds
|
|
1464
|
+
|
|
1465
|
+
## Phase 4: Deployment & Testing
|
|
1466
|
+
12. **Start Container Execution**: Use \`start_execution\` with appropriate duration and resource settings
|
|
1467
|
+
13. **Monitor Execution**: Check execution status and logs using \`get_execution_status\` and \`get_execution_logs\`
|
|
1468
|
+
14. **Handle Runtime Errors**: If execution fails:
|
|
1469
|
+
- Analyze execution logs for runtime issues
|
|
1470
|
+
- Update code files to fix runtime problems
|
|
1471
|
+
- Rebuild the container (repeat Phase 3)
|
|
1472
|
+
- Restart execution
|
|
1473
|
+
- Test functionality through the provided access URL
|
|
1474
|
+
|
|
1475
|
+
## Phase 5: Validation & Documentation
|
|
1476
|
+
15. **Functional Testing**: Verify all features work as expected
|
|
1477
|
+
16. **Performance Testing**: Check resource usage and performance
|
|
1478
|
+
17. **Security Review**: Ensure no secrets are exposed and security best practices are followed
|
|
1479
|
+
18. **Update Documentation**: Enhance container description with deployment notes and usage examples
|
|
1480
|
+
|
|
1481
|
+
## Best Practices to Follow:
|
|
1482
|
+
- Use multi-stage builds to minimize image size
|
|
1483
|
+
- Set proper file permissions and use non-root users when possible
|
|
1484
|
+
- Include health checks in the Dockerfile
|
|
1485
|
+
- Use environment variables for configuration
|
|
1486
|
+
- Add comprehensive error handling and logging
|
|
1487
|
+
- Include proper documentation and examples
|
|
1488
|
+
- Tag containers appropriately for discoverability
|
|
1489
|
+
- Set resource limits based on application needs
|
|
1490
|
+
- Use secrets management for sensitive data
|
|
1491
|
+
- Include monitoring and observability features
|
|
1492
|
+
|
|
1493
|
+
Start with Phase 1 and work through each step systematically. Let me know if you encounter any issues or need clarification on any step.`
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
]
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Get container debugging workflow content
|
|
1501
|
+
*/
|
|
1502
|
+
getContainerDebuggingWorkflowContent(args) {
|
|
1503
|
+
const { container_id, error_type, error_message } = args;
|
|
1504
|
+
return {
|
|
1505
|
+
messages: [
|
|
1506
|
+
{
|
|
1507
|
+
role: 'user',
|
|
1508
|
+
content: {
|
|
1509
|
+
type: 'text',
|
|
1510
|
+
text: `Help me debug container issues for container ${container_id}.
|
|
1511
|
+
|
|
1512
|
+
**Error Type:** ${error_type}
|
|
1513
|
+
${error_message ? `**Error Message:** ${error_message}\n` : ''}
|
|
1514
|
+
|
|
1515
|
+
Please follow this systematic debugging workflow:
|
|
1516
|
+
|
|
1517
|
+
## Step 1: Gather Information
|
|
1518
|
+
1. **Get Container Details**: Use \`get_container\` to understand the current configuration
|
|
1519
|
+
2. **Check Build Status**: Use \`get_build_status\` to see the latest build information
|
|
1520
|
+
3. **Review Build Logs**: Use \`get_build_logs\` to analyze build output and errors
|
|
1521
|
+
4. **Check Execution Status**: Use \`get_execution_status\` if the container was deployed
|
|
1522
|
+
5. **Review Execution Logs**: Use \`get_execution_logs\` to see runtime error details
|
|
1523
|
+
|
|
1524
|
+
## Step 2: Identify Root Cause
|
|
1525
|
+
Based on the error type, focus on specific areas:
|
|
1526
|
+
|
|
1527
|
+
### Build Failures:
|
|
1528
|
+
- **Dockerfile Issues**: Syntax errors, invalid instructions, missing dependencies
|
|
1529
|
+
- **Code Compilation**: Language-specific build errors, missing packages
|
|
1530
|
+
- **File Permissions**: Incorrect file access or execution permissions
|
|
1531
|
+
- **Resource Limits**: Build process running out of memory or disk space
|
|
1532
|
+
- **Network Issues**: Package downloads or external service access failures
|
|
1533
|
+
|
|
1534
|
+
### Runtime Errors:
|
|
1535
|
+
- **Configuration Issues**: Missing or incorrect environment variables
|
|
1536
|
+
- **Dependency Problems**: Missing runtime libraries or incorrect versions
|
|
1537
|
+
- **Port Conflicts**: Application trying to bind to unavailable ports
|
|
1538
|
+
- **Permission Issues**: Application lacking required file or network permissions
|
|
1539
|
+
- **Resource Constraints**: Insufficient CPU, memory, or disk space
|
|
1540
|
+
|
|
1541
|
+
### Deployment Errors:
|
|
1542
|
+
- **Image Issues**: Corrupted or incomplete container image
|
|
1543
|
+
- **Network Problems**: Service discovery or external connectivity issues
|
|
1544
|
+
- **Health Check Failures**: Application not responding to health check endpoints
|
|
1545
|
+
- **Resource Allocation**: Insufficient cluster resources or quota limits
|
|
1546
|
+
|
|
1547
|
+
## Step 3: Fix Identified Issues
|
|
1548
|
+
1. **Update Code Files**: Use \`update_file\` to fix code issues
|
|
1549
|
+
2. **Modify Dockerfile**: Update container configuration and build instructions
|
|
1550
|
+
3. **Adjust Environment Variables**: Add or modify required environment settings
|
|
1551
|
+
4. **Update Dependencies**: Fix package versions or add missing dependencies
|
|
1552
|
+
5. **Improve Error Handling**: Add better logging and error management to code
|
|
1553
|
+
|
|
1554
|
+
## Step 4: Test Fixes
|
|
1555
|
+
1. **Rebuild Container**: Use \`build_container\` to create new image with fixes
|
|
1556
|
+
2. **Monitor Build**: Check \`get_build_status\` every 15 seconds until completion
|
|
1557
|
+
3. **Verify Build Success**: Ensure build completes without errors
|
|
1558
|
+
4. **Test Deployment**: Use \`start_execution\` to deploy updated container
|
|
1559
|
+
5. **Validate Functionality**: Test all features to ensure issues are resolved
|
|
1560
|
+
|
|
1561
|
+
## Step 5: Prevent Future Issues
|
|
1562
|
+
1. **Improve Documentation**: Update container description with troubleshooting notes
|
|
1563
|
+
2. **Add Health Checks**: Include comprehensive health monitoring
|
|
1564
|
+
3. **Enhance Logging**: Improve application logging for better debugging
|
|
1565
|
+
4. **Set Appropriate Resources**: Configure proper CPU, memory, and timeout settings
|
|
1566
|
+
5. **Add Monitoring**: Include metrics and alerting for proactive issue detection
|
|
1567
|
+
|
|
1568
|
+
## Common Issue Patterns:
|
|
1569
|
+
|
|
1570
|
+
### "Permission Denied" Errors:
|
|
1571
|
+
- Switch to non-root user in Dockerfile
|
|
1572
|
+
- Set proper file permissions (chmod)
|
|
1573
|
+
- Check if application needs specific capabilities
|
|
1574
|
+
|
|
1575
|
+
### "Cannot Connect" Errors:
|
|
1576
|
+
- Verify correct port configuration
|
|
1577
|
+
- Check firewall and network policies
|
|
1578
|
+
- Ensure services are listening on correct interfaces
|
|
1579
|
+
|
|
1580
|
+
### "Out of Memory" Errors:
|
|
1581
|
+
- Increase memory limits in execution settings
|
|
1582
|
+
- Optimize application memory usage
|
|
1583
|
+
- Use memory-efficient algorithms and data structures
|
|
1584
|
+
|
|
1585
|
+
### "Build Timeout" Errors:
|
|
1586
|
+
- Optimize Dockerfile for faster builds
|
|
1587
|
+
- Use build caches and multi-stage builds
|
|
1588
|
+
- Check for infinite loops or hanging processes
|
|
1589
|
+
|
|
1590
|
+
Start debugging systematically and let me know what you discover in each step.`
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
]
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
/**
|
|
1597
|
+
* Get container deployment workflow content
|
|
1598
|
+
*/
|
|
1599
|
+
getContainerDeploymentWorkflowContent(args) {
|
|
1600
|
+
const { container_id, deployment_environment, resource_requirements } = args;
|
|
1601
|
+
return {
|
|
1602
|
+
messages: [
|
|
1603
|
+
{
|
|
1604
|
+
role: 'user',
|
|
1605
|
+
content: {
|
|
1606
|
+
type: 'text',
|
|
1607
|
+
text: `Let's deploy container ${container_id} following deployment best practices.
|
|
1608
|
+
|
|
1609
|
+
${deployment_environment ? `**Target Environment:** ${deployment_environment}\n` : ''}${resource_requirements ? `**Resource Requirements:** ${resource_requirements}\n` : ''}
|
|
1610
|
+
|
|
1611
|
+
Follow this comprehensive deployment workflow:
|
|
1612
|
+
|
|
1613
|
+
## Phase 1: Pre-Deployment Validation
|
|
1614
|
+
1. **Verify Container Status**: Use \`get_container\` to review configuration
|
|
1615
|
+
2. **Check Build Status**: Ensure latest build completed successfully with \`get_build_status\`
|
|
1616
|
+
3. **Review Build Logs**: Verify no warnings or issues in \`get_build_logs\`
|
|
1617
|
+
4. **Validate Configuration**: Check environment variables and settings are appropriate
|
|
1618
|
+
5. **Security Audit**: Ensure no secrets are hardcoded and proper security practices
|
|
1619
|
+
|
|
1620
|
+
## Phase 2: Resource Planning
|
|
1621
|
+
6. **Get Cost Estimate**: Use \`get_cost_estimate\` with expected resource settings:
|
|
1622
|
+
- **Development**: CPU: 1, Memory: 1Gi, Duration: 1-3 days
|
|
1623
|
+
- **Testing/Staging**: CPU: 1-2, Memory: 2-4Gi, Duration: 3-7 days
|
|
1624
|
+
- **Production**: CPU: 2-4, Memory: 4-8Gi, Duration: 7-30 days
|
|
1625
|
+
|
|
1626
|
+
7. **Plan Duration**: Set appropriate runtime duration based on:
|
|
1627
|
+
- Development/testing: 1-3 days for quick iterations
|
|
1628
|
+
- Staging/demo: 3-7 days for extended testing
|
|
1629
|
+
- Production: 7-30 days for stable operations
|
|
1630
|
+
|
|
1631
|
+
## Phase 3: Deployment Execution
|
|
1632
|
+
8. **Configure Environment Variables**: Set deployment-specific variables:
|
|
1633
|
+
- Database URLs and connection strings
|
|
1634
|
+
- API endpoints and service URLs
|
|
1635
|
+
- Feature flags and configuration toggles
|
|
1636
|
+
- Monitoring and logging endpoints
|
|
1637
|
+
|
|
1638
|
+
9. **Start Execution**: Use \`start_execution\` with:
|
|
1639
|
+
- Appropriate duration for environment
|
|
1640
|
+
- Proper resource allocation (CPU/Memory)
|
|
1641
|
+
- Environment-specific variable overrides
|
|
1642
|
+
|
|
1643
|
+
10. **Monitor Startup**: Track deployment progress:
|
|
1644
|
+
- Check \`get_execution_status\` every 30 seconds initially
|
|
1645
|
+
- Monitor \`get_execution_progress\` for detailed startup phases
|
|
1646
|
+
- Review \`get_execution_logs\` for startup messages and errors
|
|
1647
|
+
|
|
1648
|
+
## Phase 4: Post-Deployment Validation
|
|
1649
|
+
11. **Health Checks**: Verify application is responding:
|
|
1650
|
+
- Test primary endpoints using the access URL
|
|
1651
|
+
- Verify database connections and external services
|
|
1652
|
+
- Check application metrics and performance indicators
|
|
1653
|
+
|
|
1654
|
+
12. **Functional Testing**: Validate core features:
|
|
1655
|
+
- Test all major user workflows
|
|
1656
|
+
- Verify API endpoints and data processing
|
|
1657
|
+
- Check integration with external systems
|
|
1658
|
+
|
|
1659
|
+
13. **Performance Testing**: Monitor resource usage:
|
|
1660
|
+
- Check CPU and memory utilization
|
|
1661
|
+
- Monitor response times and throughput
|
|
1662
|
+
- Verify application handles expected load
|
|
1663
|
+
|
|
1664
|
+
## Phase 5: Monitoring & Maintenance
|
|
1665
|
+
14. **Set Up Monitoring**: Track key metrics:
|
|
1666
|
+
- Application health and availability
|
|
1667
|
+
- Resource utilization trends
|
|
1668
|
+
- Error rates and performance metrics
|
|
1669
|
+
- User activity and business metrics
|
|
1670
|
+
|
|
1671
|
+
15. **Plan Maintenance**: Schedule ongoing tasks:
|
|
1672
|
+
- Regular health checks and status monitoring
|
|
1673
|
+
- Log review and analysis
|
|
1674
|
+
- Performance optimization opportunities
|
|
1675
|
+
- Security updates and patches
|
|
1676
|
+
|
|
1677
|
+
## Environment-Specific Considerations:
|
|
1678
|
+
|
|
1679
|
+
### Development Environment:
|
|
1680
|
+
- Use minimal resources (1 CPU, 1Gi RAM)
|
|
1681
|
+
- Enable debug logging and detailed error messages
|
|
1682
|
+
- Allow rapid iteration with shorter durations
|
|
1683
|
+
- Include development tools and debugging capabilities
|
|
1684
|
+
|
|
1685
|
+
### Staging Environment:
|
|
1686
|
+
- Mirror production resources but at smaller scale
|
|
1687
|
+
- Enable comprehensive logging and monitoring
|
|
1688
|
+
- Use production-like data volumes and load patterns
|
|
1689
|
+
- Test deployment procedures and rollback scenarios
|
|
1690
|
+
|
|
1691
|
+
### Production Environment:
|
|
1692
|
+
- Use appropriate resource allocation for expected load
|
|
1693
|
+
- Enable comprehensive monitoring and alerting
|
|
1694
|
+
- Implement proper backup and disaster recovery
|
|
1695
|
+
- Follow security hardening and compliance requirements
|
|
1696
|
+
|
|
1697
|
+
## Troubleshooting Deployment Issues:
|
|
1698
|
+
|
|
1699
|
+
### Slow Startup:
|
|
1700
|
+
- Check resource allocation (CPU/Memory)
|
|
1701
|
+
- Review startup logs for bottlenecks
|
|
1702
|
+
- Optimize initialization procedures
|
|
1703
|
+
- Consider increasing startup timeout
|
|
1704
|
+
|
|
1705
|
+
### Connection Failures:
|
|
1706
|
+
- Verify network configuration and firewall rules
|
|
1707
|
+
- Check service discovery and DNS resolution
|
|
1708
|
+
- Validate external service endpoints
|
|
1709
|
+
- Test connectivity from deployment environment
|
|
1710
|
+
|
|
1711
|
+
### Resource Constraints:
|
|
1712
|
+
- Monitor actual vs. allocated resources
|
|
1713
|
+
- Check for memory leaks or CPU spikes
|
|
1714
|
+
- Consider scaling up resource allocation
|
|
1715
|
+
- Optimize application resource usage
|
|
1716
|
+
|
|
1717
|
+
Start the deployment process and monitor each phase carefully. Let me know if you encounter any issues during deployment.`
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
]
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Get container best practices content
|
|
1725
|
+
*/
|
|
1726
|
+
getContainerBestPracticesContent() {
|
|
1727
|
+
return {
|
|
1728
|
+
messages: [
|
|
1729
|
+
{
|
|
1730
|
+
role: 'user',
|
|
1731
|
+
content: {
|
|
1732
|
+
type: 'text',
|
|
1733
|
+
text: `Here are comprehensive best practices for container development with the 172.ai platform:
|
|
1734
|
+
|
|
1735
|
+
## Dockerfile Best Practices
|
|
1736
|
+
|
|
1737
|
+
### 1. Multi-Stage Builds
|
|
1738
|
+
\`\`\`dockerfile
|
|
1739
|
+
# Use multi-stage builds to reduce final image size
|
|
1740
|
+
FROM node:18-alpine AS builder
|
|
1741
|
+
WORKDIR /app
|
|
1742
|
+
COPY package*.json ./
|
|
1743
|
+
RUN npm ci --only=production
|
|
1744
|
+
|
|
1745
|
+
FROM node:18-alpine AS runtime
|
|
1746
|
+
WORKDIR /app
|
|
1747
|
+
COPY --from=builder /app/node_modules ./node_modules
|
|
1748
|
+
COPY . .
|
|
1749
|
+
EXPOSE 3000
|
|
1750
|
+
CMD ["node", "index.js"]
|
|
1751
|
+
\`\`\`
|
|
1752
|
+
|
|
1753
|
+
### 2. Security Hardening
|
|
1754
|
+
\`\`\`dockerfile
|
|
1755
|
+
# Create non-root user
|
|
1756
|
+
RUN addgroup -g 1001 -S nodejs
|
|
1757
|
+
RUN adduser -S nextjs -u 1001
|
|
1758
|
+
|
|
1759
|
+
# Set proper file permissions
|
|
1760
|
+
COPY --chown=nextjs:nodejs . .
|
|
1761
|
+
USER nextjs
|
|
1762
|
+
|
|
1763
|
+
# Use specific base image versions
|
|
1764
|
+
FROM node:18.17.0-alpine
|
|
1765
|
+
\`\`\`
|
|
1766
|
+
|
|
1767
|
+
### 3. Layer Optimization
|
|
1768
|
+
\`\`\`dockerfile
|
|
1769
|
+
# Combine RUN commands to reduce layers
|
|
1770
|
+
RUN apt-get update && apt-get install -y \\
|
|
1771
|
+
git \\
|
|
1772
|
+
curl \\
|
|
1773
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
1774
|
+
|
|
1775
|
+
# Copy dependency files first for better caching
|
|
1776
|
+
COPY package*.json ./
|
|
1777
|
+
RUN npm install
|
|
1778
|
+
COPY . .
|
|
1779
|
+
\`\`\`
|
|
1780
|
+
|
|
1781
|
+
## Container Configuration Best Practices
|
|
1782
|
+
|
|
1783
|
+
### 1. Environment Variables
|
|
1784
|
+
- Use environment variables for all configuration
|
|
1785
|
+
- Provide sensible defaults where possible
|
|
1786
|
+
- Document all required and optional variables
|
|
1787
|
+
- Use secrets management for sensitive data
|
|
1788
|
+
|
|
1789
|
+
### 2. Health Checks
|
|
1790
|
+
\`\`\`dockerfile
|
|
1791
|
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \\
|
|
1792
|
+
CMD curl -f http://localhost:3000/health || exit 1
|
|
1793
|
+
\`\`\`
|
|
1794
|
+
|
|
1795
|
+
### 3. Resource Limits
|
|
1796
|
+
- Set appropriate CPU and memory limits
|
|
1797
|
+
- Consider application startup time for duration planning
|
|
1798
|
+
- Monitor actual resource usage vs. allocated
|
|
1799
|
+
|
|
1800
|
+
## Development Workflow Best Practices
|
|
1801
|
+
|
|
1802
|
+
### 1. Code Organization
|
|
1803
|
+
- Keep application code modular and well-structured
|
|
1804
|
+
- Include comprehensive error handling and logging
|
|
1805
|
+
- Use configuration files for environment-specific settings
|
|
1806
|
+
- Include proper documentation and README files
|
|
1807
|
+
|
|
1808
|
+
### 2. File Management
|
|
1809
|
+
- Upload files in logical order (dependencies first)
|
|
1810
|
+
- Use clear, descriptive file names
|
|
1811
|
+
- Organize files in proper directory structure
|
|
1812
|
+
- Remove unnecessary files to reduce image size
|
|
1813
|
+
|
|
1814
|
+
### 3. Build Process
|
|
1815
|
+
- Monitor builds closely (check every 15 seconds)
|
|
1816
|
+
- Review build logs for warnings and optimization opportunities
|
|
1817
|
+
- Fix build issues incrementally
|
|
1818
|
+
- Use build arguments for customization
|
|
1819
|
+
|
|
1820
|
+
## Deployment Best Practices
|
|
1821
|
+
|
|
1822
|
+
### 1. Environment Management
|
|
1823
|
+
- Use separate configurations for dev/staging/production
|
|
1824
|
+
- Test in staging environments before production deployment
|
|
1825
|
+
- Implement proper rollback procedures
|
|
1826
|
+
- Monitor deployments closely during startup
|
|
1827
|
+
|
|
1828
|
+
### 2. Resource Planning
|
|
1829
|
+
- Start with conservative resource allocation
|
|
1830
|
+
- Monitor actual usage and adjust as needed
|
|
1831
|
+
- Plan duration based on environment and use case
|
|
1832
|
+
- Consider cost implications of resource choices
|
|
1833
|
+
|
|
1834
|
+
### 3. Monitoring & Observability
|
|
1835
|
+
- Include comprehensive logging in applications
|
|
1836
|
+
- Implement health check endpoints
|
|
1837
|
+
- Monitor key performance and business metrics
|
|
1838
|
+
- Set up alerting for critical issues
|
|
1839
|
+
|
|
1840
|
+
## Security Best Practices
|
|
1841
|
+
|
|
1842
|
+
### 1. Image Security
|
|
1843
|
+
- Use official base images from trusted sources
|
|
1844
|
+
- Keep base images updated with security patches
|
|
1845
|
+
- Scan images for known vulnerabilities
|
|
1846
|
+
- Remove unnecessary packages and tools
|
|
1847
|
+
|
|
1848
|
+
### 2. Runtime Security
|
|
1849
|
+
- Run containers with non-root users
|
|
1850
|
+
- Limit container capabilities and privileges
|
|
1851
|
+
- Use read-only filesystems where possible
|
|
1852
|
+
- Implement proper network segmentation
|
|
1853
|
+
|
|
1854
|
+
### 3. Secrets Management
|
|
1855
|
+
- Never hardcode secrets in images or configuration
|
|
1856
|
+
- Use environment variables for runtime secrets
|
|
1857
|
+
- Implement proper secret rotation procedures
|
|
1858
|
+
- Audit access to sensitive configuration
|
|
1859
|
+
|
|
1860
|
+
## Performance Optimization
|
|
1861
|
+
|
|
1862
|
+
### 1. Application Performance
|
|
1863
|
+
- Implement efficient algorithms and data structures
|
|
1864
|
+
- Use appropriate caching strategies
|
|
1865
|
+
- Optimize database queries and external API calls
|
|
1866
|
+
- Monitor and profile application performance
|
|
1867
|
+
|
|
1868
|
+
### 2. Container Performance
|
|
1869
|
+
- Minimize image size through multi-stage builds
|
|
1870
|
+
- Use appropriate base images for your runtime
|
|
1871
|
+
- Optimize startup time and resource utilization
|
|
1872
|
+
- Implement graceful shutdown procedures
|
|
1873
|
+
|
|
1874
|
+
### 3. Resource Efficiency
|
|
1875
|
+
- Right-size resource allocations based on actual usage
|
|
1876
|
+
- Use horizontal scaling when appropriate
|
|
1877
|
+
- Implement efficient data processing patterns
|
|
1878
|
+
- Monitor and optimize memory usage
|
|
1879
|
+
|
|
1880
|
+
## Testing & Quality Assurance
|
|
1881
|
+
|
|
1882
|
+
### 1. Container Testing
|
|
1883
|
+
- Test containers in environments similar to production
|
|
1884
|
+
- Validate all environment variable combinations
|
|
1885
|
+
- Test startup, shutdown, and restart procedures
|
|
1886
|
+
- Verify health checks and monitoring endpoints
|
|
1887
|
+
|
|
1888
|
+
### 2. Integration Testing
|
|
1889
|
+
- Test integration with external services and APIs
|
|
1890
|
+
- Validate data processing and business logic
|
|
1891
|
+
- Test error handling and recovery procedures
|
|
1892
|
+
- Verify security controls and access restrictions
|
|
1893
|
+
|
|
1894
|
+
### 3. Performance Testing
|
|
1895
|
+
- Load test applications under expected traffic
|
|
1896
|
+
- Test resource utilization under various conditions
|
|
1897
|
+
- Validate scaling behavior and limits
|
|
1898
|
+
- Test recovery from failure scenarios
|
|
1899
|
+
|
|
1900
|
+
Follow these best practices to create robust, secure, and efficient containerized applications on the 172.ai platform.`
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
]
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1308
1906
|
/**
|
|
1309
1907
|
* Start the MCP server
|
|
1310
1908
|
*/
|