@aws/ml-container-creator 0.9.1 → 0.10.3
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-THIRD-PARTY +9304 -0
- package/bin/cli.js +2 -0
- package/config/bootstrap-e2e-stack.json +341 -0
- package/config/bootstrap-stack.json +40 -3
- package/config/parameter-schema-v2.json +2049 -0
- package/config/tune-catalog.json +1781 -0
- package/infra/ci-harness/buildspec.yml +1 -0
- package/infra/ci-harness/lambda/path-prover/brain.ts +306 -0
- package/infra/ci-harness/lambda/path-prover/write-results.ts +152 -0
- package/infra/ci-harness/lib/ci-harness-stack.ts +837 -7
- package/infra/ci-harness/state-machines/path-prover.asl.json +496 -0
- package/package.json +53 -68
- package/servers/base-image-picker/index.js +121 -121
- package/servers/e2e-status/index.js +297 -0
- package/servers/e2e-status/manifest.json +14 -0
- package/servers/e2e-status/package.json +15 -0
- package/servers/endpoint-picker/LICENSE +202 -0
- package/servers/endpoint-picker/index.js +536 -0
- package/servers/endpoint-picker/manifest.json +14 -0
- package/servers/endpoint-picker/package.json +18 -0
- package/servers/hyperpod-cluster-picker/index.js +125 -125
- package/servers/instance-sizer/index.js +138 -138
- package/servers/instance-sizer/lib/instance-ranker.js +76 -76
- package/servers/instance-sizer/lib/model-resolver.js +61 -61
- package/servers/instance-sizer/lib/quota-resolver.js +113 -113
- package/servers/instance-sizer/lib/vram-estimator.js +31 -31
- package/servers/lib/bedrock-client.js +38 -38
- package/servers/lib/catalogs/jumpstart-public.json +101 -16
- package/servers/lib/catalogs/model-servers.json +201 -3
- package/servers/lib/catalogs/models.json +182 -26
- package/servers/lib/custom-validators.js +13 -13
- package/servers/lib/dynamic-resolver.js +4 -4
- package/servers/marketplace-picker/index.js +342 -0
- package/servers/marketplace-picker/manifest.json +14 -0
- package/servers/marketplace-picker/package.json +18 -0
- package/servers/model-picker/index.js +382 -382
- package/servers/region-picker/index.js +56 -56
- package/servers/workload-picker/LICENSE +202 -0
- package/servers/workload-picker/catalogs/workload-profiles.json +67 -0
- package/servers/workload-picker/index.js +171 -0
- package/servers/workload-picker/manifest.json +16 -0
- package/servers/workload-picker/package.json +16 -0
- package/src/app.js +4 -390
- package/src/lib/bootstrap-command-handler.js +710 -1148
- package/src/lib/bootstrap-config.js +36 -0
- package/src/lib/bootstrap-profile-manager.js +641 -0
- package/src/lib/bootstrap-provisioners.js +421 -0
- package/src/lib/ci-register-helpers.js +74 -0
- package/src/lib/config-loader.js +408 -0
- package/src/lib/config-manager.js +66 -1685
- package/src/lib/config-mcp-client.js +118 -0
- package/src/lib/config-validator.js +634 -0
- package/src/lib/cuda-resolver.js +149 -0
- package/src/lib/e2e-catalog-validator.js +251 -3
- package/src/lib/e2e-ci-recorder.js +103 -0
- package/src/lib/generated/cli-options.js +315 -311
- package/src/lib/generated/parameter-matrix.js +671 -0
- package/src/lib/generated/validation-rules.js +71 -71
- package/src/lib/marketplace-flow.js +276 -0
- package/src/lib/mcp-query-runner.js +768 -0
- package/src/lib/parameter-schema-validator.js +62 -18
- package/src/lib/path-prover-brain.js +607 -0
- package/src/lib/prompt-runner.js +41 -1504
- package/src/lib/prompts/feature-prompts.js +172 -0
- package/src/lib/prompts/index.js +48 -0
- package/src/lib/prompts/infrastructure-prompts.js +690 -0
- package/src/lib/prompts/model-prompts.js +552 -0
- package/src/lib/prompts/project-prompts.js +82 -0
- package/src/lib/prompts.js +2 -1446
- package/src/lib/registry-command-handler.js +135 -3
- package/src/lib/secrets-prompt-runner.js +251 -0
- package/src/lib/template-variable-resolver.js +422 -0
- package/src/lib/tune-catalog-validator.js +37 -4
- package/templates/Dockerfile +9 -0
- package/templates/code/adapter_sidecar.py +444 -0
- package/templates/code/serve +6 -0
- package/templates/code/serve.d/vllm.ejs +1 -1
- package/templates/do/.benchmark_writer.py +1476 -0
- package/templates/do/.tune_helper.py +982 -57
- package/templates/do/__pycache__/.benchmark_writer.cpython-312.pyc +0 -0
- package/templates/do/adapter +149 -0
- package/templates/do/benchmark +639 -85
- package/templates/do/config +108 -5
- package/templates/do/deploy.d/managed-inference.ejs +192 -11
- package/templates/do/optimize +106 -37
- package/templates/do/register +89 -0
- package/templates/do/test +13 -0
- package/templates/do/tune +378 -59
- package/templates/do/validate +44 -4
- package/config/parameter-schema.json +0 -88
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
* BEDROCK_REGION - AWS region for Bedrock API calls (fallback: AWS_REGION, then us-east-1)
|
|
24
24
|
*/
|
|
25
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'
|
|
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
33
|
|
|
34
34
|
// ── Catalog loader ───────────────────────────────────────────────────────────
|
|
35
35
|
|
|
36
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
37
|
-
const __dirname = dirname(__filename)
|
|
36
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
37
|
+
const __dirname = dirname(__filename);
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Load and parse a JSON catalog file relative to the server directory.
|
|
@@ -44,37 +44,37 @@ const __dirname = dirname(__filename)
|
|
|
44
44
|
* @returns {any} Parsed JSON content
|
|
45
45
|
*/
|
|
46
46
|
function loadCatalog(relativePath) {
|
|
47
|
-
const fullPath = resolve(__dirname, relativePath)
|
|
48
|
-
let raw
|
|
47
|
+
const fullPath = resolve(__dirname, relativePath);
|
|
48
|
+
let raw;
|
|
49
49
|
try {
|
|
50
|
-
raw = readFileSync(fullPath, 'utf8')
|
|
50
|
+
raw = readFileSync(fullPath, 'utf8');
|
|
51
51
|
} catch (err) {
|
|
52
|
-
throw new Error(`Catalog file not found: ${fullPath}`)
|
|
52
|
+
throw new Error(`Catalog file not found: ${fullPath}`);
|
|
53
53
|
}
|
|
54
54
|
try {
|
|
55
|
-
return JSON.parse(raw)
|
|
55
|
+
return JSON.parse(raw);
|
|
56
56
|
} catch (err) {
|
|
57
|
-
throw new Error(`Failed to parse catalog ${fullPath}: ${err.message}`)
|
|
57
|
+
throw new Error(`Failed to parse catalog ${fullPath}: ${err.message}`);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// ── Load catalogs from JSON files ─────────────────────────────────────────────
|
|
62
62
|
|
|
63
|
-
let AWS_REGIONS
|
|
64
|
-
let VALID_REGION_CODES
|
|
63
|
+
let AWS_REGIONS;
|
|
64
|
+
let VALID_REGION_CODES;
|
|
65
65
|
|
|
66
66
|
try {
|
|
67
|
-
AWS_REGIONS = loadCatalog('../lib/catalogs/regions.json')
|
|
68
|
-
VALID_REGION_CODES = new Set(AWS_REGIONS.map(r => r.code))
|
|
67
|
+
AWS_REGIONS = loadCatalog('../lib/catalogs/regions.json');
|
|
68
|
+
VALID_REGION_CODES = new Set(AWS_REGIONS.map(r => r.code));
|
|
69
69
|
} catch (err) {
|
|
70
|
-
process.stderr.write(`[region-picker] Fatal: ${err.message}\n`)
|
|
71
|
-
process.exit(1)
|
|
70
|
+
process.stderr.write(`[region-picker] Fatal: ${err.message}\n`);
|
|
71
|
+
process.exit(1);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
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'
|
|
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
78
|
|
|
79
79
|
/**
|
|
80
80
|
* Per-server configuration passed to the shared Bedrock client.
|
|
@@ -105,7 +105,7 @@ Rules:
|
|
|
105
105
|
maxTokens: 1024,
|
|
106
106
|
modelId: BEDROCK_MODEL,
|
|
107
107
|
region: BEDROCK_REGION
|
|
108
|
-
}
|
|
108
|
+
};
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Filter AWS_REGIONS by a case-insensitive substring match against
|
|
@@ -116,42 +116,42 @@ Rules:
|
|
|
116
116
|
* @returns {{ values: object, choices: object }}
|
|
117
117
|
*/
|
|
118
118
|
function filterRegions(searchTerm, limit) {
|
|
119
|
-
let matched
|
|
119
|
+
let matched;
|
|
120
120
|
|
|
121
121
|
if (searchTerm) {
|
|
122
|
-
const term = searchTerm.toLowerCase()
|
|
122
|
+
const term = searchTerm.toLowerCase();
|
|
123
123
|
matched = AWS_REGIONS.filter(
|
|
124
124
|
r => r.code.toLowerCase().includes(term) ||
|
|
125
125
|
r.labels.some(l => l.toLowerCase().includes(term))
|
|
126
|
-
)
|
|
126
|
+
);
|
|
127
127
|
} else {
|
|
128
|
-
matched = AWS_REGIONS
|
|
128
|
+
matched = AWS_REGIONS;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
const codes = matched.map(r => r.code).slice(0, limit)
|
|
131
|
+
const codes = matched.map(r => r.code).slice(0, limit);
|
|
132
132
|
|
|
133
133
|
if (codes.length === 0) {
|
|
134
|
-
return { values: {}, choices: { awsRegion: [] } }
|
|
134
|
+
return { values: {}, choices: { awsRegion: [] } };
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
return {
|
|
138
138
|
values: { awsRegion: codes[0] },
|
|
139
139
|
choices: { awsRegion: codes }
|
|
140
|
-
}
|
|
140
|
+
};
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Log to stderr so it doesn't interfere with MCP stdio protocol on stdout.
|
|
145
145
|
*/
|
|
146
146
|
function log(message) {
|
|
147
|
-
process.stderr.write(`[region-picker] ${message}\n`)
|
|
147
|
+
process.stderr.write(`[region-picker] ${message}\n`);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// Create MCP server
|
|
151
151
|
const server = new McpServer({
|
|
152
152
|
name: 'region-picker',
|
|
153
153
|
version: '1.0.0'
|
|
154
|
-
})
|
|
154
|
+
});
|
|
155
155
|
|
|
156
156
|
// Register the get_regions tool
|
|
157
157
|
server.tool(
|
|
@@ -170,37 +170,37 @@ server.tool(
|
|
|
170
170
|
type: 'text',
|
|
171
171
|
text: JSON.stringify({ values: {}, choices: {} })
|
|
172
172
|
}]
|
|
173
|
-
}
|
|
173
|
+
};
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
const searchTerm = context?.regionSearch
|
|
177
|
-
let result
|
|
176
|
+
const searchTerm = context?.regionSearch;
|
|
177
|
+
let result;
|
|
178
178
|
|
|
179
179
|
// Smart mode: try Bedrock first
|
|
180
180
|
if (SMART_MODE) {
|
|
181
|
-
log('[smart] Smart mode enabled, querying Amazon Bedrock...')
|
|
182
|
-
const bedrockResult = await queryBedrock(SERVER_CONFIG, parameters, limit, context || {})
|
|
181
|
+
log('[smart] Smart mode enabled, querying Amazon Bedrock...');
|
|
182
|
+
const bedrockResult = await queryBedrock(SERVER_CONFIG, parameters, limit, context || {});
|
|
183
183
|
|
|
184
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}`)
|
|
185
|
+
const bedrockValue = bedrockResult.values.awsRegion;
|
|
186
|
+
log(`[smart] Using Bedrock recommendation: ${bedrockValue}`);
|
|
187
187
|
|
|
188
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)]
|
|
189
|
+
const staticResult = filterRegions(searchTerm, limit);
|
|
190
|
+
const staticCodes = staticResult.choices.awsRegion || [];
|
|
191
|
+
const combined = [bedrockValue, ...staticCodes.filter(c => c !== bedrockValue)];
|
|
192
192
|
|
|
193
193
|
result = {
|
|
194
194
|
values: { awsRegion: bedrockValue },
|
|
195
195
|
choices: { awsRegion: combined.slice(0, limit) }
|
|
196
|
-
}
|
|
196
|
+
};
|
|
197
197
|
} else {
|
|
198
|
-
log('[smart] Bedrock did not return usable results, falling back to static filtering')
|
|
199
|
-
result = filterRegions(searchTerm, limit)
|
|
198
|
+
log('[smart] Bedrock did not return usable results, falling back to static filtering');
|
|
199
|
+
result = filterRegions(searchTerm, limit);
|
|
200
200
|
}
|
|
201
201
|
} else {
|
|
202
202
|
// Static mode (default)
|
|
203
|
-
result = filterRegions(searchTerm, limit)
|
|
203
|
+
result = filterRegions(searchTerm, limit);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
return {
|
|
@@ -208,23 +208,23 @@ server.tool(
|
|
|
208
208
|
type: 'text',
|
|
209
209
|
text: JSON.stringify(result)
|
|
210
210
|
}]
|
|
211
|
-
}
|
|
211
|
+
};
|
|
212
212
|
}
|
|
213
|
-
)
|
|
213
|
+
);
|
|
214
214
|
|
|
215
215
|
// Export for standalone testing
|
|
216
|
-
export { loadCatalog, filterRegions, AWS_REGIONS, VALID_REGION_CODES }
|
|
216
|
+
export { loadCatalog, filterRegions, AWS_REGIONS, VALID_REGION_CODES };
|
|
217
217
|
|
|
218
218
|
// Guard MCP transport — only connect when run as main module
|
|
219
|
-
const isMain = process.argv[1] && resolve(process.argv[1]) === __filename
|
|
219
|
+
const isMain = process.argv[1] && resolve(process.argv[1]) === __filename;
|
|
220
220
|
|
|
221
221
|
if (isMain) {
|
|
222
222
|
if (SMART_MODE) {
|
|
223
|
-
log(`Smart mode enabled (model: ${BEDROCK_MODEL}, region: ${BEDROCK_REGION})`)
|
|
223
|
+
log(`Smart mode enabled (model: ${BEDROCK_MODEL}, region: ${BEDROCK_REGION})`);
|
|
224
224
|
} else {
|
|
225
|
-
log('Static mode (set BEDROCK_SMART=true to enable Bedrock-powered recommendations)')
|
|
225
|
+
log('Static mode (set BEDROCK_SMART=true to enable Bedrock-powered recommendations)');
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
const transport = new StdioServerTransport()
|
|
229
|
-
await server.connect(transport)
|
|
228
|
+
const transport = new StdioServerTransport();
|
|
229
|
+
await server.connect(transport);
|
|
230
230
|
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"workloads": {
|
|
3
|
+
"sample": {
|
|
4
|
+
"description": "POC Sample Workload",
|
|
5
|
+
"input_tokens_mean": 100,
|
|
6
|
+
"output_tokens_mean": 100,
|
|
7
|
+
"streaming": true,
|
|
8
|
+
"dataset": "synthetic",
|
|
9
|
+
"concurrency_levels": [2],
|
|
10
|
+
"use_case": "POC Sample Workload"
|
|
11
|
+
},
|
|
12
|
+
"multi_turn_chat": {
|
|
13
|
+
"description": "Copilots, assistants, customer support — short exchanges with conversation history",
|
|
14
|
+
"input_tokens_mean": 550,
|
|
15
|
+
"output_tokens_mean": 150,
|
|
16
|
+
"streaming": true,
|
|
17
|
+
"dataset": "synthetic",
|
|
18
|
+
"concurrency_levels": [1, 4, 8, 16],
|
|
19
|
+
"use_case": "Interactive chat, low latency"
|
|
20
|
+
},
|
|
21
|
+
"rag_document_qa": {
|
|
22
|
+
"description": "Knowledge bases, legal & medical search — long context retrieval with focused answers",
|
|
23
|
+
"input_tokens_mean": 2000,
|
|
24
|
+
"output_tokens_mean": 500,
|
|
25
|
+
"streaming": true,
|
|
26
|
+
"dataset": "synthetic",
|
|
27
|
+
"concurrency_levels": [1, 4, 8],
|
|
28
|
+
"use_case": "RAG, document Q&A"
|
|
29
|
+
},
|
|
30
|
+
"agent_tool_calling": {
|
|
31
|
+
"description": "Coding agents, research agents, automation — short structured outputs (JSON)",
|
|
32
|
+
"input_tokens_mean": 200,
|
|
33
|
+
"output_tokens_mean": 100,
|
|
34
|
+
"streaming": false,
|
|
35
|
+
"dataset": "synthetic",
|
|
36
|
+
"concurrency_levels": [1, 4, 8, 16, 32],
|
|
37
|
+
"use_case": "Agents, structured output"
|
|
38
|
+
},
|
|
39
|
+
"long_context_scaling": {
|
|
40
|
+
"description": "Prefill stress test — very long inputs with moderate outputs",
|
|
41
|
+
"input_tokens_mean": 8000,
|
|
42
|
+
"output_tokens_mean": 1000,
|
|
43
|
+
"streaming": true,
|
|
44
|
+
"dataset": "synthetic",
|
|
45
|
+
"concurrency_levels": [1, 2, 4],
|
|
46
|
+
"use_case": "Long context, summarization"
|
|
47
|
+
},
|
|
48
|
+
"production_traffic_mix": {
|
|
49
|
+
"description": "Aggregate real traffic simulation — mixed input/output lengths",
|
|
50
|
+
"input_tokens_mean": 1000,
|
|
51
|
+
"output_tokens_mean": 300,
|
|
52
|
+
"streaming": true,
|
|
53
|
+
"dataset": "synthetic",
|
|
54
|
+
"concurrency_levels": [4, 8, 16, 32],
|
|
55
|
+
"use_case": "Production fleet sizing"
|
|
56
|
+
},
|
|
57
|
+
"shared_system_prompt": {
|
|
58
|
+
"description": "Prefix caching / prompt reuse — long shared prefix with short user queries",
|
|
59
|
+
"input_tokens_mean": 1000,
|
|
60
|
+
"output_tokens_mean": 200,
|
|
61
|
+
"streaming": true,
|
|
62
|
+
"dataset": "synthetic",
|
|
63
|
+
"concurrency_levels": [4, 8, 16, 32],
|
|
64
|
+
"use_case": "Prefix caching validation"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
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
|
+
* Workload Picker MCP Server
|
|
7
|
+
*
|
|
8
|
+
* A bundled MCP server that provides named benchmark workload profiles
|
|
9
|
+
* for use with `do/benchmark`. Workloads define token distributions,
|
|
10
|
+
* concurrency levels, streaming mode, and intended use cases.
|
|
11
|
+
*
|
|
12
|
+
* Tools:
|
|
13
|
+
* - list_workloads: Returns all available workload names with descriptions
|
|
14
|
+
* - get_workload_profile: Returns full parameters for a named workload
|
|
15
|
+
*
|
|
16
|
+
* The catalog is loaded from ./catalogs/workload-profiles.json and can be
|
|
17
|
+
* extended by adding entries to that file.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
21
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
import { readFileSync } from 'node:fs';
|
|
24
|
+
import { fileURLToPath } from 'node:url';
|
|
25
|
+
import { resolve, dirname } from 'node:path';
|
|
26
|
+
|
|
27
|
+
// ── Catalog loader ───────────────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
30
|
+
const __dirname = dirname(__filename);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Load and parse a JSON catalog file relative to the server directory.
|
|
34
|
+
* Throws on missing file or invalid JSON with the file path in the message.
|
|
35
|
+
*
|
|
36
|
+
* @param {string} relativePath - Path relative to server dir
|
|
37
|
+
* @returns {any} Parsed JSON content
|
|
38
|
+
*/
|
|
39
|
+
function loadCatalog(relativePath) {
|
|
40
|
+
const fullPath = resolve(__dirname, relativePath);
|
|
41
|
+
let raw;
|
|
42
|
+
try {
|
|
43
|
+
raw = readFileSync(fullPath, 'utf8');
|
|
44
|
+
} catch (err) {
|
|
45
|
+
throw new Error(`Catalog file not found: ${fullPath}`);
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
return JSON.parse(raw);
|
|
49
|
+
} catch (err) {
|
|
50
|
+
throw new Error(`Failed to parse catalog ${fullPath}: ${err.message}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ── Load workload profiles ───────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
let WORKLOAD_CATALOG;
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
WORKLOAD_CATALOG = loadCatalog('./catalogs/workload-profiles.json');
|
|
60
|
+
} catch (err) {
|
|
61
|
+
process.stderr.write(`[workload-picker] Fatal: ${err.message}\n`);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const WORKLOAD_NAMES = Object.keys(WORKLOAD_CATALOG.workloads);
|
|
66
|
+
|
|
67
|
+
// ── Helper functions ─────────────────────────────────────────────────────────
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* List all available workloads with name + description + use_case.
|
|
71
|
+
*
|
|
72
|
+
* @returns {{ workloads: Array<{ name: string, description: string, use_case: string }> }}
|
|
73
|
+
*/
|
|
74
|
+
export function listWorkloads() {
|
|
75
|
+
const workloads = WORKLOAD_NAMES.map(name => ({
|
|
76
|
+
name,
|
|
77
|
+
description: WORKLOAD_CATALOG.workloads[name].description,
|
|
78
|
+
use_case: WORKLOAD_CATALOG.workloads[name].use_case
|
|
79
|
+
}));
|
|
80
|
+
return { workloads };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get full workload profile by name.
|
|
85
|
+
*
|
|
86
|
+
* @param {string} workloadName - One of the defined workload names
|
|
87
|
+
* @returns {object|null} Full workload profile or null if not found
|
|
88
|
+
*/
|
|
89
|
+
export function getWorkloadProfile(workloadName) {
|
|
90
|
+
const profile = WORKLOAD_CATALOG.workloads[workloadName];
|
|
91
|
+
if (!profile) return null;
|
|
92
|
+
return { name: workloadName, ...profile };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Log to stderr so it doesn't interfere with MCP stdio protocol on stdout.
|
|
97
|
+
*/
|
|
98
|
+
function log(message) {
|
|
99
|
+
process.stderr.write(`[workload-picker] ${message}\n`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ── MCP Server ───────────────────────────────────────────────────────────────
|
|
103
|
+
|
|
104
|
+
const server = new McpServer({
|
|
105
|
+
name: 'workload-picker',
|
|
106
|
+
version: '1.0.0'
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Register the list_workloads tool
|
|
110
|
+
server.tool(
|
|
111
|
+
'list_workloads',
|
|
112
|
+
'Returns all available benchmark workload profiles with names, descriptions, and use cases',
|
|
113
|
+
{},
|
|
114
|
+
async () => {
|
|
115
|
+
const result = listWorkloads();
|
|
116
|
+
log(`list_workloads → ${result.workloads.length} workloads`);
|
|
117
|
+
return {
|
|
118
|
+
content: [{
|
|
119
|
+
type: 'text',
|
|
120
|
+
text: JSON.stringify(result, null, 2)
|
|
121
|
+
}]
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// Register the get_workload_profile tool
|
|
127
|
+
server.tool(
|
|
128
|
+
'get_workload_profile',
|
|
129
|
+
'Returns benchmark workload parameters for a named workload profile. Use list_workloads first to see available options.',
|
|
130
|
+
{
|
|
131
|
+
workload: z.enum(WORKLOAD_NAMES).describe('Named workload profile to retrieve')
|
|
132
|
+
},
|
|
133
|
+
async ({ workload }) => {
|
|
134
|
+
const profile = getWorkloadProfile(workload);
|
|
135
|
+
|
|
136
|
+
if (!profile) {
|
|
137
|
+
return {
|
|
138
|
+
content: [{
|
|
139
|
+
type: 'text',
|
|
140
|
+
text: JSON.stringify({
|
|
141
|
+
error: `Unknown workload: ${workload}`,
|
|
142
|
+
available: WORKLOAD_NAMES
|
|
143
|
+
})
|
|
144
|
+
}],
|
|
145
|
+
isError: true
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
log(`get_workload_profile → ${workload}`);
|
|
150
|
+
return {
|
|
151
|
+
content: [{
|
|
152
|
+
type: 'text',
|
|
153
|
+
text: JSON.stringify(profile, null, 2)
|
|
154
|
+
}]
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
// ── Start server ─────────────────────────────────────────────────────────────
|
|
160
|
+
|
|
161
|
+
async function main() {
|
|
162
|
+
const transport = new StdioServerTransport();
|
|
163
|
+
log('Starting workload-picker MCP server...');
|
|
164
|
+
await server.connect(transport);
|
|
165
|
+
log('Server connected and ready');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
main().catch(err => {
|
|
169
|
+
process.stderr.write(`[workload-picker] Fatal startup error: ${err.message}\n`);
|
|
170
|
+
process.exit(1);
|
|
171
|
+
});
|