@@ -74,15 +74,15 @@ func newMCPServer(ctx context.Context, k *kong.Kong, projectConfig projectconfig
74
74
), func (serverCtx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
75
75
return statusTool (ctx , buildEngineClient , adminClient )
76
76
})
77
- addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "NewModule" , []string {"module" , "new" }, IncludeOptional ("dir" ), Pattern ("name" , optional .Some (moduleRegex ))))
78
- addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "CallVerb" , []string {"call" }, IncludeOptional ("request" )))
77
+ addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "NewModule" , []string {"module" , "new" }, includeOptional ("dir" ), pattern ("name" , optional .Some (moduleRegex ))))
78
+ addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "CallVerb" , []string {"call" }, includeOptional ("request" )))
79
79
// all secret commands, with xor group of bools for providers
80
80
// all config commands, with xor group of bools for providers
81
81
addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "ResetSubscription" , []string {"pubsub" , "subscription" , "reset" }))
82
- addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "NewMySQLDatabase" , []string {"mysql" , "new" }, Pattern ("datasource" , optional .Some (refRegex ))))
83
- addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "NewMySQLMigration" , []string {"mysql" , "new" , "migration" }, Ignore (newSQLCmd {}, "datasource" )))
82
+ addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "NewMySQLDatabase" , []string {"mysql" , "new" }, pattern ("datasource" , optional .Some (refRegex ))))
83
+ addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "NewMySQLMigration" , []string {"mysql" , "new" , "migration" }, ignore (newSQLCmd {}, "datasource" )))
84
84
addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "NewPostgresDatabase" , []string {"postgres" , "new" }))
85
- addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "NewPostgresMigration" , []string {"postgres" , "new" , "migration" }, Ignore (newSQLCmd {}, "datasource" )))
85
+ addTool (toolFromCLI (ctx , k , projectConfig , bindContext , "NewPostgresMigration" , []string {"postgres" , "new" , "migration" }, ignore (newSQLCmd {}, "datasource" )))
86
86
return s
87
87
}
88
88
@@ -202,7 +202,7 @@ func commentForPath(pos schema.Position, modulePath string) (string, error) {
202
202
203
203
type cliToolOption func (inputOptions * cliConfig )
204
204
205
- func IncludeOptional (name string ) cliToolOption {
205
+ func includeOptional (name string ) cliToolOption {
206
206
return func (inputOptions * cliConfig ) {
207
207
o , ok := inputOptions .InputOptions [name ]
208
208
if ! ok {
@@ -213,7 +213,7 @@ func IncludeOptional(name string) cliToolOption {
213
213
}
214
214
}
215
215
216
- func Pattern (name string , pattern optional.Option [string ]) cliToolOption {
216
+ func pattern (name string , pattern optional.Option [string ]) cliToolOption {
217
217
return func (inputOptions * cliConfig ) {
218
218
o , ok := inputOptions .InputOptions [name ]
219
219
if ! ok {
@@ -224,7 +224,7 @@ func Pattern(name string, pattern optional.Option[string]) cliToolOption {
224
224
}
225
225
}
226
226
227
- func Ignore (model any , name string ) cliToolOption {
227
+ func ignore (model any , name string ) cliToolOption {
228
228
return func (inputOptions * cliConfig ) {
229
229
o , ok := inputOptions .InputOptions [name ]
230
230
if ! ok {
@@ -329,7 +329,7 @@ func toolFromCLI(ctx context.Context, k *kong.Kong, projectConfig projectconfig.
329
329
// validate that all configured options were found
330
330
for name := range config .InputOptions {
331
331
if ! included [name ] {
332
- panic (fmt .Sprintf ("ftl %v: could not find option %q in:\n %v" , strings .Join (cmdPath , " " ), name , strings .Join (slices .Map (maps .Keys (all ), func (name string ) string {
332
+ panic (fmt .Sprintf ("ftl %v: could not find option %q in:\n %v" , strings .Join (cmdPath , " " ), name , strings .Join (slices .Map (maps .Keys (all ), func (name string ) string { //nolint: exptostd
333
333
if included [name ] {
334
334
return name
335
335
}
@@ -407,7 +407,11 @@ func optionForInput(value *kong.Value, description string, flag bool, config *op
407
407
panic ("unhandled bool argument" )
408
408
}
409
409
if value .HasDefault {
410
- opts = append (opts , mcp .DefaultBool (value .DefaultValue .Interface ().(bool )))
410
+ defaultValue , ok := value .DefaultValue .Interface ().(bool )
411
+ if ! ok {
412
+ panic ("expected default value to be a bool" )
413
+ }
414
+ opts = append (opts , mcp .DefaultBool (defaultValue ))
411
415
}
412
416
return mcp .WithBoolean (name , opts ... ), func (args map [string ]any ) ([]string , error ) {
413
417
anyValue , ok := args [name ]
@@ -425,7 +429,11 @@ func optionForInput(value *kong.Value, description string, flag bool, config *op
425
429
426
430
case reflect .String :
427
431
if value .HasDefault {
428
- opts = append (opts , mcp .DefaultString (value .DefaultValue .Interface ().(string )))
432
+ defaultValue , ok := value .DefaultValue .Interface ().(string )
433
+ if ! ok {
434
+ panic ("expected default value to be a string" )
435
+ }
436
+ opts = append (opts , mcp .DefaultString (defaultValue ))
429
437
}
430
438
return newStringOption (name , flag , opts )
431
439
case reflect .Struct :
@@ -434,8 +442,9 @@ func optionForInput(value *kong.Value, description string, flag bool, config *op
434
442
opts = append (opts , mcp .Pattern (refRegex ))
435
443
return newStringOption (name , flag , opts )
436
444
}
437
- }
438
445
446
+ default :
447
+ }
439
448
panic (fmt .Sprintf ("implement type %v %v for %s (hasDefault = %v)" , value .Target .Type (), value .Target .Kind (), name , value .HasDefault ))
440
449
}
441
450
0 commit comments