mcp-prompt-optimizer 3.7.3 → 3.7.4

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/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.7.4] - 2026-07-16
9
+
10
+ ### Fixed
11
+ - **CLI commands were mostly non-functional**: the README documented 8 `mcp-prompt-optimizer <command>` subcommands, but the argv dispatcher only ever recognized `connect`. Running any of `check-status`, `validate-key`, `diagnose`, `clear-cache`, `help`, or `version` silently started the blocking stdio MCP server instead, hanging the terminal. All six are now wired to their existing `lib/*.js` implementations.
12
+ - **Unrecognized commands no longer fall through to the server.** Any argument that isn't a known command now prints an error and usage to stderr and exits 1, instead of silently starting the MCP server. This closes the bug class for future commands too, not just the six fixed here.
13
+ - **Dropped `test` from the documented CLI commands.** It mapped to `tests/test-runner.js`, a maintainer-only pre-publish validation script that isn't included in the published npm package (`tests/` is not in `files`), so it could never have worked for an end user.
14
+
8
15
  ## [3.7.3] - 2026-07-16
9
16
 
10
17
  ### Fixed
package/README.md CHANGED
@@ -368,7 +368,6 @@ All plans include AI context detection, template management, personal model conf
368
368
  npx mcp-prompt-optimizer connect # Interactive wizard: add API key to Claude Desktop config
369
369
  mcp-prompt-optimizer check-status # Check API key and quota status
370
370
  mcp-prompt-optimizer validate-key # Validate API key with backend
371
- mcp-prompt-optimizer test # Test backend integration
372
371
  mcp-prompt-optimizer diagnose # Run comprehensive diagnostic
373
372
  mcp-prompt-optimizer clear-cache # Clear validation cache
374
373
  mcp-prompt-optimizer help # Show help and setup instructions
package/index.js CHANGED
@@ -2198,12 +2198,50 @@ async function runConnectWizard() {
2198
2198
  });
2199
2199
  }
2200
2200
 
2201
+ function printCliHelp() {
2202
+ console.log(`MCP Prompt Optimizer v${packageJson.version}
2203
+
2204
+ Usage:
2205
+ mcp-prompt-optimizer Start the MCP server (used by MCP clients)
2206
+ mcp-prompt-optimizer connect Interactive wizard: add API key to Claude Desktop config
2207
+ mcp-prompt-optimizer check-status Check API key and quota status
2208
+ mcp-prompt-optimizer validate-key Validate API key with backend
2209
+ mcp-prompt-optimizer diagnose Run comprehensive diagnostic
2210
+ mcp-prompt-optimizer clear-cache Clear validation cache
2211
+ mcp-prompt-optimizer help Show this help
2212
+ mcp-prompt-optimizer version Show version information`);
2213
+ }
2214
+
2215
+ function printCliVersion() {
2216
+ console.log(packageJson.version);
2217
+ }
2218
+
2219
+ const CLI_COMMANDS = {
2220
+ connect: runConnectWizard,
2221
+ 'check-status': () => require('./lib/check-status')().then(() => process.exit(0)),
2222
+ 'validate-key': () => require('./lib/validate-key')().then(() => process.exit(0)),
2223
+ 'clear-cache': () => require('./lib/clear-cache')().then(() => process.exit(0)),
2224
+ diagnose: () => require('./lib/diagnose')().then(() => process.exit(0)),
2225
+ help: printCliHelp,
2226
+ '--help': printCliHelp,
2227
+ '-h': printCliHelp,
2228
+ version: printCliVersion,
2229
+ '--version': printCliVersion,
2230
+ '-v': printCliVersion,
2231
+ };
2232
+
2201
2233
  if (require.main === module) {
2202
2234
  const args = process.argv.slice(2);
2203
- if (args[0] === 'connect') {
2204
- runConnectWizard();
2205
- } else {
2235
+ const cmd = args[0];
2236
+
2237
+ if (!cmd) {
2206
2238
  startValidatedMCPServer();
2239
+ } else if (CLI_COMMANDS[cmd]) {
2240
+ CLI_COMMANDS[cmd]();
2241
+ } else {
2242
+ console.error(`❌ Unknown command: ${cmd}\n`);
2243
+ printCliHelp();
2244
+ process.exit(1);
2207
2245
  }
2208
2246
  }
2209
2247
 
@@ -241,7 +241,11 @@ class CloudApiKeyManager {
241
241
  // SECURITY: Offline mode removed - backend validation required
242
242
  // No cache fallback beyond 2 hours
243
243
 
244
- throw new Error(`API key validation failed: ${error.message}. Please check your internet connection.`);
244
+ // A 4xx means the backend rejected the key itself, not a connectivity
245
+ // problem — telling the user to check their internet is wrong there.
246
+ const isClientError = error.statusCode >= 400 && error.statusCode < 500;
247
+ const hint = isClientError ? '' : ' Please check your internet connection.';
248
+ throw new Error(`API key validation failed: ${error.message}.${hint}`);
245
249
  }
246
250
  }
