mcp-prompt-optimizer 1.4.2 → 2.2.3

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
@@ -1,71 +1,96 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to the MCP Prompt Optimizer will be documented in this file.
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
- ## [1.4.0] - 2025-07-28 - Backend Alignment & Feature Completion
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
7
 
7
- ### Features & Alignment
8
- - **ALIGNED**: Fully aligned request payloads and response handling with the latest backend API for enhanced reliability.
9
- - **ENHANCED**: AI Context Detection now correctly recognizes `structured_output`, `code_generation`, and `api_automation`, providing more accurate, context-aware optimizations.
10
- - **ADDED**: `search_templates` and `get_quota_status` tools are now fully implemented and validated.
11
- - **IMPROVED**: Response formatting for all tools provides a richer, more detailed, and user-friendly experience.
12
- - **VALIDATED**: The comprehensive startup validation and CLI command suite (`diagnose`, `test`, `check-status`) are now fully functional and tested.
13
- - **FIXED**: Corrected all version inconsistencies across the package for stable dependency management.
8
+ ## [1.5.0] - 2025-09-25
14
9
 
15
- ---
10
+ ### Added
11
+ - 🧠 **Bayesian Optimization Support**: Advanced parameter tuning and performance prediction
12
+ - ⚡ **AG-UI Real-Time Features**: Streaming optimization and WebSocket support
13
+ - 🎯 **Enhanced AI Context Detection**: Improved weighted scoring system with 7 contexts
14
+ - 📊 **Advanced Analytics**: New `get_optimization_insights` tool for Bayesian metrics
15
+ - 🚀 **Real-Time Status**: New `get_real_time_status` tool for live optimization monitoring
16
+ - 🔧 **Feature Flags**: `ENABLE_BAYESIAN_OPTIMIZATION` and `ENABLE_AGUI_FEATURES` environment variables
17
+ - 📋 **Enhanced Template Search**: AI-aware filtering by sophistication, complexity, and strategy
18
+ - 🎨 **Rich Formatting**: Improved output formatting with better visual organization
19
+
20
+ ### Changed
21
+ - 🔄 **Backend API Alignment**: Updated to align with FastAPI Backend production-v2.1.0-bayesian
22
+ - 🎯 **Context Detection**: Upgraded algorithm with weighted scoring and negative patterns
23
+ - 📊 **Quota Display**: Enhanced quota status with visual indicators and feature breakdown
24
+ - 🔍 **Template Search**: Expanded search parameters and improved result formatting
25
+ - 🚀 **Startup Process**: Enhanced validation with feature status reporting
26
+
27
+ ### Fixed
28
+ - ✅ **API Endpoints**: Corrected backend endpoint URLs for full compatibility
29
+ - 🛡️ **Error Handling**: Improved fallback mechanisms for network issues
30
+ - 📝 **Template Display**: Fixed template preview and confidence score formatting
31
+ - 🔧 **Environment Variables**: Better handling of feature flag defaults
16
32
 
17
- ## [1.1.0] - 2025-07-05
33
+ ### Technical
34
+ - 📦 **Dependencies**: Updated to latest MCP SDK version
35
+ - 🏗️ **Architecture**: Modular feature system with conditional tool loading
36
+ - 🧪 **Testing**: Enhanced mock responses for development mode
37
+ - 📖 **Documentation**: Updated tool descriptions and parameter schemas
18
38
 
19
- ### 🎯 Smart Tier-Aware Features
20
- - **NEW**: Smart tier detection and feature delivery
21
- - **NEW**: Auto-save templates for high-confidence optimizations (Creator/Innovator)
22
- - **NEW**: Similar template search and discovery (Creator/Innovator)
23
- - **NEW**: Advanced optimization insights and analytics (Innovator)
24
- - **NEW**: Performance improvement metrics (Innovator)
25
- - **NEW**: AI-powered optimization recommendations (Innovator)
39
+ ### Backend Compatibility
40
+ - **API Version**: v1 (aligned with FastAPI backend)
41
+ - **Endpoint Mapping**: `/api/v1/mcp/*` endpoints fully supported
42
+ - **Feature Parity**: All backend features now accessible via MCP
43
+ - **Error Codes**: Proper HTTP status code handling and user-friendly messages
26
44
 
27
- ### Enhanced User Experience
28
- - **IMPROVED**: Tier-aware response formatting
29
- - **NEW**: Upgrade prompts and value progression
30
- - **IMPROVED**: Error messages with tier-specific guidance
31
- - **NEW**: Professional messaging for each tier level
45
+ ## [2.2.3] - 2025-11-01
32
46
 
