fa-mcp-sdk 0.2.87 → 0.2.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/fa-mcp.js CHANGED
@@ -13,6 +13,7 @@ const PRINT_FILLED = true;
13
13
 
14
14
  const hl = (v) => chalk.bgGreen.black(v);
15
15
  const hly = (v) => chalk.bgYellow.black(v);
16
+ const hp = (paramName) => ` [${chalk.magenta(paramName)}]`;
16
17
  const formatDefaultValue = (v) => (v ? ` (default: ${hl(v)})` : '');
17
18
  const OPTIONAL = chalk.gray(' (optional)');
18
19
  const FROM_CONFIG = chalk.gray(' (from config)');
@@ -20,7 +21,7 @@ const trim = (s) => String(s || '').trim();
20
21
 
21
22
  const printFilled = (paramName, paramValue) => {
22
23
  if (PRINT_FILLED) {
23
- console.log(` ${paramName}: ${hl(paramValue)}`);
24
+ console.log(` ${hp(paramName)}: ${hl(paramValue)}`);
24
25
  }
25
26
  };
26
27
 
@@ -46,7 +47,7 @@ const getAsk = () => {
46
47
  optional: (title, paramName, defaultValue, example = undefined) => new Promise(resolve => {
47
48
  const defaultText = formatDefaultValue(defaultValue);
48
49
  example = example ? ` (example: ${example})` : '';
49
- const prompt = `${title} [${paramName}]${defaultText}${example}${OPTIONAL}: `;
50
+ const prompt = `${title}${hp(paramName)}${defaultText}${example}${OPTIONAL}: `;
50
51
  rl.question(prompt, (v) => {
51
52
  resolve(trim(v) || trim(defaultValue));
52
53
  });
@@ -57,8 +58,8 @@ const getAsk = () => {
57
58
  const y = isTrue ? `${hl('y')}` : 'y';
58
59
  const n = isTrue ? 'n' : `${hl('n')}`;
59
60
 
60
- paramName = paramName ? ` [${paramName}]` : '';
61
- const prompt = `${title}${paramName} (${y}/${n}): `;
61
+ const hpn = paramName ? hp(paramName) : '';
62
+ const prompt = `${title}${hpn} (${y}/${n}): `;
62
63
  while (true) {
63
64
  const answer = await yn_(prompt, defaultValue === 'true' ? 'y' : 'n');
64
65
  if (answer === 'y' || answer === 'n') {
@@ -171,6 +172,13 @@ class MCPGenerator {
171
172
  defaultValue: '',
172
173
  title: 'Domain name for nginx configuration',
173
174
  },
175
+ {
176
+ name: 'ssl-wildcard.conf.rel.path',
177
+ defaultValue: 'snippets/ssl-wildcard.conf',
178
+ title: `The relative path to the nginx configuration file
179
+ in the /etc/nginx folder that specifies the SSL
180
+ certificate's public and private keys`,
181
+ },
174
182
 
175
183
  {
176
184
  name: 'webServer.auth.enabled',
@@ -201,8 +209,9 @@ class MCPGenerator {
201
209
  name: 'NODE_ENV',
202
210
  },
203
211
  {
204
- skip: true,
205
212
  name: 'SERVICE_INSTANCE',
213
+ defaultValue: '',
214
+ title: 'Suffix of the service name in Consul and process manager',
206
215
  },
207
216
  {
208
217
  skip: true,
@@ -213,6 +222,17 @@ class MCPGenerator {
213
222
  defaultValue: '',
214
223
  title: 'Maintainer url',
215
224
  },
225
+ {
226
+ name: 'logger.useFileLogger',
227
+ defaultValue: '',
228
+ title: 'Whether to check MCP name in the token',
229
+ },
230
+ {
231
+ skip: true,
232
+ name: 'logger.dir',
233
+ defaultValue: '',
234
+ title: 'Absolute path to the folder where logs will be written',
235
+ },
216
236
  ];
217
237
  }
218
238
 
@@ -430,14 +450,28 @@ class MCPGenerator {
430
450
  value = await ask.optional(title, name, defaultValue);
431
451
  if (value) {
432
452
  // Auto-generate upstream from mcp.domain by replacing dots with dashes
433
- config['upstream'] = value.replace(/\./g, '-');
453
+ config.upstream = value.replace(/\./g, '-');
434
454
  }
435
455
  continue;
436
456
 
437
457
  case 'maintainerUrl':
438
458
  value = await ask.optional(title, name, defaultValue);
439
459
  if (value) {
440
- config['maintainerHtml'] = `<a href="${value}" target="_blank" rel="noopener" class="clickable">Support</a>`;
460
+ config.maintainerHtml = `<a href="${value}" target="_blank" rel="noopener" class="clickable">Support</a>`;
461
+ }
462
+ continue;
463
+ case 'logger.useFileLogger':
464
+ const enabled = await ask.yn(title, name, defaultValue);
465
+ config[name] = String(enabled);
466
+ if (enabled) {
467
+ const nm = 'logger.dir';
468
+ const p = this.optionalParams.find(({ name: n }) => n === nm);
469
+ value = await ask.optional(p.title, nm, config[nm] || p.defaultValue);
470
+ if (value) {
471
+ config[nm] = value;
472
+ }
473
+ } else {
474
+ config[nm] = '';
441
475
  }
442
476
  continue;
443
477
  default:
@@ -518,6 +552,11 @@ class MCPGenerator {
518
552
  // Loop until configuration is confirmed
519
553
  while (!confirmed) {
520
554
  await this.collectConfigData(configProxy, isRetry);
555
+
556
+ // Set NODE_ENV and PM2_NAMESPACE based on isProduction
557
+ config.NODE_ENV = config.isProduction === 'true' ? 'production' : 'development';
558
+ config.PM2_NAMESPACE = config.isProduction === 'true' ? 'prod' : 'dev';
559
+
521
560
  confirmed = await this.confirmConfiguration(config);
522
561
 
523
562
  if (!confirmed) {
@@ -1,6 +1,4 @@
1
1
  SERVICE_NAME={{project.name}}
2
- # Used as an alternate service name when using systemd
3
- SERVICE_NAME_ALT={{project.name}}
4
2
  NODE_ENV={{NODE_ENV}}
5
3
  # Used for PM2
6
4
  SERVICE_INSTANCE={{SERVICE_INSTANCE}}
@@ -15,7 +15,7 @@ consul:
15
15
  token: '{{consul.agent.reg.token}}'
16
16
  service:
17
17
  enable: {{consul.service.enable}} # true - Allows registration of the service with the consul
18
- instance: 'instance-0' # This value will be specified as a suffix in the id of the service
18
+ instance: '{{SERVICE_INSTANCE}}' # This value will be specified as a suffix in the id of the service
19
19
  envCode: # Used to generate the service ID
20
20
  prod: '{{consul.envCode.prod}}' # Production environment code
21
21
  dev: '{{consul.envCode.dev}}' # Development environment code
@@ -35,7 +35,9 @@ db:
35
35
 
36
36
  logger:
37
37
  level: info
38
- useFileLogger: true # To use or not to use logging to a file
38
+ useFileLogger: {{logger.useFileLogger}} # To use or not to use logging to a file
39
+ # Absolute path to the folder where logs will be written. Default <proj_root>/../logs
40
+ dir: '{{logger.dir}}'
39
41
 
40
42
  mcp:
41
43
  transportType: http # 'stdio' or 'http'
@@ -11,6 +11,7 @@ db:
11
11
  logger:
12
12
  level: LOGGER_LEVEL
13
13
  useFileLogger: LOGGER_USE_FILE_LOGGER
14
+ dir: LOGGER_DIR
14
15
 
15
16
  mcp:
16
17
  transportType: MCP_TRANSPORT_TYPE
@@ -15,6 +15,7 @@ consul:
15
15
  timeout: '5s'
16
16
  deregistercriticalserviceafter: '3m'
17
17
  agent:
18
+ # Credentials for getting information about services in the DEV DC
18
19
  dev:
19
20
  dc: '{{consul.agent.dev.dc}}'
20
21
  host: '{{consul.agent.dev.host}}'
@@ -22,6 +23,7 @@ consul:
22
23
  secure: true
23
24
  # Token for getting information about DEV services
24
25
  token: '***'
26
+ # Credentials for getting information about services in the PROD DC
25
27
  prd:
26
28
  dc: '{{consul.agent.prd.dc}}'
27
29
  host: '{{consul.agent.prd.host}}'
@@ -29,8 +31,10 @@ consul:
29
31
  secure: true
30
32
  # Token for obtaining information about PROD services
31
33
  token: '***'
34
+ # Credentials for registering the service with Consul
32
35
  reg:
33
- host: null # The host of the consul agent where the service will be registered. If not specified, the server on which the service is running is used
36
+ # The host of the consul agent where the service will be registered. If not specified, the server on which the service is running is used
37
+ host: null
34
38
  port: 8500
35
39
  secure: false
36
40
  # Token for registering the service in the consul agent
@@ -38,7 +42,7 @@ consul:
38
42
  service:
39
43
  enable: {{consul.service.enable}} # true - Allows registration of the service with the consul
40
44
  name: <name> # <name> will be replaced by <package.json>.name at initialization
41
- instance: 'instance-0' # This value will be specified as a suffix in the id of the service
45
+ instance: '{{SERVICE_INSTANCE}}' # This value will be specified as a suffix in the id of the service
42
46
  version: <version> # <version> will be replaced by <package.json>.version at initialization
43
47
  description: <description> # <description> will be replaced by <package.json>.description at initialization
44
48
  tags: [] # If null or empty array - Will be pulled up from package.keywords at initialization
@@ -63,7 +67,9 @@ db:
63
67
 
64
68
  logger:
65
69
  level: info
66
- useFileLogger: true # To use or not to use logging to a file
70
+ useFileLogger: {{logger.useFileLogger}} # To use or not to use logging to a file
71
+ # Absolute path to the folder where logs will be written. Default <proj_root>/../logs
72
+ dir: '{{logger.dir}}'
67
73
 
68
74
  mcp:
69
75
  transportType: http # stdio | http
@@ -77,12 +83,17 @@ mcp:
77
83
 
78
84
  swagger:
79
85
  servers: # An array of servers that will be added to swagger docs
80
- - url: http://localhost:{{port}}
81
- description: "Development server (localhost)"
82
- - url: http://0.0.0.0:{{port}}
83
- description: "Development server (all interfaces)"
86
+ # - url: http://localhost:9020
87
+ # description: "Development server (localhost)"
88
+ # - url: http://0.0.0.0:9020
89
+ # description: "Development server (all interfaces)"
90
+ # - url: http://<prod_server_host_or_ip>:{{port}}
91
+ # description: "PROD server"
92
+ - url: https://{{mcp.domain}}
93
+ description: "PROD server"
84
94
 
85
- uiColor: # Font color of the header and a number of interface elements on the ABOUT page
95
+ uiColor:
96
+ # Font color of the header and a number of interface elements on the ABOUT page
86
97
  primary: '#0f65dc'
87
98
 
88
99
  webServer:
@@ -40,7 +40,7 @@ server {
40
40
  }
41
41
 
42
42
  listen 443 ssl http2;
43
- include snippets/ssl-wildcard-finam-ru.conf;
43
+ include {{ssl-wildcard.conf.rel.path}};
44
44
  include snippets/ssl-params.conf;
45
45
  ssl_protocols TLSv1.3;
46
46
  }
@@ -0,0 +1,18 @@
1
+ ssl_protocols TLSv1.2;
2
+ ssl_prefer_server_ciphers on;
3
+ ssl_dhparam /etc/nginx/dhparam.pem;
4
+ ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
5
+ ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
6
+ ssl_session_timeout 10m;
7
+ ssl_session_cache shared:SSL:10m;
8
+ ssl_session_tickets off; # Requires nginx >= 1.5.9
9
+ ssl_stapling off; # Requires nginx >= 1.3.7
10
+ ssl_stapling_verify on; # Requires nginx => 1.3.7
11
+ resolver 8.8.8.8 8.8.4.4 valid=300s;
12
+ resolver_timeout 5s;
13
+ # Disable strict transport security for now. You can uncomment the following
14
+ # line if you understand the implications.
15
+ # add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
16
+ add_header X-Frame-Options DENY;
17
+ add_header X-Content-Type-Options nosniff;
18
+ add_header X-XSS-Protection "1; mode=block";
@@ -0,0 +1,3 @@
1
+ # Provide the correct paths to the certificate and private key
2
+ ssl_certificate /etc/nginx/cert/wildcard.crt;
3
+ ssl_certificate_key /etc/nginx/cert/wildcard.key;