Skip to content

Commit 812ca42

Browse files
committed
refactor: remove exposure/mcp-runtime mode from gateway-target command
All gateway targets are now behind-gateway only. The mcp-runtime exposure mode was disabled and never used by customers. - Remove ExposureMode type, EXPOSURE_MODE_OPTIONS, --exposure and --agents CLI flags - Simplify wizard flow: name → source → language → gateway → host → confirm - Remove mcp-runtime code paths from create-mcp, remove-gateway-target, McpGuidedEditor - Remove existingAgents prop chain (only used for mcp-runtime agent selection) - Clean up unused imports (ViewMode, AgentCoreMcpRuntimeTool, WizardMultiSelect)
1 parent ab4b481 commit 812ca42

15 files changed

Lines changed: 201 additions & 582 deletions

src/cli/commands/add/actions.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ export interface ValidatedAddGatewayTargetOptions {
7070
source?: 'existing-endpoint' | 'create-new';
7171
endpoint?: string;
7272
language: 'Python' | 'TypeScript' | 'Other';
73-
exposure: 'mcp-runtime' | 'behind-gateway';
74-
agents?: string;
7573
gateway?: string;
7674
host?: 'Lambda' | 'AgentCoreRuntime';
7775
outboundAuthType?: 'OAUTH' | 'API_KEY' | 'NONE';
@@ -306,23 +304,15 @@ function buildGatewayTargetConfig(options: ValidatedAddGatewayTargetOptions): Ad
306304
description,
307305
sourcePath,
308306
language: options.language,
309-
exposure: options.exposure,
310307
source: options.source,
311308
endpoint: options.endpoint,
312-
host: options.exposure === 'mcp-runtime' ? 'AgentCoreRuntime' : options.host!,
309+
host: options.host!,
313310
toolDefinition: {
314311
name: options.name,
315312
description,
316313
inputSchema: { type: 'object' },
317314
},
318-
selectedAgents:
319-
options.exposure === 'mcp-runtime'
320-
? options
321-
.agents!.split(',')
322-
.map(s => s.trim())
323-
.filter(Boolean)
324-
: [],
325-
gateway: options.exposure === 'behind-gateway' ? options.gateway : undefined,
315+
gateway: options.gateway,
326316
outboundAuth,
327317
};
328318
}