33
- ### 🔧 Technical Improvements
34
- - **UPDATED**: Backend integration for smart endpoint
35
- - **IMPROVED**: Response parsing and formatting
36
- - **NEW**: Graceful handling of template save failures
37
- - **UPDATED**: Tool descriptions to reflect smart features
47
+ ### Fixed
48
+ - **API Key Validation**: Corrected `sk-local-*` API key validation, ensuring they are properly validated against the backend instead of being treated as mock keys.
49
+ - **Context Detection Error**: Resolved `Cannot read properties of undefined (reading 'name')` error in `generateMockContextDetection` by adding robust checks for `detected_parameters`.
50
+ - **Quick Test Failures**: Updated `quick-test.js` to align with current API, fixing `AI Context detection` and removing `Goal enhancement` test.
38
51
 
39
- ### 📚 Documentation
40
- - **UPDATED**: README with tier-specific examples
41
- - **NEW**: Complete feature matrix by tier
42
- - **UPDATED**: Setup instructions for smart features
43
- - **NEW**: Example responses for all tier levels
52
+ ### Changed
53
+ - 🔄 **Endpoint Management**: Centralized all backend API endpoints into a new `ENDPOINTS` object for improved maintainability and consistency.
54
+ - 🧠 **Mock Context Detection**: Enhanced `generateMockContextDetection` logic with more accurate keyword matching for `code_generation`, `image_generation`, and `llm_interaction` contexts.
55
+ - 🔧 **CLI Flag Defaults**: Clarified default behavior for `ENABLE_BAYESIAN_OPTIMIZATION` and `ENABLE_AGUI_FEATURES` environment variables.
56
+ - ⏱️ **Timeout Handling**: Removed redundant `req.setTimeout` call in `callBackendAPI` for cleaner and more consistent timeout management.
57
+ - 🛡️ **Defensive Checks**: Added defensive checks for blindly accessed metrics in `formatOptimizationResult` to prevent errors from slim backend responses.
58
+ - 📝 **Logging**: Improved `startValidatedMCPServer` logging by using `console.log` for informational messages.
59
+ - 📖 **Documentation**: Updated `README.md` to reflect changes in API key usage and context detection patterns.
44
60
 
45
- ### 🐛 Bug Fixes
46
- - **FIXED**: Response formatting for complex nested data
47
- - **FIXED**: Error handling for backend communication
48
- - **IMPROVED**: Fallback behavior for missing features
61
+ ### Removed
62
+ - 📦 **Test Scripts from Package**: Excluded `tests/` directory from the published npm package to reduce package size and focus on core functionality.
49
63
 
50
- ---
64
+ ## [2.2.0] - 2025-10-31
51
65
 
52
- ## [1.0.2] - 2024-12-17
66
+ ### Changed
67
+ - 🔄 **Backend API Alignment**: Updated to align with FastAPI Backend production-v2.2.0-stable
68
+ - 🛠️ **Tool Refinement**: Refined `create_template`, `get_template`, `update_template`, and `detect_ai_context` tools for enhanced functionality and robustness.
53
69
 
54
70
  ### Fixed
55
- - Package installation issues
56
- - Binary execution permissions
57
- - Configuration file handling
71
+ - **API Endpoints**: Ensured all backend endpoint URLs are fully compatible and robust.
72
+
73
+ ### Technical
74
+ - 📦 **Dependencies**: Updated to latest MCP SDK version for improved stability.
75
+ - 🧪 **Testing**: Comprehensive internal testing to ensure full alignment between NPM package and FastAPI backend.
58
76
 
59
- ## [1.0.1] - 2024-12-17
77
+ ## [1.4.1] - 2025-09-15
78
+
79
+ ### Fixed
80
+ - API key format validation
81
+ - Template auto-save threshold
82
+
83
+ ## [1.4.0] - 2025-09-10
60
84
 
61
85
  ### Added
62
- - Initial MCP server implementation
63
- - Basic prompt optimization via remote API
64
- - Claude Desktop integration
65
- - Setup wizard for API key configuration
66
-
67
- ### Features
68
- - Remote optimization using AI-Enhanced Prompt Optimizer API
69
- - MCP protocol compliance
70
- - Cross-platform support (Windows, macOS, Linux)
71
- - Global npm installation support
86
+ - Template auto-save feature
87
+ - Basic optimization insights
88
+ - Cross-platform support improvements
89
+
90
+ ### Changed
91
+ - Improved context detection
92
+ - Enhanced error messages
93
+
94
+ ## [1.3.x] - Previous Versions
95
+
96
+ Historical versions with basic prompt optimization functionality.
package/CROSS-PLATFORM.md CHANGED
@@ -38,7 +38,7 @@ $env:OPTIMIZER_API_KEY = "sk-opt-your-key-here"
38
38
  mcp-prompt-optimizer