247
251
 
@@ -268,7 +272,17 @@ class CloudApiKeyManager {
268
272
  } catch (error) {
269
273
  lastError = error;
270
274
  this.log(`Attempt ${attempt} failed: ${error.message}`, 'warn');
271
-
275
+
276
+ // A 4xx means the backend definitively rejected the request (bad/expired
277
+ // key, malformed request) — retrying with the same key can't change that.
278
+ // Only network errors and 5xx (transient/server-side) are worth retrying.
279
+ // 429 is the exception: rate limits are exactly what backoff is for.
280
+ const isClientError = error.statusCode >= 400 && error.statusCode < 500 && error.statusCode !== 429;
281
+ if (isClientError) {
282
+ this.log('Non-retryable client error — not retrying', 'error');
283
+ break;
284
+ }
285
+
272
286
  if (attempt < this.maxRetries) {
273
287
  const delay = this.calculateRetryDelay(attempt);
274
288
  this.log(`Retrying in ${delay}ms...`);
@@ -690,7 +704,9 @@ class CloudApiKeyManager {
690
704
  } catch {
691
705
  errorMessage = `HTTP ${res.statusCode}: ${responseData}`;
692
706
  }
693
- reject(new Error(errorMessage));
707
+ const httpError = new Error(errorMessage);
708
+ httpError.statusCode = res.statusCode;
709
+ reject(httpError);
694
710
  }
695
711
  } catch (parseError) {
696
712
  reject(new Error(`Invalid response format: ${parseError.message}`));
@@ -25,7 +25,13 @@ async function checkStatus() {
25
25
  console.log('='.repeat(50));
26
26
  console.log(`🎯 Subscription Tier: ${apiKeyInfo.tier}`);
27
27
  console.log(`🔑 API Key Type: ${apiKeyInfo.keyType}`);
28
- console.log(`✅ Key Status: ${apiKeyInfo.isValid ? 'Valid' : 'Invalid'}`);
28
+ console.log(`${apiKeyInfo.isValid ? '✅' : '❌'} Key Status: ${apiKeyInfo.isValid ? 'Valid' : 'Invalid'}`);
29
+ if (!apiKeyInfo.isValid) {
30
+ // getApiKeyInfo() reports failure via isValid:false rather than throwing,
31
+ // so this catch block never sees it — exit(1) has to happen here instead.
32
+ if (apiKeyInfo.error) console.log(` ${apiKeyInfo.error}`);
33
+ process.exit(1);
34
+ }
29
35
  } catch (error) {
30
36
  console.error(`❌ Status check failed: ${error.message}\n`);
31
37
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-prompt-optimizer",
3
- "version": "3.7.3",
3
+ "version": "3.7.4",
4
4
  "description": "Professional cloud-based MCP server for AI-powered prompt optimization with intelligent context detection, Bayesian optimization, AG-UI real-time optimization, template auto-save, optimization insights, personal model configuration via WebUI, team collaboration, enterprise-grade features, production resilience, and startup validation. Universal compatibility with Claude Desktop, Cursor, Windsurf, and 17+ MCP clients.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -195,6 +195,15 @@
195
195
  "last_sync": "2026-06-01T00:00:00Z"
196
196
  },
197
197
  "release_notes": {
198
+ "v3.7.4": {
199
+ "major_features": [
200
+ "Fixed: 6 of 8 documented CLI commands (check-status, validate-key, diagnose, clear-cache, help, version) were not implemented in the argv dispatcher and silently started the blocking MCP server instead, hanging the terminal. Now wired to their lib/*.js implementations.",
201
+ "Fixed: unrecognized CLI arguments now print an error + usage to stderr and exit(1), instead of silently falling through to server startup. Removes the entire hung-terminal bug class, not just the known commands.",
202
+ "Removed 'test' from documented CLI commands: it mapped to a maintainer-only pre-publish script (tests/test-runner.js) that isn't included in the published package."
203
+ ],
204
+ "breaking_changes": [],
205
+ "migration_guide": "No migration required. Only affects users who ran documented CLI subcommands other than 'connect', which previously hung."
206
+ },
198
207
  "v3.7.3": {
199
208
  "major_features": [
200
209
  "Docs only: corrected stale free-tier quota in README (7 optimizations/month -> 20), matching the backend enforcement fix"