mcp-proxy-adapter-dev 8.11.16__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.
- mcp_proxy_adapter/__init__.py +73 -0
- mcp_proxy_adapter/__main__.py +13 -0
- mcp_proxy_adapter/api/__init__.py +38 -0
- mcp_proxy_adapter/api/app.py +64 -0
- mcp_proxy_adapter/api/command_session_service.py +455 -0
- mcp_proxy_adapter/api/core/__init__.py +19 -0
- mcp_proxy_adapter/api/core/app_factory.py +215 -0
- mcp_proxy_adapter/api/core/app_factory_certificates.py +159 -0
- mcp_proxy_adapter/api/core/app_factory_config.py +75 -0
- mcp_proxy_adapter/api/core/app_factory_routes.py +345 -0
- mcp_proxy_adapter/api/core/app_factory_validators.py +165 -0
- mcp_proxy_adapter/api/core/lifespan_manager/__init__.py +52 -0
- mcp_proxy_adapter/api/core/lifespan_manager/manager.py +354 -0
- mcp_proxy_adapter/api/core/lifespan_manager/queue_config.py +37 -0
- mcp_proxy_adapter/api/core/lifespan_manager/signal_registration.py +74 -0
- mcp_proxy_adapter/api/core/registration/__init__.py +24 -0
- mcp_proxy_adapter/api/core/registration/config_parsers.py +247 -0
- mcp_proxy_adapter/api/core/registration/context_builder.py +130 -0
- mcp_proxy_adapter/api/core/registration/helpers.py +36 -0
- mcp_proxy_adapter/api/core/registration/metadata_builders.py +117 -0
- mcp_proxy_adapter/api/core/registration/models.py +42 -0
- mcp_proxy_adapter/api/core/registration/resolvers.py +195 -0
- mcp_proxy_adapter/api/core/registration/url_builders.py +122 -0
- mcp_proxy_adapter/api/core/registration_context.py +30 -0
- mcp_proxy_adapter/api/core/registration_manager/__init__.py +31 -0
- mcp_proxy_adapter/api/core/registration_manager/helpers.py +307 -0
- mcp_proxy_adapter/api/core/registration_manager/manager.py +584 -0
- mcp_proxy_adapter/api/core/registration_manager/status.py +152 -0
- mcp_proxy_adapter/api/core/registration_tasks.py +387 -0
- mcp_proxy_adapter/api/core/ssl_context_factory.py +99 -0
- mcp_proxy_adapter/api/execute_async_contract.py +124 -0
- mcp_proxy_adapter/api/handlers/__init__.py +335 -0
- mcp_proxy_adapter/api/handlers/command_execution.py +709 -0
- mcp_proxy_adapter/api/handlers/health.py +157 -0
- mcp_proxy_adapter/api/handlers/jsonrpc.py +207 -0
- mcp_proxy_adapter/api/handlers/transfer_notify.py +313 -0
- mcp_proxy_adapter/api/handlers/transfer_sessions.py +287 -0
- mcp_proxy_adapter/api/handlers_async.py +233 -0
- mcp_proxy_adapter/api/health_provider.py +44 -0
- mcp_proxy_adapter/api/jsonrpc_job_lifecycle.py +165 -0
- mcp_proxy_adapter/api/jsonrpc_job_status.py +94 -0
- mcp_proxy_adapter/api/middleware/__init__.py +14 -0
- mcp_proxy_adapter/api/middleware/command_permission_middleware.py +73 -0
- mcp_proxy_adapter/api/middleware/request_logging.py +153 -0
- mcp_proxy_adapter/api/middleware/unified_security.py +367 -0
- mcp_proxy_adapter/api/openapi/__init__.py +18 -0
- mcp_proxy_adapter/api/openapi/command_integration.py +107 -0
- mcp_proxy_adapter/api/openapi/openapi_generator.py +138 -0
- mcp_proxy_adapter/api/openapi/openapi_registry.py +55 -0
- mcp_proxy_adapter/api/public_downloads.py +68 -0
- mcp_proxy_adapter/api/schemas.py +290 -0
- mcp_proxy_adapter/api/tool_integration.py +124 -0
- mcp_proxy_adapter/api/tools.py +244 -0
- mcp_proxy_adapter/api/transfer_session_service.py +329 -0
- mcp_proxy_adapter/api/ws_endpoint.py +653 -0
- mcp_proxy_adapter/api/ws_identity.py +111 -0
- mcp_proxy_adapter/cli/__init__.py +12 -0
- mcp_proxy_adapter/cli/commands/__init__.py +14 -0
- mcp_proxy_adapter/cli/commands/client.py +137 -0
- mcp_proxy_adapter/cli/commands/config_docs/__init__.py +23 -0
- mcp_proxy_adapter/cli/commands/config_docs/cli.py +63 -0
- mcp_proxy_adapter/cli/commands/config_docs/declared_settings.py +45 -0
- mcp_proxy_adapter/cli/commands/config_docs/render.py +58 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/__init__.py +61 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/_chunk.py +19 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/authentication.py +127 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/best_practices.py +166 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/common_patterns.py +154 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/overview.py +135 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/queue_manager.py +140 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/registration.py +212 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/server.py +193 -0
- mcp_proxy_adapter/cli/commands/config_docs/sections/troubleshooting.py +215 -0
- mcp_proxy_adapter/cli/commands/config_generate.py +95 -0
- mcp_proxy_adapter/cli/commands/config_generate_parts/__init__.py +1 -0
- mcp_proxy_adapter/cli/commands/config_generate_parts/arguments.py +44 -0
- mcp_proxy_adapter/cli/commands/config_generate_parts/arguments_core.py +141 -0
- mcp_proxy_adapter/cli/commands/config_generate_parts/arguments_queue.py +140 -0
- mcp_proxy_adapter/cli/commands/config_generate_parts/arguments_validation.py +142 -0
- mcp_proxy_adapter/cli/commands/config_generate_parts/generation.py +365 -0
- mcp_proxy_adapter/cli/commands/config_generate_parts/parsing.py +122 -0
- mcp_proxy_adapter/cli/commands/config_validate.py +154 -0
- mcp_proxy_adapter/cli/commands/info.py +297 -0
- mcp_proxy_adapter/cli/commands/server.py +361 -0
- mcp_proxy_adapter/cli/commands/sets.py +165 -0
- mcp_proxy_adapter/cli/commands/standalone_entry.py +25 -0
- mcp_proxy_adapter/cli/commands/testconfig.py +205 -0
- mcp_proxy_adapter/cli/examples/__init__.py +9 -0
- mcp_proxy_adapter/cli/main.py +75 -0
- mcp_proxy_adapter/cli/parser.py +244 -0
- mcp_proxy_adapter/cli/validators.py +389 -0
- mcp_proxy_adapter/client/jsonrpc_client/__init__.py +139 -0
- mcp_proxy_adapter/client/jsonrpc_client/client.py +257 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api.py +369 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api_bases/__init__.py +1 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api_bases/async_base.py +241 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api_bases/basic_base.py +150 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api_bases/catalog_base.py +178 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api_bases/constants.py +38 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api_bases/helpers.py +66 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api_bases/queue_base.py +137 -0
- mcp_proxy_adapter/client/jsonrpc_client/exceptions/__init__.py +70 -0
- mcp_proxy_adapter/client/jsonrpc_client/exceptions/base.py +102 -0
- mcp_proxy_adapter/client/jsonrpc_client/exceptions/classification.py +143 -0
- mcp_proxy_adapter/client/jsonrpc_client/exceptions/request_errors.py +169 -0
- mcp_proxy_adapter/client/jsonrpc_client/exceptions/schema_errors.py +90 -0
- mcp_proxy_adapter/client/jsonrpc_client/exceptions/transfer_errors.py +48 -0
- mcp_proxy_adapter/client/jsonrpc_client/exceptions/transport_errors.py +153 -0
- mcp_proxy_adapter/client/jsonrpc_client/execution_status_observer.py +66 -0
- mcp_proxy_adapter/client/jsonrpc_client/job_event_registry.py +322 -0
- mcp_proxy_adapter/client/jsonrpc_client/job_tracking_mixin.py +206 -0
- mcp_proxy_adapter/client/jsonrpc_client/job_tracking_types.py +135 -0
- mcp_proxy_adapter/client/jsonrpc_client/openapi_validator.py +127 -0
- mcp_proxy_adapter/client/jsonrpc_client/operation_state.py +221 -0
- mcp_proxy_adapter/client/jsonrpc_client/proxy_api.py +93 -0
- mcp_proxy_adapter/client/jsonrpc_client/proxy_api_bases/__init__.py +1 -0
- mcp_proxy_adapter/client/jsonrpc_client/proxy_api_bases/client_base.py +117 -0
- mcp_proxy_adapter/client/jsonrpc_client/proxy_api_bases/lifecycle_base.py +222 -0
- mcp_proxy_adapter/client/jsonrpc_client/proxy_api_bases/register_base.py +230 -0
- mcp_proxy_adapter/client/jsonrpc_client/proxy_api_bases/uuid_base.py +95 -0
- mcp_proxy_adapter/client/jsonrpc_client/queue_api.py +302 -0
- mcp_proxy_adapter/client/jsonrpc_client/queue_status.py +192 -0
- mcp_proxy_adapter/client/jsonrpc_client/schema_generator.py +143 -0
- mcp_proxy_adapter/client/jsonrpc_client/schema_generator_bases/__init__.py +1 -0
- mcp_proxy_adapter/client/jsonrpc_client/schema_generator_bases/models.py +45 -0
- mcp_proxy_adapter/client/jsonrpc_client/schema_generator_bases/parse_base.py +215 -0
- mcp_proxy_adapter/client/jsonrpc_client/schema_generator_bases/validate_base.py +181 -0
- mcp_proxy_adapter/client/jsonrpc_client/transfer_integrity.py +57 -0
- mcp_proxy_adapter/client/jsonrpc_client/transport/__init__.py +161 -0
- mcp_proxy_adapter/client/jsonrpc_client/transport/constants.py +30 -0
- mcp_proxy_adapter/client/jsonrpc_client/transport/helpers.py +118 -0
- mcp_proxy_adapter/client/jsonrpc_client/transport/http_base.py +325 -0
- mcp_proxy_adapter/client/jsonrpc_client/transport/rpc_base.py +311 -0
- mcp_proxy_adapter/client/jsonrpc_client/transport/tls_base.py +295 -0
- mcp_proxy_adapter/client/jsonrpc_client/transport/transfer_base.py +282 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_command_session.py +230 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_command_session_bases/__init__.py +1 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_command_session_bases/core_base.py +154 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_command_session_bases/helpers.py +72 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_command_session_bases/wait_base.py +279 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_job_status.py +337 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_job_status_parts/__init__.py +1 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_job_status_parts/channel.py +159 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_job_status_parts/command_channel.py +154 -0
- mcp_proxy_adapter/client/jsonrpc_client/ws_job_status_parts/helpers.py +76 -0
- mcp_proxy_adapter/client/proxy.py +124 -0
- mcp_proxy_adapter/commands/__init__.py +27 -0
- mcp_proxy_adapter/commands/base.py +998 -0
- mcp_proxy_adapter/commands/builtin_commands.py +186 -0
- mcp_proxy_adapter/commands/command_help_info.py +101 -0
- mcp_proxy_adapter/commands/command_registry/__init__.py +55 -0
- mcp_proxy_adapter/commands/command_registry/builtins_part.py +206 -0
- mcp_proxy_adapter/commands/command_registry/facade.py +310 -0
- mcp_proxy_adapter/commands/command_registry/lifecycle_part.py +232 -0
- mcp_proxy_adapter/commands/command_registry/loader.py +145 -0
- mcp_proxy_adapter/commands/command_registry/mutations_part.py +228 -0
- mcp_proxy_adapter/commands/command_registry/part_base.py +59 -0
- mcp_proxy_adapter/commands/command_registry/queries_part.py +304 -0
- mcp_proxy_adapter/commands/config_command.py +208 -0
- mcp_proxy_adapter/commands/dependency_container.py +35 -0
- mcp_proxy_adapter/commands/echo_command.py +97 -0
- mcp_proxy_adapter/commands/health_command.py +162 -0
- mcp_proxy_adapter/commands/help_command.py +296 -0
- mcp_proxy_adapter/commands/hooks.py +590 -0
- mcp_proxy_adapter/commands/job_metadata.py +26 -0
- mcp_proxy_adapter/commands/load_command.py +134 -0
- mcp_proxy_adapter/commands/nested_validation.py +185 -0
- mcp_proxy_adapter/commands/plugins_command.py +250 -0
- mcp_proxy_adapter/commands/proxy_registration_command.py +475 -0
- mcp_proxy_adapter/commands/queue/__init__.py +83 -0
- mcp_proxy_adapter/commands/queue/add_job_command.py +358 -0
- mcp_proxy_adapter/commands/queue/command_execution_diagnostics.py +100 -0
- mcp_proxy_adapter/commands/queue/delete_job_command.py +92 -0
- mcp_proxy_adapter/commands/queue/get_logs_command.py +90 -0
- mcp_proxy_adapter/commands/queue/get_status_command.py +105 -0
- mcp_proxy_adapter/commands/queue/health_command.py +44 -0
- mcp_proxy_adapter/commands/queue/job_domain_errors.py +117 -0
- mcp_proxy_adapter/commands/queue/job_params.py +163 -0
- mcp_proxy_adapter/commands/queue/jobs/__init__.py +41 -0
- mcp_proxy_adapter/commands/queue/jobs/basic_jobs.py +205 -0
- mcp_proxy_adapter/commands/queue/jobs/command_execution_job.py +198 -0
- mcp_proxy_adapter/commands/queue/jobs/command_restore_base.py +48 -0
- mcp_proxy_adapter/commands/queue/jobs/command_run_base.py +389 -0
- mcp_proxy_adapter/commands/queue/jobs/job_helpers.py +80 -0
- mcp_proxy_adapter/commands/queue/jobs/long_jobs.py +257 -0
- mcp_proxy_adapter/commands/queue/list_jobs_command.py +127 -0
- mcp_proxy_adapter/commands/queue/start_job_command.py +97 -0
- mcp_proxy_adapter/commands/queue/stop_job_command.py +107 -0
- mcp_proxy_adapter/commands/queue_commands.py +49 -0
- mcp_proxy_adapter/commands/registration_status_command.py +83 -0
- mcp_proxy_adapter/commands/reload_command.py +183 -0
- mcp_proxy_adapter/commands/result.py +201 -0
- mcp_proxy_adapter/commands/result_helpers.py +43 -0
- mcp_proxy_adapter/commands/role_test_command.py +119 -0
- mcp_proxy_adapter/commands/roles_management_command/__init__.py +58 -0
- mcp_proxy_adapter/commands/roles_management_command/actions_part.py +400 -0
- mcp_proxy_adapter/commands/roles_management_command/dispatch_part.py +239 -0
- mcp_proxy_adapter/commands/roles_management_command/facade.py +233 -0
- mcp_proxy_adapter/commands/roles_management_command/part_base.py +61 -0
- mcp_proxy_adapter/commands/roles_management_command/results.py +105 -0
- mcp_proxy_adapter/commands/roles_management_command/storage_part.py +181 -0
- mcp_proxy_adapter/commands/schema_helpers.py +45 -0
- mcp_proxy_adapter/commands/settings_command.py +205 -0
- mcp_proxy_adapter/commands/transfer_command_support.py +83 -0
- mcp_proxy_adapter/commands/transfer_download_begin_command.py +245 -0
- mcp_proxy_adapter/commands/transfer_download_status_command.py +121 -0
- mcp_proxy_adapter/commands/transfer_schema_support.py +96 -0
- mcp_proxy_adapter/commands/transfer_upload_begin_command.py +254 -0
- mcp_proxy_adapter/commands/transfer_upload_complete_command.py +161 -0
- mcp_proxy_adapter/commands/transfer_upload_status_command.py +122 -0
- mcp_proxy_adapter/commands/transport_management_command.py +144 -0
- mcp_proxy_adapter/commands/unload_command.py +109 -0
- mcp_proxy_adapter/config.py +30 -0
- mcp_proxy_adapter/core/__init__.py +8 -0
- mcp_proxy_adapter/core/app_factory/__init__.py +17 -0
- mcp_proxy_adapter/core/app_factory/app_creator.py +66 -0
- mcp_proxy_adapter/core/app_factory/config_loader.py +125 -0
- mcp_proxy_adapter/core/app_factory/factory.py +158 -0
- mcp_proxy_adapter/core/app_factory/server_runner.py +152 -0
- mcp_proxy_adapter/core/app_factory/ssl_config.py +194 -0
- mcp_proxy_adapter/core/app_factory/validators.py +57 -0
- mcp_proxy_adapter/core/async_context.py +28 -0
- mcp_proxy_adapter/core/auth/__init__.py +18 -0
- mcp_proxy_adapter/core/auth/certificate_validator.py +239 -0
- mcp_proxy_adapter/core/auth/models.py +47 -0
- mcp_proxy_adapter/core/auth/mtls_validator.py +84 -0
- mcp_proxy_adapter/core/auth/token_validator.py +114 -0
- mcp_proxy_adapter/core/auth_validator.py +137 -0
- mcp_proxy_adapter/core/certificate/__init__.py +20 -0
- mcp_proxy_adapter/core/certificate/certificate_validator/__init__.py +55 -0
- mcp_proxy_adapter/core/certificate/certificate_validator/facade.py +340 -0
- mcp_proxy_adapter/core/certificate/certificate_validator/info_part.py +130 -0
- mcp_proxy_adapter/core/certificate/certificate_validator/key_part.py +146 -0
- mcp_proxy_adapter/core/certificate/certificate_validator/part_base.py +65 -0
- mcp_proxy_adapter/core/certificate/certificate_validator/revocation_part.py +112 -0
- mcp_proxy_adapter/core/client/__init__.py +11 -0
- mcp_proxy_adapter/core/client/auth_handler.py +120 -0
- mcp_proxy_adapter/core/client/client.py +314 -0
- mcp_proxy_adapter/core/client/factory.py +110 -0
- mcp_proxy_adapter/core/client/request_handler.py +122 -0
- mcp_proxy_adapter/core/client/ssl_handler.py +105 -0
- mcp_proxy_adapter/core/client_manager.py +281 -0
- mcp_proxy_adapter/core/client_security/__init__.py +53 -0
- mcp_proxy_adapter/core/client_security/auth_part.py +227 -0
- mcp_proxy_adapter/core/client_security/cert_part.py +124 -0
- mcp_proxy_adapter/core/client_security/facade.py +181 -0
- mcp_proxy_adapter/core/client_security/part_base.py +62 -0
- mcp_proxy_adapter/core/client_security/ssl_part.py +275 -0
- mcp_proxy_adapter/core/config/__init__.py +29 -0
- mcp_proxy_adapter/core/config/config.py +963 -0
- mcp_proxy_adapter/core/config/config_factory.py +16 -0
- mcp_proxy_adapter/core/config/config_graph.py +250 -0
- mcp_proxy_adapter/core/config/config_loader.py +70 -0
- mcp_proxy_adapter/core/config/env_placeholders.py +52 -0
- mcp_proxy_adapter/core/config/feature_manager.py +109 -0
- mcp_proxy_adapter/core/config/orchestration_section.py +119 -0
- mcp_proxy_adapter/core/config/reload_violations.py +269 -0
- mcp_proxy_adapter/core/config/section_validators.py +190 -0
- mcp_proxy_adapter/core/config/settings_declaration.py +255 -0
- mcp_proxy_adapter/core/config/simple_config.py +893 -0
- mcp_proxy_adapter/core/config/simple_config_generator.py +917 -0
- mcp_proxy_adapter/core/config/simple_config_validator.py +333 -0
- mcp_proxy_adapter/core/config/validators/__init__.py +29 -0
- mcp_proxy_adapter/core/config/validators/auth_validator.py +146 -0
- mcp_proxy_adapter/core/config/validators/base_validator.py +102 -0
- mcp_proxy_adapter/core/config/validators/certificate_validator_helper.py +114 -0
- mcp_proxy_adapter/core/config/validators/client_validator.py +131 -0
- mcp_proxy_adapter/core/config/validators/job_push_validator.py +55 -0
- mcp_proxy_adapter/core/config/validators/queue_manager_validator.py +133 -0
- mcp_proxy_adapter/core/config/validators/registration_validator.py +366 -0
- mcp_proxy_adapter/core/config/validators/server_validation_validator.py +154 -0
- mcp_proxy_adapter/core/config/validators/server_validator.py +326 -0
- mcp_proxy_adapter/core/config/validators/ssl_validator.py +221 -0
- mcp_proxy_adapter/core/config/websocket_validator.py +99 -0
- mcp_proxy_adapter/core/config_validator.py +29 -0
- mcp_proxy_adapter/core/constants.py +201 -0
- mcp_proxy_adapter/core/crl_utils.py +338 -0
- mcp_proxy_adapter/core/date_utils.py +119 -0
- mcp_proxy_adapter/core/delivery/__init__.py +35 -0
- mcp_proxy_adapter/core/delivery/contracts.py +57 -0
- mcp_proxy_adapter/core/delivery/exceptions.py +19 -0
- mcp_proxy_adapter/core/delivery/terminal_replay_store.py +129 -0
- mcp_proxy_adapter/core/delivery/ws_delivery_manager.py +117 -0
- mcp_proxy_adapter/core/domain_errors.py +189 -0
- mcp_proxy_adapter/core/error_handling.py +98 -0
- mcp_proxy_adapter/core/errors/__init__.py +259 -0
- mcp_proxy_adapter/core/errors/config_errors.py +142 -0
- mcp_proxy_adapter/core/file_utils.py +94 -0
- mcp_proxy_adapter/core/job_manager.py +115 -0
- mcp_proxy_adapter/core/job_push/__init__.py +124 -0
- mcp_proxy_adapter/core/job_push/caller_loss.py +89 -0
- mcp_proxy_adapter/core/job_push/engine.py +282 -0
- mcp_proxy_adapter/core/job_push/events/__init__.py +111 -0
- mcp_proxy_adapter/core/job_push/events/builders.py +282 -0
- mcp_proxy_adapter/core/job_push/events/command_session_payloads.py +50 -0
- mcp_proxy_adapter/core/job_push/events/delivery_payloads.py +52 -0
- mcp_proxy_adapter/core/job_push/events/event_names.py +163 -0
- mcp_proxy_adapter/core/job_push/events/job_payloads.py +83 -0
- mcp_proxy_adapter/core/job_push/events/transfer_payloads.py +72 -0
- mcp_proxy_adapter/core/job_push/execute_async_deliver_guard.py +55 -0
- mcp_proxy_adapter/core/job_push/finish_signal.py +91 -0
- mcp_proxy_adapter/core/job_push/hooks.py +53 -0
- mcp_proxy_adapter/core/job_push/job_status_accumulator.py +376 -0
- mcp_proxy_adapter/core/job_push/lifespan_wiring.py +252 -0
- mcp_proxy_adapter/core/job_push/notifier.py +139 -0
- mcp_proxy_adapter/core/job_push/notifier_policy.py +38 -0
- mcp_proxy_adapter/core/job_push/queue_custom_push.py +67 -0
- mcp_proxy_adapter/core/job_push/subscriptions.py +160 -0
- mcp_proxy_adapter/core/job_push/transfer_correlation.py +47 -0
- mcp_proxy_adapter/core/job_push/transfer_push.py +135 -0
- mcp_proxy_adapter/core/json_utils.py +81 -0
- mcp_proxy_adapter/core/logging/__init__.py +42 -0
- mcp_proxy_adapter/core/logging/formatters.py +55 -0
- mcp_proxy_adapter/core/logging/global_logger.py +41 -0
- mcp_proxy_adapter/core/logging/request_logger.py +50 -0
- mcp_proxy_adapter/core/logging/setup.py +190 -0
- mcp_proxy_adapter/core/logging/worker.py +107 -0
- mcp_proxy_adapter/core/mtls_asgi_app.py +216 -0
- mcp_proxy_adapter/core/mtls_server.py +180 -0
- mcp_proxy_adapter/core/orchestration/__init__.py +90 -0
- mcp_proxy_adapter/core/orchestration/candidate_validator.py +196 -0
- mcp_proxy_adapter/core/orchestration/catalog_builder.py +136 -0
- mcp_proxy_adapter/core/orchestration/catalog_snapshot.py +115 -0
- mcp_proxy_adapter/core/orchestration/command_record.py +43 -0
- mcp_proxy_adapter/core/orchestration/discovery_client.py +229 -0
- mcp_proxy_adapter/core/orchestration/orchestration_api.py +273 -0
- mcp_proxy_adapter/core/orchestration/orchestration_config.py +146 -0
- mcp_proxy_adapter/core/orchestration/orchestration_errors.py +305 -0
- mcp_proxy_adapter/core/orchestration/orchestration_lifespan.py +199 -0
- mcp_proxy_adapter/core/orchestration/parameter_graph.py +106 -0
- mcp_proxy_adapter/core/orchestration/polling_loop.py +281 -0
- mcp_proxy_adapter/core/orchestration/server_record.py +37 -0
- mcp_proxy_adapter/core/orchestration/snapshot_holder.py +90 -0
- mcp_proxy_adapter/core/orchestration/tool_context_exposure.py +83 -0
- mcp_proxy_adapter/core/orchestration/tool_context_snapshot.py +164 -0
- mcp_proxy_adapter/core/path_utils.py +220 -0
- mcp_proxy_adapter/core/protocol_manager.py +260 -0
- mcp_proxy_adapter/core/proxy/__init__.py +62 -0
- mcp_proxy_adapter/core/proxy/auth_manager.py +110 -0
- mcp_proxy_adapter/core/proxy_client.py +252 -0
- mcp_proxy_adapter/core/proxy_registration.py +55 -0
- mcp_proxy_adapter/core/role_utils.py +166 -0
- mcp_proxy_adapter/core/server_adapter.py +302 -0
- mcp_proxy_adapter/core/server_engine.py +384 -0
- mcp_proxy_adapter/core/settings.py +299 -0
- mcp_proxy_adapter/core/signal_handler.py +136 -0
- mcp_proxy_adapter/core/ssl_utils.py +482 -0
- mcp_proxy_adapter/core/transport_manager.py +168 -0
- mcp_proxy_adapter/core/utils.py +74 -0
- mcp_proxy_adapter/core/validation/__init__.py +21 -0
- mcp_proxy_adapter/core/validation/config_validator.py +256 -0
- mcp_proxy_adapter/core/validation/file_validator.py +229 -0
- mcp_proxy_adapter/core/validation/protocol_validator.py +322 -0
- mcp_proxy_adapter/core/validation/proxy_registration_validator.py +268 -0
- mcp_proxy_adapter/core/validation/security_validator.py +300 -0
- mcp_proxy_adapter/core/validation/validation_result.py +34 -0
- mcp_proxy_adapter/core/validation/validator_support.py +64 -0
- mcp_proxy_adapter/core/validation_utils.py +160 -0
- mcp_proxy_adapter/core/ws_timeouts.py +88 -0
- mcp_proxy_adapter/custom_openapi.py +93 -0
- mcp_proxy_adapter/examples/PROTOCOL_EXAMPLES.md +79 -0
- mcp_proxy_adapter/examples/README.md +272 -0
- mcp_proxy_adapter/examples/README_EN.md +258 -0
- mcp_proxy_adapter/examples/SECURITY_TESTING.md +455 -0
- mcp_proxy_adapter/examples/__init__.py +16 -0
- mcp_proxy_adapter/examples/basic_framework/__init__.py +9 -0
- mcp_proxy_adapter/examples/basic_framework/commands/__init__.py +4 -0
- mcp_proxy_adapter/examples/basic_framework/configs/http_auth.json +21 -0
- mcp_proxy_adapter/examples/basic_framework/configs/http_simple.json +21 -0
- mcp_proxy_adapter/examples/basic_framework/configs/https_auth.json +21 -0
- mcp_proxy_adapter/examples/basic_framework/configs/https_no_protocol_middleware.json +21 -0
- mcp_proxy_adapter/examples/basic_framework/configs/https_simple.json +21 -0
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_no_protocol_middleware.json +21 -0
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_no_roles.json +21 -0
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_simple.json +21 -0
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_with_registration.json +73 -0
- mcp_proxy_adapter/examples/basic_framework/configs/mtls_with_roles.json +21 -0
- mcp_proxy_adapter/examples/basic_framework/hooks/__init__.py +4 -0
- mcp_proxy_adapter/examples/basic_framework/main.py +123 -0
- mcp_proxy_adapter/examples/basic_framework/roles.json +1 -0
- mcp_proxy_adapter/examples/bug_report_security_framework.md +141 -0
- mcp_proxy_adapter/examples/cert_config.json +1 -0
- mcp_proxy_adapter/examples/certs/cert_config.json +1 -0
- mcp_proxy_adapter/examples/check_config.py +71 -0
- mcp_proxy_adapter/examples/check_config_split_parts/__init__.py +3 -0
- mcp_proxy_adapter/examples/check_config_split_parts/checker.py +247 -0
- mcp_proxy_adapter/examples/check_config_split_parts/cli.py +68 -0
- mcp_proxy_adapter/examples/check_config_split_parts/commands.py +102 -0
- mcp_proxy_adapter/examples/cli_config_examples/__init__.py +8 -0
- mcp_proxy_adapter/examples/cli_config_examples/examples_configs/http.json +69 -0
- mcp_proxy_adapter/examples/cli_config_examples/examples_configs/https_token_roles.json +84 -0
- mcp_proxy_adapter/examples/cli_config_examples/examples_configs/mtls_roles.json +84 -0
- mcp_proxy_adapter/examples/cli_config_examples/http_basic.py +97 -0
- mcp_proxy_adapter/examples/cli_config_examples/https_token.py +128 -0
- mcp_proxy_adapter/examples/cli_config_examples/mtls_roles.py +140 -0
- mcp_proxy_adapter/examples/client_configs/api_key_client.json +1 -0
- mcp_proxy_adapter/examples/client_configs/basic_auth_client.json +1 -0
- mcp_proxy_adapter/examples/client_configs/certificate_client.json +1 -0
- mcp_proxy_adapter/examples/client_configs/jwt_client.json +1 -0
- mcp_proxy_adapter/examples/client_configs/no_auth_client.json +1 -0
- mcp_proxy_adapter/examples/client_usage_example.py +216 -0
- mcp_proxy_adapter/examples/commands/__init__.py +5 -0
- mcp_proxy_adapter/examples/comprehensive/__init__.py +10 -0
- mcp_proxy_adapter/examples/comprehensive/run.py +906 -0
- mcp_proxy_adapter/examples/comprehensive_config.json +10 -0
- mcp_proxy_adapter/examples/config.json +10 -0
- mcp_proxy_adapter/examples/config_builder.py +272 -0
- mcp_proxy_adapter/examples/config_cli.py +340 -0
- mcp_proxy_adapter/examples/config_factory.py +325 -0
- mcp_proxy_adapter/examples/configs/full_featured.json +10 -0
- mcp_proxy_adapter/examples/configs/http_auth.json +10 -0
- mcp_proxy_adapter/examples/configs/http_simple.json +10 -0
- mcp_proxy_adapter/examples/configs/http_token.json +10 -0
- mcp_proxy_adapter/examples/configs/https_auth.json +10 -0
- mcp_proxy_adapter/examples/configs/https_simple.json +10 -0
- mcp_proxy_adapter/examples/configs/https_token.json +10 -0
- mcp_proxy_adapter/examples/configs/mtls_no_roles.json +10 -0
- mcp_proxy_adapter/examples/configs/mtls_simple.json +10 -0
- mcp_proxy_adapter/examples/configs/mtls_with_proxy.json +10 -0
- mcp_proxy_adapter/examples/configs/mtls_with_roles.json +10 -0
- mcp_proxy_adapter/examples/configs/roles.json +1 -0
- mcp_proxy_adapter/examples/create_test_configs.py +216 -0
- mcp_proxy_adapter/examples/debug_role_chain.py +192 -0
- mcp_proxy_adapter/examples/demo_client.py +339 -0
- mcp_proxy_adapter/examples/examples_correct/http_example.json +10 -0
- mcp_proxy_adapter/examples/full_application/__init__.py +11 -0
- mcp_proxy_adapter/examples/full_application/commands/__init__.py +32 -0
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +75 -0
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +101 -0
- mcp_proxy_adapter/examples/full_application/commands/embed_job_status_command.py +133 -0
- mcp_proxy_adapter/examples/full_application/commands/embed_queue_command.py +153 -0
- mcp_proxy_adapter/examples/full_application/commands/long_running_command.py +175 -0
- mcp_proxy_adapter/examples/full_application/commands/slow_start_long_task_command.py +172 -0
- mcp_proxy_adapter/examples/full_application/configs/http_basic.json +73 -0
- mcp_proxy_adapter/examples/full_application/configs/http_basic_smart_assistant_proxy3004.json +67 -0
- mcp_proxy_adapter/examples/full_application/configs/http_no_registration.json +72 -0
- mcp_proxy_adapter/examples/full_application/configs/http_token.json +69 -0
- mcp_proxy_adapter/examples/full_application/configs/http_token_roles.json +81 -0
- mcp_proxy_adapter/examples/full_application/configs/http_token_roles_smart_assistant_proxy3004.json +81 -0
- mcp_proxy_adapter/examples/full_application/configs/http_token_smart_assistant_proxy3004.json +69 -0
- mcp_proxy_adapter/examples/full_application/configs/https_basic.json +74 -0
- mcp_proxy_adapter/examples/full_application/configs/https_basic_smart_assistant_proxy3004.json +81 -0
- mcp_proxy_adapter/examples/full_application/configs/https_token.json +76 -0
- mcp_proxy_adapter/examples/full_application/configs/https_token_roles.json +88 -0
- mcp_proxy_adapter/examples/full_application/configs/https_token_roles_smart_assistant_proxy3004.json +95 -0
- mcp_proxy_adapter/examples/full_application/configs/https_token_smart_assistant_proxy3004.json +83 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_no_roles.json +78 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_no_roles_correct.json +76 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_no_roles_smart_assistant_proxy3004.json +83 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_no_security.json +77 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_with_roles.json +82 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_with_roles_correct.json +88 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_with_roles_smart_assistant_proxy3004.json +95 -0
- mcp_proxy_adapter/examples/full_application/configs/mtls_ws_repro.json +76 -0
- mcp_proxy_adapter/examples/full_application/configs/proxy_server.json +64 -0
- mcp_proxy_adapter/examples/full_application/configs/proxy_server_https.json +63 -0
- mcp_proxy_adapter/examples/full_application/configs/proxy_server_mtls.json +63 -0
- mcp_proxy_adapter/examples/full_application/example_support.py +45 -0
- mcp_proxy_adapter/examples/full_application/hooks/__init__.py +4 -0
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +51 -0
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +46 -0
- mcp_proxy_adapter/examples/full_application/main.py +95 -0
- mcp_proxy_adapter/examples/full_application/main_modules/__init__.py +1 -0
- mcp_proxy_adapter/examples/full_application/main_modules/registration.py +122 -0
- mcp_proxy_adapter/examples/full_application/main_modules/runner.py +310 -0
- mcp_proxy_adapter/examples/full_application/proxy_commands/__init__.py +113 -0
- mcp_proxy_adapter/examples/full_application/proxy_commands/_shared.py +8 -0
- mcp_proxy_adapter/examples/full_application/proxy_commands/lifecycle_commands.py +196 -0
- mcp_proxy_adapter/examples/full_application/proxy_commands/register_command.py +254 -0
- mcp_proxy_adapter/examples/full_application/proxy_commands/registry_state.py +8 -0
- mcp_proxy_adapter/examples/full_application/proxy_commands/results.py +142 -0
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +162 -0
- mcp_proxy_adapter/examples/full_application/proxy_schemas.py +91 -0
- mcp_proxy_adapter/examples/full_application/roles.json +1 -0
- mcp_proxy_adapter/examples/full_application/test_client.py +341 -0
- mcp_proxy_adapter/examples/full_application/test_minimal_server.py +57 -0
- mcp_proxy_adapter/examples/full_application/test_queue_and_descriptions.py +283 -0
- mcp_proxy_adapter/examples/full_application/test_server.py +221 -0
- mcp_proxy_adapter/examples/full_application/test_simple_server.py +141 -0
- mcp_proxy_adapter/examples/generate_all_certificates.py +74 -0
- mcp_proxy_adapter/examples/generate_config.py +44 -0
- mcp_proxy_adapter/examples/generate_config_parts/__init__.py +3 -0
- mcp_proxy_adapter/examples/generate_config_parts/builders.py +234 -0
- mcp_proxy_adapter/examples/generate_config_parts/cli.py +260 -0
- mcp_proxy_adapter/examples/generate_config_parts/outputs.py +137 -0
- mcp_proxy_adapter/examples/generator_validator_compatibility_report.md +127 -0
- mcp_proxy_adapter/examples/http_proxy_example.json +17 -0
- mcp_proxy_adapter/examples/https_proxy_example.json +17 -0
- mcp_proxy_adapter/examples/job_tracking_demo.py +235 -0
- mcp_proxy_adapter/examples/proxy_server_support.py +384 -0
- mcp_proxy_adapter/examples/queue_demo_simple.py +37 -0
- mcp_proxy_adapter/examples/queue_demo_simple_parts/__init__.py +3 -0
- mcp_proxy_adapter/examples/queue_demo_simple_parts/_shared.py +8 -0
- mcp_proxy_adapter/examples/queue_demo_simple_parts/demo.py +213 -0
- mcp_proxy_adapter/examples/queue_demo_simple_parts/mock_commands.py +130 -0
- mcp_proxy_adapter/examples/queue_demo_simple_parts/mock_manager.py +272 -0
- mcp_proxy_adapter/examples/queue_example_support.py +36 -0
- mcp_proxy_adapter/examples/queue_fire_and_forget_example.py +370 -0
- mcp_proxy_adapter/examples/queue_server_demo.py +73 -0
- mcp_proxy_adapter/examples/queue_server_example.py +76 -0
- mcp_proxy_adapter/examples/queue_server_simple.py +251 -0
- mcp_proxy_adapter/examples/required_certificates.py +216 -0
- mcp_proxy_adapter/examples/run_example.py +119 -0
- mcp_proxy_adapter/examples/run_full_test_suite.py +674 -0
- mcp_proxy_adapter/examples/run_proxy_server.py +118 -0
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +876 -0
- mcp_proxy_adapter/examples/security_test/__init__.py +18 -0
- mcp_proxy_adapter/examples/security_test/auth_manager.py +49 -0
- mcp_proxy_adapter/examples/security_test/ssl_context_manager.py +144 -0
- mcp_proxy_adapter/examples/security_test/test_client.py +218 -0
- mcp_proxy_adapter/examples/security_test/test_result.py +23 -0
- mcp_proxy_adapter/examples/security_test_client.py +103 -0
- mcp_proxy_adapter/examples/server_configs/config_basic_http.json +16 -0
- mcp_proxy_adapter/examples/server_configs/config_http_token.json +16 -0
- mcp_proxy_adapter/examples/server_configs/config_https.json +16 -0
- mcp_proxy_adapter/examples/server_configs/config_https_token.json +16 -0
- mcp_proxy_adapter/examples/server_configs/config_mtls.json +16 -0
- mcp_proxy_adapter/examples/server_configs/config_proxy_registration.json +15 -0
- mcp_proxy_adapter/examples/server_configs/config_simple.json +9 -0
- mcp_proxy_adapter/examples/server_configs/http_simple.json +14 -0
- mcp_proxy_adapter/examples/server_configs/http_token.json +14 -0
- mcp_proxy_adapter/examples/server_configs/https_simple.json +14 -0
- mcp_proxy_adapter/examples/server_configs/https_token.json +14 -0
- mcp_proxy_adapter/examples/server_configs/mtls_no_roles.json +8 -0
- mcp_proxy_adapter/examples/server_configs/mtls_test.json +8 -0
- mcp_proxy_adapter/examples/server_configs/mtls_with_roles.json +14 -0
- mcp_proxy_adapter/examples/server_configs/roles.json +1 -0
- mcp_proxy_adapter/examples/setup/__init__.py +48 -0
- mcp_proxy_adapter/examples/setup/certificate_manager.py +384 -0
- mcp_proxy_adapter/examples/setup/config_generator.py +6 -0
- mcp_proxy_adapter/examples/setup/config_validator.py +140 -0
- mcp_proxy_adapter/examples/setup/environment_setup.py +143 -0
- mcp_proxy_adapter/examples/setup/test_files_generator.py +6 -0
- mcp_proxy_adapter/examples/setup/test_runner.py +143 -0
- mcp_proxy_adapter/examples/setup_test_environment.py +233 -0
- mcp_proxy_adapter/examples/simple_http_example.json +17 -0
- mcp_proxy_adapter/examples/simple_https_example.json +17 -0
- mcp_proxy_adapter/examples/simple_protocol_test.py +167 -0
- mcp_proxy_adapter/examples/test_client/README.md +166 -0
- mcp_proxy_adapter/examples/test_client/__init__.py +7 -0
- mcp_proxy_adapter/examples/test_client/main.py +102 -0
- mcp_proxy_adapter/examples/test_client/main_split_parts/__init__.py +1 -0
- mcp_proxy_adapter/examples/test_client/main_split_parts/helpers.py +83 -0
- mcp_proxy_adapter/examples/test_client/main_split_parts/runner.py +115 -0
- mcp_proxy_adapter/examples/test_client/main_split_parts/scenarios.py +195 -0
- mcp_proxy_adapter/examples/test_config.py +183 -0
- mcp_proxy_adapter/examples/test_configs/custom_https.json +10 -0
- mcp_proxy_adapter/examples/test_configs/http_simple.json +10 -0
- mcp_proxy_adapter/examples/test_examples.py +361 -0
- mcp_proxy_adapter/examples/test_mcp_server.py +249 -0
- mcp_proxy_adapter/examples/test_protocol_examples.py +373 -0
- mcp_proxy_adapter/examples/test_proxy/README.md +70 -0
- mcp_proxy_adapter/examples/test_proxy/__init__.py +7 -0
- mcp_proxy_adapter/examples/test_proxy/main.py +106 -0
- mcp_proxy_adapter/examples/test_server/README.md +58 -0
- mcp_proxy_adapter/examples/test_server/__init__.py +7 -0
- mcp_proxy_adapter/examples/test_server/main.py +349 -0
- mcp_proxy_adapter/examples/transparent_queue_commands.py +281 -0
- mcp_proxy_adapter/examples/transparent_queue_e1_sync_call.py +102 -0
- mcp_proxy_adapter/examples/transparent_queue_e2_event_stream.py +134 -0
- mcp_proxy_adapter/examples/transparent_queue_e3_ws_timeouts.py +341 -0
- mcp_proxy_adapter/examples/transparent_queue_e4_ws_fallback.py +159 -0
- mcp_proxy_adapter/examples/transparent_queue_e5_inner_failure.py +189 -0
- mcp_proxy_adapter/examples/transparent_queue_e6_atomic_state.py +203 -0
- mcp_proxy_adapter/examples/transparent_queue_e7_caller_loss.py +63 -0
- mcp_proxy_adapter/examples/transparent_queue_e7_split2/__init__.py +3 -0
- mcp_proxy_adapter/examples/transparent_queue_e7_split2/cases.py +335 -0
- mcp_proxy_adapter/examples/transparent_queue_e7_split2/helpers.py +66 -0
- mcp_proxy_adapter/examples/transparent_queue_support.py +377 -0
- mcp_proxy_adapter/examples/unified_error_handling_example.py +127 -0
- mcp_proxy_adapter/examples/unified_error_handling_split_parts/__init__.py +3 -0
- mcp_proxy_adapter/examples/unified_error_handling_split_parts/demos.py +180 -0
- mcp_proxy_adapter/examples/unified_error_handling_split_parts/runner.py +109 -0
- mcp_proxy_adapter/examples/unified_error_handling_split_parts/support.py +79 -0
- mcp_proxy_adapter/examples/unified_error_handling_texts.py +17 -0
- mcp_proxy_adapter/examples/universal_client.py +215 -0
- mcp_proxy_adapter/examples/universal_client_split_parts/__init__.py +3 -0
- mcp_proxy_adapter/examples/universal_client_split_parts/configs.py +104 -0
- mcp_proxy_adapter/examples/universal_client_split_parts/demos.py +144 -0
- mcp_proxy_adapter/examples/update_config_certificates.py +156 -0
- mcp_proxy_adapter/examples/validate_generator_compatibility_simple.py +60 -0
- mcp_proxy_adapter/examples/websocket_examples/__init__.py +8 -0
- mcp_proxy_adapter/examples/websocket_examples/client_bidirectional_websocket.py +100 -0
- mcp_proxy_adapter/examples/websocket_examples/client_websocket_job_status.py +103 -0
- mcp_proxy_adapter/examples/websocket_examples/run_ws_test_server.py +157 -0
- mcp_proxy_adapter/examples/ws_examples/__init__.py +6 -0
- mcp_proxy_adapter/examples/ws_examples/http_basic_ws.py +68 -0
- mcp_proxy_adapter/examples/ws_examples/http_token_roles_ws.py +66 -0
- mcp_proxy_adapter/examples/ws_examples/http_token_ws.py +80 -0
- mcp_proxy_adapter/examples/ws_examples/https_basic_ws.py +61 -0
- mcp_proxy_adapter/examples/ws_examples/https_token_roles_ws.py +67 -0
- mcp_proxy_adapter/examples/ws_examples/https_token_ws.py +64 -0
- mcp_proxy_adapter/examples/ws_examples/mtls_basic_ws.py +94 -0
- mcp_proxy_adapter/examples/ws_examples/mtls_roles_ws.py +88 -0
- mcp_proxy_adapter/examples/ws_examples/ws_example_runner.py +233 -0
- mcp_proxy_adapter/integrations/__init__.py +31 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/__init__.py +124 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/_compat.py +60 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/_health.py +299 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/_limits.py +70 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/_process_reap.py +232 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/_result_builders.py +119 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/_status_helpers.py +167 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/global_manager.py +174 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/job_types/__init__.py +375 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/job_types/value_types.py +97 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/job_types/worker_probe.py +29 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/manager/__init__.py +52 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/manager/fallback_base.py +240 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/manager/fallback_stop_base.py +179 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/manager/health_base.py +460 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/manager/integration.py +189 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/manager/job_start_base.py +333 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/manager/job_stop_base.py +274 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/manager/lifecycle_base.py +393 -0
- mcp_proxy_adapter/integrations/queuemgr_integration/manager/query_base.py +269 -0
- mcp_proxy_adapter/integrations/queuemgr_registration.py +66 -0
- mcp_proxy_adapter/integrations/queuemgr_version.py +39 -0
- mcp_proxy_adapter/main.py +385 -0
- mcp_proxy_adapter/main_ssl_paths.py +29 -0
- mcp_proxy_adapter/py.typed +0 -0
- mcp_proxy_adapter/schemas/base_schema.json +114 -0
- mcp_proxy_adapter/schemas/openapi_schema.json +269 -0
- mcp_proxy_adapter/schemas/roles.json +37 -0
- mcp_proxy_adapter/schemas/roles_schema.json +162 -0
- mcp_proxy_adapter/transfer/__init__.py +56 -0
- mcp_proxy_adapter/transfer/checksums.py +81 -0
- mcp_proxy_adapter/transfer/client_downloader/__init__.py +37 -0
- mcp_proxy_adapter/transfer/client_downloader/download_support.py +109 -0
- mcp_proxy_adapter/transfer/client_downloader/downloader.py +300 -0
- mcp_proxy_adapter/transfer/client_uploader.py +278 -0
- mcp_proxy_adapter/transfer/compression.py +127 -0
- mcp_proxy_adapter/transfer/errors.py +253 -0
- mcp_proxy_adapter/transfer/json_coerce.py +32 -0
- mcp_proxy_adapter/transfer/models.py +337 -0
- mcp_proxy_adapter/transfer/path_confinement.py +69 -0
- mcp_proxy_adapter/transfer/progress_percent.py +25 -0
- mcp_proxy_adapter/transfer/server_store.py +878 -0
- mcp_proxy_adapter/version.py +8 -0
- mcp_proxy_adapter_dev-8.11.16.dist-info/METADATA +1666 -0
- mcp_proxy_adapter_dev-8.11.16.dist-info/RECORD +644 -0
- mcp_proxy_adapter_dev-8.11.16.dist-info/WHEEL +5 -0
- mcp_proxy_adapter_dev-8.11.16.dist-info/entry_points.txt +12 -0
- mcp_proxy_adapter_dev-8.11.16.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Author: Vasiliy Zdanovskiy
|
|
2
|
+
email: vasilyvz@gmail.com
|
|
3
|
+
|
|
4
|
+
Optional WebSocket correlation envelope for transfer_session events (schema_version, job_id, ids).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def merge_transfer_correlation_envelope(
|
|
13
|
+
transfer_id: str,
|
|
14
|
+
payload: dict[str, Any] | None,
|
|
15
|
+
) -> dict[str, Any]:
|
|
16
|
+
"""
|
|
17
|
+
Attach stable correlation fields from transfer session metadata when available.
|
|
18
|
+
|
|
19
|
+
Never raises; on missing store/session returns a copy of the original payload.
|
|
20
|
+
"""
|
|
21
|
+
tid = str(transfer_id).strip()
|
|
22
|
+
base: dict[str, Any] = dict(payload) if payload else {}
|
|
23
|
+
if tid == "":
|
|
24
|
+
return base
|
|
25
|
+
try:
|
|
26
|
+
from mcp_proxy_adapter.api.handlers import get_transfer_store
|
|
27
|
+
|
|
28
|
+
session = get_transfer_store().try_load_session_metadata(tid)
|
|
29
|
+
except Exception:
|
|
30
|
+
return base
|
|
31
|
+
if session is None:
|
|
32
|
+
return base
|
|
33
|
+
out = dict(base)
|
|
34
|
+
out.setdefault("schema_version", 1)
|
|
35
|
+
if session.job_id:
|
|
36
|
+
out["job_id"] = session.job_id
|
|
37
|
+
if session.correlation_id:
|
|
38
|
+
out["correlation_id"] = session.correlation_id
|
|
39
|
+
if session.command:
|
|
40
|
+
out["command"] = session.command
|
|
41
|
+
if str(session.direction) == "upload":
|
|
42
|
+
out["inbound_transfer_id"] = session.transfer_id
|
|
43
|
+
else:
|
|
44
|
+
out["outbound_transfer_id"] = session.transfer_id
|
|
45
|
+
if session.inbound_transfer_id and str(session.direction) == "download":
|
|
46
|
+
out["inbound_transfer_id"] = session.inbound_transfer_id
|
|
47
|
+
return out
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""Author: Vasiliy Zdanovskiy
|
|
2
|
+
email: vasilyvz@gmail.com
|
|
3
|
+
|
|
4
|
+
Transfer session WebSocket push: fan-out to transfer_session subscribers (no job notifier dedup).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from fastapi import FastAPI
|
|
13
|
+
|
|
14
|
+
from mcp_proxy_adapter.core.job_push.events import (
|
|
15
|
+
SUBSCRIPTION_TYPE_TRANSFER_SESSION,
|
|
16
|
+
TRANSFER_WS_TERMINAL_EVENTS,
|
|
17
|
+
)
|
|
18
|
+
from mcp_proxy_adapter.core.job_push.subscriptions import (
|
|
19
|
+
Subscriber,
|
|
20
|
+
SubscriptionCategory,
|
|
21
|
+
)
|
|
22
|
+
from mcp_proxy_adapter.core.job_push.transfer_correlation import (
|
|
23
|
+
merge_transfer_correlation_envelope,
|
|
24
|
+
)
|
|
25
|
+
from mcp_proxy_adapter.core.logging import get_global_logger
|
|
26
|
+
|
|
27
|
+
_transfer_push_app: FastAPI | None = None
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def build_transfer_expired_ws_payload(
|
|
31
|
+
*,
|
|
32
|
+
transfer_id: str,
|
|
33
|
+
direction: str,
|
|
34
|
+
message: str | None = None,
|
|
35
|
+
) -> dict[str, Any]:
|
|
36
|
+
"""
|
|
37
|
+
Shared payload for ``transfer_expired`` events (batch TTL and request-path).
|
|
38
|
+
|
|
39
|
+
Matches ``_notify_transfer_expired`` / control-plane spec: error_type, message,
|
|
40
|
+
progress_percent 0, direction from session.
|
|
41
|
+
"""
|
|
42
|
+
from mcp_proxy_adapter.transfer.errors import TransferExpiredError
|
|
43
|
+
|
|
44
|
+
tid = str(transfer_id).strip()
|
|
45
|
+
msg = message
|
|
46
|
+
if msg is None:
|
|
47
|
+
msg = str(
|
|
48
|
+
TransferExpiredError(
|
|
49
|
+
message="Transfer session expired",
|
|
50
|
+
transfer_id=tid or None,
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
return {
|
|
54
|
+
"direction": str(direction).strip(),
|
|
55
|
+
"error_type": "TransferExpiredError",
|
|
56
|
+
"message": msg,
|
|
57
|
+
"progress_percent": 0,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
_terminal_transfer_ids: set[str] = set()
|
|
62
|
+
_terminal_lock = asyncio.Lock()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def coerce_ws_push_enabled(value: object) -> bool:
|
|
66
|
+
"""
|
|
67
|
+
Coerce config values to bool for transfer.ws_push_enabled.
|
|
68
|
+
|
|
69
|
+
Avoids ``bool("false") == True`` by handling common string/int forms.
|
|
70
|
+
"""
|
|
71
|
+
if isinstance(value, bool):
|
|
72
|
+
return value
|
|
73
|
+
if isinstance(value, int) and not isinstance(value, bool):
|
|
74
|
+
return value != 0
|
|
75
|
+
if isinstance(value, str):
|
|
76
|
+
s = value.strip().lower()
|
|
77
|
+
if s in ("0", "false", "no", "off", ""):
|
|
78
|
+
return False
|
|
79
|
+
if s in ("1", "true", "yes", "on"):
|
|
80
|
+
return True
|
|
81
|
+
return bool(value)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def set_transfer_push_app(app: FastAPI | None) -> None:
|
|
85
|
+
"""Store FastAPI app for transfer WS fan-out; None clears."""
|
|
86
|
+
global _transfer_push_app
|
|
87
|
+
_transfer_push_app = app
|
|
88
|
+
if app is None:
|
|
89
|
+
_terminal_transfer_ids.clear()
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def get_transfer_push_app() -> FastAPI | None:
|
|
93
|
+
"""Return app set by set_transfer_push_app."""
|
|
94
|
+
return _transfer_push_app
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
async def notify_transfer_state_changed(
|
|
98
|
+
transfer_id: str,
|
|
99
|
+
event: str,
|
|
100
|
+
payload: dict[str, Any] | None = None,
|
|
101
|
+
) -> None:
|
|
102
|
+
"""Push one transfer_session event to all registry subscribers for transfer_id."""
|
|
103
|
+
tid = str(transfer_id).strip()
|
|
104
|
+
if tid == "":
|
|
105
|
+
raise ValueError("notify_transfer_state_changed requires non-empty transfer_id")
|
|
106
|
+
from mcp_proxy_adapter.api.handlers import _merge_transfer_config
|
|
107
|
+
|
|
108
|
+
cfg = _merge_transfer_config()
|
|
109
|
+
if not coerce_ws_push_enabled(cfg.get("ws_push_enabled", True)):
|
|
110
|
+
return
|
|
111
|
+
app = get_transfer_push_app()
|
|
112
|
+
if app is None:
|
|
113
|
+
return
|
|
114
|
+
registry = getattr(app.state, "job_push_registry", None)
|
|
115
|
+
if registry is None:
|
|
116
|
+
return
|
|
117
|
+
if event in TRANSFER_WS_TERMINAL_EVENTS:
|
|
118
|
+
async with _terminal_lock:
|
|
119
|
+
if tid in _terminal_transfer_ids:
|
|
120
|
+
return
|
|
121
|
+
_terminal_transfer_ids.add(tid)
|
|
122
|
+
extra = merge_transfer_correlation_envelope(tid, dict(payload) if payload else None)
|
|
123
|
+
message: dict[str, Any] = dict(extra)
|
|
124
|
+
message["event"] = str(event)
|
|
125
|
+
message["subscription_type"] = SUBSCRIPTION_TYPE_TRANSFER_SESSION
|
|
126
|
+
message["transfer_id"] = tid
|
|
127
|
+
subs: list[Subscriber] = await registry.get_subscribers(
|
|
128
|
+
tid, SubscriptionCategory.TRANSFER_SESSION
|
|
129
|
+
)
|
|
130
|
+
logger = get_global_logger()
|
|
131
|
+
for sub in subs:
|
|
132
|
+
try:
|
|
133
|
+
await sub.send(message)
|
|
134
|
+
except Exception as e:
|
|
135
|
+
logger.warning("Transfer push send failed for transfer_id=%s: %s", tid, e)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
JSON utilities for common JSON file operations.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any, Dict, Optional, Tuple
|
|
11
|
+
|
|
12
|
+
from ..commands.result import ErrorResult
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def save_json_file(
|
|
16
|
+
data: Dict[str, Any],
|
|
17
|
+
file_path: str,
|
|
18
|
+
indent: int = 2,
|
|
19
|
+
) -> Tuple[bool, Optional[ErrorResult]]:
|
|
20
|
+
"""
|
|
21
|
+
Save data to JSON file.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
data: Data to save
|
|
25
|
+
file_path: Path to JSON file
|
|
26
|
+
indent: JSON indentation level
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
Tuple of (success, error_result)
|
|
30
|
+
"""
|
|
31
|
+
try:
|
|
32
|
+
path = Path(file_path)
|
|
33
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
34
|
+
with open(file_path, "w") as f:
|
|
35
|
+
json.dump(data, f, indent=indent)
|
|
36
|
+
return True, None
|
|
37
|
+
except Exception as e:
|
|
38
|
+
return False, ErrorResult(message=f"Failed to save JSON file: {str(e)}")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def load_json_file(
|
|
42
|
+
file_path: str,
|
|
43
|
+
) -> Tuple[Optional[Dict[str, Any]], Optional[ErrorResult]]:
|
|
44
|
+
"""
|
|
45
|
+
Load data from JSON file.
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
file_path: Path to JSON file
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Tuple of (data, error_result)
|
|
52
|
+
"""
|
|
53
|
+
try:
|
|
54
|
+
with open(file_path, "r") as f:
|
|
55
|
+
return json.load(f), None
|
|
56
|
+
except FileNotFoundError:
|
|
57
|
+
return None, ErrorResult(message=f"JSON file not found: {file_path}")
|
|
58
|
+
except json.JSONDecodeError as e:
|
|
59
|
+
return None, ErrorResult(message=f"Invalid JSON in file: {str(e)}")
|
|
60
|
+
except Exception as e:
|
|
61
|
+
return None, ErrorResult(message=f"Failed to load JSON file: {str(e)}")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def parse_json_string(
|
|
65
|
+
json_string: str,
|
|
66
|
+
) -> Tuple[Optional[Dict[str, Any]], Optional[ErrorResult]]:
|
|
67
|
+
"""
|
|
68
|
+
Parse JSON string.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
json_string: JSON string to parse
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
Tuple of (data, error_result)
|
|
75
|
+
"""
|
|
76
|
+
try:
|
|
77
|
+
return json.loads(json_string), None
|
|
78
|
+
except json.JSONDecodeError as e:
|
|
79
|
+
return None, ErrorResult(message=f"Invalid JSON string: {str(e)}")
|
|
80
|
+
except Exception as e:
|
|
81
|
+
return None, ErrorResult(message=f"Failed to parse JSON string: {str(e)}")
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module for configuring logging in the microservice.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging # noqa: F401
|
|
6
|
+
import os # noqa: F401
|
|
7
|
+
import sys # noqa: F401
|
|
8
|
+
import uuid # noqa: F401
|
|
9
|
+
from logging.handlers import RotatingFileHandler # noqa: F401
|
|
10
|
+
from typing import Any, Optional # noqa: F401
|
|
11
|
+
|
|
12
|
+
from .formatters import CustomFormatter # noqa: F401
|
|
13
|
+
from .formatters import RequestContextFilter # noqa: F401
|
|
14
|
+
from .global_logger import get_global_logger # noqa: F401
|
|
15
|
+
from .request_logger import RequestLogger # noqa: F401
|
|
16
|
+
from .setup import _OWNED_HANDLER_ATTR # noqa: F401
|
|
17
|
+
from .setup import _parse_file_size # noqa: F401
|
|
18
|
+
from .setup import setup_logging # noqa: F401
|
|
19
|
+
from .worker import attach_capture_stream_handler # noqa: F401
|
|
20
|
+
from .worker import bootstrap_worker_logger # noqa: F401
|
|
21
|
+
|
|
22
|
+
# The submodules stay reachable as attributes of the package but are not
|
|
23
|
+
# part of its star-import surface, exactly as in the original single module.
|
|
24
|
+
for _name in ("formatters", "global_logger", "request_logger", "setup", "worker"):
|
|
25
|
+
globals().pop(_name, None)
|
|
26
|
+
del _name
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def __getattr__(name: str) -> Any:
|
|
30
|
+
"""Return a live module global or an imported submodule by attribute name."""
|
|
31
|
+
import importlib as _importlib
|
|
32
|
+
import sys as _sys
|
|
33
|
+
|
|
34
|
+
# Module globals that functions rebind through 'global' stay live on the
|
|
35
|
+
# old path: they are read from the module that owns them, never copied.
|
|
36
|
+
live = {"logger": "global_logger"}
|
|
37
|
+
if name in live:
|
|
38
|
+
module = _importlib.import_module(f".{live[name]}", __name__)
|
|
39
|
+
return getattr(module, name)
|
|
40
|
+
if name in ("formatters", "global_logger", "request_logger", "setup", "worker"):
|
|
41
|
+
return _sys.modules[f"{__name__}.{name}"]
|
|
42
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""The formatters module of the logging package: CustomFormatter, RequestContextFilter."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class CustomFormatter(logging.Formatter):
|
|
8
|
+
"""
|
|
9
|
+
Custom formatter for logs with colored output in console.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
grey = "\x1b[38;20m"
|
|
13
|
+
yellow = "\x1b[33;20m"
|
|
14
|
+
red = "\x1b[31;20m"
|
|
15
|
+
bold_red = "\x1b[31;1m"
|
|
16
|
+
reset = "\x1b[0m"
|
|
17
|
+
format_str = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
18
|
+
|
|
19
|
+
FORMATS = {
|
|
20
|
+
logging.DEBUG: grey + format_str + reset,
|
|
21
|
+
logging.INFO: grey + format_str + reset,
|
|
22
|
+
logging.WARNING: yellow + format_str + reset,
|
|
23
|
+
logging.ERROR: red + format_str + reset,
|
|
24
|
+
logging.CRITICAL: bold_red + format_str + reset,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
def format(self, record: logging.LogRecord) -> str:
|
|
28
|
+
"""
|
|
29
|
+
Format log record with color coding.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
record: Log record to format
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
Formatted log message string
|
|
36
|
+
"""
|
|
37
|
+
log_fmt = self.FORMATS.get(record.levelno)
|
|
38
|
+
formatter = logging.Formatter(log_fmt)
|
|
39
|
+
return formatter.format(record)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class RequestContextFilter(logging.Filter):
|
|
43
|
+
"""
|
|
44
|
+
Filter for adding request context to logs.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def __init__(self, request_id: Optional[str] = None):
|
|
48
|
+
"""
|
|
49
|
+
Initialize request context filter.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
request_id: Optional request ID for logging context
|
|
53
|
+
"""
|
|
54
|
+
super().__init__()
|
|
55
|
+
self.request_id = request_id
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""The global_logger module of the logging package: get_global_logger, logger."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
# Global get_global_logger() for use throughout the application
|
|
6
|
+
# Initialize lazily to avoid import-time errors
|
|
7
|
+
logger = None
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def get_global_logger() -> logging.Logger:
|
|
11
|
+
"""Get the global package logger, library-safe by default (bug 20231492).
|
|
12
|
+
|
|
13
|
+
Merely importing ``mcp_proxy_adapter`` or calling ``create_app()`` must
|
|
14
|
+
never write to stdout or create log files as a side effect - this used
|
|
15
|
+
to call ``setup_logging()`` unconditionally on first access, which
|
|
16
|
+
hardcodes a colour ``StreamHandler(sys.stdout)`` (and file handlers
|
|
17
|
+
under ``./logs``) with no opt-out. Now, the first access instead
|
|
18
|
+
attaches a bare ``logging.NullHandler()`` to
|
|
19
|
+
``logging.getLogger("mcp_proxy_adapter")`` if nothing has configured it
|
|
20
|
+
yet - no stdout handler, no forced level, no formatter.
|
|
21
|
+
|
|
22
|
+
A real server entrypoint that wants console/file logging calls
|
|
23
|
+
``setup_logging(...)`` explicitly during its own startup (see
|
|
24
|
+
``mcp_proxy_adapter/main.py``, ``cli/commands/server.py``,
|
|
25
|
+
``examples/full_application/main.py``). Because ``logging.getLogger``
|
|
26
|
+
returns the SAME underlying object for a given name, that explicit call
|
|
27
|
+
reconfigures the very logger this function returns - regardless of
|
|
28
|
+
whether this function already ran first - so call order between the two
|
|
29
|
+
does not matter; only whether ``setup_logging()`` was ever called
|
|
30
|
+
determines whether the process gets real handlers.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
The package's global logger.
|
|
34
|
+
"""
|
|
35
|
+
global logger
|
|
36
|
+
if logger is None:
|
|
37
|
+
candidate = logging.getLogger("mcp_proxy_adapter")
|
|
38
|
+
if not candidate.handlers:
|
|
39
|
+
candidate.addHandler(logging.NullHandler())
|
|
40
|
+
logger = candidate
|
|
41
|
+
return logger
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""The request_logger module of the logging package: RequestLogger."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import uuid
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from .formatters import RequestContextFilter
|
|
8
|
+
from .global_logger import get_global_logger
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RequestLogger:
|
|
12
|
+
"""
|
|
13
|
+
Logger class for logging requests with context.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, logger_name: str, request_id: Optional[str] = None):
|
|
17
|
+
"""
|
|
18
|
+
Initialize request get_global_logger().
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
logger_name: Logger name.
|
|
22
|
+
request_id: Request identifier.
|
|
23
|
+
"""
|
|
24
|
+
self.logger = logging.getLogger(logger_name)
|
|
25
|
+
self.request_id = request_id or str(uuid.uuid4())
|
|
26
|
+
self.filter = RequestContextFilter(self.request_id)
|
|
27
|
+
|
|
28
|
+
def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
29
|
+
"""Log message with DEBUG level. Supports %-style args like logging.Logger."""
|
|
30
|
+
get_global_logger().debug(f"[{self.request_id}] {msg}", *args, **kwargs)
|
|
31
|
+
|
|
32
|
+
def info(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
33
|
+
"""Log message with INFO level. Supports %-style args like logging.Logger."""
|
|
34
|
+
get_global_logger().info(f"[{self.request_id}] {msg}", *args, **kwargs)
|
|
35
|
+
|
|
36
|
+
def warning(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
37
|
+
"""Log message with WARNING level. Supports %-style args like logging.Logger."""
|
|
38
|
+
get_global_logger().warning(f"[{self.request_id}] {msg}", *args, **kwargs)
|
|
39
|
+
|
|
40
|
+
def error(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
41
|
+
"""Log message with ERROR level. Supports %-style args like logging.Logger."""
|
|
42
|
+
get_global_logger().error(f"[{self.request_id}] {msg}", *args, **kwargs)
|
|
43
|
+
|
|
44
|
+
def exception(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
45
|
+
"""Log exception with traceback. Supports %-style args like logging.Logger."""
|
|
46
|
+
get_global_logger().exception(f"[{self.request_id}] {msg}", *args, **kwargs)
|
|
47
|
+
|
|
48
|
+
def critical(self, msg: str, *args: Any, **kwargs: Any) -> None:
|
|
49
|
+
"""Log message with CRITICAL level. Supports %-style args like logging.Logger."""
|
|
50
|
+
get_global_logger().critical(f"[{self.request_id}] {msg}", *args, **kwargs)
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"""The setup module of the logging package: setup_logging, _parse_file_size,
|
|
2
|
+
_OWNED_HANDLER_ATTR.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
from logging.handlers import RotatingFileHandler
|
|
9
|
+
from typing import Optional
|
|
10
|
+
|
|
11
|
+
from .formatters import CustomFormatter
|
|
12
|
+
|
|
13
|
+
# Attribute name used to mark a handler as one setup_logging() itself
|
|
14
|
+
# created (bug 751b4145, sub-defect 3). setup_logging() removes only
|
|
15
|
+
# handlers carrying this marker on a repeated call, so a handler a
|
|
16
|
+
# consumer attached independently - before or between calls - is never
|
|
17
|
+
# touched. See setup_logging()'s docstring for the full rationale.
|
|
18
|
+
_OWNED_HANDLER_ATTR = "_mpa_setup_logging_owned"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def setup_logging(
|
|
22
|
+
level: Optional[str] = None,
|
|
23
|
+
log_file: Optional[str] = None,
|
|
24
|
+
log_dir: Optional[str] = None,
|
|
25
|
+
file_output: Optional[bool] = None,
|
|
26
|
+
max_bytes: Optional[int] = None,
|
|
27
|
+
backup_count: Optional[int] = None,
|
|
28
|
+
rotation_type: Optional[str] = None,
|
|
29
|
+
rotation_when: Optional[str] = None,
|
|
30
|
+
rotation_interval: Optional[int] = None,
|
|
31
|
+
) -> logging.Logger:
|
|
32
|
+
"""
|
|
33
|
+
Configure logging for the microservice.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
level: Logging level. Defaults to INFO.
|
|
37
|
+
log_file: Deprecated/ignored - kept for compatibility.
|
|
38
|
+
log_dir: Directory for log files. Defaults to "./logs" if file_output is True.
|
|
39
|
+
file_output: Enable file logging. Defaults to False (library is silent by default).
|
|
40
|
+
max_bytes: Maximum log file size in bytes. By default, taken from configuration.
|
|
41
|
+
backup_count: Number of rotation files. By default, taken from configuration.
|
|
42
|
+
rotation_type: Type of log rotation ('size' or 'time'). By default, taken from configuration.
|
|
43
|
+
rotation_when: Time unit for rotation (D, H, M, S). By default, taken from configuration.
|
|
44
|
+
rotation_interval: Interval for rotation. By default, taken from configuration.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Configured get_global_logger().
|
|
48
|
+
|
|
49
|
+
Handler discipline (bug 751b4145, sub-defect 3): a repeated call
|
|
50
|
+
reconfigures only the handlers THIS FUNCTION previously created (each
|
|
51
|
+
is tagged with the ``_OWNED_HANDLER_ATTR`` marker right after
|
|
52
|
+
creation) - it never removes a handler a consumer attached some other
|
|
53
|
+
way (directly via ``logging.getLogger("mcp_proxy_adapter")
|
|
54
|
+
.addHandler(...)``, a test's marker handler, etc.). Before this fix,
|
|
55
|
+
``logger.handlers = []`` unconditionally wiped the ENTIRE handler
|
|
56
|
+
list on every call, silently destroying any such consumer handler.
|
|
57
|
+
"""
|
|
58
|
+
# Use provided parameters or defaults
|
|
59
|
+
level = level or "INFO"
|
|
60
|
+
rotation_type = rotation_type or "size"
|
|
61
|
+
log_dir = log_dir or "./logs"
|
|
62
|
+
file_output = False if file_output is None else bool(file_output)
|
|
63
|
+
log_file_name = "mcp_proxy_adapter.log"
|
|
64
|
+
error_log_file = "mcp_proxy_adapter_error.log"
|
|
65
|
+
access_log_file = "mcp_proxy_adapter_access.log"
|
|
66
|
+
|
|
67
|
+
# Get rotation settings
|
|
68
|
+
max_file_size_str = "10MB"
|
|
69
|
+
backup_count = backup_count or 5
|
|
70
|
+
|
|
71
|
+
# Parse max file size (e.g., "10MB" -> 10 * 1024 * 1024)
|
|
72
|
+
max_bytes = max_bytes or _parse_file_size(max_file_size_str)
|
|
73
|
+
|
|
74
|
+
# Get format settings
|
|
75
|
+
log_format = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
76
|
+
date_format = "%Y-%m-%d %H:%M:%S"
|
|
77
|
+
|
|
78
|
+
# Get output settings
|
|
79
|
+
console_output = True
|
|
80
|
+
|
|
81
|
+
# Convert string logging level to constant
|
|
82
|
+
numeric_level = getattr(logging, level.upper(), None)
|
|
83
|
+
if not isinstance(numeric_level, int):
|
|
84
|
+
numeric_level = logging.INFO
|
|
85
|
+
|
|
86
|
+
# Create root logger
|
|
87
|
+
logger = logging.getLogger("mcp_proxy_adapter")
|
|
88
|
+
logger.setLevel(numeric_level)
|
|
89
|
+
# Remove only the handlers THIS function installed on an earlier call
|
|
90
|
+
# (bug 751b4145, sub-defect 3) - a handler a consumer attached some
|
|
91
|
+
# other way is left untouched, so a repeated call still reconfigures
|
|
92
|
+
# this function's own console/file handlers without destroying
|
|
93
|
+
# whatever the consumer already had wired up.
|
|
94
|
+
for _existing in list(logger.handlers):
|
|
95
|
+
if getattr(_existing, _OWNED_HANDLER_ATTR, False):
|
|
96
|
+
logger.removeHandler(_existing)
|
|
97
|
+
|
|
98
|
+
# Create formatter
|
|
99
|
+
formatter = logging.Formatter(log_format, date_format)
|
|
100
|
+
|
|
101
|
+
# Create console handler if enabled
|
|
102
|
+
if console_output:
|
|
103
|
+
console_handler = logging.StreamHandler(sys.stdout)
|
|
104
|
+
console_handler.setLevel(numeric_level)
|
|
105
|
+
console_handler.setFormatter(CustomFormatter())
|
|
106
|
+
setattr(console_handler, _OWNED_HANDLER_ATTR, True)
|
|
107
|
+
logger.addHandler(console_handler)
|
|
108
|
+
|
|
109
|
+
# Create file handlers if file output is enabled
|
|
110
|
+
if file_output and log_dir:
|
|
111
|
+
# Create directory for log files if it doesn't exist
|
|
112
|
+
if not os.path.exists(log_dir):
|
|
113
|
+
os.makedirs(log_dir, exist_ok=True)
|
|
114
|
+
|
|
115
|
+
# Main log file
|
|
116
|
+
if log_file_name:
|
|
117
|
+
main_log_path = os.path.join(log_dir, log_file_name)
|
|
118
|
+
main_handler = RotatingFileHandler(
|
|
119
|
+
main_log_path,
|
|
120
|
+
maxBytes=max_bytes,
|
|
121
|
+
backupCount=backup_count,
|
|
122
|
+
encoding="utf-8",
|
|
123
|
+
)
|
|
124
|
+
main_handler.setLevel(numeric_level)
|
|
125
|
+
main_handler.setFormatter(formatter)
|
|
126
|
+
setattr(main_handler, _OWNED_HANDLER_ATTR, True)
|
|
127
|
+
logger.addHandler(main_handler)
|
|
128
|
+
|
|
129
|
+
# Error log file
|
|
130
|
+
if error_log_file:
|
|
131
|
+
error_log_path = os.path.join(log_dir, error_log_file)
|
|
132
|
+
error_handler = RotatingFileHandler(
|
|
133
|
+
error_log_path,
|
|
134
|
+
maxBytes=max_bytes,
|
|
135
|
+
backupCount=backup_count,
|
|
136
|
+
encoding="utf-8",
|
|
137
|
+
)
|
|
138
|
+
error_handler.setLevel(logging.ERROR)
|
|
139
|
+
error_handler.setFormatter(formatter)
|
|
140
|
+
setattr(error_handler, _OWNED_HANDLER_ATTR, True)
|
|
141
|
+
logger.addHandler(error_handler)
|
|
142
|
+
|
|
143
|
+
# Access log file (for HTTP requests)
|
|
144
|
+
if access_log_file:
|
|
145
|
+
access_log_path = os.path.join(log_dir, access_log_file)
|
|
146
|
+
access_handler = RotatingFileHandler(
|
|
147
|
+
access_log_path,
|
|
148
|
+
maxBytes=max_bytes,
|
|
149
|
+
backupCount=backup_count,
|
|
150
|
+
encoding="utf-8",
|
|
151
|
+
)
|
|
152
|
+
access_handler.setLevel(logging.INFO)
|
|
153
|
+
access_handler.setFormatter(formatter)
|
|
154
|
+
setattr(access_handler, _OWNED_HANDLER_ATTR, True)
|
|
155
|
+
logger.addHandler(access_handler)
|
|
156
|
+
|
|
157
|
+
# Configure loggers for external libraries
|
|
158
|
+
log_levels: dict[str, str] = {}
|
|
159
|
+
for logger_name, logger_level in log_levels.items():
|
|
160
|
+
lib_logger = logging.getLogger(logger_name)
|
|
161
|
+
lib_logger.setLevel(getattr(logging, logger_level.upper(), logging.INFO))
|
|
162
|
+
|
|
163
|
+
return logger
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _parse_file_size(size_str: str | int) -> int:
|
|
167
|
+
"""
|
|
168
|
+
Parse file size string to bytes.
|
|
169
|
+
|
|
170
|
+
Args:
|
|
171
|
+
size_str: Size string (e.g., "10MB", "1GB", "100KB") or int
|
|
172
|
+
|
|
173
|
+
Returns:
|
|
174
|
+
Size in bytes
|
|
175
|
+
"""
|
|
176
|
+
# If it's already an int, return it
|
|
177
|
+
if isinstance(size_str, int):
|
|
178
|
+
return size_str
|
|
179
|
+
|
|
180
|
+
# Convert to string and parse
|
|
181
|
+
size_str = str(size_str).upper()
|
|
182
|
+
if size_str.endswith("KB"):
|
|
183
|
+
return int(size_str[:-2]) * 1024
|
|
184
|
+
elif size_str.endswith("MB"):
|
|
185
|
+
return int(size_str[:-2]) * 1024 * 1024
|
|
186
|
+
elif size_str.endswith("GB"):
|
|
187
|
+
return int(size_str[:-2]) * 1024 * 1024 * 1024
|
|
188
|
+
else:
|
|
189
|
+
# Assume bytes if no unit specified
|
|
190
|
+
return int(size_str)
|