mcp-prompt-optimizer 1.0.2 → 1.1.0
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 +182 -7
- package/README.md +291 -116
- package/bin/start-server +21 -1
- package/index.js +27 -2
- package/lib/api-client.js +12 -3
- package/lib/mcp-protocol.js +85 -10
- package/package.json +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,84 @@ All notable changes to the MCP Prompt Optimizer package will be documented in th
|
|
|
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
|
+
## [1.1.0] - 2025-06-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **MAJOR**: AI Context Detection and Enhanced Optimization
|
|
12
|
+
- Automatic AI context detection for prompts (image_generation, llm_interaction, technical_automation, human_communication)
|
|
13
|
+
- Enhanced goal mapping with AI-specific optimization goals
|
|
14
|
+
- Parameter preservation for technical prompts (e.g., Midjourney --ar, --v parameters)
|
|
15
|
+
- Context-aware optimization routing based on prompt content
|
|
16
|
+
|
|
17
|
+
### New Features
|
|
18
|
+
- **AI-Specific Optimization Goals**:
|
|
19
|
+
- `keyword_density` - Enhanced keyword optimization for AI models
|
|
20
|
+
- `parameter_preservation` - Preserves technical parameters during optimization
|
|
21
|
+
- `token_efficiency` - Optimizes token usage for LLM interactions
|
|
22
|
+
- `embedding_strength` - Enhances semantic embedding effectiveness
|
|
23
|
+
- `context_specificity` - Improves context relevance for AI models
|
|
24
|
+
- `ai_model_compatibility` - Optimizes for specific AI model requirements
|
|
25
|
+
- `quality_enhancement` - Adds quality indicators for better AI responses
|
|
26
|
+
- `role_clarity` - Enhances role-playing and persona clarity
|
|
27
|
+
- `code_protection` - Protects code elements during optimization
|
|
28
|
+
|
|
29
|
+
- **Enhanced Tool Parameters**:
|
|
30
|
+
- `ai_context` - Manual AI context specification (auto-detected if not provided)
|
|
31
|
+
- `preserve_formatting` - Controls technical parameter preservation
|
|
32
|
+
- `target_ai_model` - Specify target AI model for optimization
|
|
33
|
+
- `optimization_level` - Choose between conservative, balanced, or aggressive optimization
|
|
34
|
+
|
|
35
|
+
### Improved
|
|
36
|
+
- **Enhanced Response Information**:
|
|
37
|
+
- Shows detected AI context in optimization results
|
|
38
|
+
- Displays optimization strategy used
|
|
39
|
+
- Indicates when goal enhancement was applied
|
|
40
|
+
- Reports preserved parameters count
|
|
41
|
+
- Shows original vs enhanced goals comparison
|
|
42
|
+
|
|
43
|
+
- **Better AI Integration**:
|
|
44
|
+
- Automatic detection of Midjourney, DALL-E, and Stable Diffusion prompts
|
|
45
|
+
- Smart handling of LLM role-playing prompts
|
|
46
|
+
- Code and technical automation prompt protection
|
|
47
|
+
- Context-aware optimization strategies
|
|
48
|
+
|
|
49
|
+
### Technical Improvements
|
|
50
|
+
- Updated MCP server version to 1.1.0
|
|
51
|
+
- Enhanced API client with AI optimization options
|
|
52
|
+
- Improved error handling for AI-specific features
|
|
53
|
+
- Added comprehensive AI context validation
|
|
54
|
+
|
|
55
|
+
### Documentation
|
|
56
|
+
- Updated tool schema with new AI-specific parameters
|
|
57
|
+
- Enhanced descriptions for all new optimization goals
|
|
58
|
+
- Added AI context detection documentation
|
|
59
|
+
- Improved examples with AI optimization use cases
|
|
60
|
+
|
|
61
|
+
### Backward Compatibility
|
|
62
|
+
- All existing functionality remains unchanged
|
|
63
|
+
- New AI features are automatically applied when beneficial
|
|
64
|
+
- Existing goal names and functionality preserved
|
|
65
|
+
- No breaking changes to API or configuration
|
|
66
|
+
|
|
67
|
+
## [1.0.3] - 2025-06-18
|
|
68
|
+
|
|
69
|
+
### Fixed
|
|
70
|
+
- **CRITICAL**: Fixed binary execution issue on Windows systems
|
|
71
|
+
- Changed binary configuration to point directly to index.js instead of bin/start-server
|
|
72
|
+
- Resolved issue where global installation commands (--help, --version) failed silently
|
|
73
|
+
- Improved version detection for global installations
|
|
74
|
+
- Fixed Windows batch file generation issues
|
|
75
|
+
|
|
76
|
+
### Improved
|
|
77
|
+
- Enhanced binary path resolution for global installations
|
|
78
|
+
- Added fallback version detection when package.json path resolution fails
|
|
79
|
+
- Better error handling in binary execution
|
|
80
|
+
|
|
81
|
+
### Notes
|
|
82
|
+
- This fix resolves the issue where `mcp-prompt-optimizer --help` and `mcp-prompt-optimizer --version` returned no output
|
|
83
|
+
- Existing functionality remains unchanged
|
|
84
|
+
- No breaking changes to API or configuration
|
|
85
|
+
|
|
8
86
|
## [1.0.2] - 2025-06-18
|
|
9
87
|
|
|
10
88
|
### Fixed
|
|
@@ -86,14 +164,74 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
86
164
|
|
|
87
165
|
## Backend Compatibility
|
|
88
166
|
|
|
89
|
-
| Package Version | Backend API Version | Deployment URL |
|
|
90
|
-
|
|
91
|
-
| 1.0
|
|
92
|
-
| 1.0.
|
|
93
|
-
| 1.0.
|
|
167
|
+
| Package Version | Backend API Version | Deployment URL | AI Features |
|
|
168
|
+
|-----------------|--------------------|--------------------|-------------|
|
|
169
|
+
| 1.1.0 | v0.3.0+ | https://p01--project-optimizer--fvrdk8m9k9j.code.run | Full AI Context Detection |
|
|
170
|
+
| 1.0.3 | v0.2.2+ | https://p01--project-optimizer--fvrdk8m9k9j.code.run | None |
|
|
171
|
+
| 1.0.2 | v0.2.2+ | https://p01--project-optimizer--fvrdk8m9k9j.code.run | None |
|
|
172
|
+
| 1.0.1 | v0.2.2+ | https://p01--project-optimizer--fvrdk8m9k9j.code.run | None |
|
|
173
|
+
| 1.0.0 | v0.2.0+ | Placeholder URL (manual configuration required) | None |
|
|
94
174
|
|
|
95
175
|
## Migration Guide
|
|
96
176
|
|
|
177
|
+
### From 1.0.3 to 1.1.0
|
|
178
|
+
|
|
179
|
+
**New AI Features Available:**
|
|
180
|
+
- Automatic AI context detection
|
|
181
|
+
- Enhanced optimization goals
|
|
182
|
+
- Parameter preservation
|
|
183
|
+
- Target AI model specification
|
|
184
|
+
|
|
185
|
+
**Update process:**
|
|
186
|
+
```bash
|
|
187
|
+
# Update the package
|
|
188
|
+
npm update -g mcp-prompt-optimizer
|
|
189
|
+
|
|
190
|
+
# Verify new version and AI features
|
|
191
|
+
mcp-prompt-optimizer --version
|
|
192
|
+
|
|
193
|
+
# Test with an AI prompt (example)
|
|
194
|
+
# The tool will now automatically detect and optimize for AI contexts
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**New Usage Examples:**
|
|
198
|
+
```json
|
|
199
|
+
// Image generation prompt (auto-detected)
|
|
200
|
+
{
|
|
201
|
+
"prompt": "A beautiful sunset over mountains --ar 16:9 --v 5.2",
|
|
202
|
+
"goals": ["clarity", "keyword_density"]
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// LLM interaction prompt (auto-detected)
|
|
206
|
+
{
|
|
207
|
+
"prompt": "Act as a professional copywriter and help me write...",
|
|
208
|
+
"goals": ["role_clarity", "context_specificity"]
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Manual AI context specification
|
|
212
|
+
{
|
|
213
|
+
"prompt": "Create a photorealistic image...",
|
|
214
|
+
"ai_context": "image_generation",
|
|
215
|
+
"target_ai_model": "midjourney"
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### From 1.0.2 to 1.0.3
|
|
220
|
+
|
|
221
|
+
No breaking changes. This update fixes binary execution issues on Windows systems.
|
|
222
|
+
|
|
223
|
+
**Update process:**
|
|
224
|
+
```bash
|
|
225
|
+
# Update the package
|
|
226
|
+
npm update -g mcp-prompt-optimizer
|
|
227
|
+
|
|
228
|
+
# Verify new version and functionality
|
|
229
|
+
mcp-prompt-optimizer --version
|
|
230
|
+
mcp-prompt-optimizer --help
|
|
231
|
+
|
|
232
|
+
# No configuration changes needed
|
|
233
|
+
```
|
|
234
|
+
|
|
97
235
|
### From 1.0.1 to 1.0.2
|
|
98
236
|
|
|
99
237
|
No breaking changes. This is a documentation-only update.
|
|
@@ -131,16 +269,52 @@ npm test
|
|
|
131
269
|
|
|
132
270
|
## Known Issues
|
|
133
271
|
|
|
134
|
-
### 1.0
|
|
272
|
+
### 1.1.0
|
|
273
|
+
- None known at release time
|
|
274
|
+
|
|
275
|
+
### 1.0.3
|
|
135
276
|
- None known at release time
|
|
136
277
|
|
|
278
|
+
### 1.0.2
|
|
279
|
+
- Binary execution issues on Windows (fixed in 1.0.3)
|
|
280
|
+
|
|
137
281
|
### 1.0.1
|
|
138
282
|
- Pricing documentation inconsistency (fixed in 1.0.2)
|
|
283
|
+
- Binary execution issues on Windows (fixed in 1.0.3)
|
|
139
284
|
|
|
140
285
|
### 1.0.0
|
|
141
286
|
- Required manual backend URL configuration
|
|
142
287
|
- Placeholder URLs in documentation
|
|
143
288
|
|
|
289
|
+
## AI Optimization Examples
|
|
290
|
+
|
|
291
|
+
### Image Generation Prompts
|
|
292
|
+
```javascript
|
|
293
|
+
// Midjourney prompt with parameters preserved
|
|
294
|
+
{
|
|
295
|
+
"prompt": "Professional headshot of a business executive --ar 1:1 --v 5.2 --stylize 100",
|
|
296
|
+
"goals": ["keyword_density", "parameter_preservation", "quality_enhancement"]
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### LLM Role-Playing
|
|
301
|
+
```javascript
|
|
302
|
+
// Role-playing prompt with enhanced clarity
|
|
303
|
+
{
|
|
304
|
+
"prompt": "Act as a senior software architect and help me design...",
|
|
305
|
+
"goals": ["role_clarity", "context_specificity", "actionability"]
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Technical Automation
|
|
310
|
+
```javascript
|
|
311
|
+
// Code-related prompt with protection
|
|
312
|
+
{
|
|
313
|
+
"prompt": "Write a Python function that processes API responses...",
|
|
314
|
+
"goals": ["code_protection", "technical_precision", "clarity"]
|
|
315
|
+
}
|
|
316
|
+
```
|
|
317
|
+
|
|
144
318
|
## Support
|
|
145
319
|
|
|
146
320
|
For version-specific support:
|
|
@@ -153,4 +327,5 @@ When reporting issues, please include:
|
|
|
153
327
|
- Node.js version (`node --version`)
|
|
154
328
|
- Operating system
|
|
155
329
|
- MCP client type and version
|
|
156
|
-
- Error messages and logs
|
|
330
|
+
- Error messages and logs
|
|
331
|
+
- AI context and optimization goals used (for AI-related issues)
|
package/README.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# MCP Prompt Optimizer
|
|
2
2
|
|
|
3
|
-
Local MCP server for accessing the Prompt Optimizer API from Claude Desktop, Cursor, Windsurf, and other MCP-compatible clients.
|
|
3
|
+
Local MCP server for accessing the AI-Enhanced Prompt Optimizer API from Claude Desktop, Cursor, Windsurf, and other MCP-compatible clients.
|
|
4
|
+
|
|
5
|
+
## ✨ New in v1.1.0: AI Context Detection & Enhanced Optimization
|
|
6
|
+
|
|
7
|
+
- 🧠 **Automatic AI Context Detection** - Automatically detects image generation, LLM interaction, and technical automation prompts
|
|
8
|
+
- 🛡️ **Parameter Preservation** - Preserves technical parameters like Midjourney `--ar 16:9`, `--v 5.2` during optimization
|
|
9
|
+
- 🎯 **Enhanced AI Goals** - New optimization goals specifically designed for AI model interactions
|
|
10
|
+
- 🤖 **Smart Goal Enhancement** - Automatically adds relevant goals based on detected AI context
|
|
11
|
+
- 🔧 **Target AI Model Support** - Optimize specifically for Midjourney, ChatGPT, Claude, and more
|
|
4
12
|
|
|
5
13
|
## Features
|
|
6
14
|
|
|
7
15
|
- 🤖 **Universal MCP Support** - Works with Claude Desktop, Cursor, Windsurf, and any MCP-compatible client
|
|
8
16
|
- 🔐 **Secure API Key Authentication** - Uses your personal API key for secure access
|
|
9
|
-
-
|
|
17
|
+
- 🧠 **AI Context Awareness** - Automatically detects and optimizes for different AI use cases
|
|
18
|
+
- 🎯 **Advanced Optimization Goals** - Support for clarity, conciseness, technical accuracy, and AI-specific enhancements
|
|
10
19
|
- 📊 **Real-time Quota Tracking** - See your usage and remaining quota
|
|
11
20
|
- 💾 **Automatic Template Saving** - All optimizations saved with rich metadata for future reference
|
|
12
21
|
- 🚀 **Easy Setup** - Simple configuration process
|
|
@@ -89,62 +98,74 @@ Add via Windsurf settings or configuration file:
|
|
|
89
98
|
}
|
|
90
99
|
```
|
|
91
100
|
|
|
92
|
-
### 4. Use the Tool
|
|
93
|
-
|
|
94
|
-
Once configured, the `optimize_prompt` tool will be available
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
- **
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- **
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
101
|
+
### 4. Use the AI-Enhanced Tool
|
|
102
|
+
|
|
103
|
+
Once configured, the `optimize_prompt` tool will be available with AI context detection:
|
|
104
|
+
|
|
105
|
+
**Required Parameters:**
|
|
106
|
+
- **prompt**: The prompt you want to optimize
|
|
107
|
+
|
|
108
|
+
**Optional AI Enhancement Parameters:**
|
|
109
|
+
- **goals**: Array of optimization goals (auto-enhanced based on AI context)
|
|
110
|
+
- **ai_context**: Manual AI context specification (`image_generation`, `llm_interaction`, `technical_automation`, `human_communication`)
|
|
111
|
+
- **preserve_formatting**: Whether to preserve technical parameters (default: true)
|
|
112
|
+
- **target_ai_model**: Target AI model (`midjourney`, `chatgpt`, `claude`, etc.)
|
|
113
|
+
- **optimization_level**: Optimization intensity (`conservative`, `balanced`, `aggressive`)
|
|
114
|
+
|
|
115
|
+
## AI Context Detection
|
|
116
|
+
|
|
117
|
+
The tool automatically detects and optimizes for different AI use cases:
|
|
118
|
+
|
|
119
|
+
### 🎨 Image Generation
|
|
120
|
+
**Automatically detected for:**
|
|
121
|
+
- Midjourney prompts (`--ar 16:9`, `--v 5.2`, `--stylize 100`)
|
|
122
|
+
- DALL-E prompts with photography/art terms
|
|
123
|
+
- Stable Diffusion prompts with quality indicators
|
|
124
|
+
|
|
125
|
+
**AI Enhancements Applied:**
|
|
126
|
+
- Preserves technical parameters (`--ar`, `--v`, `--s`, `--q`)
|
|
127
|
+
- Adds quality keywords (`award-winning`, `professional`, `masterpiece`)
|
|
128
|
+
- Optimizes keyword density for better AI model response
|
|
129
|
+
- Enhances technical precision
|
|
130
|
+
|
|
131
|
+
### 🤖 LLM Interaction
|
|
132
|
+
**Automatically detected for:**
|
|
133
|
+
- Role-playing prompts (`Act as a...`, `You are a...`)
|
|
134
|
+
- Persona-based interactions
|
|
135
|
+
- Character behavior instructions
|
|
136
|
+
|
|
137
|
+
**AI Enhancements Applied:**
|
|
138
|
+
- Clarifies role definitions and expectations
|
|
139
|
+
- Improves context specificity
|
|
140
|
+
- Optimizes token efficiency
|
|
141
|
+
- Enhances actionability and response clarity
|
|
142
|
+
|
|
143
|
+
### ⚙️ Technical Automation
|
|
144
|
+
**Automatically detected for:**
|
|
145
|
+
- Code generation requests
|
|
146
|
+
- API and automation scripts
|
|
147
|
+
- Technical documentation prompts
|
|
148
|
+
|
|
149
|
+
**AI Enhancements Applied:**
|
|
150
|
+
- Protects code elements from modification
|
|
151
|
+
- Preserves technical parameters and URLs
|
|
152
|
+
- Enhances technical precision
|
|
153
|
+
- Maintains technical accuracy
|
|
154
|
+
|
|
155
|
+
### 💬 Human Communication
|
|
156
|
+
**Default for:**
|
|
157
|
+
- General conversation prompts
|
|
158
|
+
- Creative writing requests
|
|
159
|
+
- Educational content
|
|
160
|
+
|
|
161
|
+
**AI Enhancements Applied:**
|
|
162
|
+
- Standard optimization rules
|
|
163
|
+
- Clarity and conciseness improvements
|
|
164
|
+
- Structural enhancements
|
|
165
|
+
|
|
166
|
+
## Enhanced Optimization Goals
|
|
167
|
+
|
|
168
|
+
### Standard Goals
|
|
148
169
|
- **clarity** - Make the prompt clearer and more understandable
|
|
149
170
|
- **conciseness** - Remove unnecessary words while preserving meaning
|
|
150
171
|
- **technical_accuracy** - Improve technical precision and correctness
|
|
@@ -156,85 +177,205 @@ Choose from these optimization strategies:
|
|
|
156
177
|
- **linguistic_precision** - Refine language for exact meaning
|
|
157
178
|
- **holistic_effectiveness** - Overall optimization for best results
|
|
158
179
|
|
|
180
|
+
### 🆕 AI-Specific Goals
|
|
181
|
+
- **keyword_density** - Enhanced keyword optimization for AI models
|
|
182
|
+
- **parameter_preservation** - Preserves technical parameters during optimization
|
|
183
|
+
- **token_efficiency** - Optimizes token usage for LLM interactions
|
|
184
|
+
- **embedding_strength** - Enhances semantic embedding effectiveness
|
|
185
|
+
- **context_specificity** - Improves context relevance for AI models
|
|
186
|
+
- **ai_model_compatibility** - Optimizes for specific AI model requirements
|
|
187
|
+
- **quality_enhancement** - Adds quality indicators for better AI responses
|
|
188
|
+
- **role_clarity** - Enhances role-playing and persona clarity
|
|
189
|
+
- **code_protection** - Protects code elements during optimization
|
|
190
|
+
|
|
159
191
|
## Example Usage
|
|
160
192
|
|
|
193
|
+
### 🎨 Image Generation Example
|
|
194
|
+
|
|
161
195
|
In Claude Desktop, you might ask:
|
|
162
196
|
|
|
197
|
+
```
|
|
198
|
+
Please optimize this Midjourney prompt using the optimize_prompt tool:
|
|
199
|
+
"A beautiful sunset over mountains --ar 16:9 --v 5.2"
|
|
200
|
+
|
|
201
|
+
Use goals: ["clarity", "keyword_density"]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**AI-Enhanced Result:**
|
|
205
|
+
```
|
|
206
|
+
# AI-Optimized Prompt
|
|
207
|
+
|
|
208
|
+
Breathtaking golden hour sunset over majestic mountain peaks, dramatic lighting, award-winning landscape photography, professional composition, highly detailed, masterpiece quality --ar 16:9 --v 5.2
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
**Confidence Score:** 0.92
|
|
212
|
+
**Goals Applied:** clarity, keyword_density, parameter_preservation, quality_enhancement
|
|
213
|
+
**AI Context Detected:** image_generation
|
|
214
|
+
**Optimization Strategy:** AI_PARAMETER_PRESERVATION
|
|
215
|
+
**Parameters Preserved:** 2
|
|
216
|
+
**Goal Enhancement:** Applied
|
|
217
|
+
**Original Goals:** clarity, keyword_density
|
|
218
|
+
**Enhanced Goals:** clarity, keyword_density, parameter_preservation, quality_enhancement
|
|
219
|
+
**Quota Remaining:** 195/200
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 🤖 LLM Role-Playing Example
|
|
223
|
+
|
|
163
224
|
```
|
|
164
225
|
Please optimize this prompt using the optimize_prompt tool:
|
|
165
|
-
"
|
|
226
|
+
"Act as a copywriter and help me write"
|
|
166
227
|
|
|
167
|
-
Use goals: ["clarity", "specificity"
|
|
228
|
+
Use goals: ["clarity", "specificity"]
|
|
168
229
|
```
|
|
169
230
|
|
|
170
|
-
|
|
231
|
+
**AI-Enhanced Result:**
|
|
232
|
+
```
|
|
233
|
+
# AI-Optimized Prompt
|
|
234
|
+
|
|
235
|
+
You are a professional copywriter with 10+ years of experience in digital marketing and persuasive writing. Please help me create compelling copy by:
|
|
236
|
+
|
|
237
|
+
1. Understanding my target audience and objectives
|
|
238
|
+
2. Applying proven copywriting frameworks (AIDA, PAS, etc.)
|
|
239
|
+
3. Crafting persuasive, conversion-focused content
|
|
240
|
+
4. Ensuring brand voice consistency and engagement
|
|
241
|
+
|
|
242
|
+
What specific copywriting project would you like assistance with today?
|
|
243
|
+
|
|
244
|
+
---
|
|
245
|
+
**Confidence Score:** 0.89
|
|
246
|
+
**Goals Applied:** clarity, specificity, role_clarity, context_specificity, actionability
|
|
247
|
+
**AI Context Detected:** llm_interaction
|
|
248
|
+
**Optimization Strategy:** RULES_WITH_LLM_FALLBACK
|
|
249
|
+
**Goal Enhancement:** Applied
|
|
250
|
+
**Quota Remaining:** 194/200
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### ⚙️ Technical Automation Example
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
Please optimize this prompt using the optimize_prompt tool:
|
|
257
|
+
"Write Python code for API"
|
|
171
258
|
|
|
259
|
+
Use goals: ["technical_accuracy", "specificity"]
|
|
172
260
|
```
|
|
173
|
-
|
|
261
|
+
|
|
262
|
+
**AI-Enhanced Result:**
|
|
263
|
+
```
|
|
264
|
+
# AI-Optimized Prompt
|
|
265
|
+
|
|
266
|
+
Create a Python REST API implementation with the following specifications:
|
|
174
267
|
|
|
175
268
|
## Requirements:
|
|
176
|
-
-
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
-
-
|
|
269
|
+
- Use FastAPI framework for modern async API development
|
|
270
|
+
- Implement CRUD operations for data management
|
|
271
|
+
- Include proper request/response models with Pydantic validation
|
|
272
|
+
- Add comprehensive error handling and status codes
|
|
273
|
+
- Implement authentication and authorization middleware
|
|
274
|
+
- Include API documentation with OpenAPI/Swagger
|
|
182
275
|
|
|
183
276
|
## Deliverables:
|
|
184
|
-
-
|
|
185
|
-
-
|
|
186
|
-
- Database
|
|
187
|
-
-
|
|
277
|
+
- Main application file with API endpoints
|
|
278
|
+
- Data models and validation schemas
|
|
279
|
+
- Database integration layer
|
|
280
|
+
- Authentication system
|
|
281
|
+
- Unit tests for all endpoints
|
|
282
|
+
- Documentation and usage examples
|
|
283
|
+
|
|
284
|
+
Please specify the API's purpose and data entities for customized implementation.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
**Confidence Score:** 0.86
|
|
288
|
+
**Goals Applied:** technical_accuracy, specificity, code_protection, technical_precision, parameter_preservation
|
|
289
|
+
**AI Context Detected:** technical_automation
|
|
290
|
+
**Optimization Strategy:** CODE_PROTECTION
|
|
291
|
+
**Goal Enhancement:** Applied
|
|
292
|
+
**Quota Remaining:** 193/200
|
|
293
|
+
```
|
|
188
294
|
|
|
189
|
-
|
|
190
|
-
|
|
295
|
+
## Template Saving & History
|
|
296
|
+
|
|
297
|
+
Your AI-optimized prompts are automatically saved as templates with enhanced metadata:
|
|
298
|
+
|
|
299
|
+
### Automatic Template Saving
|
|
300
|
+
- **Every Optimization Saved**: All successful optimizations are automatically saved as structured templates
|
|
301
|
+
- **AI Context Metadata**: Templates include detected AI context and optimization strategies
|
|
302
|
+
- **Parameter Preservation Tracking**: Records which technical parameters were preserved
|
|
303
|
+
- **Goal Enhancement History**: Shows original vs enhanced goals
|
|
304
|
+
- **Model Compatibility Info**: Tracks target AI model optimizations
|
|
305
|
+
|
|
306
|
+
### Enhanced Template Structure
|
|
307
|
+
Each saved template now contains AI-specific information:
|
|
308
|
+
```json
|
|
309
|
+
{
|
|
310
|
+
"saved_at_utc": "2025-06-21T12:00:00.000Z",
|
|
311
|
+
"optimization_tier": "AI_PARAMETER_PRESERVATION",
|
|
312
|
+
"confidence_score": 0.92,
|
|
313
|
+
"original_prompt": "A sunset --ar 16:9 --v 5.2",
|
|
314
|
+
"optimized_prompt": "Breathtaking golden hour sunset over majestic mountain peaks...",
|
|
315
|
+
"optimization_goals": ["clarity", "keyword_density", "parameter_preservation", "quality_enhancement"],
|
|
316
|
+
"ai_context": "image_generation",
|
|
317
|
+
"optimization_strategy": "AI_PARAMETER_PRESERVATION",
|
|
318
|
+
"preserved_parameters": 2,
|
|
319
|
+
"goal_enhancement_applied": true,
|
|
320
|
+
"original_goals": ["clarity", "keyword_density"],
|
|
321
|
+
"enhanced_goals": ["clarity", "keyword_density", "parameter_preservation", "quality_enhancement"],
|
|
322
|
+
"target_ai_model": "midjourney",
|
|
323
|
+
"context_snapshot": {
|
|
324
|
+
"domain": "Image Generation",
|
|
325
|
+
"target_audience": "AI Artists"
|
|
326
|
+
},
|
|
327
|
+
"request_id": "unique-ai-request-identifier",
|
|
328
|
+
"model_optimized_with": "AI-Aware Rules-Based"
|
|
329
|
+
}
|
|
191
330
|
```
|
|
192
331
|
|
|
332
|
+
### AI-Enhanced Template Benefits
|
|
333
|
+
- **AI Context Learning**: Understand how different AI contexts affect optimization
|
|
334
|
+
- **Parameter Preservation Tracking**: See which technical parameters are being preserved
|
|
335
|
+
- **Goal Enhancement Analysis**: Learn how the system enhances goals based on AI context
|
|
336
|
+
- **Model-Specific Optimization**: Track optimizations for specific AI models
|
|
337
|
+
- **Strategy Effectiveness**: Monitor which optimization strategies work best for your use cases
|
|
338
|
+
|
|
193
339
|
## Subscription Tiers
|
|
194
340
|
|
|
195
|
-
- **Explorer** ($2.99/month): 5,000 optimizations + 1 API key
|
|
196
|
-
- **Creator** ($25.99/month): 18,000 optimizations + 3 API keys + Template history
|
|
197
|
-
- **Innovator** ($69.99/month): 75,000 optimizations + up to 10 API keys + Advanced
|
|
341
|
+
- **Explorer** ($2.99/month): 5,000 AI-enhanced optimizations + 1 API key
|
|
342
|
+
- **Creator** ($25.99/month): 18,000 optimizations + 3 API keys + Template history + AI analytics
|
|
343
|
+
- **Innovator** ($69.99/month): 75,000 optimizations + up to 10 API keys + Advanced AI features + Priority support
|
|
198
344
|
|
|
199
345
|
## Backend Infrastructure
|
|
200
346
|
|
|
201
|
-
This package connects to a production-grade backend infrastructure:
|
|
347
|
+
This package connects to a production-grade AI-enhanced backend infrastructure:
|
|
202
348
|
|
|
203
|
-
- **FastAPI Backend** - High-performance Python API server with
|
|
349
|
+
- **AI-Enhanced FastAPI Backend** - High-performance Python API server with AI context detection
|
|
204
350
|
- **Northflank Hosting** - Enterprise cloud deployment platform with 99.9% uptime
|
|
205
|
-
- **Supabase Database** - PostgreSQL database with
|
|
351
|
+
- **Supabase Database** - PostgreSQL database with AI optimization metadata storage
|
|
206
352
|
- **Stripe Integration** - Secure payment processing and subscription management
|
|
207
|
-
- **Template Storage System** - Automatic optimization history with
|
|
208
|
-
- **Advanced Analytics** -
|
|
353
|
+
- **AI Template Storage System** - Automatic optimization history with AI context metadata
|
|
354
|
+
- **Advanced AI Analytics** - AI context detection analytics and optimization insights
|
|
209
355
|
|
|
210
|
-
### Backend
|
|
211
|
-
- **
|
|
212
|
-
- **
|
|
213
|
-
- **
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
- **Real-time Quota Tracking** - Live usage monitoring and limits
|
|
217
|
-
- **Template Persistence** - Automatic saving with comprehensive metadata
|
|
218
|
-
- **Rate Limiting** - Intelligent throttling to prevent abuse
|
|
219
|
-
- **Security Monitoring** - Advanced threat detection and prevention
|
|
220
|
-
- **Performance Optimization** - Sub-second response times for most requests
|
|
356
|
+
### AI-Enhanced Backend Features
|
|
357
|
+
- **Real-time AI Context Detection** - Automatic detection of image generation, LLM interaction, and technical prompts
|
|
358
|
+
- **Parameter Preservation Engine** - Intelligent preservation of technical parameters
|
|
359
|
+
- **Goal Enhancement System** - Automatic goal enhancement based on AI context
|
|
360
|
+
- **Model-Specific Optimization** - Optimization strategies tailored for specific AI models
|
|
361
|
+
- **AI Analytics Dashboard** - Insights into AI context detection and optimization effectiveness
|
|
221
362
|
|
|
222
363
|
## Commands
|
|
223
364
|
|
|
224
365
|
```bash
|
|
225
|
-
# Start the MCP server (usually called by MCP client)
|
|
366
|
+
# Start the AI-enhanced MCP server (usually called by MCP client)
|
|
226
367
|
mcp-prompt-optimizer
|
|
227
368
|
|
|
228
369
|
# Configure API key
|
|
229
370
|
mcp-prompt-optimizer --setup
|
|
230
371
|
|
|
231
|
-
# Show help
|
|
372
|
+
# Show help with AI features
|
|
232
373
|
mcp-prompt-optimizer --help
|
|
233
374
|
|
|
234
|
-
# Show version
|
|
375
|
+
# Show version (now v1.1.0 with AI features)
|
|
235
376
|
mcp-prompt-optimizer --version
|
|
236
377
|
|
|
237
|
-
# Test package functionality
|
|
378
|
+
# Test AI-enhanced package functionality
|
|
238
379
|
npm test
|
|
239
380
|
```
|
|
240
381
|
|
|
@@ -251,10 +392,17 @@ mcp-prompt-optimizer --setup
|
|
|
251
392
|
|
|
252
393
|
1. Verify your internet connection
|
|
253
394
|
2. Check that your API key is valid at [the dashboard](https://promptoptimizer-blog.vercel.app/dashboard)
|
|
254
|
-
3. Ensure your subscription is active
|
|
395
|
+
3. Ensure your subscription is active and supports AI features
|
|
255
396
|
4. Try regenerating your API key from the dashboard
|
|
256
397
|
5. Check backend status: `curl https://p01--project-optimizer--fvrdk8m9k9j.code.run/health`
|
|
257
398
|
|
|
399
|
+
### AI Context Detection Issues
|
|
400
|
+
|
|
401
|
+
1. Verify that your prompt contains AI-specific indicators (--ar, "act as", code blocks)
|
|
402
|
+
2. Try manually specifying the `ai_context` parameter
|
|
403
|
+
3. Check that `preserve_formatting` is set to `true` for technical prompts
|
|
404
|
+
4. Review the optimization response for AI context detection results
|
|
405
|
+
|
|
258
406
|
### MCP Client Configuration
|
|
259
407
|
|
|
260
408
|
1. Make sure the configuration file path is correct
|
|
@@ -267,7 +415,7 @@ mcp-prompt-optimizer --setup
|
|
|
267
415
|
If you experience backend connectivity issues:
|
|
268
416
|
|
|
269
417
|
```bash
|
|
270
|
-
# Test backend directly
|
|
418
|
+
# Test AI-enhanced backend directly
|
|
271
419
|
curl -X GET "https://p01--project-optimizer--fvrdk8m9k9j.code.run/health"
|
|
272
420
|
|
|
273
421
|
# Test with your API key
|
|
@@ -279,14 +427,16 @@ curl -X POST "https://p01--project-optimizer--fvrdk8m9k9j.code.run/api/v1/valida
|
|
|
279
427
|
|
|
280
428
|
Your API key is stored securely at:
|
|
281
429
|
- **Windows**: `%USERPROFILE%\.prompt-optimizer\config.json`
|
|
282
|
-
- **macOS/Linux**: `~/.prompt-optimizer
|
|
430
|
+
- **macOS/Linux**: `~/.prompt-optimizer\config.json`
|
|
283
431
|
|
|
284
432
|
The configuration includes:
|
|
285
433
|
```json
|
|
286
434
|
{
|
|
287
435
|
"apiKey": "sk-opt-your-key-here",
|
|
288
436
|
"backendUrl": "https://p01--project-optimizer--fvrdk8m9k9j.code.run",
|
|
289
|
-
"updatedAt": "2025-06-
|
|
437
|
+
"updatedAt": "2025-06-21T12:00:00.000Z",
|
|
438
|
+
"aiFeatures": true,
|
|
439
|
+
"version": "1.1.0"
|
|
290
440
|
}
|
|
291
441
|
```
|
|
292
442
|
|
|
@@ -297,31 +447,36 @@ Override configuration with environment variables:
|
|
|
297
447
|
- `PROMPT_OPTIMIZER_API_KEY`: Override stored API key
|
|
298
448
|
- `PROMPT_OPTIMIZER_BACKEND_URL`: Override backend URL
|
|
299
449
|
- `NODE_ENV`: Set to 'development' for debug logging
|
|
450
|
+
- `AI_CONTEXT_DEBUG`: Enable AI context detection debugging
|
|
300
451
|
|
|
301
452
|
Example:
|
|
302
453
|
```bash
|
|
303
|
-
PROMPT_OPTIMIZER_API_KEY=sk-opt-your-key mcp-prompt-optimizer
|
|
454
|
+
PROMPT_OPTIMIZER_API_KEY=sk-opt-your-key AI_CONTEXT_DEBUG=true mcp-prompt-optimizer
|
|
304
455
|
```
|
|
305
456
|
|
|
306
457
|
## API Compatibility
|
|
307
458
|
|
|
308
|
-
This package is compatible with the FastAPI backend API version 0.
|
|
459
|
+
This package is compatible with the AI-Enhanced FastAPI backend API version 0.3.0+ and supports:
|
|
309
460
|
|
|
310
461
|
- ✅ **MCP Protocol 2024-11-05** - Latest MCP specification
|
|
462
|
+
- ✅ **AI Context Detection** - Automatic detection of image generation, LLM interaction, technical automation
|
|
463
|
+
- ✅ **Parameter Preservation** - Technical parameter preservation during optimization
|
|
464
|
+
- ✅ **Enhanced Goal Mapping** - Automatic goal enhancement based on AI context
|
|
465
|
+
- ✅ **Target AI Model Support** - Model-specific optimization strategies
|
|
311
466
|
- ✅ **API Key Authentication** - Secure `sk-opt-` format keys
|
|
312
467
|
- ✅ **Base64 Config Encoding** - MCP protocol compliance
|
|
313
|
-
- ✅ **Real-time Quota Tracking** - Usage monitoring with
|
|
468
|
+
- ✅ **Real-time Quota Tracking** - Usage monitoring with AI analytics
|
|
314
469
|
- ✅ **Error Handling** - Comprehensive error responses
|
|
315
470
|
- ✅ **Rate Limiting** - Automatic retry logic
|
|
316
|
-
- ✅ **Template Persistence** - Automatic optimization history
|
|
471
|
+
- ✅ **AI Template Persistence** - Automatic optimization history with AI metadata
|
|
317
472
|
|
|
318
473
|
## Intellectual Property
|
|
319
474
|
|
|
320
475
|
- **Your Prompts, Your IP**: You retain full intellectual property rights over all prompts you create and optimize
|
|
321
|
-
- **Service Provision**: We provide optimization as a service - we do not claim ownership over your content
|
|
322
|
-
- **Template Storage**: Saved templates are for your reference and remain your intellectual property
|
|
323
|
-
- **Privacy Protected**: Your prompts and templates are private and accessible only to your account
|
|
324
|
-
- **Data Export**: You can export your optimization history and templates at any time
|
|
476
|
+
- **Service Provision**: We provide AI-enhanced optimization as a service - we do not claim ownership over your content
|
|
477
|
+
- **AI Template Storage**: Saved templates with AI metadata are for your reference and remain your intellectual property
|
|
478
|
+
- **Privacy Protected**: Your prompts, AI contexts, and templates are private and accessible only to your account
|
|
479
|
+
- **Data Export**: You can export your AI optimization history and templates at any time
|
|
325
480
|
|
|
326
481
|
## Support
|
|
327
482
|
|
|
@@ -329,22 +484,24 @@ This package is compatible with the FastAPI backend API version 0.2.2+ and suppo
|
|
|
329
484
|
- 🎫 [Support Portal](https://promptoptimizer-blog.vercel.app/support)
|
|
330
485
|
- 🐛 [Report Issues](https://github.com/prompt-optimizer/mcp-prompt-optimizer/issues)
|
|
331
486
|
- 💬 [Community Discord](https://discord.gg/prompt-optimizer)
|
|
487
|
+
- 🤖 [AI Features Guide](https://promptoptimizer-blog.vercel.app/docs/ai-features)
|
|
332
488
|
|
|
333
489
|
## Security
|
|
334
490
|
|
|
335
491
|
- API keys are stored locally and never shared
|
|
336
|
-
- All communication uses HTTPS encryption with the backend
|
|
492
|
+
- All communication uses HTTPS encryption with the AI-enhanced backend
|
|
337
493
|
- No prompt data is stored permanently beyond template history (which you control)
|
|
338
|
-
-
|
|
494
|
+
- AI context detection happens server-side with privacy protection
|
|
495
|
+
- Full audit trail of AI optimization usage available in dashboard
|
|
339
496
|
- Compliance with enterprise security standards
|
|
340
|
-
-
|
|
497
|
+
- AI template data encrypted at rest and in transit
|
|
341
498
|
|
|
342
499
|
## Development
|
|
343
500
|
|
|
344
501
|
### Testing
|
|
345
502
|
|
|
346
503
|
```bash
|
|
347
|
-
# Run package tests
|
|
504
|
+
# Run package tests (includes AI feature tests)
|
|
348
505
|
npm test
|
|
349
506
|
|
|
350
507
|
# Manual server test
|
|
@@ -361,12 +518,30 @@ cd mcp-prompt-optimizer
|
|
|
361
518
|
# Install dependencies
|
|
362
519
|
npm install
|
|
363
520
|
|
|
364
|
-
# Test locally
|
|
521
|
+
# Test locally with AI features
|
|
365
522
|
npm test
|
|
366
523
|
```
|
|
367
524
|
|
|
368
525
|
## Changelog
|
|
369
526
|
|
|
527
|
+
### v1.1.0 - AI Enhancement Release 🚀
|
|
528
|
+
- 🧠 **NEW**: Automatic AI context detection for image generation, LLM interaction, and technical automation
|
|
529
|
+
- 🛡️ **NEW**: Parameter preservation for technical prompts (Midjourney parameters, code blocks, URLs)
|
|
530
|
+
- 🎯 **NEW**: 9 AI-specific optimization goals (keyword_density, parameter_preservation, etc.)
|
|
531
|
+
- 🤖 **NEW**: Smart goal enhancement based on detected AI context
|
|
532
|
+
- 🔧 **NEW**: Target AI model specification support
|
|
533
|
+
- 📊 **NEW**: Enhanced optimization response with AI context information
|
|
534
|
+
- ⚡ **IMPROVED**: Better optimization strategies for different AI use cases
|
|
535
|
+
|
|
536
|
+
### v1.0.3
|
|
537
|
+
- ✅ Fixed binary execution issue on Windows systems
|
|
538
|
+
- ✅ Enhanced error handling for server responses
|
|
539
|
+
- ✅ Improved version detection for global installations
|
|
540
|
+
|
|
541
|
+
### v1.0.2
|
|
542
|
+
- ✅ Fixed pricing information discrepancy in documentation
|
|
543
|
+
- ✅ Improved documentation consistency across all package files
|
|
544
|
+
|
|
370
545
|
### v1.0.1
|
|
371
546
|
- ✅ Updated backend URL to production deployment
|
|
372
547
|
- ✅ Enhanced error handling for server responses
|
|
@@ -384,9 +559,9 @@ npm test
|
|
|
384
559
|
|
|
385
560
|
**Commercial License** - This software is licensed for commercial use. See LICENSE file for details.
|
|
386
561
|
|
|
387
|
-
**Your Content**: You retain full intellectual property rights over all prompts, templates, and content you create using this service.
|
|
562
|
+
**Your Content**: You retain full intellectual property rights over all prompts, templates, and content you create using this AI-enhanced service.
|
|
388
563
|
|
|
389
564
|
---
|
|
390
565
|
|
|
391
566
|
**Made with ❤️ by the Prompt Optimizer Team**
|
|
392
|
-
*Empowering better AI interactions through
|
|
567
|
+
*Empowering better AI interactions through intelligent, context-aware prompt optimization*
|
package/bin/start-server
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// More robust binary that handles global installation better
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
// Determine the correct path to index.js
|
|
7
|
+
let indexPath;
|
|
8
|
+
if (__dirname.includes('node_modules')) {
|
|
9
|
+
// Running from global installation
|
|
10
|
+
indexPath = path.join(__dirname, '..', 'index.js');
|
|
11
|
+
} else {
|
|
12
|
+
// Running from local development
|
|
13
|
+
indexPath = path.join(__dirname, '..', 'index.js');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
require(indexPath);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error('Failed to start MCP Prompt Optimizer:', error.message);
|
|
20
|
+
console.error('Please try: npm install -g mcp-prompt-optimizer@latest');
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const MCPServer = require('./lib/mcp-protocol');
|
|
4
4
|
const Config = require('./lib/config');
|
|
5
|
+
const path = require('path');
|
|
5
6
|
|
|
6
7
|
async function setup() {
|
|
7
8
|
const readline = require('readline');
|
|
@@ -158,8 +159,32 @@ async function showHelp() {
|
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
async function showVersion() {
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
try {
|
|
163
|
+
// Try multiple paths to find package.json when installed globally
|
|
164
|
+
let packageJson;
|
|
165
|
+
const possiblePaths = [
|
|
166
|
+
path.join(__dirname, 'package.json'), // Local development
|
|
167
|
+
path.join(__dirname, '..', 'package.json'), // When run from bin/
|
|
168
|
+
path.join(process.cwd(), 'package.json'), // Current directory
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
for (const packagePath of possiblePaths) {
|
|
172
|
+
try {
|
|
173
|
+
packageJson = require(packagePath);
|
|
174
|
+
break;
|
|
175
|
+
} catch (e) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (packageJson && packageJson.version) {
|
|
181
|
+
console.log(`mcp-prompt-optimizer v${packageJson.version}`);
|
|
182
|
+
} else {
|
|
183
|
+
console.log('mcp-prompt-optimizer v1.0.2 (version detection failed)');
|
|
184
|
+
}
|
|
185
|
+
} catch (error) {
|
|
186
|
+
console.log('mcp-prompt-optimizer v1.0.2 (version detection failed)');
|
|
187
|
+
}
|
|
163
188
|
}
|
|
164
189
|
|
|
165
190
|
// Main execution
|
package/lib/api-client.js
CHANGED
|
@@ -32,10 +32,19 @@ class PromptOptimizerApiClient {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
async optimize(prompt, goals = ['clarity']) {
|
|
35
|
+
async optimize(prompt, goals = ['clarity'], options = {}) {
|
|
36
36
|
try {
|
|
37
|
-
//
|
|
38
|
-
const config = {
|
|
37
|
+
// Enhanced config with AI optimization support
|
|
38
|
+
const config = {
|
|
39
|
+
prompt,
|
|
40
|
+
goals,
|
|
41
|
+
// Add new AI optimization options
|
|
42
|
+
ai_context: options.ai_context || null,
|
|
43
|
+
preserve_formatting: options.preserve_formatting !== false,
|
|
44
|
+
target_ai_model: options.target_ai_model || null,
|
|
45
|
+
optimization_level: options.optimization_level || "balanced"
|
|
46
|
+
};
|
|
47
|
+
|
|
39
48
|
const configB64 = Buffer.from(JSON.stringify(config)).toString('base64');
|
|
40
49
|
|
|
41
50
|
const response = await this.client.post(`/api/v1/mcp/optimize?config=${encodeURIComponent(configB64)}`);
|
package/lib/mcp-protocol.js
CHANGED
|
@@ -5,7 +5,7 @@ class MCPServer {
|
|
|
5
5
|
this.apiClient = new PromptOptimizerApiClient(apiKey);
|
|
6
6
|
this.tools = [{
|
|
7
7
|
name: "optimize_prompt",
|
|
8
|
-
description: "Optimize prompts for clarity, conciseness, and effectiveness using advanced AI techniques",
|
|
8
|
+
description: "Optimize prompts for clarity, conciseness, and effectiveness using advanced AI techniques with context awareness",
|
|
9
9
|
inputSchema: {
|
|
10
10
|
type: "object",
|
|
11
11
|
properties: {
|
|
@@ -18,6 +18,7 @@ class MCPServer {
|
|
|
18
18
|
items: {
|
|
19
19
|
type: "string",
|
|
20
20
|
enum: [
|
|
21
|
+
// Standard goals
|
|
21
22
|
"clarity",
|
|
22
23
|
"conciseness",
|
|
23
24
|
"technical_accuracy",
|
|
@@ -27,11 +28,41 @@ class MCPServer {
|
|
|
27
28
|
"structure",
|
|
28
29
|
"technical_precision",
|
|
29
30
|
"linguistic_precision",
|
|
30
|
-
"holistic_effectiveness"
|
|
31
|
+
"holistic_effectiveness",
|
|
32
|
+
// NEW: AI-specific goals
|
|
33
|
+
"keyword_density",
|
|
34
|
+
"parameter_preservation",
|
|
35
|
+
"token_efficiency",
|
|
36
|
+
"embedding_strength",
|
|
37
|
+
"context_specificity",
|
|
38
|
+
"ai_model_compatibility",
|
|
39
|
+
"quality_enhancement",
|
|
40
|
+
"role_clarity",
|
|
41
|
+
"code_protection"
|
|
31
42
|
]
|
|
32
43
|
},
|
|
33
|
-
description: "Optimization goals (default: clarity)",
|
|
44
|
+
description: "Optimization goals including AI-specific enhancements (default: clarity)",
|
|
34
45
|
default: ["clarity"]
|
|
46
|
+
},
|
|
47
|
+
ai_context: {
|
|
48
|
+
type: "string",
|
|
49
|
+
enum: ["image_generation", "llm_interaction", "technical_automation", "human_communication"],
|
|
50
|
+
description: "AI context type for optimization routing (auto-detected if not specified)"
|
|
51
|
+
},
|
|
52
|
+
preserve_formatting: {
|
|
53
|
+
type: "boolean",
|
|
54
|
+
description: "Whether to preserve technical formatting and parameters",
|
|
55
|
+
default: true
|
|
56
|
+
},
|
|
57
|
+
target_ai_model: {
|
|
58
|
+
type: "string",
|
|
59
|
+
description: "Target AI model (e.g., 'midjourney', 'chatgpt', 'claude')"
|
|
60
|
+
},
|
|
61
|
+
optimization_level: {
|
|
62
|
+
type: "string",
|
|
63
|
+
enum: ["conservative", "balanced", "aggressive"],
|
|
64
|
+
description: "Optimization level: conservative, balanced, or aggressive",
|
|
65
|
+
default: "balanced"
|
|
35
66
|
}
|
|
36
67
|
},
|
|
37
68
|
required: ["prompt"]
|
|
@@ -42,10 +73,11 @@ class MCPServer {
|
|
|
42
73
|
async initialize() {
|
|
43
74
|
try {
|
|
44
75
|
const userData = await this.apiClient.validateKey();
|
|
45
|
-
console.error(`✅ Connected to Prompt Optimizer API`);
|
|
76
|
+
console.error(`✅ Connected to Prompt Optimizer API (AI-Enhanced)`);
|
|
46
77
|
console.error(` Tier: ${userData.tier}`);
|
|
47
78
|
console.error(` Quota: ${userData.quota_used}/${userData.quota_limit} used`);
|
|
48
79
|
console.error(` Status: ${userData.subscription_status}`);
|
|
80
|
+
console.error(` AI Features: Context Detection, Parameter Preservation, Enhanced Goals`);
|
|
49
81
|
return true;
|
|
50
82
|
} catch (error) {
|
|
51
83
|
console.error(`❌ Failed to connect: ${error.message}`);
|
|
@@ -55,7 +87,14 @@ class MCPServer {
|
|
|
55
87
|
|
|
56
88
|
async handleToolCall(name, args) {
|
|
57
89
|
if (name === 'optimize_prompt') {
|
|
58
|
-
const {
|
|
90
|
+
const {
|
|
91
|
+
prompt,
|
|
92
|
+
goals = ['clarity'],
|
|
93
|
+
ai_context = null,
|
|
94
|
+
preserve_formatting = true,
|
|
95
|
+
target_ai_model = null,
|
|
96
|
+
optimization_level = "balanced"
|
|
97
|
+
} = args;
|
|
59
98
|
|
|
60
99
|
// Validate prompt
|
|
61
100
|
if (!prompt || typeof prompt !== 'string' || prompt.trim().length === 0) {
|
|
@@ -68,11 +107,15 @@ class MCPServer {
|
|
|
68
107
|
};
|
|
69
108
|
}
|
|
70
109
|
|
|
71
|
-
// Validate goals
|
|
110
|
+
// Validate goals (including new AI-specific goals)
|
|
72
111
|
const validGoals = [
|
|
73
112
|
"clarity", "conciseness", "technical_accuracy", "contextual_relevance",
|
|
74
113
|
"specificity", "actionability", "structure", "technical_precision",
|
|
75
|
-
"linguistic_precision", "holistic_effectiveness"
|
|
114
|
+
"linguistic_precision", "holistic_effectiveness",
|
|
115
|
+
// AI-specific goals
|
|
116
|
+
"keyword_density", "parameter_preservation", "token_efficiency",
|
|
117
|
+
"embedding_strength", "context_specificity", "ai_model_compatibility",
|
|
118
|
+
"quality_enhancement", "role_clarity", "code_protection"
|
|
76
119
|
];
|
|
77
120
|
|
|
78
121
|
const filteredGoals = goals.filter(goal => validGoals.includes(goal));
|
|
@@ -81,12 +124,44 @@ class MCPServer {
|
|
|
81
124
|
}
|
|
82
125
|
|
|
83
126
|
try {
|
|
84
|
-
const
|
|
127
|
+
const options = {
|
|
128
|
+
ai_context,
|
|
129
|
+
preserve_formatting,
|
|
130
|
+
target_ai_model,
|
|
131
|
+
optimization_level
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const result = await this.apiClient.optimize(prompt.trim(), filteredGoals, options);
|
|
135
|
+
|
|
136
|
+
// Enhanced response with AI context information
|
|
137
|
+
let responseText = `# AI-Optimized Prompt\n\n${result.optimized_prompt}\n\n---\n\n`;
|
|
138
|
+
responseText += `**Confidence Score:** ${result.confidence_score.toFixed(2)}\n`;
|
|
139
|
+
responseText += `**Goals Applied:** ${filteredGoals.join(', ')}\n`;
|
|
140
|
+
|
|
141
|
+
// Add AI context information if available
|
|
142
|
+
if (result.metadata?.ai_context) {
|
|
143
|
+
responseText += `**AI Context Detected:** ${result.metadata.ai_context}\n`;
|
|
144
|
+
}
|
|
145
|
+
if (result.metadata?.optimization_strategy) {
|
|
146
|
+
responseText += `**Optimization Strategy:** ${result.metadata.optimization_strategy}\n`;
|
|
147
|
+
}
|
|
148
|
+
if (result.metadata?.goal_enhancement_applied) {
|
|
149
|
+
responseText += `**Goal Enhancement:** Applied\n`;
|
|
150
|
+
}
|
|
151
|
+
if (result.metadata?.preserved_parameters) {
|
|
152
|
+
responseText += `**Parameters Preserved:** ${result.metadata.preserved_parameters}\n`;
|
|
153
|
+
}
|
|
154
|
+
if (result.metadata?.original_goals && result.metadata?.enhanced_goals) {
|
|
155
|
+
responseText += `**Original Goals:** ${result.metadata.original_goals.join(', ')}\n`;
|
|
156
|
+
responseText += `**Enhanced Goals:** ${result.metadata.enhanced_goals.join(', ')}\n`;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
responseText += `**Quota Remaining:** ${result.metadata?.quota_remaining ?? 'Unknown'}`;
|
|
85
160
|
|
|
86
161
|
return {
|
|
87
162
|
content: [{
|
|
88
163
|
type: "text",
|
|
89
|
-
text:
|
|
164
|
+
text: responseText
|
|
90
165
|
}]
|
|
91
166
|
};
|
|
92
167
|
} catch (error) {
|
|
@@ -119,7 +194,7 @@ class MCPServer {
|
|
|
119
194
|
},
|
|
120
195
|
serverInfo: {
|
|
121
196
|
name: "mcp-prompt-optimizer",
|
|
122
|
-
version: "1.
|
|
197
|
+
version: "1.1.0" // Updated version for AI features
|
|
123
198
|
}
|
|
124
199
|
}
|
|
125
200
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-prompt-optimizer",
|
|
3
|
-
"version": "1.0
|
|
4
|
-
"description": "Local MCP server for Prompt Optimizer API",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Local MCP server for AI-Enhanced Prompt Optimizer API with context awareness and parameter preservation",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"preferGlobal": true,
|
|
7
7
|
"bin": {
|
|
8
|
-
"mcp-prompt-optimizer": "
|
|
8
|
+
"mcp-prompt-optimizer": "index.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"start": "node index.js",
|
|
@@ -29,7 +29,14 @@
|
|
|
29
29
|
"windsurf",
|
|
30
30
|
"api",
|
|
31
31
|
"northflank",
|
|
32
|
-
"fastapi"
|
|
32
|
+
"fastapi",
|
|
33
|
+
"ai-context",
|
|
34
|
+
"parameter-preservation",
|
|
35
|
+
"image-generation",
|
|
36
|
+
"llm-interaction",
|
|
37
|
+
"technical-automation",
|
|
38
|
+
"goal-enhancement",
|
|
39
|
+
"context-awareness"
|
|
33
40
|
],
|
|
34
41
|
"author": "Prompt Optimizer Team <support@promptoptimizer.com>",
|
|
35
42
|
"license": "SEE LICENSE IN LICENSE",
|