@@ -13,7 +13,13 @@ import { HELP_TEXT } from '../../constants';
1313import { useListNavigation , useMultiSelectNavigation } from '../../hooks' ;
1414import { generateUniqueName } from '../../utils' ;
1515import type { AddGatewayTargetConfig , ComputeHost , ExposureMode , TargetLanguage } from './types' ;
16- import { COMPUTE_HOST_OPTIONS , EXPOSURE_MODE_OPTIONS , MCP_TOOL_STEP_LABELS , TARGET_LANGUAGE_OPTIONS } from './types' ;
16+ import {
17+ COMPUTE_HOST_OPTIONS ,
18+ EXPOSURE_MODE_OPTIONS ,
19+ MCP_TOOL_STEP_LABELS ,
20+ SOURCE_OPTIONS ,
21+ TARGET_LANGUAGE_OPTIONS ,
22+ } from './types' ;
1723import { useAddGatewayTargetWizard } from './useAddGatewayTargetWizard' ;
1824import { Box , Text } from 'ink' ;
1925import React , { useMemo } from 'react' ;
@@ -35,6 +41,11 @@ export function AddGatewayTargetScreen({
3541} : AddGatewayTargetScreenProps ) {
3642 const wizard = useAddGatewayTargetWizard ( existingGateways , existingAgents ) ;
3743
44+ const sourceItems : SelectableItem [ ] = useMemo (
45+ ( ) => SOURCE_OPTIONS . map ( o => ( { id : o . id , title : o . title , description : o . description } ) ) ,
46+ [ ]
47+ ) ;
48+
3849 const languageItems : SelectableItem [ ] = useMemo (
3950 ( ) => TARGET_LANGUAGE_OPTIONS . map ( o => ( { id : o . id , title : o . title , description : o . description } ) ) ,
4051 [ ]
@@ -52,7 +63,10 @@ export function AddGatewayTargetScreen({
5263 ) ;
5364
5465 const gatewayItems : SelectableItem [ ] = useMemo (
55- ( ) => existingGateways . map ( g => ( { id : g , title : g } ) ) ,
66+ ( ) => [
67+ ...existingGateways . map ( g => ( { id : g , title : g } ) ) ,
68+ { id : 'skip-for-now' , title : 'Skip for now' , description : 'Create unassigned target' } ,
69+ ] ,
5670 [ existingGateways ]
5771 ) ;
5872
@@ -63,16 +77,24 @@ export function AddGatewayTargetScreen({
6377
6478 const agentItems : SelectableItem [ ] = useMemo ( ( ) => existingAgents . map ( a => ( { id : a , title : a } ) ) , [ existingAgents ] ) ;
6579
80+ const isSourceStep = wizard . step === 'source' ;
6681 const isLanguageStep = wizard . step === 'language' ;
6782 const isExposureStep = wizard . step === 'exposure' ;
6883 const isAgentsStep = wizard . step === 'agents' ;
6984 const isGatewayStep = wizard . step === 'gateway' ;
7085 const isHostStep = wizard . step === 'host' ;
71- const isTextStep = wizard . step === 'name' ;
86+ const isTextStep = wizard . step === 'name' || wizard . step === 'endpoint' ;
7287 const isConfirmStep = wizard . step === 'confirm' ;
7388 const noGatewaysAvailable = isGatewayStep && existingGateways . length === 0 ;
7489 const noAgentsAvailable = isAgentsStep && existingAgents . length === 0 ;
7590
91+ const sourceNav = useListNavigation ( {
92+ items : sourceItems ,
93+ onSelect : item => wizard . setSource ( item . id as 'existing-endpoint' | 'create-new' ) ,
94+ onExit : ( ) => wizard . goBack ( ) ,
95+ isActive : isSourceStep ,
96+ } ) ;
97+
7698 const languageNav = useListNavigation ( {
7799 items : languageItems ,
78100 onSelect : item => wizard . setLanguage ( item . id as TargetLanguage ) ,
@@ -132,6 +154,15 @@ export function AddGatewayTargetScreen({
132154 return (
133155 < Screen title = "Add MCP Tool" onExit = { onExit } helpText = { helpText } headerContent = { headerContent } >
134156 < Panel >
157+ { isSourceStep && (
158+ < WizardSelect
159+ title = "Select source"
160+ description = "How would you like to create this MCP tool?"
161+ items = { sourceItems }
162+ selectedIndex = { sourceNav . selectedIndex }
163+ />
164+ ) }
165+
135166 { isLanguageStep && (
136167 < WizardSelect title = "Select language" items = { languageItems } selectedIndex = { languageNav . selectedIndex } />
137168 ) }
@@ -180,27 +211,43 @@ export function AddGatewayTargetScreen({
180211 { isTextStep && (
181212 < TextInput
182213 key = { wizard . step }
183- prompt = { MCP_TOOL_STEP_LABELS [ wizard . step ] }
184- initialValue = { generateUniqueName ( 'mytool' , existingToolNames ) }
185- onSubmit = { wizard . setName }
214+ prompt = { wizard . step === 'endpoint' ? 'MCP server endpoint URL' : MCP_TOOL_STEP_LABELS [ wizard . step ] }
215+ initialValue = {
216+ wizard . step === 'endpoint' ? 'https://example.com/mcp' : generateUniqueName ( 'mytool' , existingToolNames )
217+ }
218+ onSubmit = { wizard . step === 'endpoint' ? wizard . setEndpoint : wizard . setName }
186219 onCancel = { ( ) => ( wizard . currentIndex === 0 ? onExit ( ) : wizard . goBack ( ) ) }
187- schema = { ToolNameSchema }
188- customValidation = { value => ! existingToolNames . includes ( value ) || 'Tool name already exists' }
220+ schema = { wizard . step === 'name' ? ToolNameSchema : undefined }
221+ customValidation = {
222+ wizard . step === 'name'
223+ ? value => ! existingToolNames . includes ( value ) || 'Tool name already exists'
224+ : undefined
225+ }
189226 />
190227 ) }
191228
192229 { isConfirmStep && (
193230 < ConfirmReview
194231 fields = { [
195232 { label : 'Name' , value : wizard . config . name } ,
196- { label : 'Language' , value : wizard . config . language } ,
197- { label : 'Exposure' , value : isMcpRuntime ? 'MCP Runtime' : 'Behind Gateway' } ,
233+ {
234+ label : 'Source' ,
235+ value : wizard . config . source === 'existing-endpoint' ? 'Existing endpoint' : 'Create new' ,
236+ } ,
237+ ...( wizard . config . endpoint ? [ { label : 'Endpoint' , value : wizard . config . endpoint } ] : [ ] ) ,
238+ ...( wizard . config . source === 'create-new' ? [ { label : 'Language' , value : wizard . config . language } ] : [ ] ) ,
239+ ...( wizard . config . source === 'create-new'
240+ ? [ { label : 'Exposure' , value : isMcpRuntime ? 'MCP Runtime' : 'Behind Gateway' } ]
241+ : [ ] ) ,
198242 ...( isMcpRuntime && wizard . config . selectedAgents . length > 0
199243 ? [ { label : 'Agents' , value : wizard . config . selectedAgents . join ( ', ' ) } ]
200244 : [ ] ) ,
201245 ...( ! isMcpRuntime && wizard . config . gateway ? [ { label : 'Gateway' , value : wizard . config . gateway } ] : [ ] ) ,
202- { label : 'Host' , value : wizard . config . host } ,
203- { label : 'Source' , value : wizard . config . sourcePath } ,
246+ ...( ! isMcpRuntime && ! wizard . config . gateway
247+ ? [ { label : 'Gateway' , value : '(none - assign later)' } ]
248+ : [ ] ) ,
249+ ...( wizard . config . source === 'create-new' ? [ { label : 'Host' , value : wizard . config . host } ] : [ ] ) ,
250+ ...( wizard . config . source === 'create-new' ? [ { label : 'Source' , value : wizard . config . sourcePath } ] : [ ] ) ,
204251 ] }
205252 />
206253 ) }
0 commit comments