39
39
 
40
40
  # Command Prompt
41
- set OPTIMIZER_API_KEY=sk-opt-your-key-here
41
+ set OPTIMIZER_API_KEY=sk-local-your-key-here
42
42
  mcp-prompt-optimizer
43
43
 
44
44
  # Or use the Windows-specific development script
@@ -49,7 +49,7 @@ npm run dev:windows
49
49
 
50
50
  ```bash
51
51
  # Bash/Zsh
52
- export OPTIMIZER_API_KEY="sk-opt-your-key-here"
52
+ export OPTIMIZER_API_KEY="sk-local-your-key-here"
53
53
  mcp-prompt-optimizer
54
54
 
55
55
  # Or use the Unix-specific development script
@@ -116,7 +116,7 @@ All environment variables work consistently across platforms:
116
116
 
117
117
  ```bash
118
118
  # Core configuration
119
- OPTIMIZER_API_KEY=sk-opt-your-key-here
119
+ OPTIMIZER_API_KEY=sk-local-your-key-here
120
120
  OPTIMIZER_BACKEND_URL=https://custom-backend.com
121
121
  OPTIMIZER_DEV_MODE=true
122
122
  NODE_ENV=development
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # MCP Prompt Optimizer
1
+ # MCP Prompt Optimizer v2.2.3
2
2
 
3
3
  🚀 **Professional cloud-based MCP server** for AI-powered prompt optimization with intelligent context detection, template management, team collaboration, enterprise-grade features, and **optional personal model configuration**. Starting at $2.99/month.
4
4
 
@@ -7,7 +7,7 @@
7
7
  🧠 **AI Context Detection** - Automatically detects and optimizes for image generation, LLM interaction, technical automation
8
8
  📁 **Template Management** - Auto-save high-confidence optimizations, search & reuse patterns
9
9
  👥 **Team Collaboration** - Shared quotas, team templates, role-based access
10
- 📊 **Real-time Analytics** - Confidence scoring, usage tracking, optimization insights
10
+ 📊 **Real-time Analytics** - Confidence scoring, usage tracking, optimization insights (Note: Advanced features like Bayesian Optimization and AG-UI are configurable and may provide mock data if disabled in the backend)
11
11
  ☁️ **Cloud Processing** - Always up-to-date AI models, no local setup required
12
12
  🎛️ **Personal Model Choice** - Use your own OpenRouter models via WebUI configuration
13
13
  🔧 **Universal MCP** - Works with Claude Desktop, Cursor, Windsurf, Cline, VS Code, Zed, Replit
@@ -20,7 +20,7 @@ npm install -g mcp-prompt-optimizer
20
20
  ```
21
21
 
22
22
  **2. Get your API key:**
23
- Visit [https://promptoptimizer-blog.vercel.app/pricing](https://promptoptimizer-blog.vercel.app/pricing) for your free trial (5 optimizations)
23
+ Visit [https://promptoptimizer-blog.vercel.app/pricing](https://promptoptimizer-blog.vercel.app/pricing) for your free tier (`sk-local-*` key, 5 optimizations per day)
24
24
 
25
25
  **3. Configure Claude Desktop:**
26
26
  Add to your `~/.claude/claude_desktop_config.json`:
@@ -31,7 +31,7 @@ Add to your `~/.claude/claude_desktop_config.json`:
31
31
  "command": "npx",
32
32
  "args": ["mcp-prompt-optimizer"],
33
33
  "env": {
34
- "OPTIMIZER_API_KEY": "sk-opt-your-key-here"
34
+ "OPTIMIZER_API_KEY": "sk-local-your-key-here" // Use sk-local-* for free tier, sk-opt-* for paid subscriptions
35
35
  }
36
36
  }
37
37
  }
@@ -158,16 +158,25 @@ Input: "A beautiful landscape --ar 16:9 --v 6"
158
158
  ```
159
159
 
160
160
  ### 🤖 LLM Interaction Context
