@aws/ml-container-creator 0.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/LICENSE +202 -0
- package/LICENSE-THIRD-PARTY +68620 -0
- package/NOTICE +2 -0
- package/README.md +106 -0
- package/bin/cli.js +365 -0
- package/config/defaults.json +32 -0
- package/config/presets/transformers-djl.json +26 -0
- package/config/presets/transformers-gpu.json +24 -0
- package/config/presets/transformers-lmi.json +27 -0
- package/package.json +129 -0
- package/servers/README.md +419 -0
- package/servers/base-image-picker/catalogs/model-servers.json +1191 -0
- package/servers/base-image-picker/catalogs/python-slim.json +38 -0
- package/servers/base-image-picker/catalogs/triton-backends.json +51 -0
- package/servers/base-image-picker/catalogs/triton.json +38 -0
- package/servers/base-image-picker/index.js +495 -0
- package/servers/base-image-picker/manifest.json +17 -0
- package/servers/base-image-picker/package.json +15 -0
- package/servers/hyperpod-cluster-picker/LICENSE +202 -0
- package/servers/hyperpod-cluster-picker/index.js +424 -0
- package/servers/hyperpod-cluster-picker/manifest.json +14 -0
- package/servers/hyperpod-cluster-picker/package.json +17 -0
- package/servers/instance-recommender/LICENSE +202 -0
- package/servers/instance-recommender/catalogs/instances.json +852 -0
- package/servers/instance-recommender/index.js +284 -0
- package/servers/instance-recommender/manifest.json +16 -0
- package/servers/instance-recommender/package.json +15 -0
- package/servers/lib/LICENSE +202 -0
- package/servers/lib/bedrock-client.js +160 -0
- package/servers/lib/custom-validators.js +46 -0
- package/servers/lib/dynamic-resolver.js +36 -0
- package/servers/lib/package.json +11 -0
- package/servers/lib/schemas/image-catalog.schema.json +185 -0
- package/servers/lib/schemas/instances.schema.json +124 -0
- package/servers/lib/schemas/manifest.schema.json +64 -0
- package/servers/lib/schemas/model-catalog.schema.json +91 -0
- package/servers/lib/schemas/regions.schema.json +26 -0
- package/servers/lib/schemas/triton-backends.schema.json +51 -0
- package/servers/model-picker/catalogs/jumpstart-public.json +66 -0
- package/servers/model-picker/catalogs/popular-diffusors.json +88 -0
- package/servers/model-picker/catalogs/popular-transformers.json +226 -0
- package/servers/model-picker/index.js +1693 -0
- package/servers/model-picker/manifest.json +18 -0
- package/servers/model-picker/package.json +20 -0
- package/servers/region-picker/LICENSE +202 -0
- package/servers/region-picker/catalogs/regions.json +263 -0
- package/servers/region-picker/index.js +230 -0
- package/servers/region-picker/manifest.json +16 -0
- package/servers/region-picker/package.json +15 -0
- package/src/app.js +1007 -0
- package/src/copy-tpl.js +77 -0
- package/src/lib/accelerator-validator.js +39 -0
- package/src/lib/asset-manager.js +385 -0
- package/src/lib/aws-profile-parser.js +181 -0
- package/src/lib/bootstrap-command-handler.js +1647 -0
- package/src/lib/bootstrap-config.js +238 -0
- package/src/lib/ci-register-helpers.js +124 -0
- package/src/lib/ci-report-helpers.js +158 -0
- package/src/lib/ci-stage-helpers.js +268 -0
- package/src/lib/cli-handler.js +529 -0
- package/src/lib/comment-generator.js +544 -0
- package/src/lib/community-reports-validator.js +91 -0
- package/src/lib/config-manager.js +2106 -0
- package/src/lib/configuration-exporter.js +204 -0
- package/src/lib/configuration-manager.js +695 -0
- package/src/lib/configuration-matcher.js +221 -0
- package/src/lib/cpu-validator.js +36 -0
- package/src/lib/cuda-validator.js +57 -0
- package/src/lib/deployment-config-resolver.js +103 -0
- package/src/lib/deployment-entry-schema.js +125 -0
- package/src/lib/deployment-registry.js +598 -0
- package/src/lib/docker-introspection-validator.js +51 -0
- package/src/lib/engine-prefix-resolver.js +60 -0
- package/src/lib/huggingface-client.js +172 -0
- package/src/lib/key-value-parser.js +37 -0
- package/src/lib/known-flags-validator.js +200 -0
- package/src/lib/manifest-cli.js +280 -0
- package/src/lib/mcp-client.js +303 -0
- package/src/lib/mcp-command-handler.js +532 -0
- package/src/lib/neuron-validator.js +80 -0
- package/src/lib/parameter-schema-validator.js +284 -0
- package/src/lib/prompt-runner.js +1349 -0
- package/src/lib/prompts.js +1138 -0
- package/src/lib/registry-command-handler.js +519 -0
- package/src/lib/registry-loader.js +198 -0
- package/src/lib/rocm-validator.js +80 -0
- package/src/lib/schema-validator.js +157 -0
- package/src/lib/sensitive-redactor.js +59 -0
- package/src/lib/template-engine.js +156 -0
- package/src/lib/template-manager.js +341 -0
- package/src/lib/validation-engine.js +314 -0
- package/src/prompt-adapter.js +63 -0
- package/templates/Dockerfile +300 -0
- package/templates/IAM_PERMISSIONS.md +84 -0
- package/templates/MIGRATION.md +488 -0
- package/templates/PROJECT_README.md +439 -0
- package/templates/TEMPLATE_SYSTEM.md +243 -0
- package/templates/buildspec.yml +64 -0
- package/templates/code/chat_template.jinja +1 -0
- package/templates/code/flask/gunicorn_config.py +35 -0
- package/templates/code/flask/wsgi.py +10 -0
- package/templates/code/model_handler.py +387 -0
- package/templates/code/serve +300 -0
- package/templates/code/serve.py +175 -0
- package/templates/code/serving.properties +105 -0
- package/templates/code/start_server.py +39 -0
- package/templates/code/start_server.sh +39 -0
- package/templates/diffusors/Dockerfile +72 -0
- package/templates/diffusors/patch_image_api.py +35 -0
- package/templates/diffusors/serve +115 -0
- package/templates/diffusors/start_server.sh +114 -0
- package/templates/do/.gitkeep +1 -0
- package/templates/do/README.md +541 -0
- package/templates/do/build +83 -0
- package/templates/do/ci +681 -0
- package/templates/do/clean +811 -0
- package/templates/do/config +260 -0
- package/templates/do/deploy +1560 -0
- package/templates/do/export +306 -0
- package/templates/do/logs +319 -0
- package/templates/do/manifest +12 -0
- package/templates/do/push +119 -0
- package/templates/do/register +580 -0
- package/templates/do/run +113 -0
- package/templates/do/submit +417 -0
- package/templates/do/test +1147 -0
- package/templates/hyperpod/configmap.yaml +24 -0
- package/templates/hyperpod/deployment.yaml +71 -0
- package/templates/hyperpod/pvc.yaml +42 -0
- package/templates/hyperpod/service.yaml +17 -0
- package/templates/nginx-diffusors.conf +74 -0
- package/templates/nginx-predictors.conf +47 -0
- package/templates/nginx-tensorrt.conf +74 -0
- package/templates/requirements.txt +61 -0
- package/templates/sample_model/test_inference.py +123 -0
- package/templates/sample_model/train_abalone.py +252 -0
- package/templates/test/test_endpoint.sh +79 -0
- package/templates/test/test_local_image.sh +80 -0
- package/templates/test/test_model_handler.py +180 -0
- package/templates/triton/Dockerfile +128 -0
- package/templates/triton/config.pbtxt +163 -0
- package/templates/triton/model.py +130 -0
- package/templates/triton/requirements.txt +11 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Region Picker MCP Server
|
|
7
|
+
*
|
|
8
|
+
* A bundled MCP server that suggests AWS regions based on a search term.
|
|
9
|
+
* Useful for discovering available SageMaker regions without memorizing codes.
|
|
10
|
+
*
|
|
11
|
+
* Supports two modes:
|
|
12
|
+
* - Static (default): Filters a hardcoded region list by string matching
|
|
13
|
+
* - Smart (BEDROCK_SMART=true): Queries Amazon Bedrock for context-aware
|
|
14
|
+
* region suggestions, falling back to static on failure
|
|
15
|
+
*
|
|
16
|
+
* Tool: get_regions
|
|
17
|
+
* Accepts: { parameters: string[], limit: number, context: object }
|
|
18
|
+
* Returns: { values: Record<string, string>, choices: Record<string, string[]> }
|
|
19
|
+
*
|
|
20
|
+
* Environment variables:
|
|
21
|
+
* BEDROCK_SMART - Set to "true" to enable Bedrock-powered recommendations
|
|
22
|
+
* BEDROCK_MODEL - Bedrock model ID (default: global.anthropic.claude-sonnet-4-20250514-v1:0)
|
|
23
|
+
* BEDROCK_REGION - AWS region for Bedrock API calls (fallback: AWS_REGION, then us-east-1)
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
|
27
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
28
|
+
import { z } from 'zod'
|
|
29
|
+
import { readFileSync } from 'node:fs'
|
|
30
|
+
import { fileURLToPath } from 'node:url'
|
|
31
|
+
import { resolve, dirname } from 'node:path'
|
|
32
|
+
import { queryBedrock } from '../lib/bedrock-client.js'
|
|
33
|
+
|
|
34
|
+
// ── Catalog loader ───────────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
37
|
+
const __dirname = dirname(__filename)
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Load and parse a JSON catalog file relative to the server directory.
|
|
41
|
+
* Throws on missing file or invalid JSON with the file path in the message.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} relativePath - Path relative to server dir (e.g. './catalogs/regions.json')
|
|
44
|
+
* @returns {any} Parsed JSON content
|
|
45
|
+
*/
|
|
46
|
+
function loadCatalog(relativePath) {
|
|
47
|
+
const fullPath = resolve(__dirname, relativePath)
|
|
48
|
+
let raw
|
|
49
|
+
try {
|
|
50
|
+
raw = readFileSync(fullPath, 'utf8')
|
|
51
|
+
} catch (err) {
|
|
52
|
+
throw new Error(`Catalog file not found: ${fullPath}`)
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
return JSON.parse(raw)
|
|
56
|
+
} catch (err) {
|
|
57
|
+
throw new Error(`Failed to parse catalog ${fullPath}: ${err.message}`)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ── Load catalogs from JSON files ─────────────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
let AWS_REGIONS
|
|
64
|
+
let VALID_REGION_CODES
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
AWS_REGIONS = loadCatalog('./catalogs/regions.json')
|
|
68
|
+
VALID_REGION_CODES = new Set(AWS_REGIONS.map(r => r.code))
|
|
69
|
+
} catch (err) {
|
|
70
|
+
process.stderr.write(`[region-picker] Fatal: ${err.message}\n`)
|
|
71
|
+
process.exit(1)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Bedrock / smart-mode configuration
|
|
75
|
+
const SMART_MODE = process.env.BEDROCK_SMART === 'true'
|
|
76
|
+
const BEDROCK_MODEL = process.env.BEDROCK_MODEL || 'global.anthropic.claude-sonnet-4-20250514-v1:0'
|
|
77
|
+
const BEDROCK_REGION = process.env.BEDROCK_REGION || process.env.AWS_REGION || 'us-east-1'
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Per-server configuration passed to the shared Bedrock client.
|
|
81
|
+
*/
|
|
82
|
+
const SERVER_CONFIG = {
|
|
83
|
+
serverName: 'region-picker',
|
|
84
|
+
systemPromptTemplate: `You are an AWS region advisor for SageMaker deployments. Given the following deployment context, recommend the best AWS region.
|
|
85
|
+
|
|
86
|
+
Current configuration: {context}
|
|
87
|
+
Requested parameters: {parameters}
|
|
88
|
+
Maximum recommendations: {limit}
|
|
89
|
+
|
|
90
|
+
Respond with ONLY a JSON object in this exact format, no other text:
|
|
91
|
+
{
|
|
92
|
+
"values": {
|
|
93
|
+
"awsRegion": "the single best region code as a string"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Rules:
|
|
98
|
+
- Only include parameters that were requested
|
|
99
|
+
- For awsRegion: recommend real AWS region codes (e.g., us-east-1, eu-west-1)
|
|
100
|
+
- Consider service availability, latency, and pricing
|
|
101
|
+
- Consider the user's existing configuration context
|
|
102
|
+
- The first value should be your top recommendation
|
|
103
|
+
- Return valid JSON only`,
|
|
104
|
+
temperature: 0.3,
|
|
105
|
+
maxTokens: 1024,
|
|
106
|
+
modelId: BEDROCK_MODEL,
|
|
107
|
+
region: BEDROCK_REGION
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Filter AWS_REGIONS by a case-insensitive substring match against
|
|
112
|
+
* the region code and all labels in the labels array.
|
|
113
|
+
*
|
|
114
|
+
* @param {string|undefined} searchTerm - Substring to match (case-insensitive)
|
|
115
|
+
* @param {number} limit - Maximum number of results to return
|
|
116
|
+
* @returns {{ values: object, choices: object }}
|
|
117
|
+
*/
|
|
118
|
+
function filterRegions(searchTerm, limit) {
|
|
119
|
+
let matched
|
|
120
|
+
|
|
121
|
+
if (searchTerm) {
|
|
122
|
+
const term = searchTerm.toLowerCase()
|
|
123
|
+
matched = AWS_REGIONS.filter(
|
|
124
|
+
r => r.code.toLowerCase().includes(term) ||
|
|
125
|
+
r.labels.some(l => l.toLowerCase().includes(term))
|
|
126
|
+
)
|
|
127
|
+
} else {
|
|
128
|
+
matched = AWS_REGIONS
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const codes = matched.map(r => r.code).slice(0, limit)
|
|
132
|
+
|
|
133
|
+
if (codes.length === 0) {
|
|
134
|
+
return { values: {}, choices: { awsRegion: [] } }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
values: { awsRegion: codes[0] },
|
|
139
|
+
choices: { awsRegion: codes }
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Log to stderr so it doesn't interfere with MCP stdio protocol on stdout.
|
|
145
|
+
*/
|
|
146
|
+
function log(message) {
|
|
147
|
+
process.stderr.write(`[region-picker] ${message}\n`)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Create MCP server
|
|
151
|
+
const server = new McpServer({
|
|
152
|
+
name: 'region-picker',
|
|
153
|
+
version: '1.0.0'
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
// Register the get_regions tool
|
|
157
|
+
server.tool(
|
|
158
|
+
'get_regions',
|
|
159
|
+
'Returns recommended AWS regions for SageMaker deployments',
|
|
160
|
+
{
|
|
161
|
+
parameters: z.array(z.string()).describe('List of parameter names to provide values for'),
|
|
162
|
+
limit: z.number().int().positive().default(10).describe('Maximum number of choices per parameter'),
|
|
163
|
+
context: z.record(z.string(), z.any()).optional().describe('Current configuration context (regionSearch, framework, etc.)')
|
|
164
|
+
},
|
|
165
|
+
async ({ parameters, limit, context }) => {
|
|
166
|
+
// If awsRegion is not requested, return empty
|
|
167
|
+
if (!parameters.includes('awsRegion')) {
|
|
168
|
+
return {
|
|
169
|
+
content: [{
|
|
170
|
+
type: 'text',
|
|
171
|
+
text: JSON.stringify({ values: {}, choices: {} })
|
|
172
|
+
}]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const searchTerm = context?.regionSearch
|
|
177
|
+
let result
|
|
178
|
+
|
|
179
|
+
// Smart mode: try Bedrock first
|
|
180
|
+
if (SMART_MODE) {
|
|
181
|
+
log('[smart] Smart mode enabled, querying Amazon Bedrock...')
|
|
182
|
+
const bedrockResult = await queryBedrock(SERVER_CONFIG, parameters, limit, context || {})
|
|
183
|
+
|
|
184
|
+
if (bedrockResult?.values?.awsRegion && VALID_REGION_CODES.has(bedrockResult.values.awsRegion)) {
|
|
185
|
+
const bedrockValue = bedrockResult.values.awsRegion
|
|
186
|
+
log(`[smart] Using Bedrock recommendation: ${bedrockValue}`)
|
|
187
|
+
|
|
188
|
+
// Pad with static results, deduplicating the Bedrock pick
|
|
189
|
+
const staticResult = filterRegions(searchTerm, limit)
|
|
190
|
+
const staticCodes = staticResult.choices.awsRegion || []
|
|
191
|
+
const combined = [bedrockValue, ...staticCodes.filter(c => c !== bedrockValue)]
|
|
192
|
+
|
|
193
|
+
result = {
|
|
194
|
+
values: { awsRegion: bedrockValue },
|
|
195
|
+
choices: { awsRegion: combined.slice(0, limit) }
|
|
196
|
+
}
|
|
197
|
+
} else {
|
|
198
|
+
log('[smart] Bedrock did not return usable results, falling back to static filtering')
|
|
199
|
+
result = filterRegions(searchTerm, limit)
|
|
200
|
+
}
|
|
201
|
+
} else {
|
|
202
|
+
// Static mode (default)
|
|
203
|
+
result = filterRegions(searchTerm, limit)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return {
|
|
207
|
+
content: [{
|
|
208
|
+
type: 'text',
|
|
209
|
+
text: JSON.stringify(result)
|
|
210
|
+
}]
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
// Export for standalone testing
|
|
216
|
+
export { loadCatalog, filterRegions, AWS_REGIONS, VALID_REGION_CODES }
|
|
217
|
+
|
|
218
|
+
// Guard MCP transport — only connect when run as main module
|
|
219
|
+
const isMain = process.argv[1] && resolve(process.argv[1]) === __filename
|
|
220
|
+
|
|
221
|
+
if (isMain) {
|
|
222
|
+
if (SMART_MODE) {
|
|
223
|
+
log(`Smart mode enabled (model: ${BEDROCK_MODEL}, region: ${BEDROCK_REGION})`)
|
|
224
|
+
} else {
|
|
225
|
+
log('Static mode (set BEDROCK_SMART=true to enable Bedrock-powered recommendations)')
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const transport = new StdioServerTransport()
|
|
229
|
+
await server.connect(transport)
|
|
230
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amzn/ml-container-creator-region-picker",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP server that suggests AWS regions for SageMaker deployments.",
|
|
5
|
+
"modes": {
|
|
6
|
+
"static": true,
|
|
7
|
+
"smart": true,
|
|
8
|
+
"discover": false
|
|
9
|
+
},
|
|
10
|
+
"catalogs": {
|
|
11
|
+
"regions": "./catalogs/regions.json"
|
|
12
|
+
},
|
|
13
|
+
"tool": {
|
|
14
|
+
"name": "get_regions"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@amzn/ml-container-creator-region-picker",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "MCP server that suggests AWS regions based on a search term for ML Container Creator. Supports Bedrock-powered smart recommendations.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node test.js"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
14
|
+
}
|
|
15
|
+
}
|