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,354 @@
|
|
|
1
|
+
"""The manager module of the lifespan_manager package: LifespanManager."""
|
|
2
|
+
|
|
3
|
+
from contextlib import asynccontextmanager
|
|
4
|
+
from typing import Any, AsyncContextManager, AsyncIterator, Callable, Dict, Optional
|
|
5
|
+
|
|
6
|
+
from fastapi import FastAPI
|
|
7
|
+
|
|
8
|
+
from mcp_proxy_adapter.api.core.app_factory_validators import (
|
|
9
|
+
_has_effective_handler,
|
|
10
|
+
_report_fatal_to_stderr,
|
|
11
|
+
)
|
|
12
|
+
from mcp_proxy_adapter.core.logging import get_global_logger
|
|
13
|
+
from mcp_proxy_adapter.core.path_utils import (
|
|
14
|
+
ensure_application_path,
|
|
15
|
+
ensure_registered_modules_paths,
|
|
16
|
+
)
|
|
17
|
+
from mcp_proxy_adapter.integrations.queuemgr_integration import (
|
|
18
|
+
QUEUE_MANAGER_ENABLED_DEFAULT,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
from ..registration_manager import RegistrationManager, RegistrationSetupError
|
|
22
|
+
from .queue_config import _resolve_queue_config_dict
|
|
23
|
+
from .signal_registration import _make_signal_registration
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class LifespanManager:
|
|
27
|
+
"""Manager for application lifespan events."""
|
|
28
|
+
|
|
29
|
+
def __init__(self) -> None:
|
|
30
|
+
"""Initialize lifespan manager."""
|
|
31
|
+
self.logger = get_global_logger()
|
|
32
|
+
self.registration_manager = RegistrationManager()
|
|
33
|
+
|
|
34
|
+
def create_lifespan(
|
|
35
|
+
self,
|
|
36
|
+
config_path: Optional[str] = None,
|
|
37
|
+
current_config: Optional[Dict[str, Any]] = None,
|
|
38
|
+
) -> Callable[[FastAPI], AsyncContextManager[None]]:
|
|
39
|
+
"""
|
|
40
|
+
Create lifespan manager for the FastAPI application.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
config_path: Path to configuration file (optional)
|
|
44
|
+
current_config: Current configuration data (optional)
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Lifespan context manager
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
_register_signal_handlers = _make_signal_registration()
|
|
51
|
+
|
|
52
|
+
# Register signal handlers HERE, synchronously, before hypercorn's own
|
|
53
|
+
# serve() call ever runs (mirrors the pre-0a669075 call site).
|
|
54
|
+
#
|
|
55
|
+
# REGRESSION (found while verifying release 8.10.50): registering
|
|
56
|
+
# from *inside* the async lifespan startup phase - as bug
|
|
57
|
+
# 0a669075's fix originally did - runs AFTER hypercorn's own
|
|
58
|
+
# internal shutdown-trigger setup. core/server_engine.py calls
|
|
59
|
+
# ``hypercorn.asyncio.serve(app, hypercorn_config)`` with no
|
|
60
|
+
# explicit ``shutdown_trigger``, so hypercorn installs its OWN
|
|
61
|
+
# ``loop.add_signal_handler(SIGINT/SIGTERM, ...)`` to know when to
|
|
62
|
+
# stop serving and trigger the ASGI 'shutdown' lifecycle event.
|
|
63
|
+
# ``loop.add_signal_handler()`` REPLACES any existing handler for
|
|
64
|
+
# that signal - only the most recently registered callback survives.
|
|
65
|
+
# Calling it again from inside lifespan *startup* (which hypercorn
|
|
66
|
+
# invokes only after its own signal handler is already installed)
|
|
67
|
+
# silently overwrites hypercorn's handler with ours, which only
|
|
68
|
+
# sets a stop flag and does nothing to make hypercorn.serve()
|
|
69
|
+
# return: SIGTERM is "handled" (the flag flips, the heartbeat loop
|
|
70
|
+
# notices and stops) but the ASGI shutdown sequence - the code
|
|
71
|
+
# after ``yield`` below, which stops the queue manager and its
|
|
72
|
+
# multiprocessing workers - never runs, and the process never
|
|
73
|
+
# exits on its own. Confirmed live: after this regression, SIGTERM
|
|
74
|
+
# left the process running 40+ seconds later (still idle in
|
|
75
|
+
# ep_poll); on the pre-regression code the same signal produced a
|
|
76
|
+
# clean, fully-logged shutdown in well under a second.
|
|
77
|
+
#
|
|
78
|
+
# Registering here instead - synchronously, when create_lifespan()
|
|
79
|
+
# itself is called, before hypercorn's serve() coroutine has ever
|
|
80
|
+
# run - restores the original, correct ordering: no event loop is
|
|
81
|
+
# running yet at this point, so ``asyncio.get_running_loop()``
|
|
82
|
+
# inside _register_signal_handlers() raises RuntimeError and it
|
|
83
|
+
# falls back to plain ``signal.signal()`` (identical side effect,
|
|
84
|
+
# same as before bug 0a669075's fix). Once hypercorn's serve() then
|
|
85
|
+
# starts and installs its OWN loop-integrated handler, that
|
|
86
|
+
# (correctly) overwrites ours - our handler still ran once as a
|
|
87
|
+
# side effect (stop flag observed by the heartbeat loop is
|
|
88
|
+
# harmless either way) but hypercorn's own handler is what actually
|
|
89
|
+
# drives shutdown, exactly as before.
|
|
90
|
+
_register_signal_handlers()
|
|
91
|
+
|
|
92
|
+
lifespan = self._make_lifespan(config_path, current_config)
|
|
93
|
+
|
|
94
|
+
return lifespan
|
|
95
|
+
|
|
96
|
+
def _make_lifespan(
|
|
97
|
+
self, config_path: Optional[str], current_config: Optional[Dict[str, Any]]
|
|
98
|
+
) -> Callable[[FastAPI], AsyncContextManager[None]]:
|
|
99
|
+
"""Helper cut out of ``LifespanManager.create_lifespan``."""
|
|
100
|
+
|
|
101
|
+
@asynccontextmanager
|
|
102
|
+
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
|
103
|
+
"""Lifespan context manager."""
|
|
104
|
+
# Startup
|
|
105
|
+
logger = get_global_logger()
|
|
106
|
+
try:
|
|
107
|
+
logger.info("=" * 80)
|
|
108
|
+
logger.info("🚀 LIFESPAN STARTUP CALLED")
|
|
109
|
+
logger.info("=" * 80)
|
|
110
|
+
logger.info("Starting MCP Proxy Adapter")
|
|
111
|
+
|
|
112
|
+
# CRITICAL: Ensure application path is in PYTHONPATH for spawn mode
|
|
113
|
+
# This ensures that custom modules are importable in child processes
|
|
114
|
+
try:
|
|
115
|
+
added_paths = ensure_application_path(config_path)
|
|
116
|
+
if added_paths:
|
|
117
|
+
logger.info(
|
|
118
|
+
f"✅ Added application paths to PYTHONPATH for spawn mode: {added_paths}"
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Also ensure registered modules' paths are available
|
|
122
|
+
registered_paths = ensure_registered_modules_paths()
|
|
123
|
+
if registered_paths:
|
|
124
|
+
logger.info(
|
|
125
|
+
f"✅ Added registered module paths to PYTHONPATH: {registered_paths}"
|
|
126
|
+
)
|
|
127
|
+
except Exception as path_error:
|
|
128
|
+
logger.warning(
|
|
129
|
+
f"⚠️ Failed to ensure application paths for spawn mode: {path_error}"
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
logger.info(
|
|
133
|
+
f"🔍 lifespan function: current_config parameter value: {current_config}"
|
|
134
|
+
)
|
|
135
|
+
logger.info(
|
|
136
|
+
f"🔍 lifespan function: current_config is None: {current_config is None}"
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# Start heartbeat task only if registration is enabled
|
|
140
|
+
# Check if registration is enabled before calling start_heartbeat
|
|
141
|
+
logger = get_global_logger()
|
|
142
|
+
logger.info(
|
|
143
|
+
f"🔍 Lifespan: current_config is {'None' if current_config is None else 'not None'}"
|
|
144
|
+
)
|
|
145
|
+
if current_config:
|
|
146
|
+
logger.info(
|
|
147
|
+
f"🔍 Lifespan: current_config type: {type(current_config)}"
|
|
148
|
+
)
|
|
149
|
+
logger.info(
|
|
150
|
+
f"🔍 Lifespan: current_config keys: {list(current_config.keys()) if hasattr(current_config, 'keys') else 'no keys'}"
|
|
151
|
+
)
|
|
152
|
+
if hasattr(current_config, "keys"):
|
|
153
|
+
logger.info(
|
|
154
|
+
f"🔍 Lifespan: current_config['registration'] exists: {'registration' in current_config}"
|
|
155
|
+
)
|
|
156
|
+
if "registration" in current_config:
|
|
157
|
+
reg_section = current_config.get("registration")
|
|
158
|
+
logger.info(
|
|
159
|
+
f"🔍 Lifespan: registration section type: {type(reg_section)}"
|
|
160
|
+
)
|
|
161
|
+
logger.info(
|
|
162
|
+
f"🔍 Lifespan: registration section: {reg_section}"
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
registration_enabled = False
|
|
166
|
+
# Check SimpleConfigModel first
|
|
167
|
+
try:
|
|
168
|
+
from mcp_proxy_adapter.config import get_config
|
|
169
|
+
|
|
170
|
+
cfg = get_config()
|
|
171
|
+
logger.info(f"🔍 SimpleConfigModel: cfg type: {type(cfg)}")
|
|
172
|
+
logger.info(
|
|
173
|
+
f"🔍 SimpleConfigModel: hasattr(cfg, 'model'): {hasattr(cfg, 'model')}"
|
|
174
|
+
)
|
|
175
|
+
if hasattr(cfg, "model"):
|
|
176
|
+
logger.info(
|
|
177
|
+
f"🔍 SimpleConfigModel: cfg.model type: {type(cfg.model)}"
|
|
178
|
+
)
|
|
179
|
+
logger.info(
|
|
180
|
+
f"🔍 SimpleConfigModel: hasattr(cfg.model, 'registration'): {hasattr(cfg.model, 'registration')}"
|
|
181
|
+
)
|
|
182
|
+
if hasattr(cfg.model, "registration"):
|
|
183
|
+
reg_model = cfg.model.registration
|
|
184
|
+
logger.info(
|
|
185
|
+
f"🔍 SimpleConfigModel: reg_model type: {type(reg_model)}"
|
|
186
|
+
)
|
|
187
|
+
logger.info(
|
|
188
|
+
f"🔍 SimpleConfigModel: reg_model.enabled: {reg_model.enabled}, reg_model.auto_on_startup: {reg_model.auto_on_startup}"
|
|
189
|
+
)
|
|
190
|
+
registration_enabled = (
|
|
191
|
+
reg_model.enabled and reg_model.auto_on_startup
|
|
192
|
+
)
|
|
193
|
+
logger.info(
|
|
194
|
+
f"🔍 Registration enabled check (SimpleConfigModel): {registration_enabled}"
|
|
195
|
+
)
|
|
196
|
+
except Exception as e:
|
|
197
|
+
logger.info(f"🔍 SimpleConfigModel check failed: {e}")
|
|
198
|
+
import traceback
|
|
199
|
+
|
|
200
|
+
logger.info(
|
|
201
|
+
f"🔍 SimpleConfigModel check traceback: {traceback.format_exc()}"
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
# Check registration section
|
|
205
|
+
if not registration_enabled:
|
|
206
|
+
registration_config = current_config.get("registration") or {}
|
|
207
|
+
if registration_config:
|
|
208
|
+
reg_enabled = registration_config.get("enabled", False)
|
|
209
|
+
reg_auto_startup = registration_config.get(
|
|
210
|
+
"auto_on_startup", True
|
|
211
|
+
)
|
|
212
|
+
registration_enabled = reg_enabled and reg_auto_startup
|
|
213
|
+
|
|
214
|
+
logger.info(
|
|
215
|
+
f"🔍 FINAL registration_enabled: {registration_enabled}"
|
|
216
|
+
)
|
|
217
|
+
if registration_enabled:
|
|
218
|
+
logger.info("✅ Registration enabled, starting heartbeat task")
|
|
219
|
+
try:
|
|
220
|
+
await self.registration_manager.start_heartbeat(
|
|
221
|
+
current_config
|
|
222
|
+
)
|
|
223
|
+
except RegistrationSetupError as e:
|
|
224
|
+
# Bug 85fbfd87 (regression re-fix): a
|
|
225
|
+
# registration *configuration* error is FATAL
|
|
226
|
+
# to startup. start_heartbeat() already
|
|
227
|
+
# validated the config and raises this typed
|
|
228
|
+
# error instead of calling sys.exit() itself
|
|
229
|
+
# (RegistrationManager stays a library-safe
|
|
230
|
+
# unit); THIS call site is the one place that
|
|
231
|
+
# decides what a registration setup failure
|
|
232
|
+
# means for server startup, and it decides
|
|
233
|
+
# "fatal" - the same treatment
|
|
234
|
+
# app_factory_validators.py gives an invalid
|
|
235
|
+
# server configuration. logger.critical() plus
|
|
236
|
+
# _report_fatal_to_stderr() (guarded by
|
|
237
|
+
# _has_effective_handler(), both reused from
|
|
238
|
+
# app_factory_validators.py) guarantees a
|
|
239
|
+
# NullHandler-default consumer still sees WHY
|
|
240
|
+
# the process is about to die exactly once,
|
|
241
|
+
# and a consumer with its own handler is not
|
|
242
|
+
# shown the message twice. Re-raising lets
|
|
243
|
+
# Starlette's lifespan handling mark
|
|
244
|
+
# lifespan.startup.failed, which hypercorn
|
|
245
|
+
# propagates out of
|
|
246
|
+
# hypercorn.asyncio.serve() - caught by
|
|
247
|
+
# core/app_factory/server_runner.py's
|
|
248
|
+
# run_server(), which already sys.exit(1)s on
|
|
249
|
+
# any startup exception. No new sys.exit() is
|
|
250
|
+
# added here or in RegistrationManager.
|
|
251
|
+
logger.critical(
|
|
252
|
+
"🛑 CRITICAL REGISTRATION ERROR: registration "
|
|
253
|
+
f"setup failed, aborting startup: {e}",
|
|
254
|
+
exc_info=True,
|
|
255
|
+
)
|
|
256
|
+
if not _has_effective_handler(logger):
|
|
257
|
+
_report_fatal_to_stderr(
|
|
258
|
+
"CRITICAL REGISTRATION ERROR: registration "
|
|
259
|
+
f"setup failed, aborting startup: {e}"
|
|
260
|
+
)
|
|
261
|
+
raise
|
|
262
|
+
else:
|
|
263
|
+
logger.info(
|
|
264
|
+
"⚠️ Registration is disabled, skipping heartbeat task"
|
|
265
|
+
)
|
|
266
|
+
else:
|
|
267
|
+
logger.info("⚠️ current_config is None, skipping heartbeat task")
|
|
268
|
+
|
|
269
|
+
except RegistrationSetupError:
|
|
270
|
+
# Already reported (logger.critical() / _report_fatal_to_stderr())
|
|
271
|
+
# and must propagate as fatal - see the inner except above.
|
|
272
|
+
# This broad startup try/except must not re-swallow it.
|
|
273
|
+
raise
|
|
274
|
+
except Exception as e:
|
|
275
|
+
logger.error(f"❌ Lifespan startup failed: {e}", exc_info=True)
|
|
276
|
+
|
|
277
|
+
queue_config = _resolve_queue_config_dict(current_config, logger)
|
|
278
|
+
if queue_config.get("enabled", QUEUE_MANAGER_ENABLED_DEFAULT):
|
|
279
|
+
try:
|
|
280
|
+
from mcp_proxy_adapter.integrations.queuemgr_integration import (
|
|
281
|
+
init_global_queue_manager,
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
await init_global_queue_manager(
|
|
285
|
+
registry_path=queue_config.get("registry_path"),
|
|
286
|
+
shutdown_timeout=queue_config.get("shutdown_timeout", 30.0),
|
|
287
|
+
max_concurrent_jobs=queue_config.get("max_concurrent_jobs", 10),
|
|
288
|
+
in_memory=queue_config.get("in_memory", True),
|
|
289
|
+
max_queue_size=queue_config.get("max_queue_size"),
|
|
290
|
+
per_job_type_limits=queue_config.get("per_job_type_limits"),
|
|
291
|
+
completed_job_retention_seconds=queue_config.get(
|
|
292
|
+
"completed_job_retention_seconds", 21600
|
|
293
|
+
),
|
|
294
|
+
command_timeout=queue_config.get("command_timeout"),
|
|
295
|
+
stop_job_wait_timeout=queue_config.get("stop_job_wait_timeout"),
|
|
296
|
+
max_retained_terminal_jobs=queue_config.get(
|
|
297
|
+
"max_retained_terminal_jobs"
|
|
298
|
+
),
|
|
299
|
+
)
|
|
300
|
+
logger.info("✅ Queue manager initialized")
|
|
301
|
+
except Exception:
|
|
302
|
+
logger.error(
|
|
303
|
+
"Queue manager is enabled (or defaulted on); initialization failed "
|
|
304
|
+
"during application startup. The service will not start or serve until "
|
|
305
|
+
"this is resolved.",
|
|
306
|
+
exc_info=True,
|
|
307
|
+
)
|
|
308
|
+
logger.error(
|
|
309
|
+
"Remediation: fix queue configuration, queuemgr dependency, or "
|
|
310
|
+
"environment; or set queue_manager.enabled to false in config if the "
|
|
311
|
+
"queue is not required.",
|
|
312
|
+
)
|
|
313
|
+
raise
|
|
314
|
+
else:
|
|
315
|
+
logger.info("⚠️ Queue manager is disabled in configuration")
|
|
316
|
+
|
|
317
|
+
# WebSocket /ws and job push: always on (server pushes job results via WS, no config)
|
|
318
|
+
try:
|
|
319
|
+
from mcp_proxy_adapter.core.job_push.lifespan_wiring import (
|
|
320
|
+
startup_job_push,
|
|
321
|
+
)
|
|
322
|
+
|
|
323
|
+
await startup_job_push(app, current_config)
|
|
324
|
+
except Exception as jp_err:
|
|
325
|
+
logger.warning("⚠️ Job push startup failed: %s", jp_err)
|
|
326
|
+
|
|
327
|
+
yield
|
|
328
|
+
|
|
329
|
+
# Shutdown
|
|
330
|
+
get_global_logger().info("Shutting down MCP Proxy Adapter")
|
|
331
|
+
await self.registration_manager.stop()
|
|
332
|
+
try:
|
|
333
|
+
from mcp_proxy_adapter.core.job_push.lifespan_wiring import (
|
|
334
|
+
shutdown_job_push,
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
await shutdown_job_push(app)
|
|
338
|
+
except Exception as jp_err:
|
|
339
|
+
get_global_logger().warning("⚠️ Job push shutdown failed: %s", jp_err)
|
|
340
|
+
|
|
341
|
+
# Shutdown queue manager if initialized
|
|
342
|
+
try:
|
|
343
|
+
from mcp_proxy_adapter.integrations.queuemgr_integration import (
|
|
344
|
+
shutdown_global_queue_manager,
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
await shutdown_global_queue_manager()
|
|
348
|
+
get_global_logger().info("✅ Queue manager stopped")
|
|
349
|
+
except ImportError:
|
|
350
|
+
pass # Queue manager not available
|
|
351
|
+
except Exception as e:
|
|
352
|
+
get_global_logger().warning(f"⚠️ Queue manager shutdown failed: {e}")
|
|
353
|
+
|
|
354
|
+
return lifespan
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""The queue_config module of the lifespan_manager package: _resolve_queue_config_dict."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, Dict, Optional
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def _resolve_queue_config_dict(
|
|
7
|
+
current_config: Optional[Dict[str, Any]], logger: Any
|
|
8
|
+
) -> Dict[str, Any]:
|
|
9
|
+
"""Resolve ``queue_manager`` section from app config or global ``get_config()`` model."""
|
|
10
|
+
queue_config: Optional[Dict[str, Any]] = None
|
|
11
|
+
if current_config and "queue_manager" in current_config:
|
|
12
|
+
queue_config = current_config.get("queue_manager", {})
|
|
13
|
+
else:
|
|
14
|
+
try:
|
|
15
|
+
from mcp_proxy_adapter.config import get_config
|
|
16
|
+
|
|
17
|
+
cfg = get_config()
|
|
18
|
+
if hasattr(cfg, "model") and hasattr(cfg.model, "queue_manager"):
|
|
19
|
+
queue_config = {
|
|
20
|
+
"enabled": cfg.model.queue_manager.enabled,
|
|
21
|
+
"in_memory": cfg.model.queue_manager.in_memory,
|
|
22
|
+
"registry_path": cfg.model.queue_manager.registry_path,
|
|
23
|
+
"shutdown_timeout": cfg.model.queue_manager.shutdown_timeout,
|
|
24
|
+
"max_concurrent_jobs": cfg.model.queue_manager.max_concurrent_jobs,
|
|
25
|
+
"max_queue_size": cfg.model.queue_manager.max_queue_size,
|
|
26
|
+
"per_job_type_limits": cfg.model.queue_manager.per_job_type_limits,
|
|
27
|
+
"completed_job_retention_seconds": cfg.model.queue_manager.completed_job_retention_seconds,
|
|
28
|
+
"max_retained_terminal_jobs": cfg.model.queue_manager.max_retained_terminal_jobs,
|
|
29
|
+
"command_timeout": cfg.model.queue_manager.command_timeout,
|
|
30
|
+
"stop_job_wait_timeout": cfg.model.queue_manager.stop_job_wait_timeout,
|
|
31
|
+
}
|
|
32
|
+
except Exception as e:
|
|
33
|
+
logger.debug(f"Could not read queue config from global config: {e}")
|
|
34
|
+
|
|
35
|
+
if queue_config is None:
|
|
36
|
+
queue_config = {}
|
|
37
|
+
return queue_config
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""The signal_registration module of the lifespan_manager package:
|
|
2
|
+
_make_signal_registration.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import signal
|
|
7
|
+
from types import FrameType
|
|
8
|
+
from typing import Any, Optional
|
|
9
|
+
|
|
10
|
+
from mcp_proxy_adapter.core.logging import get_global_logger
|
|
11
|
+
|
|
12
|
+
from ..registration_manager import set_stop_flag_sync
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _make_signal_registration() -> Any:
|
|
16
|
+
"""Helper cut out of ``LifespanManager.create_lifespan``."""
|
|
17
|
+
|
|
18
|
+
def _sync_signal_handler(signum: int, frame: Optional[FrameType]) -> None:
|
|
19
|
+
"""Fallback signal handler used when loop.add_signal_handler is
|
|
20
|
+
unavailable (e.g. no running loop, or a platform - Windows'
|
|
21
|
+
ProactorEventLoop - that does not support it)."""
|
|
22
|
+
_ = frame
|
|
23
|
+
logger = get_global_logger()
|
|
24
|
+
logger.info(f"🛑 Received signal {signum}, setting stop flag...")
|
|
25
|
+
set_stop_flag_sync(True)
|
|
26
|
+
|
|
27
|
+
def _loop_signal_handler(signum: int) -> None:
|
|
28
|
+
"""Loop-integrated signal handler, invoked via loop.add_signal_handler."""
|
|
29
|
+
logger = get_global_logger()
|
|
30
|
+
logger.info(f"🛑 Received signal {signum}, setting stop flag...")
|
|
31
|
+
set_stop_flag_sync(True)
|
|
32
|
+
|
|
33
|
+
def _register_signal_handlers() -> None:
|
|
34
|
+
"""Register SIGINT/SIGTERM handlers for graceful shutdown.
|
|
35
|
+
|
|
36
|
+
Bug 0a669075-808e-41d1-937f-a711c96009f7: plain ``signal.signal()``
|
|
37
|
+
installs a handler at the C/interpreter level, but under asyncio
|
|
38
|
+
the Python-level callback is only actually invoked between
|
|
39
|
+
bytecode-eval-loop checks - it does not wake the event loop from
|
|
40
|
+
its underlying I/O wait, so a signal arriving while the loop is
|
|
41
|
+
blocked (e.g. long-running I/O-bound coroutines with nothing
|
|
42
|
+
else scheduled) can sit un-actioned for an unpredictable
|
|
43
|
+
interval. ``loop.add_signal_handler()`` registers the signal via
|
|
44
|
+
the loop's own self-pipe/wakeup mechanism instead: the callback
|
|
45
|
+
is scheduled promptly as a normal callback the next time the
|
|
46
|
+
loop processes its ready queue, with no dependency on unrelated
|
|
47
|
+
bytecode execution resuming, and it is safe to call
|
|
48
|
+
loop-interacting code directly from it (unlike a
|
|
49
|
+
``signal.signal()`` handler).
|
|
50
|
+
|
|
51
|
+
Falls back to ``signal.signal()`` when no running loop is
|
|
52
|
+
available (this can be called outside an async context) or the
|
|
53
|
+
platform does not support ``add_signal_handler`` at all
|
|
54
|
+
(``NotImplementedError`` - raised by Windows' ProactorEventLoop),
|
|
55
|
+
so behavior stays identical on platforms that need the
|
|
56
|
+
fallback. The side effect (``set_stop_flag_sync(True)`` plus the
|
|
57
|
+
same log line) is identical on both paths.
|
|
58
|
+
"""
|
|
59
|
+
try:
|
|
60
|
+
loop = asyncio.get_running_loop()
|
|
61
|
+
for sig in (signal.SIGINT, signal.SIGTERM):
|
|
62
|
+
loop.add_signal_handler(sig, _loop_signal_handler, sig)
|
|
63
|
+
return
|
|
64
|
+
except NotImplementedError:
|
|
65
|
+
# Platform does not support loop-integrated signal handlers
|
|
66
|
+
# (e.g. Windows' ProactorEventLoop).
|
|
67
|
+
pass
|
|
68
|
+
except RuntimeError:
|
|
69
|
+
# No running event loop (called outside an async context).
|
|
70
|
+
pass
|
|
71
|
+
signal.signal(signal.SIGINT, _sync_signal_handler)
|
|
72
|
+
signal.signal(signal.SIGTERM, _sync_signal_handler)
|
|
73
|
+
|
|
74
|
+
return _register_signal_handlers
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Registration context package for proxy interactions.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .context_builder import prepare_registration_context
|
|
9
|
+
from .models import HeartbeatSettings, ProxyCredentials, RegistrationContext
|
|
10
|
+
from .resolvers import (
|
|
11
|
+
resolve_heartbeat_settings,
|
|
12
|
+
resolve_runtime_credentials,
|
|
13
|
+
resolve_unregister_endpoint,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"ProxyCredentials",
|
|
18
|
+
"RegistrationContext",
|
|
19
|
+
"HeartbeatSettings",
|
|
20
|
+
"prepare_registration_context",
|
|
21
|
+
"resolve_runtime_credentials",
|
|
22
|
+
"resolve_heartbeat_settings",
|
|
23
|
+
"resolve_unregister_endpoint",
|
|
24
|
+
]
|