161
- **Detected patterns:** `act as`, `you are a`, `role:`, `persona:`, `behave like`
161
+ **Detected patterns:** `analyze`, `explain`, `evaluate`, `summary`, `research`, `paper`, `analysis`, `interpret`, `discussion`, `assessment`, `compare`, `contrast`
162
162
  ```
163
- Input: "Act as a professional writer and help me with..."
163
+ Input: "Analyze the pros and cons of this research paper and provide a comprehensive evaluation"
164
164
  ✅ Enhanced goals: context_specificity, token_efficiency, actionability
165
165
  ✅ Improves role clarity and instruction precision
166
166
  ✅ Optimizes for better AI understanding
167
167
  ```
168
168
 
169
+ ### 💻 Code Generation Context
170
+ **Detected patterns:** `def`, `function`, `code`, `python`, `javascript`, `java`, `c++`, `return`, `import`, `class`, `for`, `while`, `if`, `else`, `elif`
171
+ ```
172
+ Input: "def fibonacci(n): return n if n <= 1 else fibonacci(n-1) + fibonacci(n-2)"
173
+ ✅ Enhanced goals: technical_accuracy, parameter_preservation, precision
174
+ ✅ Protects code elements and technical syntax
175
+ ✅ Enhances technical precision and clarity
176
+ ```
177
+
169
178
  ### ⚙️ Technical Automation Context
170
- **Detected patterns:** `def`, `function`, `execute`, `script`, `automation`
179
+ **Detected patterns:** `automate`, `script`, `api`
171
180
  ```
172
181
  Input: "Create a script to automate deployment process"
173
182
  ✅ Enhanced goals: technical_accuracy, parameter_preservation, precision
@@ -272,60 +281,110 @@ Configure in IDE settings or add to MCP configuration file.
272
281
  - **JetBrains IDEs:** MCP plugin configuration
273
282
  - **Emacs/Vim/Neovim:** MCP client setup
274
283
 
275
- ## 🛠️ Available Tools
284
+ ## 🛠️ Available MCP Tools (for AI Agents & MCP Clients)
285
+
286
+ These tools are exposed via the Model Context Protocol (MCP) server and are intended for use by AI agents, MCP-compatible clients (like Claude Desktop, Cursor IDE), or custom scripts that interact with the server via stdin/stdout.
276
287
 
277
288
  ### `optimize_prompt`
278
- **Professional AI optimization with context detection**
289
+ **Professional AI optimization with context detection, auto-save, and insights.**
279
290
  ```javascript
280
291
  {
281
292
  "prompt": "Your prompt text",
282
- "goals": ["clarity", "specificity"], // Optional
283
- "ai_context": "llm_interaction" // Auto-detected if not specified
293
+ "goals": ["clarity", "specificity"], // Optional: e.g., "clarity", "conciseness", "creativity", "technical_accuracy"
294
+ "ai_context": "llm_interaction", // Optional: Auto-detected if not specified. e.g., "code_generation", "image_generation"
295
+ "enable_bayesian": true // Optional: Enable Bayesian optimization features (if available in backend)
284
296
  }
285
297
  ```
286
298
 
287
- ### `get_quota_status`
288
- **Check subscription status and usage**
299
+ ### `detect_ai_context`
300
+ **Detects the AI context for a given prompt using advanced backend analysis.**
289
301
  ```javascript
290
- // No parameters needed
302
+ {
303
+ "prompt": "The prompt text for which to detect the AI context"
304
+ }
305
+ ```
306
+
307
+ ### `create_template`
308
+ **Create a new optimization template.**
309
+ ```javascript
310
+ {
311
+ "title": "Title of the template",
312
+ "description": "Description of the template", // Optional
313
+ "original_prompt": "The original prompt text",
314
+ "optimized_prompt": "The optimized prompt text",
315
+ "optimization_goals": ["clarity"], // Optional: e.g., ["clarity", "conciseness"]
316
+ "confidence_score": 0.9, // (0.0-1.0)
317
+ "model_used": "openai/gpt-4o-mini", // Optional
318
+ "optimization_tier": "llm", // Optional: e.g., "rules", "llm", "hybrid"
319
+ "ai_context_detected": "llm_interaction", // Optional: e.g., "code_generation", "image_generation"
320
+ "is_public": false, // Optional: Whether the template is public
321
+ "tags": ["marketing", "email"] // Optional
322
+ }
323
+ ```
324
+
325
+ ### `get_template`
326
+ **Retrieve a specific template by its ID.**
327
+ ```javascript
328
+ {
329
+ "template_id": "the-template-id"
330
+ }
331
+ ```
332
+
333
+ ### `update_template`
334
+ **Update an existing optimization template.**
335
+ ```javascript
336
+ {
337
+ "template_id": "the-template-id",
338
+ "title": "New title for the template", // Optional
339
+ "description": "New description for the template", // Optional
340
+ "is_public": true // Optional: Update public status
341
+ // Other fields from 'create_template' can also be updated
342
+ }
291
343
  ```
292
344
 
293
345
  ### `search_templates`
294
- **Search your saved template library**
346
+ **Search your saved template library with AI-aware filtering.**
295
347
  ```javascript
