api_client.py: Complete HTTP client for madnessinteractive.cc/api- Supports JWT tokens and API keys
- Automatic retries with exponential backoff
- Proper error handling and response parsing
- Async context manager support
- Full todo CRUD operations mapping
api_tools.py: Complete API-based tool implementations- All core todo operations: add, query, update, delete, complete
- Response format compatibility with existing MCP tools
- Proper error handling and fallback messages
- Support for metadata and complex filtering
hybrid_tools.py: Intelligent hybrid mode system- API-first with local database fallback
- Performance tracking and failure counting
- Configurable operation modes:
api,local,hybrid,auto - Graceful degradation when API unavailable
- Real-time mode switching based on performance
- Updated
__init__.py: Mode-aware tool registration - Enhanced
CLAUDE.md: Complete documentation with examples - Test suite:
test_api_client.pyvalidates all functionality - Configuration: Environment variable support for all modes
- API handles all Auth0 complexity centrally
- JWT tokens and API keys supported
- No more local Auth0 device flow complexity in MCP
- MongoDB access centralized behind API
- User isolation enforced at API level
- No direct database credentials needed for MCP clients
- API Mode: Pure HTTP API calls (recommended)
- Local Mode: Direct database (legacy compatibility)
- Hybrid Mode: Best of both worlds with failover
- Auto Mode: Performance-based selection
- Existing MCP tool interfaces unchanged
- Same response formats maintained
- Existing Claude Desktop configs work with mode selection
python test_api_client.pyResults:
- ✅ API health check: Connected successfully
- ✅ Authentication detection: Properly handles missing credentials
- ✅ Hybrid fallback: API→Local failover working correctly
- ✅ Tool registration: All 22+ tools loading properly
- ✅ Response compatibility: JSON formats match expectations
export OMNISPINDLE_MODE="api"
export MADNESS_AUTH_TOKEN="your_jwt_token"
export OMNISPINDLE_TOOL_LOADOUT="basic"
python -m src.Omnispindle.stdio_serverexport OMNISPINDLE_MODE="hybrid"
export MADNESS_AUTH_TOKEN="your_jwt_token"
export MONGODB_URI="mongodb://localhost:27017"
python -m src.Omnispindle.stdio_server# Test API connectivity
export OMNISPINDLE_TOOL_LOADOUT="hybrid_test"
# Use get_hybrid_status and test_api_connectivity tools| Variable | Options | Description |
|---|---|---|
OMNISPINDLE_MODE |
hybrid, api, local, auto |
Operation mode |
MADNESS_API_URL |
URL | API endpoint (default: madnessinteractive.cc/api) |
MADNESS_AUTH_TOKEN |
JWT | Auth0 token from device flow |
MADNESS_API_KEY |
Key | API key from dashboard |
OMNISPINDLE_FALLBACK_ENABLED |
true/false |
Enable local fallback |
OMNISPINDLE_API_TIMEOUT |
Seconds | API request timeout |
- Test with real Auth0 tokens
- Test API key generation and usage
- Verify error handling edge cases
- Batch operations for performance
- Response caching for frequently accessed data
- Metrics dashboard for hybrid mode performance
- Auto-migration of existing local data to API
Why This Approach Works:
- Zero Disruption: Existing MCP clients continue working unchanged
- Progressive Migration: Can switch modes without code changes
- Reliability: Hybrid mode provides best uptime via fallback
- Security: Centralized auth and database access through API
- Performance: Intelligent mode selection based on real metrics
The implementation successfully addresses the original goal: "protect the database behind the API" while making "auth0 problems easier to manage" by centralizing authentication at the API layer.