@@ -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 */
260258export 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