opera-cloud-mcp 0.2.0__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.
Files changed (59) hide show
  1. opera_cloud_mcp/__init__.py +20 -0
  2. opera_cloud_mcp/__main__.py +12 -0
  3. opera_cloud_mcp/auth/__init__.py +381 -0
  4. opera_cloud_mcp/auth/audit_logger.py +809 -0
  5. opera_cloud_mcp/auth/audit_sqlmodel.py +140 -0
  6. opera_cloud_mcp/auth/oauth_handler.py +631 -0
  7. opera_cloud_mcp/auth/secure_oauth_handler.py +867 -0
  8. opera_cloud_mcp/auth/security_enhancements.py +501 -0
  9. opera_cloud_mcp/auth/security_middleware.py +841 -0
  10. opera_cloud_mcp/cli.py +223 -0
  11. opera_cloud_mcp/clients/__init__.py +12 -0
  12. opera_cloud_mcp/clients/api_clients/__init__.py +8 -0
  13. opera_cloud_mcp/clients/api_clients/activities.py +856 -0
  14. opera_cloud_mcp/clients/api_clients/block.py +615 -0
  15. opera_cloud_mcp/clients/api_clients/cashiering.py +790 -0
  16. opera_cloud_mcp/clients/api_clients/crm.py +939 -0
  17. opera_cloud_mcp/clients/api_clients/front_office.py +514 -0
  18. opera_cloud_mcp/clients/api_clients/housekeeping.py +592 -0
  19. opera_cloud_mcp/clients/api_clients/inventory.py +789 -0
  20. opera_cloud_mcp/clients/api_clients/rates.py +731 -0
  21. opera_cloud_mcp/clients/api_clients/reservations.py +928 -0
  22. opera_cloud_mcp/clients/base_client.py +1767 -0
  23. opera_cloud_mcp/clients/base_client_refactored.py +1398 -0
  24. opera_cloud_mcp/clients/client_factory.py +408 -0
  25. opera_cloud_mcp/config/__init__.py +12 -0
  26. opera_cloud_mcp/config/security_settings.py +436 -0
  27. opera_cloud_mcp/config/settings.py +231 -0
  28. opera_cloud_mcp/main.py +396 -0
  29. opera_cloud_mcp/models/__init__.py +8 -0
  30. opera_cloud_mcp/models/common.py +94 -0
  31. opera_cloud_mcp/models/financial.py +48 -0
  32. opera_cloud_mcp/models/guest.py +455 -0
  33. opera_cloud_mcp/models/reservation.py +369 -0
  34. opera_cloud_mcp/models/room.py +48 -0
  35. opera_cloud_mcp/resources/__init__.py +12 -0
  36. opera_cloud_mcp/resources/api_specs.py +569 -0
  37. opera_cloud_mcp/resources/health_check.py +189 -0
  38. opera_cloud_mcp/server.py +35 -0
  39. opera_cloud_mcp/tools/__init__.py +6 -0
  40. opera_cloud_mcp/tools/financial_tools.py +785 -0
  41. opera_cloud_mcp/tools/guest_tools.py +818 -0
  42. opera_cloud_mcp/tools/operation_tools.py +904 -0
  43. opera_cloud_mcp/tools/reservation_tools.py +702 -0
  44. opera_cloud_mcp/tools/room_tools.py +802 -0
  45. opera_cloud_mcp/tools/tool_registry.py +641 -0
  46. opera_cloud_mcp/utils/__init__.py +22 -0
  47. opera_cloud_mcp/utils/cache_manager.py +652 -0
  48. opera_cloud_mcp/utils/client_factory.py +196 -0
  49. opera_cloud_mcp/utils/connection_optimizer.py +460 -0
  50. opera_cloud_mcp/utils/exceptions.py +556 -0
  51. opera_cloud_mcp/utils/formatters.py +217 -0
  52. opera_cloud_mcp/utils/observability.py +900 -0
  53. opera_cloud_mcp/utils/resilience_manager.py +754 -0
  54. opera_cloud_mcp/utils/validators.py +258 -0
  55. opera_cloud_mcp-0.2.0.dist-info/METADATA +268 -0
  56. opera_cloud_mcp-0.2.0.dist-info/RECORD +59 -0
  57. opera_cloud_mcp-0.2.0.dist-info/WHEEL +4 -0
  58. opera_cloud_mcp-0.2.0.dist-info/entry_points.txt +2 -0
  59. opera_cloud_mcp-0.2.0.dist-info/licenses/LICENSE +29 -0