src/cli/commands/add/command.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ async function handleAddGatewayTargetCLI(options: AddGatewayTargetOptions): Prom
111111
name: options.name!,
112112
description: options.description,
113113
language: options.language! as 'Python' | 'TypeScript',
114-
exposure: options.exposure!,
115-
agents: options.agents,
116114
gateway: options.gateway,
117115
host: options.host,
118116
});
@@ -266,10 +264,8 @@ export function registerAdd(program: Command) {
266264
.option('--source <source>', 'Source: existing-endpoint or create-new')
267265
.option('--endpoint <url>', 'MCP server endpoint URL')
268266
.option('--language <lang>', 'Language: Python or TypeScript')
269-
.option('--exposure <mode>', 'Exposure mode: mcp-runtime or behind-gateway')
270-
.option('--agents <names>', 'Comma-separated agent names (for mcp-runtime)')
271-
.option('--gateway <name>', 'Gateway name (for behind-gateway)')
272-
.option('--host <host>', 'Compute host: Lambda or AgentCoreRuntime (for behind-gateway)')
267+
.option('--gateway <name>', 'Gateway name')
268+
.option('--host <host>', 'Compute host: Lambda or AgentCoreRuntime')
273269
.option('--json', 'Output as JSON')
274270
.action(async options => {
275271
requireProject();

src/cli/commands/add/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ export interface AddGatewayTargetOptions {
4949
source?: string;
5050
endpoint?: string;
5151
language?: 'Python' | 'TypeScript' | 'Other';
52-
exposure?: 'mcp-runtime' | 'behind-gateway';
53-
agents?: string;
5452
gateway?: string;
5553
host?: 'Lambda' | 'AgentCoreRuntime';
5654
outboundAuthType?: 'OAUTH' | 'API_KEY' | 'NONE';

src/cli/commands/add/validate.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ export async function validateAddGatewayTargetOptions(options: AddGatewayTargetO
213213

214214
// Populate defaults for fields skipped by external endpoint flow
215215
options.language ??= 'Other';
216-
options.exposure ??= 'behind-gateway';
217216
options.gateway ??= undefined;
218217

219218
return { valid: true };
@@ -227,27 +226,6 @@ export async function validateAddGatewayTargetOptions(options: AddGatewayTargetO
227226
return { valid: false, error: 'Invalid language. Valid options: Python, TypeScript, Other' };
228227
}
229228

230-
if (!options.exposure) {
231-
return { valid: false, error: '--exposure is required' };
232-
}
233-
234-
if (options.exposure !== 'mcp-runtime' && options.exposure !== 'behind-gateway') {
235-
return { valid: false, error: "Invalid exposure. Use 'mcp-runtime' or 'behind-gateway'" };
236-
}
237-
238-
if (options.exposure === 'mcp-runtime') {
239-
if (!options.agents) {
240-
return { valid: false, error: '--agents is required for mcp-runtime exposure' };
241-
}
242-
const agents = options.agents
243-
.split(',')
244-
.map(s => s.trim())
245-
.filter(Boolean);
246-
if (agents.length === 0) {
247-
return { valid: false, error: 'At least one agent is required' };
248-
}
249-
}
250-
251229
// Validate outbound auth configuration
252230
if (options.outboundAuthType && options.outboundAuthType !== 'NONE') {
253231
if (!options.credentialName) {

src/cli/operations/mcp/create-mcp.ts

Lines changed: 61 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import type {
33
AgentCoreCliMcpDefs,
44
AgentCoreGateway,
55
AgentCoreGatewayTarget,
6-
AgentCoreMcpRuntimeTool,
76
AgentCoreMcpSpec,
8-
CodeZipRuntimeConfig,
97
DirectoryPath,
108
FilePath,
119
} from '../../../schema';
@@ -255,7 +253,7 @@ export async function createExternalGatewayTarget(config: AddGatewayTargetConfig
255253
}
256254

257255
/**
258-
* Create an MCP tool (MCP runtime or behind gateway).
256+
* Create an MCP tool (behind gateway only).
259257
*/
260258
export async function createToolFromWizard(config: AddGatewayTargetConfig): Promise<CreateToolResult> {
261259
validateGatewayTargetLanguage(config.language);
@@ -280,117 +278,76 @@ export async function createToolFromWizard(config: AddGatewayTargetConfig): Prom
280278
ToolDefinitionSchema.parse(toolDef);
281279
}
282280

283-
if (config.exposure === 'mcp-runtime') {
284-
// MCP Runtime tool - always AgentCoreRuntime (single tool)
285-
// Build explicit CodeZipRuntimeConfig - no CLI-managed placeholders
286-
const runtimeConfig: CodeZipRuntimeConfig = {
287-
artifact: 'CodeZip',
288-
pythonVersion: DEFAULT_PYTHON_VERSION,
289-
name: config.name,
290-
entrypoint: 'server.py:main' as FilePath,
291-
codeLocation: config.sourcePath as DirectoryPath,
292-
networkMode: 'PUBLIC',
293-
};
294-
295-
// 'Other' language requires container config - not supported for mcp-runtime yet
296-
if (config.language === 'Other') {
297-
throw new Error('Language "Other" is not yet supported for MCP runtime tools. Use Python or TypeScript.');
298-
}
299-
300-
const mcpRuntimeTool: AgentCoreMcpRuntimeTool = {
301-
name: config.name,
302-
toolDefinition: config.toolDefinition,
303-
compute: {
304-
host: 'AgentCoreRuntime',
305-
implementation: {
306-
path: config.sourcePath,
307-
language: config.language,
308-
handler: DEFAULT_HANDLER,
309-
},
310-
runtime: runtimeConfig,
311-
},
312-
};
313-
314-
const mcpRuntimeTools = mcpSpec.mcpRuntimeTools ?? [];
315-
if (mcpRuntimeTools.some(tool => tool.name === mcpRuntimeTool.name)) {
316-
throw new Error(`MCP runtime tool "${mcpRuntimeTool.name}" already exists.`);
317-
}
318-
mcpSpec.mcpRuntimeTools = [...mcpRuntimeTools, mcpRuntimeTool];
319-
320-
// Write mcp.json
321-
await configIO.writeMcpSpec(mcpSpec);
322-
} else {
323-
// Behind gateway
324-
if (!config.gateway) {
325-
throw new Error('Gateway name is required for tools behind a gateway.');
326-
}
281+
// Behind gateway
282+
if (!config.gateway) {
283+
throw new Error('Gateway name is required for tools behind a gateway.');
284+
}
327285

328-
const gateway = mcpSpec.agentCoreGateways.find(g => g.name === config.gateway);
329-
if (!gateway) {
330-
throw new Error(`Gateway "${config.gateway}" not found.`);
331-
}
286+
const gateway = mcpSpec.agentCoreGateways.find(g => g.name === config.gateway);
287+
if (!gateway) {
288+
throw new Error(`Gateway "${config.gateway}" not found.`);
289+
}
332290

333-
// Check for duplicate target name
334-
if (gateway.targets.some(t => t.name === config.name)) {
335-
throw new Error(`Target "${config.name}" already exists in gateway "${gateway.name}".`);
336-
}
291+
// Check for duplicate target name
292+
if (gateway.targets.some(t => t.name === config.name)) {
293+
throw new Error(`Target "${config.name}" already exists in gateway "${gateway.name}".`);
294+
}
337295

338-
// Check for duplicate tool names
339-
for (const toolDef of toolDefs) {
340-
for (const existingTarget of gateway.targets) {
341-
if ((existingTarget.toolDefinitions ?? []).some(t => t.name === toolDef.name)) {
342-
throw new Error(`Tool "${toolDef.name}" already exists in gateway "${gateway.name}".`);
343-
}
296+
// Check for duplicate tool names
297+
for (const toolDef of toolDefs) {
298+
for (const existingTarget of gateway.targets) {
299+
if ((existingTarget.toolDefinitions ?? []).some(t => t.name === toolDef.name)) {
300+
throw new Error(`Tool "${toolDef.name}" already exists in gateway "${gateway.name}".`);
344301
}
345302
}
303+
}
346304

347-
// 'Other' language requires container config - not supported for gateway tools yet
348-
if (config.language === 'Other') {
349-
throw new Error('Language "Other" is not yet supported for gateway tools. Use Python or TypeScript.');
350-
}
305+
// 'Other' language requires container config - not supported for gateway tools yet
306+
if (config.language === 'Other') {
307+
throw new Error('Language "Other" is not yet supported for gateway tools. Use Python or TypeScript.');
308+
}
351309

352-
// Create a single target with all tool definitions
353-
const target: AgentCoreGatewayTarget = {
354-
name: config.name,
355-
targetType: config.host === 'AgentCoreRuntime' ? 'mcpServer' : 'lambda',
356-
toolDefinitions: toolDefs,
357-
compute:
358-
config.host === 'Lambda'
359-
? {
360-
host: 'Lambda',
361-
implementation: {
362-
path: config.sourcePath,
363-
language: config.language,
364-
handler: DEFAULT_HANDLER,
365-
},
366-
...(config.language === 'Python'
367-
? { pythonVersion: DEFAULT_PYTHON_VERSION }
368-
: { nodeVersion: DEFAULT_NODE_VERSION }),
369-
}
370-
: {
371-
host: 'AgentCoreRuntime',
372-
implementation: {
373-
path: config.sourcePath,
374-
language: 'Python',
375-
handler: 'server.py:main',
376-
},
377-
runtime: {
378-
artifact: 'CodeZip',
379-
pythonVersion: DEFAULT_PYTHON_VERSION,
380-
name: config.name,
381-
entrypoint: 'server.py:main' as FilePath,
382-
codeLocation: config.sourcePath as DirectoryPath,
383-
networkMode: 'PUBLIC',
384-
},
310+
// Create a single target with all tool definitions
311+
const target: AgentCoreGatewayTarget = {
312+
name: config.name,
313+
targetType: config.host === 'AgentCoreRuntime' ? 'mcpServer' : 'lambda',
314+
toolDefinitions: toolDefs,
315+
compute:
316+
config.host === 'Lambda'
317+
? {
318+
host: 'Lambda',
319+
implementation: {
320+
path: config.sourcePath,
321+
language: config.language,
322+
handler: DEFAULT_HANDLER,
323+
},
324+
...(config.language === 'Python'
325+
? { pythonVersion: DEFAULT_PYTHON_VERSION }
326+
: { nodeVersion: DEFAULT_NODE_VERSION }),
327+
}
328+
: {
329+
host: 'AgentCoreRuntime',
330+
implementation: {
331+
path: config.sourcePath,
332+
language: 'Python',
333+
handler: 'server.py:main',
385334
},
386-
...(config.outboundAuth && { outboundAuth: config.outboundAuth }),
387-
};
335+
runtime: {
336+
artifact: 'CodeZip',
337+
pythonVersion: DEFAULT_PYTHON_VERSION,
338+
name: config.name,
339+
entrypoint: 'server.py:main' as FilePath,
340+
codeLocation: config.sourcePath as DirectoryPath,
341+
networkMode: 'PUBLIC',
342+
},
343+
},
344+
...(config.outboundAuth && { outboundAuth: config.outboundAuth }),
345+
};
388346

389-
gateway.targets.push(target);
347+
gateway.targets.push(target);
390348

391-
// Write mcp.json for gateway case
392-
await configIO.writeMcpSpec(mcpSpec);
393-
}
349+
// Write mcp.json for gateway case
350+
await configIO.writeMcpSpec(mcpSpec);
394351

395352
// Update mcp-defs.json with all tool definitions
396353
const mcpDefsPath = resolveMcpDefsPath();

0 commit comments

Comments
 (0)