@@ -9,6 +9,8 @@ const args = process.argv.slice(2);
99let token = "" ;
1010let baseUrl = "http://localhost:3000" ;
1111let debug = false ;
12+ // Array to collect rules
13+ let rules = [ ] ;
1214
1315// Parse arguments
1416for ( let i = 0 ; i < args . length ; i ++ ) {
@@ -24,14 +26,20 @@ for (let i = 0; i < args.length; i++) {
2426 baseUrl = args [ i ] . split ( "=" ) [ 1 ] ;
2527 } else if ( args [ i ] === "--debug" ) {
2628 debug = true ;
29+ // Add support for --rule parameter
30+ } else if ( args [ i ] === "--rule" && i + 1 < args . length ) {
31+ rules . push ( args [ i + 1 ] ) ;
32+ i ++ ;
33+ } else if ( args [ i ] . startsWith ( "--rule=" ) ) {
34+ rules . push ( args [ i ] . split ( "=" ) [ 1 ] ) ;
2735 }
2836}
2937
3038// Check required arguments
3139if ( ! token ) {
3240 console . error ( "Error: Missing MasterGo API Token" ) ;
3341 console . error (
34- "Usage: npx mastergo-magic-mcp --token=YOUR_TOKEN [--url=API_URL]"
42+ "Usage: npx mastergo-magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME] "
3543 ) ;
3644 console . error ( "Use --help or -h for more information" ) ;
3745 process . exit ( 1 ) ;
@@ -43,6 +51,8 @@ const env = {
4351 MASTERGO_API_TOKEN : token ,
4452 API_BASE_URL : baseUrl ,
4553 DEBUG : debug ? "true" : "false" ,
54+ // Add RULES environment variable as stringified array
55+ RULES : JSON . stringify ( rules ) ,
4656} ;
4757
4858// Get package path
@@ -51,7 +61,9 @@ const indexPath = path.join(packageDir, "index.js");
5161
5262// Check if file exists
5363if ( ! fs . existsSync ( indexPath ) ) {
54- console . error ( "Error: Executable file not found. Please ensure the package is correctly installed." ) ;
64+ console . error (
65+ "Error: Executable file not found. Please ensure the package is correctly installed."
66+ ) ;
5567 process . exit ( 1 ) ;
5668}
5769
@@ -60,6 +72,7 @@ if (debug) {
6072 console . log ( `Package path: ${ indexPath } ` ) ;
6173 console . log ( `Token: ${ token ? "set" : "not set" } ` ) ;
6274 console . log ( `API URL: ${ baseUrl } ` ) ;
75+ console . log ( `Rules: ${ rules . length > 0 ? rules . join ( ", " ) : "none" } ` ) ;
6376 console . log ( `Debug mode: ${ debug ? "enabled" : "disabled" } ` ) ;
6477}
6578
0 commit comments