296
348
  {
297
- "query": "blog post", // Optional
298
- "ai_context": "human_communication", // Optional filter
299
- "limit": 5 // Max results
349
+ "query": "blog post", // Optional: Search term to filter templates by content or title
350
+ "ai_context": "human_communication", // Optional: Filter templates by AI context type
351
+ "sophistication_level": "advanced", // Optional: Filter by template sophistication level
352
+ "complexity_level": "complex", // Optional: Filter by template complexity level
353
+ "optimization_strategy": "rules_only", // Optional: Filter by optimization strategy used
354
+ "limit": 5, // Optional: Number of templates to return (1-20)
355
+ "sort_by": "confidence_score", // Optional: e.g., "created_at", "usage_count", "title"
356
+ "sort_order": "desc" // Optional: "asc" or "desc"
300
357
  }
301
358
  ```
302
359
 
303
- ## 🎯 Optimization Goals
360
+ ### `get_quota_status`
361
+ **Check subscription status, quota usage, and account information.**
362
+ ```javascript
363
+ // No parameters needed
364
+ ```
304
365
 
305
- - **clarity** - Make prompts clearer and more understandable
306
- - **conciseness** - Remove unnecessary words while preserving meaning
307
- - **creativity** - Enhance creative and imaginative aspects
308
- - **specificity** - Add specific details and concrete examples
309
- - **actionability** - Make prompts more directive and actionable
310
- - **technical_accuracy** - Improve technical precision and terminology
311
- - **keyword_density** - Optimize keyword placement and density
312
- - **parameter_preservation** - Preserve technical parameters (for image gen/code)
313
- - **context_specificity** - Enhance context-specific clarity
314
- - **token_efficiency** - Optimize for AI token usage
366
+ ### `get_optimization_insights` (Conditional)
367
+ **Get advanced Bayesian optimization insights, performance analytics, and parameter tuning recommendations.**
368
+ *Note: This tool provides mock data if Bayesian optimization is disabled in the backend.*
369
+ ```javascript
370
+ {
371
+ "analysis_depth": "detailed", // Optional: "basic", "detailed", "comprehensive"
372
+ "include_recommendations": true // Optional: Include optimization recommendations
373
+ }
374
+ ```
315
375
 
316
- ## 🤖 AI Context Types
376
+ ### `get_real_time_status` (Conditional)
377
+ **Get real-time optimization status and AG-UI capabilities.**
378
+ *Note: This tool provides mock data if AG-UI features are disabled in the backend.*
379
+ ```javascript
380
+ // No parameters needed
381
+ ```
317
382
 
318
- - **human_communication** - Emails, letters, social content
319
- - **llm_interaction** - AI conversations, role-playing prompts
320
- - **image_generation** - Image/art generation prompts (Midjourney, DALL-E)
321
- - **technical_automation** - DevOps, system administration, scripts
322
- - **structured_output** - JSON, data formats, templates
323
- - **code_generation** - Programming and development prompts
324
- - **api_automation** - API calls, integrations, workflows
383
+ ---
325
384
 
326
- ## 🔧 Professional CLI Tools
385
+ ## 🔧 Professional CLI Commands (Direct Execution)
327
386
 
328
- Enhanced command-line tools for power users:
387
+ These are direct command-line tools provided by the `mcp-prompt-optimizer` executable for administrative and diagnostic purposes.
329
388
 
330
389
  ```bash
331
390
  # Check API key and quota status
@@ -387,6 +446,7 @@ mcp-prompt-optimizer version
387
446
  - **Confidence scoring** with detailed analysis
388
447
  - **AI-powered recommendations** for continuous improvement
389
448
  - **Usage analytics** and optimization patterns
449
+ *Note: Advanced features like Bayesian Optimization and AG-UI Real-time Features are configurable and may provide mock data if disabled in the backend.*
390
450
 
391
451
  ### Intelligent Context Routing
392
452
  - **Automatic detection** of prompt context and intent