MULTI-TOOL-ARCHITECTURE-IMPLEMENTATION.mdβ’10.7 kB
# Multi-Tool Architecture Implementation Plan
**EuConquisto Composer MCP Server - Specialized Tools Approach**
**Document Version**: 1.2.0
**Created**: 2025-07-10
**Updated**: 2025-07-10
**Status**: β
ALL PHASES COMPLETE - Production Ready
**Priority**: High - Critical for resolving 500 error debugging issues
---
## π― **Objective**
Replace the current monolithic `create_educational_composition` tool with 4 specialized tools to improve error isolation, debugging capabilities, and maintainability.
## π **Current Problems**
- **Monolithic Tool Scope**: Single tool handles 7 distinct operations
- **Error Isolation Failure**: Cannot determine where in the process failures occur
- **Debugging Complexity**: 500 errors provide no actionable information
- **No Intermediate Validation**: Cannot inspect data between transformation steps
---
## ποΈ **Proposed Architecture**
### **Current Flow**
```
Claude β get_lesson_guidance β create_educational_composition (monolithic)
β
[7 operations in black box]
β
Success/500 Error
```
### **New Specialized Flow**
```
Claude β get_lesson_guidance
β
validate_lesson_data
β
format_for_composer
β
save_composition_api
β
open_composition_editor
```
---
## π **Implementation Tasks**
### **Phase 1: Tool Design & Specification**
**Duration**: 1-2 hours
**Goal**: Define exact interfaces and responsibilities
- [x] **Task 1.1**: Define `validate_lesson_data` tool specification β
- Input schema: Claude's lesson data format
- Output schema: Validation results with specific error details
- Validation rules: Required fields, data types, content constraints
- **Completed**: Full specification with 68+ validation rules created
- [x] **Task 1.2**: Define `format_for_composer` tool specification β
- Input schema: Validated lesson data
- Output schema: Composer-compatible JSON structure
- Intelligence level: Deterministic vs AI-enhanced formatting
- **Completed**: Educational intelligence and content-based adaptations specified
- [x] **Task 1.3**: Define `save_composition_api` tool specification β
- Input schema: Formatted composition JSON
- Output schema: API response details, composition ID
- Error handling: HTTP status codes, API error messages
- **Completed**: Comprehensive error analysis and debugging capabilities
- [x] **Task 1.4**: Define `open_composition_editor` tool specification β
- Input schema: Composition ID and base URL
- Output schema: Navigation success/failure with detailed error info
- Browser management: Session handling, error capture
- **Completed**: Navigation debugging and page health assessment
### **Phase 2: Core Tool Implementation**
**Duration**: 2-3 hours
**Goal**: Implement the 4 specialized tools
- [x] **Task 2.1**: Implement `validate_lesson_data` tool β
- Validate metadata structure (topic, duration, objectives)
- Validate widgets array (required fields, valid types)
- Check content completeness (no empty text, valid URLs)
- Validate educational flow (logical progression)
- **Completed**: 500+ lines, 68+ validation rules, 100% test success
- [x] **Task 2.2**: Implement `format_for_composer` tool β
- Extract current formatting logic from claude-guided-composer.js
- Add content-based intelligence (text length β widget sizing)
- Add educational intelligence (learning flow optimization)
- Add Composer compatibility checks
- **Completed**: 600+ lines, educational intelligence, subject optimizations
- [x] **Task 2.3**: Implement `save_composition_api` tool β
- Extract authentication logic (JWT, localStorage extraction)
- Extract API call logic (FormData creation, fetch request)
- Enhanced error reporting (detailed API response logging)
- Response validation (ensure proper composition ID extraction)
- **Completed**: 500+ lines, comprehensive API debugging, error analysis
- [x] **Task 2.4**: Implement `open_composition_editor` tool β
- Extract navigation logic (URL construction, browser automation)
- Enhanced error capture (page load status, console errors)
- Success validation (ensure composition loads properly)
- Detailed debugging output (final URL, page status)
- **Completed**: 450+ lines, navigation health assessment, page monitoring
### **Phase 3: Integration & Testing**
**Duration**: 1-2 hours
**Goal**: Integrate tools and test the complete workflow
- [x] **Task 3.1**: Update MCP server tool registration β
- Remove monolithic `create_educational_composition` tool
- Register 4 new specialized tools
- Update tool descriptions and schemas
- **Completed**: New MCP server v5.0.0 with 5-tool architecture
- [x] **Task 3.2**: Update Claude guidance instructions β
- Modify `get_lesson_guidance` output to instruct sequential tool usage
- Provide clear workflow steps for Claude to follow
- Add error handling guidance for each tool
- **Completed**: Multi-tool workflow instructions with benefits explanation
- [x] **Task 3.3**: Test individual tools in isolation β
- Test `validate_lesson_data` with various input formats
- Test `format_for_composer` with validated data
- Test `save_composition_api` with formatted data
- Test `open_composition_editor` with saved composition ID
- **Completed**: 6/6 individual tests passed (100% success rate)
- [x] **Task 3.4**: Test complete multi-tool workflow β
- End-to-end test: "Crie uma aula de ciΓͺncias sobre o sistema solar"
- Verify error isolation works at each step
- Confirm debugging information is actionable
- **Completed**: Integration test passed with 16/16 validation checks
### **Phase 4: Advanced Intelligence Features**
**Duration**: 2-3 hours (Optional Enhancement)
**Goal**: Add AI-enhanced formatting and validation
- [ ] **Task 4.1**: Implement intelligent widget selection validation
- Content analysis: text complexity β appropriate widget types
- Educational analysis: learning objectives β widget alignment
- Flow analysis: cognitive load distribution optimization
- [ ] **Task 4.2**: Implement adaptive formatting intelligence
- Dynamic property adjustment based on content characteristics
- Educational best practices enforcement (assessment placement, etc.)
- Composer-specific optimizations (layout, performance)
- [ ] **Task 4.3**: Implement enhanced error diagnostics
- Predictive error detection (likely to cause 500 errors)
- Content quality assessment (engagement, educational value)
- Composer compatibility scoring
---
## π― **Success Criteria**
### **Immediate Goals (Phases 1-3)**
- [x] **Error Isolation**: Can identify exactly which step fails in multi-tool workflow β
- [x] **Actionable Debugging**: 500 errors provide specific, fixable information β
- [x] **Intermediate Inspection**: Can examine data at each transformation step β
- [x] **Selective Retry**: Can retry individual failed steps without full workflow restart β
### **Advanced Goals (Phase 4)**
- [ ] **Intelligent Validation**: Prevents 500 errors through predictive content analysis
- [ ] **Educational Optimization**: Improves learning outcomes through AI-enhanced formatting
- [ ] **Composer Integration**: Optimal compatibility with Composer platform capabilities
---
## π **Technical Specifications**
### **Tool Interface Standards**
```typescript
interface ToolInput {
[key: string]: any;
}
interface ToolOutput {
success: boolean;
data?: any;
error?: {
code: string;
message: string;
details: any;
};
debug?: {
timestamp: string;
processingTime: number;
additionalInfo: any;
};
}
```
### **Error Code Standards**
```
VALIDATION_ERROR: Invalid input data format
FORMAT_ERROR: Composition formatting failure
API_ERROR: Composer API save failure
NAVIGATION_ERROR: Browser navigation failure
COMPOSER_ERROR: Composer rendering failure
```
### **Debugging Output Standards**
```
[TOOL_NAME] Step X: Description
[TOOL_NAME] Input: Data summary
[TOOL_NAME] Processing: Status updates
[TOOL_NAME] Output: Result summary
[TOOL_NAME] Debug: Detailed information
```
---
## π **Risk Assessment**
### **Low Risk**
- **Tool Interface Design**: Well-defined, similar to existing patterns
- **Code Extraction**: Existing logic can be cleanly separated
### **Medium Risk**
- **Claude Workflow Adaptation**: Need to train Claude on new multi-tool sequence
- **Integration Testing**: Ensuring smooth data flow between tools
### **High Risk**
- **Performance Impact**: 4 tool calls vs 1 (mitigated by better debugging)
- **Complexity Increase**: More moving parts (mitigated by better error isolation)
---
## π **Implementation Priority**
**Phase 1-3: CRITICAL** - Directly addresses current 500 error debugging issues
**Phase 4: ENHANCEMENT** - Improves system intelligence and error prevention
**Recommendation**: Implement Phases 1-3 immediately to resolve current debugging blindness, then evaluate Phase 4 based on results.
---
## β
**Next Actions**
1. **Approve Architecture**: Review and approve this multi-tool approach
2. **Begin Phase 1**: Start with tool specification design
3. **Validate Concept**: Implement one tool as proof-of-concept
4. **Full Implementation**: Complete Phases 1-3 for production readiness
---
## π **Phase 1 Completion Summary**
### **Achievements**
- β
**4 Complete Tool Specifications**: All tools fully defined with comprehensive interfaces
- β
**68+ Validation Rules**: Detailed validation for all widget types and content formats
- β
**Educational Intelligence**: Subject-specific and grade-level adaptations specified
- β
**Error Code Framework**: Specific error codes for precise debugging at each step
- β
**Debug Logging Standards**: Comprehensive logging for actionable troubleshooting
### **Key Technical Deliverables**
- `TOOL-SPEC-validate_lesson_data.md` - Input validation with educational standards
- `TOOL-SPEC-format_for_composer.md` - Intelligent formatting with Composer compatibility
- `TOOL-SPEC-save_composition_api.md` - API integration with enhanced error analysis
- `TOOL-SPEC-open_composition_editor.md` - Navigation with health assessment
### **Impact on Current Issues**
- **500 Error Resolution**: Each tool provides specific error isolation and debugging
- **Quiz Question Validation**: Catches malformed questions before API submission
- **Authentication Debugging**: Detailed auth extraction and validation steps
- **Navigation Analysis**: Comprehensive page health and load verification
---
**Status**: β
**Phase 1 Complete** - Ready to begin Phase 2 Implementation