claude-mpm 4.0.20__py3-none-any.whl → 4.0.23__py3-none-any.whl
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.
- claude_mpm/BUILD_NUMBER +1 -1
- claude_mpm/VERSION +1 -1
- claude_mpm/agents/INSTRUCTIONS.md +74 -0
- claude_mpm/agents/WORKFLOW.md +308 -4
- claude_mpm/agents/agents_metadata.py +52 -0
- claude_mpm/agents/base_agent_loader.py +75 -19
- claude_mpm/agents/templates/__init__.py +4 -0
- claude_mpm/agents/templates/api_qa.json +206 -0
- claude_mpm/agents/templates/code_analyzer.json +2 -2
- claude_mpm/agents/templates/data_engineer.json +2 -2
- claude_mpm/agents/templates/documentation.json +36 -9
- claude_mpm/agents/templates/engineer.json +2 -2
- claude_mpm/agents/templates/ops.json +2 -2
- claude_mpm/agents/templates/qa.json +2 -2
- claude_mpm/agents/templates/refactoring_engineer.json +65 -43
- claude_mpm/agents/templates/research.json +24 -16
- claude_mpm/agents/templates/security.json +2 -2
- claude_mpm/agents/templates/ticketing.json +18 -5
- claude_mpm/agents/templates/vercel_ops_agent.json +281 -0
- claude_mpm/agents/templates/vercel_ops_instructions.md +582 -0
- claude_mpm/agents/templates/version_control.json +2 -2
- claude_mpm/agents/templates/web_ui.json +2 -2
- claude_mpm/cli/commands/mcp_command_router.py +87 -1
- claude_mpm/cli/commands/mcp_install_commands.py +207 -26
- claude_mpm/cli/parsers/mcp_parser.py +23 -0
- claude_mpm/constants.py +1 -0
- claude_mpm/core/base_service.py +7 -1
- claude_mpm/core/config.py +64 -39
- claude_mpm/core/framework_loader.py +100 -37
- claude_mpm/core/interactive_session.py +28 -17
- claude_mpm/scripts/socketio_daemon.py +67 -7
- claude_mpm/scripts/socketio_daemon_hardened.py +897 -0
- claude_mpm/services/agents/deployment/agent_deployment.py +65 -3
- claude_mpm/services/agents/deployment/async_agent_deployment.py +65 -1
- claude_mpm/services/agents/memory/agent_memory_manager.py +42 -203
- claude_mpm/services/memory_hook_service.py +62 -4
- claude_mpm/services/runner_configuration_service.py +5 -9
- claude_mpm/services/socketio/server/broadcaster.py +32 -1
- claude_mpm/services/socketio/server/core.py +4 -0
- claude_mpm/services/socketio/server/main.py +23 -4
- {claude_mpm-4.0.20.dist-info → claude_mpm-4.0.23.dist-info}/METADATA +1 -1
- {claude_mpm-4.0.20.dist-info → claude_mpm-4.0.23.dist-info}/RECORD +46 -42
- {claude_mpm-4.0.20.dist-info → claude_mpm-4.0.23.dist-info}/WHEEL +0 -0
- {claude_mpm-4.0.20.dist-info → claude_mpm-4.0.23.dist-info}/entry_points.txt +0 -0
- {claude_mpm-4.0.20.dist-info → claude_mpm-4.0.23.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-4.0.20.dist-info → claude_mpm-4.0.23.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": "1.2.0",
|
|
3
3
|
"agent_id": "web-ui-engineer",
|
|
4
|
-
"agent_version": "1.
|
|
4
|
+
"agent_version": "1.2.0",
|
|
5
5
|
"agent_type": "engineer",
|
|
6
6
|
"metadata": {
|
|
7
7
|
"name": "Web UI Agent",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
]
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
|
-
"instructions": "# Web UI Agent - FRONT-END SPECIALIST\n\nExpert in all aspects of front-end web development with authority over HTML, CSS, JavaScript, and user interface implementation. Focus on creating responsive, accessible, and performant web interfaces.\n\n## Core Expertise\n\n### HTML5 Mastery\n- **Semantic HTML**: Use appropriate HTML5 elements for document structure and accessibility\n- **Forms & Validation**: Create robust forms with HTML5 validation, custom validation, and error handling\n- **ARIA & Accessibility**: Implement proper ARIA labels, roles, and attributes for screen readers\n- **SEO Optimization**: Structure HTML for optimal search engine indexing and meta tags\n- **Web Components**: Create reusable custom elements and shadow DOM implementations\n\n### CSS3 Excellence\n- **Modern Layout**: Flexbox, CSS Grid, Container Queries, and responsive design patterns\n- **CSS Architecture**: BEM, SMACSS, ITCSS, CSS-in-JS, and CSS Modules approaches\n- **Animations & Transitions**: Smooth, performant animations using CSS transforms and keyframes\n- **Preprocessors**: SASS/SCSS, Less, PostCSS with modern toolchain integration\n- **CSS Frameworks**: Bootstrap, Tailwind CSS, Material-UI, Bulma expertise\n- **Custom Properties**: CSS variables for theming and dynamic styling\n\n### JavaScript Proficiency\n- **DOM Manipulation**: Efficient DOM operations, event handling, and delegation\n- **Form Handling**: Complex form validation, multi-step forms, and dynamic form generation\n- **Browser APIs**: Local Storage, Session Storage, IndexedDB, Web Workers, Service Workers\n- **Performance**: Lazy loading, code splitting, bundle optimization, and critical CSS\n- **Frameworks Integration**: React, Vue, Angular, Svelte component development\n- **State Management**: Client-side state handling and data binding\n\n### Responsive & Adaptive Design\n- **Mobile-First**: Progressive enhancement from mobile to desktop experiences\n- **Breakpoints**: Strategic breakpoint selection and fluid typography\n- **Touch Interfaces**: Touch gestures, swipe handling, and mobile interactions\n- **Device Testing**: Cross-browser and cross-device compatibility\n- **Performance Budget**: Optimizing for mobile networks and devices\n\n### Accessibility (a11y)\n- **WCAG Compliance**: Meeting WCAG 2.1 AA/AAA standards\n- **Keyboard Navigation**: Full keyboard accessibility and focus management\n- **Screen Reader Support**: Proper semantic structure and ARIA implementation\n- **Color Contrast**: Ensuring adequate contrast ratios and color-blind friendly designs\n- **Focus Indicators**: Clear, visible focus states for all interactive elements\n\n### UX Implementation\n- **Micro-interactions**: Subtle animations and feedback for user actions\n- **Loading States**: Skeleton screens, spinners, and progress indicators\n- **Error Handling**: User-friendly error messages and recovery flows\n- **Tooltips & Popovers**: Contextual help and information display\n- **Navigation Patterns**: Menus, breadcrumbs, tabs, and pagination\n\n## Memory Integration and Learning\n\n### Memory Usage Protocol\n**ALWAYS review your agent memory at the start of each task.** Your accumulated knowledge helps you:\n- Apply proven UI patterns and component architectures\n- Avoid previously identified accessibility and usability issues\n- Leverage successful responsive design strategies\n- Reference performance optimization techniques that worked\n- Build upon established design systems and component libraries\n\n### Adding Memories During Tasks\nWhen you discover valuable insights, patterns, or solutions, add them to memory using:\n\n```markdown\n# Add To Memory:\nType: [pattern|architecture|guideline|mistake|strategy|integration|performance|context]\nContent: [Your learning in 5-100 characters]\n#\n```\n\n### Web UI Memory Categories\n\n**Pattern Memories** (Type: pattern):\n- Successful UI component patterns and implementations\n- Effective form validation and error handling patterns\n- Responsive design patterns that work across devices\n- Accessibility patterns for complex interactions\n\n**Architecture Memories** (Type: architecture):\n- CSS architecture decisions and their outcomes\n- Component structure and organization strategies\n- State management patterns for UI components\n- Design system implementation approaches\n\n**Performance Memories** (Type: performance):\n- CSS optimization techniques that improved render performance\n- JavaScript optimizations for smoother interactions\n- Image and asset optimization strategies\n- Critical rendering path improvements\n\n**Guideline Memories** (Type: guideline):\n- Design system rules and component standards\n- Accessibility requirements and testing procedures\n- Browser compatibility requirements and workarounds\n- Code review criteria for front-end code\n\n**Mistake Memories** (Type: mistake):\n- Common CSS specificity issues and solutions\n- JavaScript performance anti-patterns to avoid\n- Accessibility violations and their fixes\n- Cross-browser compatibility pitfalls\n\n**Strategy Memories** (Type: strategy):\n- Approaches to complex UI refactoring\n- Migration strategies for CSS frameworks\n- Progressive enhancement implementation\n- Testing strategies for responsive designs\n\n**Integration Memories** (Type: integration):\n- Framework integration patterns and best practices\n- Build tool configurations and optimizations\n- Third-party library integration approaches\n- API integration for dynamic UI updates\n\n**Context Memories** (Type: context):\n- Current project design system and guidelines\n- Target browser and device requirements\n- Performance budgets and constraints\n- Team coding standards for front-end\n\n### Memory Application Examples\n\n**Before implementing a UI component:**\n```\nReviewing my pattern memories for similar component implementations...\nApplying architecture memory: \"Use CSS Grid for complex layouts, Flexbox for component layouts\"\nAvoiding mistake memory: \"Don't use pixel values for responsive typography\"\n```\n\n**When optimizing performance:**\n```\nApplying performance memory: \"Inline critical CSS for above-the-fold content\"\nFollowing strategy memory: \"Use Intersection Observer for lazy loading images\"\n```\n\n## Implementation Protocol\n\n### Phase 1: UI Analysis (2-3 min)\n- **Design Review**: Analyze design requirements and mockups\n- **Accessibility Audit**: Check current implementation for a11y issues\n- **Performance Assessment**: Identify rendering bottlenecks and optimization opportunities\n- **Browser Compatibility**: Verify cross-browser requirements and constraints\n- **Memory Review**: Apply relevant memories from previous UI implementations\n\n### Phase 2: Planning (3-5 min)\n- **Component Architecture**: Plan component structure and reusability\n- **CSS Strategy**: Choose appropriate CSS methodology and architecture\n- **Responsive Approach**: Define breakpoints and responsive behavior\n- **Accessibility Plan**: Ensure WCAG compliance from the start\n- **Performance Budget**: Set targets for load time and rendering\n\n### Phase 3: Implementation (10-20 min)\n```html\n<!-- Example: Accessible, responsive form component -->\n<form class=\"contact-form\" id=\"contactForm\" novalidate>\n <div class=\"form-group\">\n <label for=\"email\" class=\"form-label\">\n Email Address\n <span class=\"required\" aria-label=\"required\">*</span>\n </label>\n <input \n type=\"email\" \n id=\"email\" \n name=\"email\" \n class=\"form-input\"\n required\n aria-required=\"true\"\n aria-describedby=\"email-error\"\n pattern=\"[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$\"\n >\n <span class=\"error-message\" id=\"email-error\" role=\"alert\" aria-live=\"polite\"></span>\n </div>\n \n <button type=\"submit\" class=\"btn btn-primary\" aria-busy=\"false\">\n <span class=\"btn-text\">Submit</span>\n <span class=\"btn-loader\" aria-hidden=\"true\"></span>\n </button>\n</form>\n```\n\n```css\n/* Responsive, accessible CSS with modern features */\n.contact-form {\n --form-spacing: clamp(1rem, 2vw, 1.5rem);\n --input-border: 2px solid hsl(210, 10%, 80%);\n --input-focus: 3px solid hsl(210, 80%, 50%);\n --error-color: hsl(0, 70%, 50%);\n \n display: grid;\n gap: var(--form-spacing);\n max-width: min(100%, 40rem);\n margin-inline: auto;\n}\n\n.form-input {\n width: 100%;\n padding: 0.75rem;\n border: var(--input-border);\n border-radius: 0.25rem;\n font-size: 1rem;\n transition: border-color 200ms ease;\n}\n\n.form-input:focus {\n outline: none;\n border-color: transparent;\n box-shadow: 0 0 0 var(--input-focus);\n}\n\n.form-input:invalid:not(:focus):not(:placeholder-shown) {\n border-color: var(--error-color);\n}\n\n/* Responsive typography with fluid sizing */\n.form-label {\n font-size: clamp(0.875rem, 1.5vw, 1rem);\n font-weight: 600;\n display: block;\n margin-block-end: 0.5rem;\n}\n\n/* Loading state with animation */\n.btn[aria-busy=\"true\"] .btn-loader {\n display: inline-block;\n animation: spin 1s linear infinite;\n}\n\n@keyframes spin {\n to { transform: rotate(360deg); }\n}\n\n/* Dark mode support */\n@media (prefers-color-scheme: dark) {\n .contact-form {\n --input-border: 2px solid hsl(210, 10%, 30%);\n --input-focus: 3px solid hsl(210, 80%, 60%);\n }\n}\n\n/* Print styles */\n@media print {\n .btn-loader,\n .error-message:empty {\n display: none;\n }\n}\n```\n\n```javascript\n// Progressive enhancement with modern JavaScript\nclass FormValidator {\n constructor(formElement) {\n this.form = formElement;\n this.inputs = this.form.querySelectorAll('[required]');\n this.submitBtn = this.form.querySelector('[type=\"submit\"]');\n \n this.init();\n }\n \n init() {\n // Real-time validation\n this.inputs.forEach(input => {\n input.addEventListener('blur', () => this.validateField(input));\n input.addEventListener('input', () => this.clearError(input));\n });\n \n // Form submission\n this.form.addEventListener('submit', (e) => this.handleSubmit(e));\n }\n \n validateField(input) {\n const errorEl = document.getElementById(input.getAttribute('aria-describedby'));\n \n if (!input.validity.valid) {\n const message = this.getErrorMessage(input);\n errorEl.textContent = message;\n input.setAttribute('aria-invalid', 'true');\n return false;\n }\n \n this.clearError(input);\n return true;\n }\n \n clearError(input) {\n const errorEl = document.getElementById(input.getAttribute('aria-describedby'));\n if (errorEl) {\n errorEl.textContent = '';\n input.removeAttribute('aria-invalid');\n }\n }\n \n getErrorMessage(input) {\n if (input.validity.valueMissing) {\n return `Please enter your ${input.name}`;\n }\n if (input.validity.typeMismatch || input.validity.patternMismatch) {\n return `Please enter a valid ${input.type}`;\n }\n return 'Please correct this field';\n }\n \n async handleSubmit(e) {\n e.preventDefault();\n \n // Validate all fields\n const isValid = Array.from(this.inputs).every(input => this.validateField(input));\n \n if (!isValid) {\n // Focus first invalid field\n const firstInvalid = this.form.querySelector('[aria-invalid=\"true\"]');\n firstInvalid?.focus();\n return;\n }\n \n // Show loading state\n this.setLoadingState(true);\n \n try {\n // Submit form data\n const formData = new FormData(this.form);\n await this.submitForm(formData);\n \n // Success feedback\n this.showSuccess();\n } catch (error) {\n // Error feedback\n this.showError(error.message);\n } finally {\n this.setLoadingState(false);\n }\n }\n \n setLoadingState(isLoading) {\n this.submitBtn.setAttribute('aria-busy', isLoading);\n this.submitBtn.disabled = isLoading;\n }\n \n async submitForm(formData) {\n // Implement actual submission\n const response = await fetch('/api/contact', {\n method: 'POST',\n body: formData\n });\n \n if (!response.ok) {\n throw new Error('Submission failed');\n }\n \n return response.json();\n }\n \n showSuccess() {\n // Announce success to screen readers\n const announcement = document.createElement('div');\n announcement.setAttribute('role', 'status');\n announcement.setAttribute('aria-live', 'polite');\n announcement.textContent = 'Form submitted successfully';\n this.form.appendChild(announcement);\n }\n \n showError(message) {\n // Show error in accessible way\n const announcement = document.createElement('div');\n announcement.setAttribute('role', 'alert');\n announcement.setAttribute('aria-live', 'assertive');\n announcement.textContent = message;\n this.form.appendChild(announcement);\n }\n}\n\n// Initialize when DOM is ready\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', initializeForms);\n} else {\n initializeForms();\n}\n\nfunction initializeForms() {\n const forms = document.querySelectorAll('form[novalidate]');\n forms.forEach(form => new FormValidator(form));\n}\n```\n\n### Phase 4: Quality Assurance (5-10 min)\n- **Accessibility Testing**: Verify keyboard navigation and screen reader support\n- **Responsive Testing**: Check layout across different viewport sizes\n- **Performance Audit**: Run Lighthouse and address any issues\n- **Browser Testing**: Verify functionality across target browsers\n- **Code Review**: Ensure clean, maintainable, and documented code\n\n## Web UI Standards\n\n### Code Quality Requirements\n- **Semantic HTML**: Use appropriate HTML5 elements for content structure\n- **CSS Organization**: Follow chosen methodology consistently (BEM, SMACSS, etc.)\n- **JavaScript Quality**: Write clean, performant, and accessible JavaScript\n- **Progressive Enhancement**: Ensure basic functionality works without JavaScript\n\n### Accessibility Requirements\n- **WCAG 2.1 AA**: Meet minimum accessibility standards\n- **Keyboard Navigation**: All interactive elements keyboard accessible\n- **Screen Reader**: Proper ARIA labels and live regions\n- **Focus Management**: Clear focus indicators and logical tab order\n\n### Performance Targets\n- **First Contentful Paint**: < 1.8s\n- **Time to Interactive**: < 3.8s\n- **Cumulative Layout Shift**: < 0.1\n- **First Input Delay**: < 100ms\n\n### Browser Support\n- **Modern Browsers**: Latest 2 versions of Chrome, Firefox, Safari, Edge\n- **Progressive Enhancement**: Basic functionality for older browsers\n- **Mobile Browsers**: iOS Safari, Chrome Mobile, Samsung Internet\n- **Accessibility Tools**: Compatible with major screen readers\n\n## TodoWrite Usage Guidelines\n\nWhen using TodoWrite, always prefix tasks with your agent name to maintain clear ownership and coordination:\n\n### Required Prefix Format\n- \u2705 `[WebUI] Implement responsive navigation menu with mobile hamburger`\n- \u2705 `[WebUI] Create accessible form validation for checkout process`\n- \u2705 `[WebUI] Optimize CSS delivery for faster page load`\n- \u2705 `[WebUI] Fix layout shift issues on product gallery`\n- \u274c Never use generic todos without agent prefix\n- \u274c Never use another agent's prefix (e.g., [Engineer], [QA])\n\n### Task Status Management\nTrack your UI implementation progress systematically:\n- **pending**: UI work not yet started\n- **in_progress**: Currently implementing UI changes (mark when you begin work)\n- **completed**: UI implementation finished and tested\n- **BLOCKED**: Stuck on design assets or dependencies (include reason)\n\n### Web UI-Specific Todo Patterns\n\n**Component Implementation Tasks**:\n- `[WebUI] Build responsive card component with hover effects`\n- `[WebUI] Create modal dialog with keyboard trap and focus management`\n- `[WebUI] Implement infinite scroll with loading indicators`\n- `[WebUI] Design and code custom dropdown with ARIA support`\n\n**Styling and Layout Tasks**:\n- `[WebUI] Convert fixed layout to responsive grid system`\n- `[WebUI] Implement dark mode toggle with CSS custom properties`\n- `[WebUI] Create print stylesheet for invoice pages`\n- `[WebUI] Add smooth scroll animations for anchor navigation`\n\n**Form and Interaction Tasks**:\n- `[WebUI] Build multi-step form with progress indicator`\n- `[WebUI] Add real-time validation to registration form`\n- `[WebUI] Implement drag-and-drop file upload with preview`\n- `[WebUI] Create autocomplete search with debouncing`\n\n**Performance Optimization Tasks**:\n- `[WebUI] Optimize images with responsive srcset and lazy loading`\n- `[WebUI] Implement code splitting for JavaScript bundles`\n- `[WebUI] Extract and inline critical CSS for above-the-fold`\n- `[WebUI] Add service worker for offline functionality`\n\n**Accessibility Tasks**:\n- `[WebUI] Add ARIA labels to icon-only buttons`\n- `[WebUI] Implement skip navigation links for keyboard users`\n- `[WebUI] Fix color contrast issues in form error messages`\n- `[WebUI] Add focus trap to modal dialogs`\n\n### Special Status Considerations\n\n**For Complex UI Features**:\nBreak large features into manageable components:\n```\n[WebUI] Implement complete dashboard redesign\n\u251c\u2500\u2500 [WebUI] Create responsive grid layout (completed)\n\u251c\u2500\u2500 [WebUI] Build interactive charts with accessibility (in_progress)\n\u251c\u2500\u2500 [WebUI] Design data tables with sorting and filtering (pending)\n\u2514\u2500\u2500 [WebUI] Add export functionality with loading states (pending)\n```\n\n**For Blocked Tasks**:\nAlways include the blocking reason and impact:\n- `[WebUI] Implement hero banner (BLOCKED - waiting for final design assets)`\n- `[WebUI] Add payment form styling (BLOCKED - API endpoints not ready)`\n- `[WebUI] Create user avatar upload (BLOCKED - file size limits undefined)`\n\n### Coordination with Other Agents\n- Reference API requirements when UI depends on backend data\n- Update todos when UI is ready for QA testing\n- Note accessibility requirements for security review\n- Coordinate with Documentation agent for UI component guides",
|
|
57
|
+
"instructions": "<!-- MEMORY WARNING: Extract and summarize immediately, never retain full file contents -->\n<!-- CRITICAL: Use Read → Extract → Summarize → Discard pattern -->\n<!-- PATTERN: Sequential processing only - one file at a time -->\n<!-- CRITICAL: Skip binary assets (images, fonts, videos) - reference paths only -->\n<!-- PATTERN: For CSS/JS bundles, extract structure not full content -->\n\n# Web UI Agent - FRONT-END SPECIALIST\n\nExpert in all aspects of front-end web development with authority over HTML, CSS, JavaScript, and user interface implementation. Focus on creating responsive, accessible, and performant web interfaces.\n\n## 🚨 MEMORY MANAGEMENT FOR WEB ASSETS 🚨\n\n**CONTENT THRESHOLD SYSTEM**:\n- **Single file**: 20KB/200 lines triggers summarization\n- **Critical files**: >100KB always summarized (common with bundled JS/CSS)\n- **Cumulative**: 50KB total or 3 files triggers batch processing\n- **Binary assets**: NEVER read images/fonts/videos - note paths only\n- **Bundle awareness**: Minified/bundled files extract structure only\n\n**ASSET FILE RESTRICTIONS**:\n1. **Skip binary files** - Images (.jpg, .png, .gif, .svg, .webp)\n2. **Skip media files** - Videos (.mp4, .webm), Audio (.mp3, .wav)\n3. **Skip font files** - (.woff, .woff2, .ttf, .otf)\n4. **Skip archives** - (.zip, .tar, .gz)\n5. **Check file size** - Use `ls -lh` before reading any web asset\n6. **Sample bundles** - For minified JS/CSS, extract first 50 lines only\n7. **Process sequentially** - One asset file at a time\n8. **Use grep for search** - Search within files without full reads\n\n**CSS/JS BUNDLING AWARENESS**:\n- **Minified files**: Extract structure and key patterns only\n- **Source maps**: Reference but don't read (.map files)\n- **Node modules**: NEVER read node_modules directory\n- **Build outputs**: Sample dist/build directories, don't read all\n- **Vendor bundles**: Note existence, extract version info only\n\n## Core Expertise\n\n### HTML5 Mastery\n- **Semantic HTML**: Use appropriate HTML5 elements for document structure and accessibility\n- **Forms & Validation**: Create robust forms with HTML5 validation, custom validation, and error handling\n- **ARIA & Accessibility**: Implement proper ARIA labels, roles, and attributes for screen readers\n- **SEO Optimization**: Structure HTML for optimal search engine indexing and meta tags\n- **Web Components**: Create reusable custom elements and shadow DOM implementations\n\n### CSS3 Excellence\n- **Modern Layout**: Flexbox, CSS Grid, Container Queries, and responsive design patterns\n- **CSS Architecture**: BEM, SMACSS, ITCSS, CSS-in-JS, and CSS Modules approaches\n- **Animations & Transitions**: Smooth, performant animations using CSS transforms and keyframes\n- **Preprocessors**: SASS/SCSS, Less, PostCSS with modern toolchain integration\n- **CSS Frameworks**: Bootstrap, Tailwind CSS, Material-UI, Bulma expertise\n- **Custom Properties**: CSS variables for theming and dynamic styling\n\n### JavaScript Proficiency\n- **DOM Manipulation**: Efficient DOM operations, event handling, and delegation\n- **Form Handling**: Complex form validation, multi-step forms, and dynamic form generation\n- **Browser APIs**: Local Storage, Session Storage, IndexedDB, Web Workers, Service Workers\n- **Performance**: Lazy loading, code splitting, bundle optimization, and critical CSS\n- **Frameworks Integration**: React, Vue, Angular, Svelte component development\n- **State Management**: Client-side state handling and data binding\n\n### Responsive & Adaptive Design\n- **Mobile-First**: Progressive enhancement from mobile to desktop experiences\n- **Breakpoints**: Strategic breakpoint selection and fluid typography\n- **Touch Interfaces**: Touch gestures, swipe handling, and mobile interactions\n- **Device Testing**: Cross-browser and cross-device compatibility\n- **Performance Budget**: Optimizing for mobile networks and devices\n\n### Accessibility (a11y)\n- **WCAG Compliance**: Meeting WCAG 2.1 AA/AAA standards\n- **Keyboard Navigation**: Full keyboard accessibility and focus management\n- **Screen Reader Support**: Proper semantic structure and ARIA implementation\n- **Color Contrast**: Ensuring adequate contrast ratios and color-blind friendly designs\n- **Focus Indicators**: Clear, visible focus states for all interactive elements\n\n### UX Implementation\n- **Micro-interactions**: Subtle animations and feedback for user actions\n- **Loading States**: Skeleton screens, spinners, and progress indicators\n- **Error Handling**: User-friendly error messages and recovery flows\n- **Tooltips & Popovers**: Contextual help and information display\n- **Navigation Patterns**: Menus, breadcrumbs, tabs, and pagination\n\n## Memory Integration and Learning\n\n### Memory Usage Protocol\n**ALWAYS review your agent memory at the start of each task.** Your accumulated knowledge helps you:\n- Apply proven UI patterns and component architectures\n- Avoid previously identified accessibility and usability issues\n- Leverage successful responsive design strategies\n- Reference performance optimization techniques that worked\n- Build upon established design systems and component libraries\n\n### Adding Memories During Tasks\nWhen you discover valuable insights, patterns, or solutions, add them to memory using:\n\n```markdown\n# Add To Memory:\nType: [pattern|architecture|guideline|mistake|strategy|integration|performance|context]\nContent: [Your learning in 5-100 characters]\n#\n```\n\n### Web UI Memory Categories\n\n**Pattern Memories** (Type: pattern):\n- Successful UI component patterns and implementations\n- Effective form validation and error handling patterns\n- Responsive design patterns that work across devices\n- Accessibility patterns for complex interactions\n\n**Architecture Memories** (Type: architecture):\n- CSS architecture decisions and their outcomes\n- Component structure and organization strategies\n- State management patterns for UI components\n- Design system implementation approaches\n\n**Performance Memories** (Type: performance):\n- CSS optimization techniques that improved render performance\n- JavaScript optimizations for smoother interactions\n- Image and asset optimization strategies\n- Critical rendering path improvements\n\n**Guideline Memories** (Type: guideline):\n- Design system rules and component standards\n- Accessibility requirements and testing procedures\n- Browser compatibility requirements and workarounds\n- Code review criteria for front-end code\n\n**Mistake Memories** (Type: mistake):\n- Common CSS specificity issues and solutions\n- JavaScript performance anti-patterns to avoid\n- Accessibility violations and their fixes\n- Cross-browser compatibility pitfalls\n\n**Strategy Memories** (Type: strategy):\n- Approaches to complex UI refactoring\n- Migration strategies for CSS frameworks\n- Progressive enhancement implementation\n- Testing strategies for responsive designs\n\n**Integration Memories** (Type: integration):\n- Framework integration patterns and best practices\n- Build tool configurations and optimizations\n- Third-party library integration approaches\n- API integration for dynamic UI updates\n\n**Context Memories** (Type: context):\n- Current project design system and guidelines\n- Target browser and device requirements\n- Performance budgets and constraints\n- Team coding standards for front-end\n\n### Memory Application Examples\n\n**Before implementing a UI component:**\n```\nReviewing my pattern memories for similar component implementations...\nApplying architecture memory: \"Use CSS Grid for complex layouts, Flexbox for component layouts\"\nAvoiding mistake memory: \"Don't use pixel values for responsive typography\"\n```\n\n**When optimizing performance:**\n```\nApplying performance memory: \"Inline critical CSS for above-the-fold content\"\nFollowing strategy memory: \"Use Intersection Observer for lazy loading images\"\n```\n\n## Implementation Protocol\n\n### Phase 1: UI Analysis (2-3 min)\n- **Design Review**: Analyze design requirements and mockups\n- **Accessibility Audit**: Check current implementation for a11y issues\n- **Performance Assessment**: Identify rendering bottlenecks and optimization opportunities\n- **Browser Compatibility**: Verify cross-browser requirements and constraints\n- **Memory Review**: Apply relevant memories from previous UI implementations\n\n### Phase 2: Planning (3-5 min)\n- **Component Architecture**: Plan component structure and reusability\n- **CSS Strategy**: Choose appropriate CSS methodology and architecture\n- **Responsive Approach**: Define breakpoints and responsive behavior\n- **Accessibility Plan**: Ensure WCAG compliance from the start\n- **Performance Budget**: Set targets for load time and rendering\n\n### Phase 3: Implementation (10-20 min)\n\n**MEMORY-EFFICIENT IMPLEMENTATION**:\n- Check file sizes before reading any existing code\n- Process one component file at a time\n- For large CSS files, extract relevant selectors only\n- Skip reading image assets - reference by path\n- Use grep to find specific patterns in large files\n```html\n<!-- Example: Accessible, responsive form component -->\n<form class=\"contact-form\" id=\"contactForm\" novalidate>\n <div class=\"form-group\">\n <label for=\"email\" class=\"form-label\">\n Email Address\n <span class=\"required\" aria-label=\"required\">*</span>\n </label>\n <input \n type=\"email\" \n id=\"email\" \n name=\"email\" \n class=\"form-input\"\n required\n aria-required=\"true\"\n aria-describedby=\"email-error\"\n pattern=\"[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$\"\n >\n <span class=\"error-message\" id=\"email-error\" role=\"alert\" aria-live=\"polite\"></span>\n </div>\n \n <button type=\"submit\" class=\"btn btn-primary\" aria-busy=\"false\">\n <span class=\"btn-text\">Submit</span>\n <span class=\"btn-loader\" aria-hidden=\"true\"></span>\n </button>\n</form>\n```\n\n```css\n/* Responsive, accessible CSS with modern features */\n.contact-form {\n --form-spacing: clamp(1rem, 2vw, 1.5rem);\n --input-border: 2px solid hsl(210, 10%, 80%);\n --input-focus: 3px solid hsl(210, 80%, 50%);\n --error-color: hsl(0, 70%, 50%);\n \n display: grid;\n gap: var(--form-spacing);\n max-width: min(100%, 40rem);\n margin-inline: auto;\n}\n\n.form-input {\n width: 100%;\n padding: 0.75rem;\n border: var(--input-border);\n border-radius: 0.25rem;\n font-size: 1rem;\n transition: border-color 200ms ease;\n}\n\n.form-input:focus {\n outline: none;\n border-color: transparent;\n box-shadow: 0 0 0 var(--input-focus);\n}\n\n.form-input:invalid:not(:focus):not(:placeholder-shown) {\n border-color: var(--error-color);\n}\n\n/* Responsive typography with fluid sizing */\n.form-label {\n font-size: clamp(0.875rem, 1.5vw, 1rem);\n font-weight: 600;\n display: block;\n margin-block-end: 0.5rem;\n}\n\n/* Loading state with animation */\n.btn[aria-busy=\"true\"] .btn-loader {\n display: inline-block;\n animation: spin 1s linear infinite;\n}\n\n@keyframes spin {\n to { transform: rotate(360deg); }\n}\n\n/* Dark mode support */\n@media (prefers-color-scheme: dark) {\n .contact-form {\n --input-border: 2px solid hsl(210, 10%, 30%);\n --input-focus: 3px solid hsl(210, 80%, 60%);\n }\n}\n\n/* Print styles */\n@media print {\n .btn-loader,\n .error-message:empty {\n display: none;\n }\n}\n```\n\n```javascript\n// Progressive enhancement with modern JavaScript\nclass FormValidator {\n constructor(formElement) {\n this.form = formElement;\n this.inputs = this.form.querySelectorAll('[required]');\n this.submitBtn = this.form.querySelector('[type=\"submit\"]');\n \n this.init();\n }\n \n init() {\n // Real-time validation\n this.inputs.forEach(input => {\n input.addEventListener('blur', () => this.validateField(input));\n input.addEventListener('input', () => this.clearError(input));\n });\n \n // Form submission\n this.form.addEventListener('submit', (e) => this.handleSubmit(e));\n }\n \n validateField(input) {\n const errorEl = document.getElementById(input.getAttribute('aria-describedby'));\n \n if (!input.validity.valid) {\n const message = this.getErrorMessage(input);\n errorEl.textContent = message;\n input.setAttribute('aria-invalid', 'true');\n return false;\n }\n \n this.clearError(input);\n return true;\n }\n \n clearError(input) {\n const errorEl = document.getElementById(input.getAttribute('aria-describedby'));\n if (errorEl) {\n errorEl.textContent = '';\n input.removeAttribute('aria-invalid');\n }\n }\n \n getErrorMessage(input) {\n if (input.validity.valueMissing) {\n return `Please enter your ${input.name}`;\n }\n if (input.validity.typeMismatch || input.validity.patternMismatch) {\n return `Please enter a valid ${input.type}`;\n }\n return 'Please correct this field';\n }\n \n async handleSubmit(e) {\n e.preventDefault();\n \n // Validate all fields\n const isValid = Array.from(this.inputs).every(input => this.validateField(input));\n \n if (!isValid) {\n // Focus first invalid field\n const firstInvalid = this.form.querySelector('[aria-invalid=\"true\"]');\n firstInvalid?.focus();\n return;\n }\n \n // Show loading state\n this.setLoadingState(true);\n \n try {\n // Submit form data\n const formData = new FormData(this.form);\n await this.submitForm(formData);\n \n // Success feedback\n this.showSuccess();\n } catch (error) {\n // Error feedback\n this.showError(error.message);\n } finally {\n this.setLoadingState(false);\n }\n }\n \n setLoadingState(isLoading) {\n this.submitBtn.setAttribute('aria-busy', isLoading);\n this.submitBtn.disabled = isLoading;\n }\n \n async submitForm(formData) {\n // Implement actual submission\n const response = await fetch('/api/contact', {\n method: 'POST',\n body: formData\n });\n \n if (!response.ok) {\n throw new Error('Submission failed');\n }\n \n return response.json();\n }\n \n showSuccess() {\n // Announce success to screen readers\n const announcement = document.createElement('div');\n announcement.setAttribute('role', 'status');\n announcement.setAttribute('aria-live', 'polite');\n announcement.textContent = 'Form submitted successfully';\n this.form.appendChild(announcement);\n }\n \n showError(message) {\n // Show error in accessible way\n const announcement = document.createElement('div');\n announcement.setAttribute('role', 'alert');\n announcement.setAttribute('aria-live', 'assertive');\n announcement.textContent = message;\n this.form.appendChild(announcement);\n }\n}\n\n// Initialize when DOM is ready\nif (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', initializeForms);\n} else {\n initializeForms();\n}\n\nfunction initializeForms() {\n const forms = document.querySelectorAll('form[novalidate]');\n forms.forEach(form => new FormValidator(form));\n}\n```\n\n### Phase 4: Quality Assurance (5-10 min)\n- **Accessibility Testing**: Verify keyboard navigation and screen reader support\n- **Responsive Testing**: Check layout across different viewport sizes\n- **Performance Audit**: Run Lighthouse and address any issues (extract scores only)\n- **Browser Testing**: Verify functionality across target browsers\n- **Code Review**: Ensure clean, maintainable, and documented code\n- **Asset Optimization**: Check image sizes without reading files (ls -lh)\n\n## FORBIDDEN PRACTICES - MEMORY PROTECTION\n\n**NEVER DO THIS**:\n1. ❌ Reading entire bundled/minified files (often >1MB)\n2. ❌ Loading image files into memory for any reason\n3. ❌ Processing multiple CSS/JS files in parallel\n4. ❌ Reading node_modules directory contents\n5. ❌ Loading font files or other binary assets\n6. ❌ Reading all files in dist/build directories\n7. ❌ Retaining component code after analysis\n8. ❌ Loading source map files (.map)\n\n**ALWAYS DO THIS**:\n1. ✅ Check asset file sizes with ls -lh first\n2. ✅ Skip binary files completely (images, fonts, media)\n3. ✅ Process files sequentially, one at a time\n4. ✅ Extract CSS/JS structure, not full content\n5. ✅ Use grep for searching in large files\n6. ✅ Maximum 3-5 component files per analysis\n7. ✅ Reference asset paths without reading\n8. ✅ Summarize findings immediately and discard\n\n## Web UI Standards\n\n### Code Quality Requirements\n- **Semantic HTML**: Use appropriate HTML5 elements for content structure\n- **CSS Organization**: Follow chosen methodology consistently (BEM, SMACSS, etc.)\n- **JavaScript Quality**: Write clean, performant, and accessible JavaScript\n- **Progressive Enhancement**: Ensure basic functionality works without JavaScript\n\n### Accessibility Requirements\n- **WCAG 2.1 AA**: Meet minimum accessibility standards\n- **Keyboard Navigation**: All interactive elements keyboard accessible\n- **Screen Reader**: Proper ARIA labels and live regions\n- **Focus Management**: Clear focus indicators and logical tab order\n\n### Performance Targets\n- **First Contentful Paint**: < 1.8s\n- **Time to Interactive**: < 3.8s\n- **Cumulative Layout Shift**: < 0.1\n- **First Input Delay**: < 100ms\n\n### Browser Support\n- **Modern Browsers**: Latest 2 versions of Chrome, Firefox, Safari, Edge\n- **Progressive Enhancement**: Basic functionality for older browsers\n- **Mobile Browsers**: iOS Safari, Chrome Mobile, Samsung Internet\n- **Accessibility Tools**: Compatible with major screen readers\n\n## TodoWrite Usage Guidelines\n\nWhen using TodoWrite, always prefix tasks with your agent name to maintain clear ownership and coordination:\n\n### Required Prefix Format\n- \u2705 `[WebUI] Implement responsive navigation menu with mobile hamburger`\n- \u2705 `[WebUI] Create accessible form validation for checkout process`\n- \u2705 `[WebUI] Optimize CSS delivery for faster page load`\n- \u2705 `[WebUI] Fix layout shift issues on product gallery`\n- \u274c Never use generic todos without agent prefix\n- \u274c Never use another agent's prefix (e.g., [Engineer], [QA])\n\n### Task Status Management\nTrack your UI implementation progress systematically:\n- **pending**: UI work not yet started\n- **in_progress**: Currently implementing UI changes (mark when you begin work)\n- **completed**: UI implementation finished and tested\n- **BLOCKED**: Stuck on design assets or dependencies (include reason)\n\n### Web UI-Specific Todo Patterns\n\n**Component Implementation Tasks**:\n- `[WebUI] Build responsive card component with hover effects`\n- `[WebUI] Create modal dialog with keyboard trap and focus management`\n- `[WebUI] Implement infinite scroll with loading indicators`\n- `[WebUI] Design and code custom dropdown with ARIA support`\n\n**Styling and Layout Tasks**:\n- `[WebUI] Convert fixed layout to responsive grid system`\n- `[WebUI] Implement dark mode toggle with CSS custom properties`\n- `[WebUI] Create print stylesheet for invoice pages`\n- `[WebUI] Add smooth scroll animations for anchor navigation`\n\n**Form and Interaction Tasks**:\n- `[WebUI] Build multi-step form with progress indicator`\n- `[WebUI] Add real-time validation to registration form`\n- `[WebUI] Implement drag-and-drop file upload with preview`\n- `[WebUI] Create autocomplete search with debouncing`\n\n**Performance Optimization Tasks**:\n- `[WebUI] Optimize images with responsive srcset and lazy loading`\n- `[WebUI] Implement code splitting for JavaScript bundles`\n- `[WebUI] Extract and inline critical CSS for above-the-fold`\n- `[WebUI] Add service worker for offline functionality`\n\n**Accessibility Tasks**:\n- `[WebUI] Add ARIA labels to icon-only buttons`\n- `[WebUI] Implement skip navigation links for keyboard users`\n- `[WebUI] Fix color contrast issues in form error messages`\n- `[WebUI] Add focus trap to modal dialogs`\n\n### Special Status Considerations\n\n**For Complex UI Features**:\nBreak large features into manageable components:\n```\n[WebUI] Implement complete dashboard redesign\n\u251c\u2500\u2500 [WebUI] Create responsive grid layout (completed)\n\u251c\u2500\u2500 [WebUI] Build interactive charts with accessibility (in_progress)\n\u251c\u2500\u2500 [WebUI] Design data tables with sorting and filtering (pending)\n\u2514\u2500\u2500 [WebUI] Add export functionality with loading states (pending)\n```\n\n**For Blocked Tasks**:\nAlways include the blocking reason and impact:\n- `[WebUI] Implement hero banner (BLOCKED - waiting for final design assets)`\n- `[WebUI] Add payment form styling (BLOCKED - API endpoints not ready)`\n- `[WebUI] Create user avatar upload (BLOCKED - file size limits undefined)`\n\n### Coordination with Other Agents\n- Reference API requirements when UI depends on backend data\n- Update todos when UI is ready for QA testing\n- Note accessibility requirements for security review\n- Coordinate with Documentation agent for UI component guides",
|
|
58
58
|
"knowledge": {
|
|
59
59
|
"domain_expertise": [
|
|
60
60
|
"HTML5 semantic markup and web standards",
|
|
@@ -5,6 +5,8 @@ Extracted from mcp.py to reduce complexity and improve maintainability.
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import asyncio
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
8
10
|
from typing import Any
|
|
9
11
|
|
|
10
12
|
from ...constants import MCPCommands
|
|
@@ -43,6 +45,9 @@ class MCPCommandRouter:
|
|
|
43
45
|
elif args.mcp_command == MCPCommands.CONFIG.value:
|
|
44
46
|
return self._manage_config(args)
|
|
45
47
|
|
|
48
|
+
elif args.mcp_command == MCPCommands.SERVER.value:
|
|
49
|
+
return self._run_server(args)
|
|
50
|
+
|
|
46
51
|
elif args.mcp_command == "cleanup":
|
|
47
52
|
return self._cleanup_locks(args)
|
|
48
53
|
|
|
@@ -115,11 +120,91 @@ class MCPCommandRouter:
|
|
|
115
120
|
handler = MCPServerCommands(self.logger)
|
|
116
121
|
return handler.cleanup_locks(args)
|
|
117
122
|
|
|
123
|
+
def _run_server(self, args) -> int:
|
|
124
|
+
"""Run server command handler - direct server execution."""
|
|
125
|
+
try:
|
|
126
|
+
self.logger.info("Starting MCP server directly via CLI command")
|
|
127
|
+
|
|
128
|
+
# Import the server components
|
|
129
|
+
from claude_mpm.services.mcp_gateway.server.stdio_server import SimpleMCPServer
|
|
130
|
+
|
|
131
|
+
# Create server instance
|
|
132
|
+
server = SimpleMCPServer(name="claude-mpm-gateway", version="1.0.0")
|
|
133
|
+
|
|
134
|
+
if args.test:
|
|
135
|
+
self.logger.info("Running in test mode")
|
|
136
|
+
print("🧪 Starting MCP server in test mode...", file=sys.stderr)
|
|
137
|
+
print(" This will run the server with stdio communication.", file=sys.stderr)
|
|
138
|
+
print(" Press Ctrl+C to stop.\n", file=sys.stderr)
|
|
139
|
+
|
|
140
|
+
# Run the server, handling event loop properly
|
|
141
|
+
try:
|
|
142
|
+
# Check if there's already an event loop running
|
|
143
|
+
loop = asyncio.get_running_loop()
|
|
144
|
+
# If we get here, there's already a loop running
|
|
145
|
+
# We need to run in a subprocess to avoid conflicts
|
|
146
|
+
import subprocess
|
|
147
|
+
import json
|
|
148
|
+
|
|
149
|
+
# Create a simple script to run the server
|
|
150
|
+
script_content = f'''
|
|
151
|
+
import asyncio
|
|
152
|
+
import sys
|
|
153
|
+
import os
|
|
154
|
+
sys.path.insert(0, "{os.path.join(os.path.dirname(__file__), '..', '..', '..')}")
|
|
155
|
+
|
|
156
|
+
async def main():
|
|
157
|
+
from claude_mpm.services.mcp_gateway.server.stdio_server import SimpleMCPServer
|
|
158
|
+
server = SimpleMCPServer(name="claude-mpm-gateway", version="1.0.0")
|
|
159
|
+
await server.run()
|
|
160
|
+
|
|
161
|
+
if __name__ == "__main__":
|
|
162
|
+
asyncio.run(main())
|
|
163
|
+
'''
|
|
164
|
+
|
|
165
|
+
# Write the script to a temporary file
|
|
166
|
+
import tempfile
|
|
167
|
+
with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as f:
|
|
168
|
+
f.write(script_content)
|
|
169
|
+
temp_script = f.name
|
|
170
|
+
|
|
171
|
+
try:
|
|
172
|
+
# Run the server in a subprocess
|
|
173
|
+
result = subprocess.run([sys.executable, temp_script])
|
|
174
|
+
return result.returncode
|
|
175
|
+
finally:
|
|
176
|
+
# Clean up the temporary file
|
|
177
|
+
os.unlink(temp_script)
|
|
178
|
+
|
|
179
|
+
except RuntimeError:
|
|
180
|
+
# No event loop running, we can use asyncio.run
|
|
181
|
+
async def run_async():
|
|
182
|
+
await server.run()
|
|
183
|
+
|
|
184
|
+
asyncio.run(run_async())
|
|
185
|
+
return 0
|
|
186
|
+
|
|
187
|
+
except ImportError as e:
|
|
188
|
+
self.logger.error(f"Failed to import MCP server: {e}")
|
|
189
|
+
print(f"❌ Error: Could not import MCP server components: {e}", file=sys.stderr)
|
|
190
|
+
print("\nMake sure the MCP package is installed:", file=sys.stderr)
|
|
191
|
+
print(" pip install mcp", file=sys.stderr)
|
|
192
|
+
return 1
|
|
193
|
+
except KeyboardInterrupt:
|
|
194
|
+
self.logger.info("MCP server interrupted")
|
|
195
|
+
print("\n🛑 MCP server stopped", file=sys.stderr)
|
|
196
|
+
return 0
|
|
197
|
+
except Exception as e:
|
|
198
|
+
self.logger.error(f"Server error: {e}")
|
|
199
|
+
print(f"❌ Error running server: {e}", file=sys.stderr)
|
|
200
|
+
return 1
|
|
201
|
+
|
|
118
202
|
def _show_help(self):
|
|
119
203
|
"""Show available MCP commands."""
|
|
120
204
|
print("\nAvailable MCP commands:")
|
|
121
205
|
print(" install - Install and configure MCP Gateway")
|
|
122
206
|
print(" start - Start the MCP Gateway server (stdio mode)")
|
|
207
|
+
print(" server - Run the MCP Gateway server directly")
|
|
123
208
|
print(" stop - Stop the MCP Gateway server")
|
|
124
209
|
print(" status - Show server and tool status")
|
|
125
210
|
print(" tools - List and manage registered tools")
|
|
@@ -132,8 +217,9 @@ class MCPCommandRouter:
|
|
|
132
217
|
print("\nExamples:")
|
|
133
218
|
print(" claude-mpm mcp install")
|
|
134
219
|
print(" claude-mpm mcp start # Run server (for Claude Code)")
|
|
220
|
+
print(" claude-mpm mcp server # Run server directly")
|
|
221
|
+
print(" claude-mpm mcp server --test # Test mode with debug output")
|
|
135
222
|
print(" claude-mpm mcp start --instructions # Show setup instructions")
|
|
136
|
-
print(" claude-mpm mcp start --test # Test mode with debug output")
|
|
137
223
|
print(" claude-mpm mcp tools")
|
|
138
224
|
print(" claude-mpm mcp register my-tool")
|
|
139
225
|
print(" claude-mpm mcp test my-tool")
|
|
@@ -18,17 +18,17 @@ class MCPInstallCommands:
|
|
|
18
18
|
|
|
19
19
|
def install_gateway(self, args):
|
|
20
20
|
"""Install and configure MCP gateway.
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
WHY: This command installs the MCP package dependencies and configures
|
|
23
|
-
Claude Desktop to use the MCP gateway server.
|
|
24
|
-
|
|
23
|
+
Claude Desktop to use the MCP gateway server directly via the CLI command.
|
|
24
|
+
|
|
25
25
|
DESIGN DECISION: We handle both package installation and configuration
|
|
26
|
-
in one command for user convenience.
|
|
26
|
+
in one command for user convenience, using the new direct CLI approach.
|
|
27
27
|
"""
|
|
28
28
|
self.logger.info("MCP gateway installation command called")
|
|
29
29
|
print("📦 Installing and Configuring MCP Gateway")
|
|
30
30
|
print("=" * 50)
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
# Step 1: Install MCP package if needed
|
|
33
33
|
print("\n1️⃣ Checking MCP package installation...")
|
|
34
34
|
try:
|
|
@@ -43,35 +43,216 @@ class MCPInstallCommands:
|
|
|
43
43
|
print(f"❌ Error installing MCP package: {e}")
|
|
44
44
|
print("\nPlease install manually with: pip install mcp")
|
|
45
45
|
return 1
|
|
46
|
-
|
|
47
|
-
# Step 2:
|
|
46
|
+
|
|
47
|
+
# Step 2: Configure Claude Desktop with the new CLI command
|
|
48
48
|
print("\n2️⃣ Configuring Claude Desktop...")
|
|
49
|
-
project_root = Path(__file__).parent.parent.parent.parent.parent
|
|
50
|
-
config_script = project_root / "scripts" / "configure_mcp_server.py"
|
|
51
|
-
|
|
52
|
-
if not config_script.exists():
|
|
53
|
-
print(f"⚠️ Configuration script not found at {config_script}")
|
|
54
|
-
print("\nPlease configure manually. See:")
|
|
55
|
-
print(" claude-mpm mcp start --instructions")
|
|
56
|
-
return 1
|
|
57
|
-
|
|
58
49
|
try:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
cwd=str(project_root)
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
if result.returncode == 0:
|
|
50
|
+
success = self._configure_claude_desktop(args.force)
|
|
51
|
+
if success:
|
|
65
52
|
print("✅ Configuration completed successfully")
|
|
66
53
|
print("\n🎉 MCP Gateway is ready to use!")
|
|
67
54
|
print("\nNext steps:")
|
|
68
55
|
print("1. Restart Claude Desktop")
|
|
69
|
-
print("2.
|
|
56
|
+
print("2. Test the server: claude-mpm mcp server --test")
|
|
57
|
+
print("3. Check status: claude-mpm mcp status")
|
|
70
58
|
return 0
|
|
71
59
|
else:
|
|
72
|
-
print("❌ Configuration
|
|
60
|
+
print("❌ Configuration failed")
|
|
73
61
|
return 1
|
|
74
|
-
|
|
62
|
+
|
|
75
63
|
except Exception as e:
|
|
76
|
-
print(f"❌ Error
|
|
64
|
+
print(f"❌ Error during configuration: {e}")
|
|
77
65
|
return 1
|
|
66
|
+
|
|
67
|
+
def _configure_claude_desktop(self, force=False):
|
|
68
|
+
"""Configure Claude Desktop to use the MCP gateway via CLI command.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
force: Whether to overwrite existing configuration
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
bool: True if configuration was successful
|
|
75
|
+
"""
|
|
76
|
+
import json
|
|
77
|
+
import platform
|
|
78
|
+
from pathlib import Path
|
|
79
|
+
from datetime import datetime
|
|
80
|
+
|
|
81
|
+
# Determine Claude Desktop config path based on platform
|
|
82
|
+
config_path = self._get_claude_config_path()
|
|
83
|
+
if not config_path:
|
|
84
|
+
print("❌ Could not determine Claude Desktop configuration path")
|
|
85
|
+
return False
|
|
86
|
+
|
|
87
|
+
print(f" Configuration path: {config_path}")
|
|
88
|
+
|
|
89
|
+
# Load existing configuration or create new one
|
|
90
|
+
config = self._load_or_create_config(config_path, force)
|
|
91
|
+
if config is None:
|
|
92
|
+
return False
|
|
93
|
+
|
|
94
|
+
# Configure the claude-mpm-gateway server using the CLI command
|
|
95
|
+
claude_mpm_path = self._find_claude_mpm_executable()
|
|
96
|
+
if not claude_mpm_path:
|
|
97
|
+
print("❌ Could not find claude-mpm executable")
|
|
98
|
+
return False
|
|
99
|
+
|
|
100
|
+
mcp_config = {
|
|
101
|
+
"command": claude_mpm_path,
|
|
102
|
+
"args": ["mcp", "server"],
|
|
103
|
+
"env": {
|
|
104
|
+
"PYTHONPATH": str(Path(__file__).parent.parent.parent.parent),
|
|
105
|
+
"MCP_MODE": "production"
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
# Update configuration
|
|
110
|
+
if "mcpServers" not in config:
|
|
111
|
+
config["mcpServers"] = {}
|
|
112
|
+
|
|
113
|
+
config["mcpServers"]["claude-mpm-gateway"] = mcp_config
|
|
114
|
+
|
|
115
|
+
print("\n✅ Configured claude-mpm-gateway server:")
|
|
116
|
+
print(f" Command: {mcp_config['command']}")
|
|
117
|
+
print(f" Args: {mcp_config['args']}")
|
|
118
|
+
print(f" Environment variables: {list(mcp_config['env'].keys())}")
|
|
119
|
+
|
|
120
|
+
# Save configuration
|
|
121
|
+
return self._save_config(config, config_path)
|
|
122
|
+
|
|
123
|
+
def _get_claude_config_path(self):
|
|
124
|
+
"""Get the Claude Desktop configuration file path based on platform.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
Path or None: Path to Claude Desktop config file
|
|
128
|
+
"""
|
|
129
|
+
import platform
|
|
130
|
+
from pathlib import Path
|
|
131
|
+
|
|
132
|
+
system = platform.system()
|
|
133
|
+
|
|
134
|
+
if system == "Darwin": # macOS
|
|
135
|
+
return Path.home() / "Library" / "Application Support" / "Claude" / "claude_desktop_config.json"
|
|
136
|
+
elif system == "Windows":
|
|
137
|
+
return Path.home() / "AppData" / "Roaming" / "Claude" / "claude_desktop_config.json"
|
|
138
|
+
elif system == "Linux":
|
|
139
|
+
return Path.home() / ".config" / "Claude" / "claude_desktop_config.json"
|
|
140
|
+
else:
|
|
141
|
+
print(f"❌ Unsupported platform: {system}")
|
|
142
|
+
return None
|
|
143
|
+
|
|
144
|
+
def _find_claude_mpm_executable(self):
|
|
145
|
+
"""Find the claude-mpm executable path.
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
str or None: Path to claude-mpm executable
|
|
149
|
+
"""
|
|
150
|
+
import shutil
|
|
151
|
+
import sys
|
|
152
|
+
|
|
153
|
+
# Try to find claude-mpm in PATH
|
|
154
|
+
claude_mpm_path = shutil.which("claude-mpm")
|
|
155
|
+
if claude_mpm_path:
|
|
156
|
+
return claude_mpm_path
|
|
157
|
+
|
|
158
|
+
# If not in PATH, try using python -m claude_mpm
|
|
159
|
+
# This works if claude-mpm is installed in the current Python environment
|
|
160
|
+
try:
|
|
161
|
+
import claude_mpm
|
|
162
|
+
return f"{sys.executable} -m claude_mpm"
|
|
163
|
+
except ImportError:
|
|
164
|
+
pass
|
|
165
|
+
|
|
166
|
+
# Last resort: try relative to current script
|
|
167
|
+
project_root = Path(__file__).parent.parent.parent.parent.parent
|
|
168
|
+
local_script = project_root / "scripts" / "claude-mpm"
|
|
169
|
+
if local_script.exists():
|
|
170
|
+
return str(local_script)
|
|
171
|
+
|
|
172
|
+
return None
|
|
173
|
+
|
|
174
|
+
def _load_or_create_config(self, config_path, force=False):
|
|
175
|
+
"""Load existing configuration or create a new one.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
config_path: Path to configuration file
|
|
179
|
+
force: Whether to overwrite existing configuration
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
dict or None: Configuration dictionary
|
|
183
|
+
"""
|
|
184
|
+
import json
|
|
185
|
+
from datetime import datetime
|
|
186
|
+
|
|
187
|
+
config = {}
|
|
188
|
+
|
|
189
|
+
if config_path.exists():
|
|
190
|
+
if not force:
|
|
191
|
+
# Check if claude-mpm-gateway already exists
|
|
192
|
+
try:
|
|
193
|
+
with open(config_path, 'r') as f:
|
|
194
|
+
existing_config = json.load(f)
|
|
195
|
+
|
|
196
|
+
if (existing_config.get("mcpServers", {}).get("claude-mpm-gateway") and
|
|
197
|
+
not force):
|
|
198
|
+
print("⚠️ claude-mpm-gateway is already configured")
|
|
199
|
+
response = input("Do you want to overwrite it? (y/N): ").strip().lower()
|
|
200
|
+
if response not in ['y', 'yes']:
|
|
201
|
+
print("❌ Configuration cancelled")
|
|
202
|
+
return None
|
|
203
|
+
|
|
204
|
+
config = existing_config
|
|
205
|
+
|
|
206
|
+
except (json.JSONDecodeError, IOError) as e:
|
|
207
|
+
print(f"⚠️ Error reading existing config: {e}")
|
|
208
|
+
print("Creating backup and starting fresh...")
|
|
209
|
+
|
|
210
|
+
# Create backup
|
|
211
|
+
backup_path = config_path.with_suffix(f'.backup.{datetime.now().strftime("%Y%m%d_%H%M%S")}.json')
|
|
212
|
+
try:
|
|
213
|
+
config_path.rename(backup_path)
|
|
214
|
+
print(f" Backup created: {backup_path}")
|
|
215
|
+
except Exception as backup_error:
|
|
216
|
+
print(f" Warning: Could not create backup: {backup_error}")
|
|
217
|
+
else:
|
|
218
|
+
# Force mode - create backup but proceed
|
|
219
|
+
try:
|
|
220
|
+
with open(config_path, 'r') as f:
|
|
221
|
+
existing_config = json.load(f)
|
|
222
|
+
config = existing_config
|
|
223
|
+
print(" Force mode: Overwriting existing configuration")
|
|
224
|
+
except:
|
|
225
|
+
pass # File doesn't exist or is invalid, start fresh
|
|
226
|
+
|
|
227
|
+
# Ensure mcpServers section exists
|
|
228
|
+
if "mcpServers" not in config:
|
|
229
|
+
config["mcpServers"] = {}
|
|
230
|
+
|
|
231
|
+
return config
|
|
232
|
+
|
|
233
|
+
def _save_config(self, config, config_path):
|
|
234
|
+
"""Save configuration to file.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
config: Configuration dictionary
|
|
238
|
+
config_path: Path to save configuration
|
|
239
|
+
|
|
240
|
+
Returns:
|
|
241
|
+
bool: True if successful
|
|
242
|
+
"""
|
|
243
|
+
import json
|
|
244
|
+
|
|
245
|
+
try:
|
|
246
|
+
# Ensure directory exists
|
|
247
|
+
config_path.parent.mkdir(parents=True, exist_ok=True)
|
|
248
|
+
|
|
249
|
+
# Write configuration with nice formatting
|
|
250
|
+
with open(config_path, 'w') as f:
|
|
251
|
+
json.dump(config, f, indent=2)
|
|
252
|
+
|
|
253
|
+
print(f"\n✅ Configuration saved to {config_path}")
|
|
254
|
+
return True
|
|
255
|
+
|
|
256
|
+
except Exception as e:
|
|
257
|
+
print(f"❌ Error saving configuration: {e}")
|
|
258
|
+
return False
|
|
@@ -149,4 +149,27 @@ def add_mcp_subparser(subparsers) -> argparse.ArgumentParser:
|
|
|
149
149
|
help="Configuration action (default: view)",
|
|
150
150
|
)
|
|
151
151
|
|
|
152
|
+
# MCP Server command (direct server execution)
|
|
153
|
+
server_mcp_parser = mcp_subparsers.add_parser(
|
|
154
|
+
MCPCommands.SERVER.value, help="Run the MCP Gateway server directly"
|
|
155
|
+
)
|
|
156
|
+
server_mcp_parser.add_argument(
|
|
157
|
+
"--mode",
|
|
158
|
+
choices=["stdio", "standalone"],
|
|
159
|
+
default="stdio",
|
|
160
|
+
help="Server mode: stdio for Claude integration, standalone for testing (default: stdio)",
|
|
161
|
+
)
|
|
162
|
+
server_mcp_parser.add_argument(
|
|
163
|
+
"--port",
|
|
164
|
+
type=int,
|
|
165
|
+
default=8766,
|
|
166
|
+
help="Port for standalone mode (default: 8766)",
|
|
167
|
+
)
|
|
168
|
+
server_mcp_parser.add_argument(
|
|
169
|
+
"--config-file", type=Path, help="Path to MCP configuration file"
|
|
170
|
+
)
|
|
171
|
+
server_mcp_parser.add_argument(
|
|
172
|
+
"--test", action="store_true", help="Run in test mode with debug output"
|
|
173
|
+
)
|
|
174
|
+
|
|
152
175
|
return mcp_parser
|
claude_mpm/constants.py
CHANGED
claude_mpm/core/base_service.py
CHANGED
|
@@ -120,7 +120,13 @@ class BaseService(LoggerMixin, ABC):
|
|
|
120
120
|
container: Optional service container for dependency injection
|
|
121
121
|
"""
|
|
122
122
|
self.name = name
|
|
123
|
-
|
|
123
|
+
# Use singleton Config instance to prevent duplicate configuration loading
|
|
124
|
+
# Only pass config_path if it's different from what might already be loaded
|
|
125
|
+
if config_path:
|
|
126
|
+
self.config = Config(config or {}, config_path)
|
|
127
|
+
else:
|
|
128
|
+
# Use existing singleton instance without forcing reload
|
|
129
|
+
self.config = Config(config or {})
|
|
124
130
|
self._enable_enhanced = enable_enhanced_features
|
|
125
131
|
self._container = container
|
|
126
132
|
|