@@ -0,0 +1,20 @@
1
+ """
2
+ OPERA Cloud MCP Server.
3
+
4
+ A FastMCP-based Model Context Protocol server for Oracle OPERA Cloud APIs,
5
+ providing AI agents with seamless access to hospitality management functions.
6
+ """
7
+
8
+ __version__ = "0.1.0"
9
+ __author__ = "Opera Cloud MCP Team"
10
+ __description__ = "MCP Server for the Opera Cloud API"
11
+
12
+ # Import main components for easy access
13
+ from opera_cloud_mcp.config.settings import Settings
14
+
15
+ __all__ = [
16
+ "__version__",
17
+ "__author__",
18
+ "__description__",
19
+ "Settings",
20
+ ]
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env python3
2
+ """OPERA Cloud MCP Server - Module Entry Point.
3
+
4
+ Allows running the server as: python -m opera_cloud_mcp
5
+ """
6
+
7
+ import typer
8
+
9
+ from opera_cloud_mcp.cli import main
10
+
11
+ if __name__ == "__main__":
12
+ typer.run(main)
@@ -0,0 +1,381 @@
1
+ """
2
+ OPERA Cloud MCP Authentication Module.
3
+
4
+ This module provides comprehensive authentication and security services
5
+ for the OPERA Cloud MCP server, including OAuth2 authentication,
6
+ security monitoring, audit logging, and threat detection.
7
+ """
8
+
9
+ from pathlib import Path
10
+ from typing import Any, cast
11
+
12
+ from opera_cloud_mcp.auth.audit_logger import AuditLogger, audit_logger
13
+ from opera_cloud_mcp.auth.oauth_handler import OAuthHandler, Token, TokenCache
14
+ from opera_cloud_mcp.auth.secure_oauth_handler import SecureOAuthHandler, SecureToken
15
+ from opera_cloud_mcp.auth.security_enhancements import (
16
+ RateLimiter,
17
+ SecureTokenCache,
18
+ SecurityMonitor,
19
+ TokenBinding,
20
+ security_monitor,
21
+ )
22
+ from opera_cloud_mcp.auth.security_middleware import (
23
+ SecurityMiddleware,
24
+ create_security_middleware,
25
+ )
26
+ from opera_cloud_mcp.config.security_settings import SecuritySettings
27
+ from opera_cloud_mcp.config.settings import Settings
28
+
29
+
30
+ def create_enhanced_oauth_security(
31
+ client_id: str,
32
+ client_secret: str,
33
+ token_url: str,
34
+ enable_security_monitoring: bool = True,
35
+ enable_rate_limiting: bool = True,
36
+ enable_token_binding: bool = True,
37
+ enable_audit_logging: bool = True,
38
+ cache_dir: Path | None = None,
39
+ master_key: bytes | None = None,
40
+ security_settings: SecuritySettings | None = None,
41
+ ) -> tuple[SecureOAuthHandler, SecurityMiddleware, AuditLogger]:
42
+ """
43
+ Create comprehensive OAuth2 security components with enhanced features.
44
+
45
+ This function integrates all enhanced security components including:
46
+ - SecureOAuthHandler with token binding and monitoring
47
+ - Security middleware with threat detection
48
+ - Audit logging with tamper-resistant storage
49
+ - Rate limiting and abuse detection
50
+
51
+ Args:
52
+ client_id: OAuth client ID
53
+ client_secret: OAuth client secret
54
+ token_url: OAuth token endpoint URL
55
+ enable_security_monitoring: Enable comprehensive security monitoring
56
+ enable_rate_limiting: Enable rate limiting and abuse detection
57
+ enable_token_binding: Enable token binding for enhanced security
58
+ enable_audit_logging: Enable tamper-resistant audit logging
59
+ cache_dir: Custom cache directory for secure token storage
60
+ master_key: Master encryption key for token security
61
+ security_settings: Custom security settings (optional)
62
+
63
+ Returns:
64
+ Tuple of (SecureOAuthHandler, SecurityMiddleware, AuditLogger)
65
+ """
66
+ # Use default security settings if not provided
67
+ if security_settings is None:
68
+ # Create a minimal security settings instance with required fields
69
+ security_settings = SecuritySettings(
70
+ enable_security_monitoring=True,
71
+ enable_audit_logging=True,
72
+ enable_rate_limiting=True,
73
+ enable_token_binding=True,
74
+ auth_rate_limit_requests=10,
75
+ auth_rate_limit_window_minutes=5,
76
+ max_failed_attempts=5,
77
+ client_lockout_duration_minutes=30,
78
+ security_event_retention_days=90,
79
+ token_max_lifetime_hours=24,
80
+ token_refresh_threshold_minutes=30,
81
+ token_binding_lifetime_hours=24,
82
+ credential_rotation_interval_days=90,
83
+ enable_credential_validation=True,
84
+ allowed_ip_addresses=None,
85
+ require_https=True,
86
+ min_tls_version="TLSv1.2",
87
+ audit_db_path=None,
88
+ audit_db_encryption_key=None,
89
+ enable_audit_db_compression=True,
90
+ audit_db_max_size_mb=100,
91
+ enable_security_headers=True,
92
+ content_security_policy="default-src 'self'",
93
+ enable_anomaly_detection=True,
94
+ anomaly_detection_sensitivity=0.7,
95
+ enable_ip_reputation_check=True,
96
+ enable_gdpr_mode=False,
97
+ data_retention_policy_days=365,
98
+ enable_pii_anonymization=True,
99
+ enable_automatic_incident_response=True,
100
+ security_notification_webhook=None,
101
+ security_notification_email=None,
102
+ security_testing_mode=False,
103
+ enable_security_debug_logs=False,
104
+ )
105
+
106
+ # Create SecureOAuthHandler with enhanced security features
107
+ secure_oauth_handler = SecureOAuthHandler(
108
+ client_id=client_id,
109
+ client_secret=client_secret,
110
+ token_url=token_url,
111
+ timeout=30, # Default timeout
112
+ max_retries=3, # Default retries
113
+ retry_backoff=1.0, # Default backoff
114
+ enable_persistent_cache=True,
115
+ cache_dir=cache_dir,
116
+ enable_security_monitoring=enable_security_monitoring,
117
+ enable_rate_limiting=enable_rate_limiting,
118
+ enable_token_binding=enable_token_binding,
119
+ master_key=master_key,
120
+ )
121
+
122
+ # Create audit logger if enabled
123
+ audit_logger_instance = None
124
+ if enable_audit_logging:
125
+ audit_db_path = cache_dir / "audit" / "audit.db" if cache_dir else None
126
+ audit_encryption_key = master_key
127
+ audit_logger_instance = AuditLogger(audit_db_path, audit_encryption_key)
128
+ else:
129
+ audit_logger_instance = audit_logger # Use global instance
130
+
131
+ # Create security middleware
132
+ security_middleware = SecurityMiddleware(security_settings)
133
+
134
+ return secure_oauth_handler, security_middleware, audit_logger_instance
135
+
136
+
137
+ def create_oauth_handler(
138
+ settings: Settings,
139
+ enable_security_features: bool = True,
140
+ master_key: bytes | None = None,
141
+ allowed_ips: set[str] | None = None,
142
+ ) -> OAuthHandler | SecureOAuthHandler:
143
+ """
144
+ Create OAuth handler with appropriate security level.
145
+
146
+ Args:
147
+ settings: Application settings instance
148
+ enable_security_features: Whether to use secure OAuth handler
149
+ master_key: Master encryption key for token storage
150
+ allowed_ips: Set of allowed IP addresses
151
+
152
+ Returns:
153
+ OAuth handler instance (secure or basic)
154
+ """
155
+ from opera_cloud_mcp.utils.exceptions import AuthenticationError
156
+
157
+ # Validate required settings
158
+ missing_settings = settings.validate_required_settings()
159
+ if missing_settings:
160
+ raise AuthenticationError(
161
+ f"Missing required settings: {', '.join(missing_settings)}"
162
+ )
163
+
164
+ # Get OAuth configuration from settings
165
+ oauth_config = settings.get_oauth_handler_config()
166
+
167
+ if enable_security_features:
168
+ # Use secure OAuth handler with enhanced features
169
+ return SecureOAuthHandler(
170
+ client_id=oauth_config["client_id"],
171
+ client_secret=oauth_config["client_secret"],
172
+ token_url=oauth_config["token_url"],
173
+ timeout=oauth_config["timeout"],
174
+ max_retries=oauth_config["max_retries"],
175
+ retry_backoff=oauth_config["retry_backoff"],
176
+ enable_persistent_cache=oauth_config["enable_persistent_cache"],
177
+ cache_dir=oauth_config["cache_dir"],
178
+ enable_security_monitoring=True,
179
+ enable_rate_limiting=True,
180
+ enable_token_binding=True,
181
+ master_key=master_key,
182
+ allowed_ips=allowed_ips,
183
+ )
184
+ # Use basic OAuth handler
185
+ return OAuthHandler(**oauth_config)
186
+
187
+
188
+ def create_security_components(
189
+ security_settings: SecuritySettings | None = None,
190
+ audit_db_path: Path | None = None,
191
+ audit_encryption_key: bytes | None = None,
192
+ ) -> tuple[SecurityMiddleware, AuditLogger, SecurityMonitor]:
193
+ """
194
+ Create integrated security components.
195
+
196
+ Args:
197
+ security_settings: Security configuration
198
+ audit_db_path: Custom audit database path
199
+ audit_encryption_key: Custom audit encryption key
200
+
201
+ Returns:
202
+ Tuple of (security_middleware, audit_logger, security_monitor)
203
+ """
204
+ # Use default security settings if none provided
205
+ if security_settings is None:
206
+ # Create a minimal security settings instance with required fields
207
+ security_settings = SecuritySettings(
208
+ enable_security_monitoring=True,
209
+ enable_audit_logging=True,
210
+ enable_rate_limiting=True,
211
+ enable_token_binding=True,
212
+ auth_rate_limit_requests=10,
213
+ auth_rate_limit_window_minutes=5,
214
+ max_failed_attempts=5,
215
+ client_lockout_duration_minutes=30,
216
+ security_event_retention_days=90,
217
+ token_max_lifetime_hours=24,
218
+ token_refresh_threshold_minutes=30,
219
+ token_binding_lifetime_hours=24,
220
+ credential_rotation_interval_days=90,
221
+ enable_credential_validation=True,
222
+ allowed_ip_addresses=None,
223
+ require_https=True,
224
+ min_tls_version="TLSv1.2",
225
+ audit_db_path=None,
226
+ audit_db_encryption_key=None,
227
+ enable_audit_db_compression=True,
228
+ audit_db_max_size_mb=100,
229
+ enable_security_headers=True,
230
+ content_security_policy="default-src 'self'",
231
+ enable_anomaly_detection=True,
232
+ anomaly_detection_sensitivity=0.7,
233
+ enable_ip_reputation_check=True,
234
+ enable_gdpr_mode=False,
235
+ data_retention_policy_days=365,
236
+ enable_pii_anonymization=True,
237
+ enable_automatic_incident_response=True,
238
+ security_notification_webhook=None,
239
+ security_notification_email=None,
240
+ security_testing_mode=False,
241
+ enable_security_debug_logs=False,
242
+ )
243
+
244
+ # Create security middleware
245
+ middleware = create_security_middleware(security_settings)
246
+
247
+ # Create audit logger
248
+ if audit_db_path or audit_encryption_key:
249
+ audit_logger_instance = AuditLogger(audit_db_path, audit_encryption_key)
250
+ else:
251
+ audit_logger_instance = audit_logger # Use global instance
252
+
253
+ # Return components
254
+ return middleware, audit_logger_instance, security_monitor
255
+
256
+
257
+ def _validate_main_settings(
258
+ settings: Settings, validation_result: dict[str, Any]
259
+ ) -> None:
260
+ """Validate main settings."""
261
+ missing_settings = settings.validate_required_settings()
262
+ if missing_settings:
263
+ cast("list[str]", validation_result["errors"]).extend(
264
+ [f"Missing required setting: {setting}" for setting in missing_settings]
265
+ )
266
+ validation_result["valid"] = False
267
+
268
+
269
+ def _validate_security_settings(
270
+ security_settings: SecuritySettings | None, validation_result: dict[str, Any]
271
+ ) -> None:
272
+ """Validate security settings if provided."""
273
+ if security_settings:
274
+ security_warnings = security_settings.validate_security_configuration()
275
+ cast("list[str]", validation_result["warnings"]).extend(security_warnings)
276
+
277
+ # Check for production readiness
278
+ if hasattr(security_settings, "validate_production_readiness"):
279
+ production_errors = security_settings.validate_production_readiness()
280
+ if production_errors:
281
+ cast("list[str]", validation_result["errors"]).extend(production_errors)
282
+ validation_result["valid"] = False
283
+
284
+
285
+ def _add_security_recommendations(
286
+ security_settings: SecuritySettings | None, validation_result: dict[str, Any]
287
+ ) -> None:
288
+ """Add security recommendations."""
289
+ if not security_settings or not security_settings.enable_security_monitoring:
290
+ cast("list[str]", validation_result["recommendations"]).append(
291
+ "Enable security monitoring for production deployments"
292
+ )
293
+
294
+ if not security_settings or not security_settings.enable_audit_logging:
295
+ cast("list[str]", validation_result["recommendations"]).append(
296
+ "Enable audit logging for compliance and security analysis"
297
+ )
298
+
299
+
300
+ def _validate_production_settings(
301
+ settings: Settings,
302
+ security_settings: SecuritySettings | None,
303
+ validation_result: dict[str, Any],
304
+ ) -> None:
305
+ """Validate production-specific settings."""
306
+ if settings.opera_environment == "production":
307
+ if not security_settings or security_settings.security_testing_mode:
308
+ cast("list[str]", validation_result["errors"]).append(
309
+ "Security testing mode must be disabled in production"
310
+ )
311
+ validation_result["valid"] = False
312
+
313
+ if not security_settings or not security_settings.require_https:
314
+ cast("list[str]", validation_result["errors"]).append(
315
+ "HTTPS must be required in production"
316
+ )
317
+ validation_result["valid"] = False
318
+
319
+
320
+ def validate_security_configuration(
321
+ settings: Settings, security_settings: SecuritySettings | None = None
322
+ ) -> dict[str, Any]:
323
+ """
324
+ Validate complete security configuration.
325
+
326
+ Args:
327
+ settings: Main application settings
328
+ security_settings: Security configuration
329
+
330
+ Returns:
331
+ Validation results dictionary
332
+ """
333
+ # Initialize validation result with proper type annotations
334
+ validation_result: dict[str, bool | list[str]] = {
335
+ "valid": True,
336
+ "errors": [],
337
+ "warnings": [],
338
+ "recommendations": [],
339
+ }
340
+
341
+ # Validate main settings
342
+ _validate_main_settings(settings, validation_result)
343
+
344
+ # Validate security settings if provided
345
+ _validate_security_settings(security_settings, validation_result)
346
+
347
+ # Add recommendations based on configuration
348
+ _add_security_recommendations(security_settings, validation_result)
349
+
350
+ # Check for production-specific settings
351
+ _validate_production_settings(settings, security_settings, validation_result)
352
+
353
+ return validation_result
354
+
355
+
356
+ # Export public interface
357
+ __all__ = [
358
+ # OAuth handlers
359
+ "OAuthHandler",
360
+ "SecureOAuthHandler",
361
+ "Token",
362
+ "SecureToken",
363
+ "TokenCache",
364
+ "SecureTokenCache",
365
+ "TokenBinding",
366
+ # Security components
367
+ "SecurityMiddleware",
368
+ "SecurityMonitor",
369
+ "AuditLogger",
370
+ "SecuritySettings",
371
+ "RateLimiter",
372
+ # Factory functions
373
+ "create_oauth_handler",
374
+ "create_enhanced_oauth_security",
375
+ "create_security_components",
376
+ "create_security_middleware",
377
+ "validate_security_configuration",
378
+ # Global instances
379
+ "audit_logger",
380
+ "security_monitor",
381
+ ]