@@ -27,6 +27,10 @@ If not found, it will treat the argument as a Docker image and run it directly.
27
27
The container will be started with minimal permissions and the specified transport mode.` ,
28
28
Args : cobra .MinimumNArgs (1 ),
29
29
RunE : runCmdFunc ,
30
+ // Ignore unknown flags to allow passing flags to the MCP server
31
+ FParseErrWhitelist : cobra.FParseErrWhitelist {
32
+ UnknownFlags : true ,
33
+ },
30
34
}
31
35
32
36
var (
@@ -92,9 +96,14 @@ func init() {
92
96
}
93
97
94
98
func runCmdFunc (cmd * cobra.Command , args []string ) error {
95
- // Get the server name or image and command arguments
99
+ // Get the server name or image
96
100
serverOrImage := args [0 ]
97
- cmdArgs := args [1 :]
101
+
102
+ // Process command arguments using os.Args to find everything after --
103
+ cmdArgs := parseCommandArguments (os .Args )
104
+
105
+ // Print the processed command arguments for debugging
106
+ logger .Log .Info (fmt .Sprintf ("Processed cmdArgs: %v" , cmdArgs ))
98
107
99
108
// Create context
100
109
ctx , cancel := context .WithCancel (context .Background ())
@@ -354,3 +363,17 @@ func logDebug(debugMode bool, format string, args ...interface{}) {
354
363
logger .Log .Info (fmt .Sprintf (format + "" , args ... ))
355
364
}
356
365
}
366
+
367
+ // parseCommandArguments processes command-line arguments to find everything after the -- separator
368
+ // which are the arguments to be passed to the MCP server
369
+ func parseCommandArguments (args []string ) []string {
370
+ var cmdArgs []string
371
+ for i , arg := range args {
372
+ if arg == "--" && i < len (args )- 1 {
373
+ // Found the separator, take everything after it
374
+ cmdArgs = args [i + 1 :]
375
+ break
376
+ }
377
+ }
378
+ return cmdArgs
379
+ }
0 commit comments