mcp-prompt-optimizer 1.1.1 ā 1.3.2
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/index.js +752 -121
- package/lib/api-key-manager.js +348 -0
- package/lib/check-status.js +143 -0
- package/lib/clear-cache.js +100 -0
- package/lib/validate-key.js +111 -0
- package/package.json +281 -20
package/index.js
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* MCP Prompt Optimizer - Professional
|
|
5
|
-
*
|
|
4
|
+
* MCP Prompt Optimizer - Professional Cloud-Based AI Optimization Server
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Intelligent AI context detection (image gen, LLM interaction, technical)
|
|
8
|
+
* - 10+ professional optimization techniques
|
|
9
|
+
* - Template management with auto-save
|
|
10
|
+
* - Team collaboration and shared quotas
|
|
11
|
+
* - Universal MCP compatibility
|
|
12
|
+
* - Enterprise-grade analytics
|
|
13
|
+
*
|
|
14
|
+
* Starting at $2.99/month with 5,000 optimizations
|
|
15
|
+
* Free trial: 5 optimizations with full feature access
|
|
16
|
+
*
|
|
17
|
+
* Compatible with: Claude Desktop, Cursor, Windsurf, Cline, VS Code, Zed, Replit, and more
|
|
6
18
|
*/
|
|
7
19
|
|
|
8
|
-
|
|
9
|
-
const {
|
|
20
|
+
// ā
FIXED: Use absolute paths to bypass package.json export issues
|
|
21
|
+
const { Server } = require('./node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js');
|
|
22
|
+
const { StdioServerTransport } = require('./node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js');
|
|
10
23
|
const fetch = require('node-fetch');
|
|
24
|
+
const CloudApiKeyManager = require('./lib/api-key-manager');
|
|
11
25
|
|
|
12
26
|
class MCPPromptOptimizer {
|
|
13
27
|
constructor() {
|
|
14
28
|
this.server = new Server({
|
|
15
29
|
name: "mcp-prompt-optimizer",
|
|
16
|
-
version: "1.
|
|
30
|
+
version: "1.3.0" // Updated version for alignment
|
|
17
31
|
}, {
|
|
18
32
|
capabilities: {
|
|
19
33
|
tools: {}
|
|
@@ -25,131 +39,492 @@ class MCPPromptOptimizer {
|
|
|
25
39
|
this.setupTools();
|
|
26
40
|
}
|
|
27
41
|
|
|
42
|
+
validateApiKey(apiKey) {
|
|
43
|
+
if (!apiKey) return { valid: false, error: 'missing' };
|
|
44
|
+
|
|
45
|
+
// Valid cloud API key formats: sk-opt-*, sk-team-*
|
|
46
|
+
const validFormats = [
|
|
47
|
+
/^sk-opt-[a-zA-Z0-9_-]+$/, // Individual keys
|
|
48
|
+
/^sk-team-[a-zA-Z0-9_-]+$/ // Team keys
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const isValidFormat = validFormats.some(format => format.test(apiKey));
|
|
52
|
+
if (!isValidFormat) {
|
|
53
|
+
return {
|
|
54
|
+
valid: false,
|
|
55
|
+
error: 'invalid_format',
|
|
56
|
+
expectedFormats: ['sk-opt-*', 'sk-team-*']
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { valid: true };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
detectKeyType(apiKey) {
|
|
64
|
+
if (!apiKey) return 'unknown';
|
|
65
|
+
if (apiKey.startsWith('sk-opt-')) return 'individual';
|
|
66
|
+
if (apiKey.startsWith('sk-team-')) return 'team';
|
|
67
|
+
return 'unknown';
|
|
68
|
+
}
|
|
69
|
+
|
|
28
70
|
setupTools() {
|
|
29
|
-
//
|
|
71
|
+
// Main optimization tool with full feature set
|
|
30
72
|
this.server.setRequestHandler('tools/list', async () => {
|
|
31
73
|
return {
|
|
32
74
|
tools: [
|
|
33
75
|
{
|
|
34
76
|
name: "optimize_prompt",
|
|
35
|
-
description: "Professional
|
|
77
|
+
description: "Professional cloud-based AI prompt optimization with intelligent context detection, template management, and team collaboration. All plans include the same sophisticated AI engine - differences are only in quotas, team size, and support levels.",
|
|
36
78
|
inputSchema: {
|
|
37
79
|
type: "object",
|
|
38
80
|
properties: {
|
|
39
81
|
prompt: {
|
|
40
82
|
type: "string",
|
|
41
|
-
description: "The prompt text to optimize"
|
|
83
|
+
description: "The prompt text to optimize (required)",
|
|
84
|
+
minLength: 1,
|
|
85
|
+
maxLength: 50000
|
|
42
86
|
},
|
|
43
87
|
goals: {
|
|
44
88
|
type: "array",
|
|
45
89
|
items: { type: "string" },
|
|
46
|
-
description: "Optimization goals
|
|
47
|
-
default: ["clarity"]
|
|
90
|
+
description: "Optimization goals: clarity, conciseness, creativity, specificity, actionability, technical_accuracy, keyword_density, parameter_preservation, context_specificity, token_efficiency",
|
|
91
|
+
default: ["clarity"],
|
|
92
|
+
minItems: 1,
|
|
93
|
+
maxItems: 10
|
|
48
94
|
},
|
|
49
95
|
ai_context: {
|
|
50
96
|
type: "string",
|
|
51
|
-
enum: [
|
|
52
|
-
|
|
97
|
+
enum: [
|
|
98
|
+
"human_communication",
|
|
99
|
+
"llm_interaction",
|
|
100
|
+
"image_generation",
|
|
101
|
+
"technical_automation",
|
|
102
|
+
"structured_output",
|
|
103
|
+
"code_generation",
|
|
104
|
+
"api_automation"
|
|
105
|
+
],
|
|
106
|
+
description: "AI context for intelligent optimization routing (auto-detected if not specified)",
|
|
53
107
|
default: "llm_interaction"
|
|
54
108
|
}
|
|
55
109
|
},
|
|
56
110
|
required: ["prompt"]
|
|
57
111
|
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "get_quota_status",
|
|
115
|
+
description: "Check your current subscription quota status, usage, and plan details",
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: "object",
|
|
118
|
+
properties: {},
|
|
119
|
+
required: []
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "search_templates",
|
|
124
|
+
description: "Search your saved templates by content, tags, or AI context",
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: {
|
|
128
|
+
query: {
|
|
129
|
+
type: "string",
|
|
130
|
+
description: "Search query for template content",
|
|
131
|
+
maxLength: 500
|
|
132
|
+
},
|
|
133
|
+
ai_context: {
|
|
134
|
+
type: "string",
|
|
135
|
+
enum: [
|
|
136
|
+
"human_communication",
|
|
137
|
+
"llm_interaction",
|
|
138
|
+
"image_generation",
|
|
139
|
+
"technical_automation",
|
|
140
|
+
"structured_output",
|
|
141
|
+
"code_generation",
|
|
142
|
+
"api_automation"
|
|
143
|
+
],
|
|
144
|
+
description: "Filter by AI context type"
|
|
145
|
+
},
|
|
146
|
+
limit: {
|
|
147
|
+
type: "integer",
|
|
148
|
+
minimum: 1,
|
|
149
|
+
maximum: 20,
|
|
150
|
+
default: 5,
|
|
151
|
+
description: "Maximum number of templates to return"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
required: []
|
|
155
|
+
}
|
|
58
156
|
}
|
|
59
157
|
]
|
|
60
158
|
};
|
|
61
159
|
});
|
|
62
160
|
|
|
63
161
|
this.server.setRequestHandler('tools/call', async (request) => {
|
|
64
|
-
|
|
65
|
-
return await this.handleOptimize(request.params.arguments);
|
|
66
|
-
}
|
|
162
|
+
const { name, arguments: args } = request.params;
|
|
67
163
|
|
|
68
|
-
|
|
164
|
+
switch (name) {
|
|
165
|
+
case "optimize_prompt":
|
|
166
|
+
return await this.handleOptimize(args);
|
|
167
|
+
case "get_quota_status":
|
|
168
|
+
return await this.handleQuotaStatus(args);
|
|
169
|
+
case "search_templates":
|
|
170
|
+
return await this.handleSearchTemplates(args);
|
|
171
|
+
default:
|
|
172
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
173
|
+
}
|
|
69
174
|
});
|
|
70
175
|
}
|
|
71
176
|
|
|
72
177
|
async handleOptimize(args) {
|
|
73
178
|
try {
|
|
74
|
-
// Validate API key
|
|
75
|
-
|
|
179
|
+
// Validate API key
|
|
180
|
+
const keyValidation = this.validateApiKey(this.apiKey);
|
|
181
|
+
if (!keyValidation.valid) {
|
|
182
|
+
return this.createSubscriptionRequiredResponse(keyValidation);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Validate required arguments
|
|
186
|
+
if (!args.prompt || !args.prompt.trim()) {
|
|
76
187
|
return {
|
|
77
188
|
content: [{
|
|
78
189
|
type: "text",
|
|
79
|
-
text:
|
|
80
|
-
|
|
81
|
-
This professional MCP server requires an active subscription starting at $2.99/month.
|
|
82
|
-
|
|
83
|
-
**š Try it free first:**
|
|
84
|
-
Get your API key with 5 free optimizations at:
|
|
85
|
-
https://promptoptimizer-blog.vercel.app/pricing
|
|
86
|
-
|
|
87
|
-
**š° Professional plans (same AI quality, different quotas):**
|
|
88
|
-
- **Explorer ($2.99/mo):** 5,000 optimizations + individual use
|
|
89
|
-
- **Creator ($25.99/mo):** 18,000 optimizations + team features (2 members)
|
|
90
|
-
- **Innovator ($69.99/mo):** 75,000 optimizations + large teams (5 members) + priority support
|
|
91
|
-
|
|
92
|
-
**āļø Setup:**
|
|
93
|
-
Add your API key to Claude Desktop config:
|
|
94
|
-
\`\`\`json
|
|
95
|
-
{
|
|
96
|
-
"mcpServers": {
|
|
97
|
-
"prompt-optimizer": {
|
|
98
|
-
"command": "npx",
|
|
99
|
-
"args": ["mcp-prompt-optimizer"],
|
|
100
|
-
"env": {
|
|
101
|
-
"OPTIMIZER_API_KEY": "sk-opt-your-key-here"
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
\`\`\``
|
|
190
|
+
text: "# ā Error\n\nPrompt cannot be empty. Please provide a prompt to optimize."
|
|
107
191
|
}],
|
|
108
192
|
isError: true
|
|
109
193
|
};
|
|
110
194
|
}
|
|
111
195
|
|
|
112
|
-
//
|
|
196
|
+
// Prepare request payload matching backend expectations
|
|
197
|
+
const requestPayload = {
|
|
198
|
+
prompt: args.prompt.trim(),
|
|
199
|
+
goals: args.goals || ["clarity"],
|
|
200
|
+
ai_context: args.ai_context || "llm_interaction"
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// Call backend API using standardized header
|
|
113
204
|
const response = await fetch(`${this.backendUrl}/api/v1/mcp/optimize`, {
|
|
114
205
|
method: 'POST',
|
|
115
206
|
headers: {
|
|
116
207
|
'Content-Type': 'application/json',
|
|
117
|
-
'
|
|
118
|
-
'User-Agent': 'mcp-prompt-optimizer/1.
|
|
208
|
+
'x-api-key': this.apiKey, // ā
FIXED: Use lowercase header to match backend
|
|
209
|
+
'User-Agent': 'mcp-prompt-optimizer/1.3.0'
|
|
119
210
|
},
|
|
120
|
-
body: JSON.stringify(
|
|
211
|
+
body: JSON.stringify(requestPayload)
|
|
121
212
|
});
|
|
122
213
|
|
|
123
214
|
if (!response.ok) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
215
|
+
return await this.handleApiError(response);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const result = await response.json();
|
|
219
|
+
return {
|
|
220
|
+
content: [{
|
|
221
|
+
type: "text",
|
|
222
|
+
text: this.formatOptimizationResult(result, args)
|
|
223
|
+
}]
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.error('Optimization error:', error);
|
|
228
|
+
return {
|
|
229
|
+
content: [{
|
|
230
|
+
type: "text",
|
|
231
|
+
text: `# ā Network Error\n\n${error.message}\n\nPlease check your internet connection and try again.`
|
|
232
|
+
}],
|
|
233
|
+
isError: true
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async handleQuotaStatus(args) {
|
|
239
|
+
try {
|
|
240
|
+
const keyValidation = this.validateApiKey(this.apiKey);
|
|
241
|
+
if (!keyValidation.valid) {
|
|
242
|
+
return this.createSubscriptionRequiredResponse(keyValidation);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const response = await fetch(`${this.backendUrl}/api/v1/mcp/quota-status`, {
|
|
246
|
+
method: 'GET',
|
|
247
|
+
headers: {
|
|
248
|
+
'x-api-key': this.apiKey, // ā
FIXED: Use lowercase header
|
|
249
|
+
'User-Agent': 'mcp-prompt-optimizer/1.3.0'
|
|
133
250
|
}
|
|
134
|
-
|
|
135
|
-
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
if (!response.ok) {
|
|
254
|
+
return await this.handleApiError(response);
|
|
136
255
|
}
|
|
137
256
|
|
|
138
257
|
const result = await response.json();
|
|
139
|
-
return {
|
|
258
|
+
return {
|
|
259
|
+
content: [{
|
|
260
|
+
type: "text",
|
|
261
|
+
text: this.formatQuotaStatus(result)
|
|
262
|
+
}]
|
|
263
|
+
};
|
|
140
264
|
|
|
141
265
|
} catch (error) {
|
|
142
266
|
return {
|
|
143
267
|
content: [{
|
|
144
268
|
type: "text",
|
|
145
|
-
text: `# ā Error\n\n${error.message}`
|
|
269
|
+
text: `# ā Error Getting Quota Status\n\n${error.message}`
|
|
146
270
|
}],
|
|
147
271
|
isError: true
|
|
148
272
|
};
|
|
149
273
|
}
|
|
150
274
|
}
|
|
151
275
|
|
|
152
|
-
|
|
276
|
+
async handleSearchTemplates(args) {
|
|
277
|
+
try {
|
|
278
|
+
const keyValidation = this.validateApiKey(this.apiKey);
|
|
279
|
+
if (!keyValidation.valid) {
|
|
280
|
+
return this.createSubscriptionRequiredResponse(keyValidation);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const params = new URLSearchParams();
|
|
284
|
+
if (args.query) params.append('query', args.query);
|
|
285
|
+
if (args.ai_context) params.append('ai_context', args.ai_context);
|
|
286
|
+
params.append('per_page', (args.limit || 5).toString());
|
|
287
|
+
|
|
288
|
+
const response = await fetch(`${this.backendUrl}/api/v1/templates?${params.toString()}`, {
|
|
289
|
+
method: 'GET',
|
|
290
|
+
headers: {
|
|
291
|
+
'x-api-key': this.apiKey, // ā
FIXED: Use lowercase header
|
|
292
|
+
'User-Agent': 'mcp-prompt-optimizer/1.3.0'
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
if (!response.ok) {
|
|
297
|
+
return await this.handleApiError(response);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const result = await response.json();
|
|
301
|
+
return {
|
|
302
|
+
content: [{
|
|
303
|
+
type: "text",
|
|
304
|
+
text: this.formatTemplateSearchResults(result, args)
|
|
305
|
+
}]
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
} catch (error) {
|
|
309
|
+
return {
|
|
310
|
+
content: [{
|
|
311
|
+
type: "text",
|
|
312
|
+
text: `# ā Template Search Error\n\n${error.message}`
|
|
313
|
+
}],
|
|
314
|
+
isError: true
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async handleApiError(response) {
|
|
320
|
+
const status = response.status;
|
|
321
|
+
let errorMessage = `API Error: ${response.statusText}`;
|
|
322
|
+
|
|
323
|
+
try {
|
|
324
|
+
const errorData = await response.json();
|
|
325
|
+
errorMessage = errorData.detail || errorMessage;
|
|
326
|
+
} catch (e) {
|
|
327
|
+
// Use default message if JSON parsing fails
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (status === 401) {
|
|
331
|
+
return {
|
|
332
|
+
content: [{
|
|
333
|
+
type: "text",
|
|
334
|
+
text: this.createInvalidKeyResponse(errorMessage)
|
|
335
|
+
}],
|
|
336
|
+
isError: true
|
|
337
|
+
};
|
|
338
|
+
} else if (status === 402 || status === 429) {
|
|
339
|
+
return {
|
|
340
|
+
content: [{
|
|
341
|
+
type: "text",
|
|
342
|
+
text: this.createQuotaExceededResponse(errorMessage)
|
|
343
|
+
}],
|
|
344
|
+
isError: true
|
|
345
|
+
};
|
|
346
|
+
} else if (status === 500) {
|
|
347
|
+
return {
|
|
348
|
+
content: [{
|
|
349
|
+
type: "text",
|
|
350
|
+
text: `# ā ļø Server Error\n\n${errorMessage}\n\nPlease try again in a moment. If the issue persists, contact support@promptoptimizer.help`
|
|
351
|
+
}],
|
|
352
|
+
isError: true
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
return {
|
|
357
|
+
content: [{
|
|
358
|
+
type: "text",
|
|
359
|
+
text: `# ā Error (${status})\n\n${errorMessage}`
|
|
360
|
+
}],
|
|
361
|
+
isError: true
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
createSubscriptionRequiredResponse(keyValidation) {
|
|
366
|
+
const keyType = this.detectKeyType(this.apiKey);
|
|
367
|
+
|
|
368
|
+
let content = `# š Professional MCP Server - Cloud Subscription Required
|
|
369
|
+
|
|
370
|
+
This professional cloud-based MCP server requires an active subscription starting at **$2.99/month**.
|
|
371
|
+
|
|
372
|
+
## š **Get Started Free**
|
|
373
|
+
Get your API key with **5 free optimizations** at:
|
|
374
|
+
**https://promptoptimizer-blog.vercel.app/pricing**
|
|
375
|
+
|
|
376
|
+
## š° **Cloud Subscription Plans** (same AI quality, different quotas)
|
|
377
|
+
- **Explorer ($2.99/mo):** 5,000 optimizations + individual use
|
|
378
|
+
- **Creator ($25.99/mo):** 18,000 optimizations + team features (2 members)
|
|
379
|
+
- **Innovator ($69.99/mo):** 75,000 optimizations + large teams (5 members) + priority support
|
|
380
|
+
|
|
381
|
+
## ⨠**Professional Cloud Features** (all plans)
|
|
382
|
+
- š§ **AI Context Detection** - Automatically detects image generation, LLM interaction, technical contexts
|
|
383
|
+
- šÆ **10+ Optimization Techniques** - Clarity, specificity, technical accuracy, and more
|
|
384
|
+
- š **Template Management** - Auto-save high-confidence optimizations, search & reuse
|
|
385
|
+
- š **Real-time Analytics** - Confidence scoring, usage tracking, performance insights
|
|
386
|
+
- š„ **Team Collaboration** - Shared quotas, team templates, role-based access
|
|
387
|
+
- š§ **Universal MCP** - Works with Claude Desktop, Cursor, Windsurf, Cline, VS Code, Zed, Replit
|
|
388
|
+
- āļø **Cloud Processing** - No local setup, always up-to-date AI models
|
|
389
|
+
- š **Priority Processing** - Creator and Innovator plans get faster response times
|
|
390
|
+
|
|
391
|
+
## āļø **Setup Instructions**
|
|
392
|
+
Add your API key to Claude Desktop config:
|
|
393
|
+
\`\`\`json
|
|
394
|
+
{
|
|
395
|
+
"mcpServers": {
|
|
396
|
+
"prompt-optimizer": {
|
|
397
|
+
"command": "npx",
|
|
398
|
+
"args": ["mcp-prompt-optimizer"],
|
|
399
|
+
"env": {
|
|
400
|
+
"OPTIMIZER_API_KEY": "sk-opt-your-key-here"
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
\`\`\`
|
|
406
|
+
|
|
407
|
+
## š§ **Other MCP Clients**
|
|
408
|
+
- **Cursor:** Add to ~/.cursor/mcp.json
|
|
409
|
+
- **Windsurf:** Configure in settings
|
|
410
|
+
- **Cline:** Use standard MCP configuration
|
|
411
|
+
- **VS Code/Zed/Replit:** Standard MCP setup
|
|
412
|
+
|
|
413
|
+
## š¢ **Team Plans Available**
|
|
414
|
+
Team API keys (\`sk-team-*\`) provide:
|
|
415
|
+
- Shared quotas across team members
|
|
416
|
+
- Centralized billing and management
|
|
417
|
+
- Team template libraries
|
|
418
|
+
- Role-based access control
|
|
419
|
+
|
|
420
|
+
## š§ **Troubleshooting Tools**
|
|
421
|
+
- **Check status:** mcp-prompt-optimizer check-status
|
|
422
|
+
- **Validate key:** mcp-prompt-optimizer validate-key
|
|
423
|
+
- **Clear cache:** mcp-prompt-optimizer clear-cache
|
|
424
|
+
|
|
425
|
+
## š§ **Support**
|
|
426
|
+
- General: support@promptoptimizer.help
|
|
427
|
+
- Enterprise: enterprise@promptoptimizer.help
|
|
428
|
+
- Documentation: https://promptoptimizer-blog.vercel.app/docs
|
|
429
|
+
- Dashboard: https://promptoptimizer-blog.vercel.app/dashboard`;
|
|
430
|
+
|
|
431
|
+
if (keyValidation.error === 'invalid_format') {
|
|
432
|
+
content += `\n\n## ā **API Key Format Issue**
|
|
433
|
+
Your API key format is invalid. Expected formats:
|
|
434
|
+
- Individual: \`sk-opt-*\`
|
|
435
|
+
- Team: \`sk-team-*\`
|
|
436
|
+
|
|
437
|
+
Current key type detected: \`${keyType}\`
|
|
438
|
+
Please get a new API key from: https://promptoptimizer-blog.vercel.app/pricing`;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return {
|
|
442
|
+
content: [{
|
|
443
|
+
type: "text",
|
|
444
|
+
text: content
|
|
445
|
+
}],
|
|
446
|
+
isError: true
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
createInvalidKeyResponse(errorMessage) {
|
|
451
|
+
return `# š Invalid API Key
|
|
452
|
+
|
|
453
|
+
**Error:** ${errorMessage}
|
|
454
|
+
|
|
455
|
+
## š§ **Fix Options:**
|
|
456
|
+
|
|
457
|
+
1. **Get a new API key** from: https://promptoptimizer-blog.vercel.app/pricing
|
|
458
|
+
2. **Check your configuration** - ensure \`OPTIMIZER_API_KEY\` is set correctly
|
|
459
|
+
3. **Verify key format** - should start with \`sk-opt-\` (individual) or \`sk-team-\` (team)
|
|
460
|
+
|
|
461
|
+
## āļø **Claude Desktop Config:**
|
|
462
|
+
\`\`\`json
|
|
463
|
+
{
|
|
464
|
+
"mcpServers": {
|
|
465
|
+
"prompt-optimizer": {
|
|
466
|
+
"command": "npx",
|
|
467
|
+
"args": ["mcp-prompt-optimizer"],
|
|
468
|
+
"env": {
|
|
469
|
+
"OPTIMIZER_API_KEY": "sk-opt-your-actual-key-here"
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
\`\`\`
|
|
475
|
+
|
|
476
|
+
## š§ **Quick Diagnostic:**
|
|
477
|
+
- **Validate your key:** mcp-prompt-optimizer validate-key
|
|
478
|
+
- **Check full status:** mcp-prompt-optimizer check-status
|
|
479
|
+
- **Clear cache:** mcp-prompt-optimizer clear-cache
|
|
480
|
+
|
|
481
|
+
## š **Need a New Key?**
|
|
482
|
+
Visit https://promptoptimizer-blog.vercel.app/pricing to:
|
|
483
|
+
- Get 5 free trial optimizations
|
|
484
|
+
- Choose from Explorer ($2.99), Creator ($25.99), or Innovator ($69.99) plans
|
|
485
|
+
- Set up team accounts with shared quotas
|
|
486
|
+
|
|
487
|
+
## š§ **Still Having Issues?**
|
|
488
|
+
Contact support@promptoptimizer.help with your key prefix (first 8 characters) for assistance.`;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
createQuotaExceededResponse(errorMessage) {
|
|
492
|
+
return `# š Quota Exceeded
|
|
493
|
+
|
|
494
|
+
**Error:** ${errorMessage}
|
|
495
|
+
|
|
496
|
+
## š **Upgrade Options:**
|
|
497
|
+
|
|
498
|
+
### Current Plans:
|
|
499
|
+
- **Explorer ($2.99/mo):** 5,000 optimizations
|
|
500
|
+
- **Creator ($25.99/mo):** 18,000 optimizations + team features
|
|
501
|
+
- **Innovator ($69.99/mo):** 75,000 optimizations + large teams
|
|
502
|
+
|
|
503
|
+
## š **Upgrade Now:**
|
|
504
|
+
Visit https://promptoptimizer-blog.vercel.app/dashboard to:
|
|
505
|
+
- View your current usage
|
|
506
|
+
- Upgrade to a higher plan
|
|
507
|
+
- Manage team subscriptions
|
|
508
|
+
|
|
509
|
+
## š
**Quota Reset:**
|
|
510
|
+
Individual quotas reset monthly on your billing date.
|
|
511
|
+
Team quotas reset monthly on the team billing cycle.
|
|
512
|
+
|
|
513
|
+
## š§ **Check Usage:**
|
|
514
|
+
- **Detailed status:** mcp-prompt-optimizer check-status
|
|
515
|
+
- **Current quota:** Use the \`get_quota_status\` tool
|
|
516
|
+
- **Usage trends:** Visit your dashboard
|
|
517
|
+
|
|
518
|
+
## š” **Tips:**
|
|
519
|
+
- Consider upgrading if you regularly hit limits
|
|
520
|
+
- Team plans offer better value for multiple users
|
|
521
|
+
- Pro tip: Use templates to avoid re-optimizing similar prompts
|
|
522
|
+
|
|
523
|
+
## š§ **Need Help?**
|
|
524
|
+
Contact support@promptoptimizer.help for usage optimization advice or enterprise solutions.`;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
formatOptimizationResult(result, originalArgs) {
|
|
153
528
|
let output = `# šÆ Optimized Prompt\n\n${result.optimized_prompt}\n\n`;
|
|
154
529
|
|
|
155
530
|
// Same response for ALL users - no tier differences in optimization quality
|
|
@@ -159,6 +534,21 @@ Add your API key to Claude Desktop config:
|
|
|
159
534
|
output += `**Plan:** ${result.tier.charAt(0).toUpperCase() + result.tier.slice(1)}\n`;
|
|
160
535
|
}
|
|
161
536
|
|
|
537
|
+
// AI Context information
|
|
538
|
+
if (originalArgs.ai_context || result.ai_context) {
|
|
539
|
+
const context = originalArgs.ai_context || result.ai_context;
|
|
540
|
+
const contextLabels = {
|
|
541
|
+
'human_communication': 'Human Communication',
|
|
542
|
+
'llm_interaction': 'LLM Interaction',
|
|
543
|
+
'image_generation': 'Image Generation',
|
|
544
|
+
'technical_automation': 'Technical Automation',
|
|
545
|
+
'structured_output': 'Structured Output',
|
|
546
|
+
'code_generation': 'Code Generation',
|
|
547
|
+
'api_automation': 'API Automation'
|
|
548
|
+
};
|
|
549
|
+
output += `**AI Context:** ${contextLabels[context] || context}\n`;
|
|
550
|
+
}
|
|
551
|
+
|
|
162
552
|
// Template auto-saving (available for ALL users)
|
|
163
553
|
if (result.template_saved) {
|
|
164
554
|
output += `\nā
**Auto-saved as template** (ID: ${result.template_id})\n`;
|
|
@@ -176,7 +566,7 @@ Add your API key to Claude Desktop config:
|
|
|
176
566
|
result.templates_found.forEach((t, index) => {
|
|
177
567
|
output += `${index + 1}. **${t.title}** (${(t.confidence_score * 100).toFixed(1)}% similarity)\n`;
|
|
178
568
|
});
|
|
179
|
-
output += `*
|
|
569
|
+
output += `*Use \`search_templates\` tool to explore your template library*\n`;
|
|
180
570
|
}
|
|
181
571
|
|
|
182
572
|
// Optimization insights (available for ALL users)
|
|
@@ -212,8 +602,153 @@ Add your API key to Claude Desktop config:
|
|
|
212
602
|
}
|
|
213
603
|
|
|
214
604
|
// Professional footer
|
|
215
|
-
output += `\n---\n*Professional
|
|
216
|
-
output += `\nš” **Manage
|
|
605
|
+
output += `\n---\n*Professional cloud-based AI optimization*`;
|
|
606
|
+
output += `\nš” **Manage account:** https://promptoptimizer-blog.vercel.app/dashboard`;
|
|
607
|
+
output += `\nš **Check quota:** Use \`get_quota_status\` tool`;
|
|
608
|
+
output += `\nš **Search templates:** Use \`search_templates\` tool`;
|
|
609
|
+
|
|
610
|
+
return output;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
formatQuotaStatus(result) {
|
|
614
|
+
let output = `# š Subscription Quota Status\n\n`;
|
|
615
|
+
|
|
616
|
+
// Plan information
|
|
617
|
+
output += `**Plan:** ${result.tier.charAt(0).toUpperCase() + result.tier.slice(1)}\n`;
|
|
618
|
+
|
|
619
|
+
// Quota details
|
|
620
|
+
if (result.quota.unlimited) {
|
|
621
|
+
output += `**Usage:** Unlimited optimizations\n`;
|
|
622
|
+
} else {
|
|
623
|
+
output += `**Usage:** ${result.quota.used.toLocaleString()} / ${result.quota.limit.toLocaleString()} optimizations\n`;
|
|
624
|
+
output += `**Remaining:** ${result.quota.remaining.toLocaleString()} optimizations\n`;
|
|
625
|
+
output += `**Usage:** ${result.quota.usage_percentage}% of monthly quota\n`;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
// Status indicator
|
|
629
|
+
const status = result.status;
|
|
630
|
+
const statusEmoji = {
|
|
631
|
+
'healthy': 'ā
',
|
|
632
|
+
'warning': 'ā ļø',
|
|
633
|
+
'critical': 'š“'
|
|
634
|
+
};
|
|
635
|
+
output += `**Status:** ${statusEmoji[status] || 'ā'} ${status.charAt(0).toUpperCase() + status.slice(1)}\n`;
|
|
636
|
+
|
|
637
|
+
// Context information
|
|
638
|
+
if (result.api_key_type === 'team') {
|
|
639
|
+
output += `\n## š„ Team Information\n`;
|
|
640
|
+
if (result.team_info) {
|
|
641
|
+
output += `**Team:** ${result.team_info.team_name || 'Unknown'}\n`;
|
|
642
|
+
output += `**Team ID:** ${result.team_info.team_id}\n`;
|
|
643
|
+
}
|
|
644
|
+
output += `*This is a team subscription with shared quota*\n`;
|
|
645
|
+
} else {
|
|
646
|
+
output += `\n## š¤ Individual Information\n`;
|
|
647
|
+
output += `**Account Type:** Individual subscription\n`;
|
|
648
|
+
if (result.user_info) {
|
|
649
|
+
output += `**User ID:** ${result.user_info.user_id}\n`;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// Features available
|
|
654
|
+
output += `\n## ⨠Features Available\n`;
|
|
655
|
+
const features = result.features_available;
|
|
656
|
+
if (features.professional_optimization) output += `- ā
Professional AI optimization\n`;
|
|
657
|
+
if (features.auto_save_templates) output += `- ā
Template auto-save\n`;
|
|
658
|
+
if (features.template_search) output += `- ā
Template search\n`;
|
|
659
|
+
if (features.optimization_insights) output += `- ā
Optimization insights\n`;
|
|
660
|
+
|
|
661
|
+
// Upgrade suggestions
|
|
662
|
+
if (status === 'warning' || status === 'critical') {
|
|
663
|
+
output += `\n## š Upgrade Recommendations\n`;
|
|
664
|
+
output += `Consider upgrading to a higher tier for more optimizations:\n`;
|
|
665
|
+
output += `- **Creator ($25.99/mo):** 18,000 optimizations + team features\n`;
|
|
666
|
+
output += `- **Innovator ($69.99/mo):** 75,000 optimizations + priority support\n`;
|
|
667
|
+
output += `\n**Upgrade:** https://promptoptimizer-blog.vercel.app/dashboard\n`;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
output += `\n---\n*Use \`optimize_prompt\` to start optimizing with AI context detection*`;
|
|
671
|
+
output += `\n*Use \`search_templates\` to find and reuse saved optimizations*`;
|
|
672
|
+
|
|
673
|
+
return output;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
formatTemplateSearchResults(result, originalArgs) {
|
|
677
|
+
let output = `# š Template Search Results\n\n`;
|
|
678
|
+
|
|
679
|
+
if (!result.templates || result.templates.length === 0) {
|
|
680
|
+
output += `No templates found`;
|
|
681
|
+
if (originalArgs.query) {
|
|
682
|
+
output += ` matching "${originalArgs.query}"`;
|
|
683
|
+
}
|
|
684
|
+
if (originalArgs.ai_context) {
|
|
685
|
+
output += ` in context "${originalArgs.ai_context}"`;
|
|
686
|
+
}
|
|
687
|
+
output += `.\n\n`;
|
|
688
|
+
output += `š” **Tips:**\n`;
|
|
689
|
+
output += `- Try broader search terms\n`;
|
|
690
|
+
output += `- Remove AI context filter\n`;
|
|
691
|
+
output += `- Use \`optimize_prompt\` to create new templates\n`;
|
|
692
|
+
return output;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
output += `Found ${result.templates.length} template(s)`;
|
|
696
|
+
if (originalArgs.query) {
|
|
697
|
+
output += ` matching "${originalArgs.query}"`;
|
|
698
|
+
}
|
|
699
|
+
output += `:\n\n`;
|
|
700
|
+
|
|
701
|
+
result.templates.forEach((template, index) => {
|
|
702
|
+
output += `## ${index + 1}. ${template.title}\n`;
|
|
703
|
+
|
|
704
|
+
// Template metadata
|
|
705
|
+
if (template.ai_context_detected) {
|
|
706
|
+
const contextLabels = {
|
|
707
|
+
'human_communication': 'Human Communication',
|
|
708
|
+
'llm_interaction': 'LLM Interaction',
|
|
709
|
+
'image_generation': 'Image Generation',
|
|
710
|
+
'technical_automation': 'Technical Automation',
|
|
711
|
+
'structured_output': 'Structured Output',
|
|
712
|
+
'code_generation': 'Code Generation',
|
|
713
|
+
'api_automation': 'API Automation'
|
|
714
|
+
};
|
|
715
|
+
output += `**Context:** ${contextLabels[template.ai_context_detected] || template.ai_context_detected}\n`;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (template.confidence_score) {
|
|
719
|
+
output += `**Confidence:** ${(template.confidence_score * 100).toFixed(1)}%\n`;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
if (template.tags && template.tags.length > 0) {
|
|
723
|
+
output += `**Tags:** ${template.tags.join(', ')}\n`;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
// Show optimized prompt preview
|
|
727
|
+
const preview = template.optimized_prompt.length > 200
|
|
728
|
+
? template.optimized_prompt.substring(0, 200) + '...'
|
|
729
|
+
: template.optimized_prompt;
|
|
730
|
+
output += `**Optimized Prompt:** ${preview}\n`;
|
|
731
|
+
|
|
732
|
+
if (template.created_at) {
|
|
733
|
+
const date = new Date(template.created_at).toLocaleDateString();
|
|
734
|
+
output += `**Created:** ${date}\n`;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
output += `\n`;
|
|
738
|
+
});
|
|
739
|
+
|
|
740
|
+
// Show pagination info
|
|
741
|
+
if (result.total_pages > 1) {
|
|
742
|
+
output += `---\n`;
|
|
743
|
+
output += `**Page ${result.page} of ${result.total_pages}** (${result.total} total templates)\n`;
|
|
744
|
+
output += `*Adjust \`limit\` parameter to see more results per search*\n\n`;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
output += `š” **Template Usage:**\n`;
|
|
748
|
+
output += `- Copy optimized prompts for immediate use\n`;
|
|
749
|
+
output += `- Study successful patterns for your context\n`;
|
|
750
|
+
output += `- Create variations based on proven templates\n`;
|
|
751
|
+
output += `\n*Visit https://promptoptimizer-blog.vercel.app/dashboard to manage all templates*`;
|
|
217
752
|
|
|
218
753
|
return output;
|
|
219
754
|
}
|
|
@@ -224,67 +759,163 @@ Add your API key to Claude Desktop config:
|
|
|
224
759
|
}
|
|
225
760
|
}
|
|
226
761
|
|
|
227
|
-
//
|
|
228
|
-
async function
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
console.log('Add to ~/.claude/claude_desktop_config.json:');
|
|
245
|
-
console.log(JSON.stringify({
|
|
246
|
-
"mcpServers": {
|
|
247
|
-
"prompt-optimizer": {
|
|
248
|
-
"command": "npx",
|
|
249
|
-
"args": ["mcp-prompt-optimizer"],
|
|
250
|
-
"env": {
|
|
251
|
-
"OPTIMIZER_API_KEY": "sk-opt-your-key-here"
|
|
762
|
+
// ā
NEW: Startup validation function (following local pattern)
|
|
763
|
+
async function startValidatedMCPServer() {
|
|
764
|
+
console.error('š MCP Prompt Optimizer - Professional Cloud Server v1.3.0\n');
|
|
765
|
+
|
|
766
|
+
try {
|
|
767
|
+
// Step 1: Get API key
|
|
768
|
+
const apiKey = process.env.OPTIMIZER_API_KEY;
|
|
769
|
+
|
|
770
|
+
if (!apiKey) {
|
|
771
|
+
console.error('ā API key required');
|
|
772
|
+
console.error('\nš” Get your API key in 30 seconds:');
|
|
773
|
+
console.error(' 1. Visit: https://promptoptimizer-blog.vercel.app/pricing');
|
|
774
|
+
console.error(' 2. Get your free trial (5 optimizations)');
|
|
775
|
+
console.error(' 3. Set: export OPTIMIZER_API_KEY=sk-opt-...');
|
|
776
|
+
console.error(' 4. Run: mcp-prompt-optimizer');
|
|
777
|
+
console.error('\nšÆ Plans: Explorer ($2.99), Creator ($25.99), Innovator ($69.99)');
|
|
778
|
+
process.exit(1);
|
|
252
779
|
}
|
|
780
|
+
|
|
781
|
+
// Step 2: Validate API key and check quota
|
|
782
|
+
const manager = new CloudApiKeyManager(apiKey);
|
|
783
|
+
const validation = await manager.validateAndPrepare();
|
|
784
|
+
|
|
785
|
+
// Step 3: Start the MCP server with validated context
|
|
786
|
+
console.error('š§ Starting MCP server...\n');
|
|
787
|
+
|
|
788
|
+
// Create and start the MCP server instance
|
|
789
|
+
const mcpServer = new MCPPromptOptimizer();
|
|
790
|
+
|
|
791
|
+
console.error('ā
MCP server ready for connections');
|
|
792
|
+
console.error(`š Plan: ${validation.tier} | Quota: ${validation.quotaStatus.unlimited ? 'Unlimited' : `${validation.quotaStatus.remaining}/${validation.quotaStatus.limit} remaining`}`);
|
|
793
|
+
console.error('š” Connect from your MCP client (Claude Desktop, Cursor, etc.)\n');
|
|
794
|
+
|
|
795
|
+
// Start the server
|
|
796
|
+
await mcpServer.run();
|
|
797
|
+
|
|
798
|
+
} catch (error) {
|
|
799
|
+
console.error(`ā Failed to start MCP server: ${error.message}`);
|
|
800
|
+
|
|
801
|
+
if (error.message.includes('quota exceeded')) {
|
|
802
|
+
console.error('\nš Upgrade for more optimizations:');
|
|
803
|
+
console.error(' https://promptoptimizer-blog.vercel.app/pricing');
|
|
804
|
+
} else if (error.message.includes('validation failed') || error.message.includes('Invalid')) {
|
|
805
|
+
console.error('\nš ļø Troubleshooting:');
|
|
806
|
+
console.error(' 1. Check your API key: mcp-prompt-optimizer validate-key');
|
|
807
|
+
console.error(' 2. Clear cache: mcp-prompt-optimizer clear-cache');
|
|
808
|
+
console.error(' 3. Get new key: https://promptoptimizer-blog.vercel.app/pricing');
|
|
809
|
+
} else if (error.message.includes('Network error')) {
|
|
810
|
+
console.error('\nš Connection Issue:');
|
|
811
|
+
console.error(' - Check your internet connection');
|
|
812
|
+
console.error(' - Verify firewall/proxy settings');
|
|
813
|
+
console.error(' - Try again in a moment');
|
|
814
|
+
} else {
|
|
815
|
+
console.error('\nš§ General Troubleshooting:');
|
|
816
|
+
console.error(' 1. Clear cache: mcp-prompt-optimizer clear-cache');
|
|
817
|
+
console.error(' 2. Check status: mcp-prompt-optimizer check-status');
|
|
818
|
+
console.error(' 3. Contact support: support@promptoptimizer.help');
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
process.exit(1);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// Show enhanced help and subscription info when run directly
|
|
826
|
+
async function showInfo() {
|
|
827
|
+
console.log('š MCP Prompt Optimizer - Professional Cloud-Based Server v1.3.0');
|
|
828
|
+
console.log('==================================================================');
|
|
829
|
+
console.log('');
|
|
830
|
+
console.log('Professional cloud-based MCP server for AI-powered prompt optimization.');
|
|
831
|
+
console.log('Requires active subscription starting at $2.99/month.');
|
|
832
|
+
console.log('');
|
|
833
|
+
console.log('š° Cloud Subscription Plans (same AI quality, different quotas):');
|
|
834
|
+
console.log(' Explorer ($2.99/mo): 5,000 optimizations + individual use');
|
|
835
|
+
console.log(' Creator ($25.99/mo): 18,000 optimizations + team features (2 members)');
|
|
836
|
+
console.log(' Innovator ($69.99/mo): 75,000 optimizations + large teams (5 members) + priority support');
|
|
837
|
+
console.log('');
|
|
838
|
+
console.log('⨠Professional Cloud Features (all plans):');
|
|
839
|
+
console.log(' š§ AI Context Detection - Image gen, LLM interaction, technical automation');
|
|
840
|
+
console.log(' šÆ 10+ Optimization Techniques - Clarity, specificity, technical accuracy');
|
|
841
|
+
console.log(' š Template Management - Auto-save, search, reuse optimizations');
|
|
842
|
+
console.log(' š Real-time Analytics - Confidence scoring, usage tracking');
|
|
843
|
+
console.log(' š„ Team Collaboration - Shared quotas, team templates');
|
|
844
|
+
console.log(' āļø Cloud Processing - Always up-to-date, no local setup');
|
|
845
|
+
console.log(' š Priority Processing - Faster response times (Creator/Innovator)');
|
|
846
|
+
console.log('');
|
|
847
|
+
console.log('š Free Trial: 5 optimizations included');
|
|
848
|
+
console.log('š Get started: https://promptoptimizer-blog.vercel.app/pricing');
|
|
849
|
+
console.log('š Dashboard: https://promptoptimizer-blog.vercel.app/dashboard');
|
|
850
|
+
console.log('');
|
|
851
|
+
console.log('āļø Claude Desktop Setup:');
|
|
852
|
+
console.log('Add to ~/.claude/claude_desktop_config.json:');
|
|
853
|
+
console.log(JSON.stringify({
|
|
854
|
+
"mcpServers": {
|
|
855
|
+
"prompt-optimizer": {
|
|
856
|
+
"command": "npx",
|
|
857
|
+
"args": ["mcp-prompt-optimizer"],
|
|
858
|
+
"env": {
|
|
859
|
+
"OPTIMIZER_API_KEY": "sk-opt-your-key-here"
|
|
253
860
|
}
|
|
254
861
|
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
862
|
+
}
|
|
863
|
+
}, null, 2));
|
|
864
|
+
console.log('');
|
|
865
|
+
console.log('š§ Other MCP Clients:');
|
|
866
|
+
console.log(' Cursor: Add to ~/.cursor/mcp.json');
|
|
867
|
+
console.log(' Windsurf: Configure in settings');
|
|
868
|
+
console.log(' Cline: Use standard MCP configuration');
|
|
869
|
+
console.log(' VS Code/Zed/Replit: Standard MCP setup');
|
|
870
|
+
console.log('');
|
|
871
|
+
console.log('š§ Professional CLI Commands:');
|
|
872
|
+
console.log(' mcp-prompt-optimizer check-status Check API key and quota status');
|
|
873
|
+
console.log(' mcp-prompt-optimizer validate-key Validate your API key');
|
|
874
|
+
console.log(' mcp-prompt-optimizer clear-cache Clear validation cache');
|
|
875
|
+
console.log(' mcp-prompt-optimizer help Show this help');
|
|
876
|
+
console.log(' mcp-prompt-optimizer version Show version');
|
|
877
|
+
console.log('');
|
|
878
|
+
console.log('š¢ Enterprise Solutions:');
|
|
879
|
+
console.log(' Custom deployment options available');
|
|
880
|
+
console.log(' Higher quotas and dedicated support');
|
|
881
|
+
console.log(' Contact: enterprise@promptoptimizer.help');
|
|
882
|
+
console.log('');
|
|
883
|
+
console.log('š§ Support: support@promptoptimizer.help');
|
|
263
884
|
}
|
|
264
885
|
|
|
265
|
-
//
|
|
886
|
+
// ā
NEW: Enhanced CLI command handling (following local pattern)
|
|
266
887
|
if (require.main === module) {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
// Running in terminal - show info
|
|
282
|
-
showInfo();
|
|
283
|
-
} else {
|
|
284
|
-
// Running via MCP protocol - start server
|
|
285
|
-
const optimizer = new MCPPromptOptimizer();
|
|
286
|
-
optimizer.run().catch(console.error);
|
|
888
|
+
const args = process.argv.slice(2);
|
|
889
|
+
|
|
890
|
+
if (args.includes('--help') || args.includes('-h') || args.includes('help')) {
|
|
891
|
+
showInfo();
|
|
892
|
+
} else if (args.includes('--version') || args.includes('-v') || args.includes('version')) {
|
|
893
|
+
try {
|
|
894
|
+
const packageJson = require('./package.json');
|
|
895
|
+
console.log(`mcp-prompt-optimizer v${packageJson.version}`);
|
|
896
|
+
console.log('Professional Cloud-Based MCP Server - Starting at $2.99/month');
|
|
897
|
+
console.log('š Get started: https://promptoptimizer-blog.vercel.app/pricing');
|
|
898
|
+
} catch (error) {
|
|
899
|
+
console.log('mcp-prompt-optimizer v1.3.0');
|
|
900
|
+
console.log('Professional Cloud-Based MCP Server - Starting at $2.99/month');
|
|
901
|
+
console.log('š Get started: https://promptoptimizer-blog.vercel.app/pricing');
|
|
287
902
|
}
|
|
903
|
+
} else if (args.includes('check-status') || args.includes('status')) {
|
|
904
|
+
// ā
NEW: CLI command integration
|
|
905
|
+
require('./lib/check-status');
|
|
906
|
+
} else if (args.includes('validate-key')) {
|
|
907
|
+
// ā
NEW: CLI command integration
|
|
908
|
+
require('./lib/validate-key');
|
|
909
|
+
} else if (args.includes('clear-cache') || args.includes('clear')) {
|
|
910
|
+
// ā
NEW: CLI command integration
|
|
911
|
+
require('./lib/clear-cache');
|
|
912
|
+
} else if (process.stdin.isTTY) {
|
|
913
|
+
// Running in terminal - show info
|
|
914
|
+
showInfo();
|
|
915
|
+
} else {
|
|
916
|
+
// ā
UPDATED: Running via MCP protocol - start server with validation
|
|
917
|
+
startValidatedMCPServer();
|
|
918
|
+
}
|
|
288
919
|
}
|
|
289
920
|
|
|
290
921
|
module.exports = MCPPromptOptimizer;
|