Skip to content

feat: implement dynamic capability detection and generic system archi…#8

Merged
avrabe merged 5 commits intomainfrom
autodiscover
Jun 11, 2025
Merged

feat: implement dynamic capability detection and generic system archi…#8
avrabe merged 5 commits intomainfrom
autodiscover

Conversation

@avrabe
Copy link
Owner

@avrabe avrabe commented Jun 10, 2025

…tecture

Major architectural improvements to make the MCP server generic and configuration-aware:

Core Features Added:

  • Dynamic capability detection system that analyzes each user's specific Loxone configuration
  • Real-time WebSocket monitoring with automatic sensor discovery
  • Token-based authentication for improved security
  • State logging and change tracking for door/window sensors
  • Comprehensive error handling with helpful capability guidance

Architecture Changes:

  • SystemCapabilities dataclass for detecting available features at startup
  • Intelligent device categorization by type, category, and name patterns
  • Generic MCP tools that adapt to available devices rather than assuming hardcoded setups
  • Configuration-aware error messages that prevent AI confusion about missing devices

New Components:

  • LoxoneTokenClient: Secure JWT authentication replacing basic auth
  • LoxoneWebSocketClient: Real-time state monitoring for Gen 1 systems
  • DynamicSensorDiscovery: Automatic detection of functional sensors
  • SensorStateLogger: Persistent logging of sensor state changes

Landing Page Updates:

  • Removed all hardcoded device counts and specific configuration references
  • Updated to reflect generic, capability-aware nature of the system
  • Added terminal demo showing capability detection during setup
  • Matrix animation now shows generic capability data instead of hardcoded device states

Testing & Documentation:

  • Comprehensive test suite covering all major components
  • Updated CLAUDE.md with new architecture patterns
  • Added MCP usage examples and deployment documentation

Breaking Changes:

  • Server now requires capability detection at startup
  • Tools check availability before execution to prevent errors
  • Landing page reflects generic nature rather than specific device counts

This transformation addresses the critical requirement that "the AI tries to do something it can't" by implementing comprehensive capability detection and configuration-aware operation.

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Code style update (formatting, renaming)
  • ♻️ Refactoring (no functional changes)
  • ⚡ Performance improvement
  • ✅ Test update
  • 🔧 Configuration change
  • 🔒 Security fix

Related Issue

Fixes #(issue number)

Changes Made

Testing

  • Unit tests pass
  • Integration tests pass (if applicable)
  • Manual testing completed
  • Tested with actual Loxone Miniserver

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked my code for potential security issues
  • I have verified no credentials or sensitive data are included

Screenshots (if applicable)

Additional Notes

avrabe added 4 commits June 10, 2025 19:16
…tecture

Major architectural improvements to make the MCP server generic and configuration-aware:

Core Features Added:
- Dynamic capability detection system that analyzes each user's specific Loxone configuration
- Real-time WebSocket monitoring with automatic sensor discovery
- Token-based authentication for improved security
- State logging and change tracking for door/window sensors
- Comprehensive error handling with helpful capability guidance

Architecture Changes:
- SystemCapabilities dataclass for detecting available features at startup
- Intelligent device categorization by type, category, and name patterns
- Generic MCP tools that adapt to available devices rather than assuming hardcoded setups
- Configuration-aware error messages that prevent AI confusion about missing devices

New Components:
- LoxoneTokenClient: Secure JWT authentication replacing basic auth
- LoxoneWebSocketClient: Real-time state monitoring for Gen 1 systems
- DynamicSensorDiscovery: Automatic detection of functional sensors
- SensorStateLogger: Persistent logging of sensor state changes

Landing Page Updates:
- Removed all hardcoded device counts and specific configuration references
- Updated to reflect generic, capability-aware nature of the system
- Added terminal demo showing capability detection during setup
- Matrix animation now shows generic capability data instead of hardcoded device states

Testing & Documentation:
- Comprehensive test suite covering all major components
- Updated CLAUDE.md with new architecture patterns
- Added MCP usage examples and deployment documentation

Breaking Changes:
- Server now requires capability detection at startup
- Tools check availability before execution to prevent errors
- Landing page reflects generic nature rather than specific device counts

This transformation addresses the critical requirement that "the AI tries to do something it can't"
by implementing comprehensive capability detection and configuration-aware operation.
… functionality

- Add complete SSE API key authentication system with Bearer token and X-API-Key support
- Integrate SSE API key management into credential setup wizard with auto-generation
- Implement JWT token authentication for MCP server with automatic refresh
- Add comprehensive weather forecast functionality using Open-Meteo and OpenWeatherMap APIs
- Fix 867 linting errors across entire codebase for CI compatibility
- Enhance server initialization with lazy loading and connection health monitoring
- Update documentation with security architecture deployment diagrams
- Add production-ready Docker configuration with environment variable overrides
- Implement constant-time API key comparison for timing attack prevention
- Add sensor state logging and dynamic discovery with background processing

BREAKING CHANGE: Authentication is now required for SSE endpoints by default.
Set LOXONE_SSE_REQUIRE_AUTH=false to disable authentication.

Security improvements:
- All credentials stored in OS keychain with environment variable fallback
- HMAC-SHA256 JWT tokens for MCP authentication
- 32-byte cryptographically secure API keys for SSE
- Request logging with client IP tracking for security monitoring
- Health check endpoints remain unauthenticated for monitoring

New features:
- Daily and hourly weather forecasts with location auto-detection
- Complete sensor state history tracking with JSON persistence
- Dynamic sensor discovery without hardcoded UUIDs
- Production deployment with Docker Compose
- Comprehensive system capability detection

Documentation updates:
- Replace setup wizard flow with deployment architecture diagram
- Add visual security flow showing JWT and API key authentication
- Update index.html with complete security architecture visualization
- Fix layout overlaps in deployment diagram
- Fix critical syntax error in sse_server.py (global declaration order)
- Fix all linting errors (line length, type annotations, whitespace)
- Fix security issue with SHA1 usage (added usedforsecurity=False)
- Add MCP prompt for system overview to satisfy validation
- Implement comprehensive HTTPS/SSL support for SSE server
- Add SSL configuration module with certificate validation
- Create setup scripts for local and production HTTPS
- Update documentation with HTTPS setup instructions
- Add uv installation commands to index.html
- Make all CI checks pass (linting, security, MCP validation)

The CI should now pass all tests successfully.
Applied ruff format to fix formatting violations in:
- src/loxone_mcp/server.py
- src/loxone_mcp/sse_server.py
- src/loxone_mcp/ssl_config.py
@avrabe avrabe force-pushed the autodiscover branch 2 times, most recently from 2128419 to 72e488a Compare June 11, 2025 10:20
…ing dependencies

- Add fastapi>=0.104.0 dependency to fix SSE server imports
- Rewrite test files to match current server.py structure
- Remove tests for non-existent functions (LoxoneDevice, find_matching_room, etc.)
- Fix ServerContext constructor usage in all test files
- Clean up linting issues and ensure code quality standards
- Tests now properly reflect the actual codebase implementation
@avrabe avrabe merged commit d68e7bb into main Jun 11, 2025
9 checks passed
@avrabe avrabe deleted the autodiscover branch June 11, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant