@@ -27,6 +27,10 @@ If not found, it will treat the argument as a Docker image and run it directly.
2727The container will be started with minimal permissions and the specified transport mode.` ,
2828 Args : cobra .MinimumNArgs (1 ),
2929 RunE : runCmdFunc ,
30+ // Ignore unknown flags to allow passing flags to the MCP server
31+ FParseErrWhitelist : cobra.FParseErrWhitelist {
32+ UnknownFlags : true ,
33+ },
3034}
3135
3236var (
@@ -92,9 +96,14 @@ func init() {
9296}
9397
9498func runCmdFunc (cmd * cobra.Command , args []string ) error {
95- // Get the server name or image and command arguments
99+ // Get the server name or image
96100 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 ))
98107
99108 // Create context
100109 ctx , cancel := context .WithCancel (context .Background ())
@@ -354,3 +363,17 @@ func logDebug(debugMode bool, format string, args ...interface{}) {
354363 logger .Log .Info (fmt .Sprintf (format + "" , args ... ))
355364 }
356365}
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