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,345 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Route registration helper for AppFactory.
|
|
6
|
+
FastAPI route registration for the MCP proxy adapter application factory.
|
|
7
|
+
Registers JSON-RPC, tools, WebSocket, and transfer HTTP endpoints.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import inspect
|
|
11
|
+
import json
|
|
12
|
+
from typing import Any, Awaitable, Callable, Dict, List, Optional, Union, cast
|
|
13
|
+
|
|
14
|
+
from fastapi import Body, FastAPI, Query, Request, WebSocket
|
|
15
|
+
from fastapi.responses import JSONResponse, Response
|
|
16
|
+
|
|
17
|
+
from mcp_proxy_adapter.api.handlers import (
|
|
18
|
+
complete_upload_session,
|
|
19
|
+
create_download_session,
|
|
20
|
+
create_upload_session,
|
|
21
|
+
download_chunk,
|
|
22
|
+
execute_command_async,
|
|
23
|
+
get_commands_list,
|
|
24
|
+
get_download_status,
|
|
25
|
+
get_server_health,
|
|
26
|
+
get_upload_status,
|
|
27
|
+
handle_batch_json_rpc,
|
|
28
|
+
handle_heartbeat,
|
|
29
|
+
handle_json_rpc,
|
|
30
|
+
upload_chunk,
|
|
31
|
+
)
|
|
32
|
+
from mcp_proxy_adapter.api.health_provider import get_health_provider
|
|
33
|
+
from mcp_proxy_adapter.core.errors import (
|
|
34
|
+
InvalidRequestError,
|
|
35
|
+
MethodNotFoundError,
|
|
36
|
+
NotFoundError,
|
|
37
|
+
ValidationError,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
from ..public_downloads import (
|
|
41
|
+
install_public_download_routes,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
from mcp_proxy_adapter.api.schemas import (
|
|
46
|
+
AsyncExecuteRequest,
|
|
47
|
+
CommandListResponse,
|
|
48
|
+
JsonRpcErrorResponse,
|
|
49
|
+
JsonRpcSuccessResponse,
|
|
50
|
+
)
|
|
51
|
+
except Exception: # pragma: no cover - fallback for simplified environments
|
|
52
|
+
JsonRpcSuccessResponse = Dict[str, Any] # type: ignore
|
|
53
|
+
JsonRpcErrorResponse = Dict[str, Any] # type: ignore
|
|
54
|
+
CommandListResponse = Dict[str, Any] # type: ignore
|
|
55
|
+
AsyncExecuteRequest = Dict[str, Any] # type: ignore
|
|
56
|
+
|
|
57
|
+
get_tool_description: Optional[Callable[[str], Awaitable[Union[Dict[str, Any], str]]]]
|
|
58
|
+
execute_tool: Optional[Callable[[str, Any, Dict[str, Any]], Awaitable[Dict[str, Any]]]]
|
|
59
|
+
try:
|
|
60
|
+
from mcp_proxy_adapter.api.tools import execute_tool, get_tool_description
|
|
61
|
+
except Exception: # pragma: no cover - optional dependency
|
|
62
|
+
get_tool_description = None
|
|
63
|
+
execute_tool = None
|
|
64
|
+
|
|
65
|
+
handle_websocket_job_push: Optional[Callable[[Any, FastAPI], Awaitable[None]]]
|
|
66
|
+
try:
|
|
67
|
+
from mcp_proxy_adapter.api.ws_endpoint import handle_websocket_job_push
|
|
68
|
+
except ImportError: # pragma: no cover
|
|
69
|
+
handle_websocket_job_push = None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
_JSONRPC_REQUEST_OPENAPI_SCHEMA: Dict[str, Any] = {
|
|
73
|
+
"type": "object",
|
|
74
|
+
"properties": {
|
|
75
|
+
"jsonrpc": {"type": "string", "enum": ["2.0"], "default": "2.0"},
|
|
76
|
+
"method": {"type": "string"},
|
|
77
|
+
"command": {"type": "string"},
|
|
78
|
+
"params": {
|
|
79
|
+
"oneOf": [
|
|
80
|
+
{"type": "object", "additionalProperties": True},
|
|
81
|
+
{"type": "array"},
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"id": {"oneOf": [{"type": "string"}, {"type": "integer"}, {"type": "null"}]},
|
|
85
|
+
},
|
|
86
|
+
"additionalProperties": True,
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
async def _read_json_body(request: Request) -> Any:
|
|
91
|
+
"""Parse JSON from immutable raw request bytes."""
|
|
92
|
+
body_bytes = await request.body()
|
|
93
|
+
try:
|
|
94
|
+
text = body_bytes.decode("utf-8")
|
|
95
|
+
except UnicodeDecodeError as exc:
|
|
96
|
+
raise ValueError("Request body must be UTF-8 JSON") from exc
|
|
97
|
+
try:
|
|
98
|
+
return json.loads(text)
|
|
99
|
+
except json.JSONDecodeError as exc:
|
|
100
|
+
raise ValueError("Invalid JSON body") from exc
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _invalid_json_response(exc: ValueError) -> JSONResponse:
|
|
104
|
+
"""Return the adapter's HTTP-level invalid JSON response."""
|
|
105
|
+
return JSONResponse(status_code=400, content={"detail": str(exc)})
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def setup_routes(app: FastAPI) -> None:
|
|
109
|
+
"""
|
|
110
|
+
Register built-in API routes.
|
|
111
|
+
|
|
112
|
+
/ws is always registered when the handler is available. WS is the way
|
|
113
|
+
the server pushes job results to the client (no polling). No config.
|
|
114
|
+
"""
|
|
115
|
+
install_public_download_routes(app)
|
|
116
|
+
|
|
117
|
+
# Bug 39931df8: an application may replace this payload via set_health_provider().
|
|
118
|
+
@app.get("/health")
|
|
119
|
+
async def health(): # type: ignore
|
|
120
|
+
"""Return server health status.
|
|
121
|
+
|
|
122
|
+
Always HTTP 200 when the server answered at all (bug 85f2426e,
|
|
123
|
+
orchestrator decision R1: an earlier version of this route
|
|
124
|
+
returned 503 for a non-``"ok"`` top-level status, but this
|
|
125
|
+
package's OWN clients treat a non-2xx ``/health`` response as
|
|
126
|
+
"server unreachable" - ``core/orchestration/candidate_validator.py``
|
|
127
|
+
drops the server from its catalog, ``client/jsonrpc_client/
|
|
128
|
+
transport.py``'s ``health()`` raises instead of returning the body,
|
|
129
|
+
``core/client/client.py``'s ``test_connection()`` reports a
|
|
130
|
+
reachable-but-degraded server as failed - so a 503 here would have
|
|
131
|
+
made a degraded server invisible to exactly the tooling meant to
|
|
132
|
+
see it). The outage is conveyed by the BODY instead: top-level
|
|
133
|
+
``status`` is ``"ok"`` only on genuine liveness evidence and
|
|
134
|
+
``"degraded"`` otherwise (see
|
|
135
|
+
``queuemgr_integration.derive_overall_status()``; a component
|
|
136
|
+
underneath, e.g. ``components.queue``, may separately read
|
|
137
|
+
``"unhealthy"`` as diagnostic detail) - callers must read the body,
|
|
138
|
+
not the HTTP status, to detect degradation. A custom provider fully
|
|
139
|
+
owns its own payload AND status code (never overridden here) - this
|
|
140
|
+
composes with the provider hook instead of bypassing it.
|
|
141
|
+
"""
|
|
142
|
+
provider = get_health_provider()
|
|
143
|
+
if provider is not None:
|
|
144
|
+
result = provider()
|
|
145
|
+
if inspect.isawaitable(result):
|
|
146
|
+
result = await result
|
|
147
|
+
return result
|
|
148
|
+
return await get_server_health()
|
|
149
|
+
|
|
150
|
+
@app.get("/commands", response_model=CommandListResponse)
|
|
151
|
+
async def commands(): # type: ignore
|
|
152
|
+
"""Return list of available commands."""
|
|
153
|
+
return await get_commands_list()
|
|
154
|
+
|
|
155
|
+
@app.get("/heartbeat")
|
|
156
|
+
async def heartbeat(): # type: ignore
|
|
157
|
+
"""Built-in heartbeat endpoint for proxy health checks."""
|
|
158
|
+
return await handle_heartbeat()
|
|
159
|
+
|
|
160
|
+
@app.post(
|
|
161
|
+
"/api/jsonrpc",
|
|
162
|
+
response_model=Union[JsonRpcSuccessResponse, JsonRpcErrorResponse],
|
|
163
|
+
openapi_extra={
|
|
164
|
+
"requestBody": {
|
|
165
|
+
"content": {
|
|
166
|
+
"application/json": {"schema": _JSONRPC_REQUEST_OPENAPI_SCHEMA}
|
|
167
|
+
},
|
|
168
|
+
"required": True,
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
)
|
|
172
|
+
async def jsonrpc(http_request: Request): # type: ignore
|
|
173
|
+
"""Handle single JSON-RPC 2.0 request."""
|
|
174
|
+
request_id = getattr(http_request.state, "request_id", None)
|
|
175
|
+
try:
|
|
176
|
+
body = await _read_json_body(http_request)
|
|
177
|
+
except ValueError as exc:
|
|
178
|
+
return _invalid_json_response(exc)
|
|
179
|
+
if not isinstance(body, dict):
|
|
180
|
+
return JSONResponse(
|
|
181
|
+
status_code=422,
|
|
182
|
+
content={"detail": "JSON-RPC body must be a JSON object"},
|
|
183
|
+
)
|
|
184
|
+
return await handle_json_rpc(
|
|
185
|
+
cast(Dict[str, Any], body), request_id, http_request
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
@app.post(
|
|
189
|
+
"/api/jsonrpc/batch",
|
|
190
|
+
response_model=List[Union[JsonRpcSuccessResponse, JsonRpcErrorResponse]],
|
|
191
|
+
openapi_extra={
|
|
192
|
+
"requestBody": {
|
|
193
|
+
"content": {
|
|
194
|
+
"application/json": {
|
|
195
|
+
"schema": {
|
|
196
|
+
"type": "array",
|
|
197
|
+
"items": _JSONRPC_REQUEST_OPENAPI_SCHEMA,
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"required": True,
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
)
|
|
205
|
+
async def jsonrpc_batch(http_request: Request): # type: ignore
|
|
206
|
+
"""Handle batch JSON-RPC 2.0 requests."""
|
|
207
|
+
try:
|
|
208
|
+
payload = await _read_json_body(http_request)
|
|
209
|
+
except ValueError as exc:
|
|
210
|
+
return _invalid_json_response(exc)
|
|
211
|
+
if not isinstance(payload, list) or not all(
|
|
212
|
+
isinstance(item, dict) for item in payload
|
|
213
|
+
):
|
|
214
|
+
return JSONResponse(
|
|
215
|
+
status_code=422,
|
|
216
|
+
content={"detail": "JSON-RPC batch body must be an array of objects"},
|
|
217
|
+
)
|
|
218
|
+
return await handle_batch_json_rpc(
|
|
219
|
+
[cast(Dict[str, Any], item) for item in payload], http_request
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
@app.post("/api/async")
|
|
223
|
+
async def api_async(request: Request, body: AsyncExecuteRequest) -> Any:
|
|
224
|
+
"""
|
|
225
|
+
Accept async command execution; return immediately.
|
|
226
|
+
Response includes server-generated ws_id, job_id null for in-process
|
|
227
|
+
async, and nested delivery; result is delivered via WebSocket to
|
|
228
|
+
subscribers for that ws_id.
|
|
229
|
+
"""
|
|
230
|
+
cmd = body.command or ""
|
|
231
|
+
params = body.params or {}
|
|
232
|
+
if not cmd.strip():
|
|
233
|
+
return JSONResponse(
|
|
234
|
+
status_code=400,
|
|
235
|
+
content={"error": "command is required"},
|
|
236
|
+
)
|
|
237
|
+
request_id = getattr(request.state, "request_id", None)
|
|
238
|
+
try:
|
|
239
|
+
result = await execute_command_async(cmd, params, None, request_id, request)
|
|
240
|
+
return result
|
|
241
|
+
except MethodNotFoundError as e:
|
|
242
|
+
return JSONResponse(
|
|
243
|
+
status_code=404,
|
|
244
|
+
content={"error": e.message, "code": e.code, "data": e.data},
|
|
245
|
+
)
|
|
246
|
+
except (ValidationError, InvalidRequestError) as e:
|
|
247
|
+
return JSONResponse(
|
|
248
|
+
status_code=400,
|
|
249
|
+
content={"error": e.message, "code": e.code, "data": e.data},
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
@app.post("/tools/{tool_name}", response_model=None)
|
|
253
|
+
async def execute_tool_endpoint(
|
|
254
|
+
tool_name: str,
|
|
255
|
+
request: Request,
|
|
256
|
+
payload: Dict[str, Any] = Body(default_factory=dict),
|
|
257
|
+
) -> Union[Dict[str, Any], JSONResponse]:
|
|
258
|
+
"""Execute named tool with payload; return result."""
|
|
259
|
+
if execute_tool is None:
|
|
260
|
+
raise ValueError("Tool execution is not available in this environment")
|
|
261
|
+
try:
|
|
262
|
+
return await execute_tool(tool_name, request, payload)
|
|
263
|
+
except NotFoundError as e:
|
|
264
|
+
return JSONResponse(
|
|
265
|
+
status_code=404,
|
|
266
|
+
content={"error": e.message, "code": e.code, "data": e.data},
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
@app.get("/tools/{tool_name}", response_model=None)
|
|
270
|
+
async def get_tool_endpoint(
|
|
271
|
+
tool_name: str,
|
|
272
|
+
) -> Union[Dict[str, Any], str, JSONResponse]:
|
|
273
|
+
"""Return description of named tool."""
|
|
274
|
+
if get_tool_description is None:
|
|
275
|
+
raise ValueError("Tool description is not available in this environment")
|
|
276
|
+
try:
|
|
277
|
+
return await get_tool_description(tool_name)
|
|
278
|
+
except NotFoundError as e:
|
|
279
|
+
return JSONResponse(
|
|
280
|
+
status_code=404,
|
|
281
|
+
content={"error": e.message, "code": e.code, "data": e.data},
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
# Transfer HTTP API — registered paths:
|
|
285
|
+
# POST /api/transfer/uploads
|
|
286
|
+
# GET /api/transfer/uploads/{transfer_id}
|
|
287
|
+
# PUT /api/transfer/uploads/{transfer_id}/chunks
|
|
288
|
+
# POST /api/transfer/uploads/{transfer_id}/complete
|
|
289
|
+
# POST /api/transfer/downloads
|
|
290
|
+
# GET /api/transfer/downloads/{transfer_id}
|
|
291
|
+
# GET /api/transfer/downloads/{transfer_id}/chunks
|
|
292
|
+
|
|
293
|
+
@app.post("/api/transfer/uploads", response_model=None)
|
|
294
|
+
async def transfer_uploads_create(
|
|
295
|
+
payload: dict[str, object] = Body(...),
|
|
296
|
+
) -> JSONResponse:
|
|
297
|
+
"""Create upload transfer session."""
|
|
298
|
+
return await create_upload_session(payload)
|
|
299
|
+
|
|
300
|
+
@app.get("/api/transfer/uploads/{transfer_id}", response_model=None)
|
|
301
|
+
async def transfer_uploads_status(transfer_id: str) -> JSONResponse:
|
|
302
|
+
"""Get upload transfer session status."""
|
|
303
|
+
return await get_upload_status(transfer_id)
|
|
304
|
+
|
|
305
|
+
@app.put("/api/transfer/uploads/{transfer_id}/chunks", response_model=None)
|
|
306
|
+
async def transfer_uploads_chunks(
|
|
307
|
+
transfer_id: str,
|
|
308
|
+
request: Request,
|
|
309
|
+
offset: int = Query(..., ge=0),
|
|
310
|
+
) -> JSONResponse:
|
|
311
|
+
"""Upload file chunk at offset."""
|
|
312
|
+
return await upload_chunk(transfer_id, offset, request)
|
|
313
|
+
|
|
314
|
+
@app.post("/api/transfer/uploads/{transfer_id}/complete", response_model=None)
|
|
315
|
+
async def transfer_uploads_complete(transfer_id: str) -> JSONResponse:
|
|
316
|
+
"""Finalize upload session."""
|
|
317
|
+
return await complete_upload_session(transfer_id)
|
|
318
|
+
|
|
319
|
+
@app.post("/api/transfer/downloads", response_model=None)
|
|
320
|
+
async def transfer_downloads_create(
|
|
321
|
+
payload: dict[str, object] = Body(...),
|
|
322
|
+
) -> JSONResponse:
|
|
323
|
+
"""Create download transfer session."""
|
|
324
|
+
return await create_download_session(payload)
|
|
325
|
+
|
|
326
|
+
@app.get("/api/transfer/downloads/{transfer_id}", response_model=None)
|
|
327
|
+
async def transfer_downloads_status(transfer_id: str) -> JSONResponse:
|
|
328
|
+
"""Get download transfer session status."""
|
|
329
|
+
return await get_download_status(transfer_id)
|
|
330
|
+
|
|
331
|
+
@app.get("/api/transfer/downloads/{transfer_id}/chunks", response_model=None)
|
|
332
|
+
async def transfer_downloads_chunks(
|
|
333
|
+
transfer_id: str,
|
|
334
|
+
offset: int = Query(..., ge=0),
|
|
335
|
+
limit: int = Query(..., ge=1),
|
|
336
|
+
) -> Union[Response, JSONResponse]:
|
|
337
|
+
"""Download file chunk at offset with size limit."""
|
|
338
|
+
return await download_chunk(transfer_id, offset, limit)
|
|
339
|
+
|
|
340
|
+
if handle_websocket_job_push is not None:
|
|
341
|
+
|
|
342
|
+
@app.websocket("/ws")
|
|
343
|
+
async def websocket_job_push(websocket: WebSocket) -> None:
|
|
344
|
+
"""Handle WebSocket connection for job result delivery."""
|
|
345
|
+
await handle_websocket_job_push(websocket, app)
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Validation helpers for API AppFactory.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import logging
|
|
9
|
+
import sys
|
|
10
|
+
from typing import Any, Dict, Optional
|
|
11
|
+
|
|
12
|
+
# Real logger hierarchies are always a handful of levels deep (this
|
|
13
|
+
# process's root logger is the deepest any config could reasonably nest).
|
|
14
|
+
# This bound is purely a defensive backstop against a walk that would
|
|
15
|
+
# otherwise never terminate - see _has_effective_handler's docstring.
|
|
16
|
+
_MAX_LOGGER_CHAIN_DEPTH = 50
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _has_effective_handler(logger: logging.Logger) -> bool:
|
|
20
|
+
"""
|
|
21
|
+
Check if a logger has an effective handler that will deliver messages.
|
|
22
|
+
|
|
23
|
+
Walks the logger and its ancestors (while propagate is True) to check if
|
|
24
|
+
any handler is NOT a NullHandler. This is used to determine whether a
|
|
25
|
+
message logged via logger.critical() will actually reach an output stream,
|
|
26
|
+
allowing us to avoid duplicate reporting via _report_fatal_to_stderr().
|
|
27
|
+
|
|
28
|
+
Bug 9574d00d regression (discovered via
|
|
29
|
+
tests/test_server_bootstrap_validation.py, which calls this
|
|
30
|
+
indirectly with a unittest.mock.MagicMock() standing in for the
|
|
31
|
+
logger): the walk only advances through genuine logging.Logger
|
|
32
|
+
ancestors now. A real root logger's .parent is None, which
|
|
33
|
+
naturally ends the loop; an object that merely LOOKS like a Logger
|
|
34
|
+
(a MagicMock, say) has a .parent attribute that never becomes falsy
|
|
35
|
+
on its own - every access returns a fresh, still-truthy child mock -
|
|
36
|
+
so the old unconditional `while current:` loop never returned. The
|
|
37
|
+
isinstance() guard stops walking the instant something other than a
|
|
38
|
+
real Logger shows up (treating it as "no effective handler",
|
|
39
|
+
matching what this function already returns for a bare NullHandler
|
|
40
|
+
chain), and the depth cap is a second, independent backstop.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
logger: The logger to check.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
True if any handler in the logger chain is not a NullHandler
|
|
47
|
+
(i.e., a record would actually be delivered somewhere).
|
|
48
|
+
"""
|
|
49
|
+
# A real root logger's .parent is None (logging.Logger.parent is typed
|
|
50
|
+
# Optional[Logger] by the stdlib itself) - current legitimately becomes
|
|
51
|
+
# None once the walk reaches the root, which is exactly what the
|
|
52
|
+
# isinstance() check below already treats as "stop walking, no
|
|
53
|
+
# effective handler" (no behaviour change, just naming the type this
|
|
54
|
+
# variable always had).
|
|
55
|
+
current: Optional[logging.Logger] = logger
|
|
56
|
+
depth = 0
|
|
57
|
+
while isinstance(current, logging.Logger) and depth < _MAX_LOGGER_CHAIN_DEPTH:
|
|
58
|
+
# Check this logger's handlers
|
|
59
|
+
for handler in current.handlers:
|
|
60
|
+
if not isinstance(handler, logging.NullHandler):
|
|
61
|
+
return True
|
|
62
|
+
# If propagate is False, stop here
|
|
63
|
+
if not current.propagate:
|
|
64
|
+
break
|
|
65
|
+
# Move to parent logger
|
|
66
|
+
current = current.parent
|
|
67
|
+
depth += 1
|
|
68
|
+
return False
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def validate_configuration(
|
|
72
|
+
current_config: Dict[str, Any],
|
|
73
|
+
logger: logging.Logger,
|
|
74
|
+
config_path: str | None = None,
|
|
75
|
+
) -> None:
|
|
76
|
+
"""
|
|
77
|
+
Validate configuration at startup using SimpleConfigValidator.
|
|
78
|
+
|
|
79
|
+
This is the ONE enforcement point ``create_app`` calls. Configuration in
|
|
80
|
+
this project is exclusively SimpleConfig-shaped (``server``/``client``/
|
|
81
|
+
``registration``/``auth``/``queue_manager``); a dict that cannot be
|
|
82
|
+
reconstructed into a ``SimpleConfigModel`` is, by construction, an
|
|
83
|
+
invalid configuration, so no separate "is this the legacy flat schema"
|
|
84
|
+
branch is needed - ``build_simple_config_model``/``SimpleConfigValidator``
|
|
85
|
+
is run unconditionally and any failure (missing required fields, a bad
|
|
86
|
+
protocol, an unknown role, ...) is reported and rejected here.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
current_config: Configuration dictionary.
|
|
90
|
+
logger: Logger instance for reporting errors.
|
|
91
|
+
config_path: Optional path to the config file (used to resolve
|
|
92
|
+
relative file paths, e.g. certificates).
|
|
93
|
+
|
|
94
|
+
Raises:
|
|
95
|
+
SystemExit: If validation fails. The failure is also always written
|
|
96
|
+
directly to stderr (see ``_report_fatal_to_stderr``) so it is
|
|
97
|
+
self-reporting even when ``logger`` has no configured handlers
|
|
98
|
+
(bug 20231492 follow-up, regression "R1" - see that helper's
|
|
99
|
+
docstring).
|
|
100
|
+
"""
|
|
101
|
+
try:
|
|
102
|
+
# The dict-to-model reconstruction is shared with the rest of the
|
|
103
|
+
# startup path so there is exactly one implementation of "build a
|
|
104
|
+
# SimpleConfigModel from a raw dict".
|
|
105
|
+
from mcp_proxy_adapter.api.core.app_factory_certificates import (
|
|
106
|
+
build_simple_config_model,
|
|
107
|
+
)
|
|
108
|
+
from mcp_proxy_adapter.core.config.simple_config_validator import (
|
|
109
|
+
SimpleConfigValidator,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
model = build_simple_config_model(current_config)
|
|
113
|
+
|
|
114
|
+
validator = SimpleConfigValidator(config_path=config_path)
|
|
115
|
+
validation_errors = validator.validate(model, raw_config=current_config)
|
|
116
|
+
if validation_errors:
|
|
117
|
+
from mcp_proxy_adapter.core.config.config import (
|
|
118
|
+
_format_validation_error,
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
rendered = [_format_validation_error(e) for e in validation_errors]
|
|
122
|
+
detail = "; ".join(rendered)
|
|
123
|
+
logger.critical("CRITICAL CONFIG ERROR: Invalid configuration at startup:")
|
|
124
|
+
for line in rendered:
|
|
125
|
+
logger.critical(f" - {line}")
|
|
126
|
+
if not _has_effective_handler(logger):
|
|
127
|
+
_report_fatal_to_stderr(
|
|
128
|
+
f"CRITICAL CONFIG ERROR: Invalid configuration at startup: {detail}"
|
|
129
|
+
)
|
|
130
|
+
raise SystemExit(1)
|
|
131
|
+
except SystemExit:
|
|
132
|
+
raise
|
|
133
|
+
except Exception as ex:
|
|
134
|
+
logger.critical(f"Failed to run startup configuration validation: {ex}")
|
|
135
|
+
if not _has_effective_handler(logger):
|
|
136
|
+
_report_fatal_to_stderr(
|
|
137
|
+
f"CRITICAL CONFIG ERROR: Failed to run startup configuration "
|
|
138
|
+
f"validation: {ex}"
|
|
139
|
+
)
|
|
140
|
+
raise SystemExit(1) from ex
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _report_fatal_to_stderr(message: str) -> None:
|
|
144
|
+
"""
|
|
145
|
+
Write a fatal startup message directly to stderr, independent of logging
|
|
146
|
+
configuration (bug 20231492 follow-up, regression "R1").
|
|
147
|
+
|
|
148
|
+
The library's silent-by-default logger
|
|
149
|
+
(``core.logging.get_global_logger()``'s ``NullHandler`` default) made
|
|
150
|
+
the ``logger.critical(...)`` calls above silent for any consumer who
|
|
151
|
+
never opted into console logging: a fatal, invalid-config startup
|
|
152
|
+
failure used to always print a critical log line before exiting 1; after
|
|
153
|
+
the silence fix, that line stopped reaching stdout OR stderr at all -
|
|
154
|
+
Python's ``logging.Handler.callHandlers()`` counts a ``NullHandler`` as
|
|
155
|
+
"a handler was found" and never falls back to ``logging.lastResort``, so
|
|
156
|
+
the process exited 1 with ZERO diagnostic bytes anywhere. This writes
|
|
157
|
+
directly to stderr so a fatal startup error is ALWAYS self-reporting,
|
|
158
|
+
regardless of whatever logging configuration (if any) the caller has set
|
|
159
|
+
up - matching pre-fix visibility without depending on console logging
|
|
160
|
+
having been enabled.
|
|
161
|
+
|
|
162
|
+
Args:
|
|
163
|
+
message: The fatal error text to write to stderr.
|
|
164
|
+
"""
|
|
165
|
+
print(message, file=sys.stderr)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Lifespan management utilities for MCP Proxy Adapter API.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# flake8: noqa: F401
|
|
9
|
+
import asyncio # noqa: F401
|
|
10
|
+
import signal # noqa: F401
|
|
11
|
+
from contextlib import asynccontextmanager # noqa: F401
|
|
12
|
+
from types import FrameType # noqa: F401
|
|
13
|
+
from typing import Any, AsyncContextManager, AsyncIterator, Callable, Dict, Optional
|
|
14
|
+
|
|
15
|
+
from fastapi import FastAPI # noqa: F401
|
|
16
|
+
|
|
17
|
+
from mcp_proxy_adapter.api.core.app_factory_validators import ( # noqa: F401
|
|
18
|
+
_has_effective_handler,
|
|
19
|
+
_report_fatal_to_stderr,
|
|
20
|
+
)
|
|
21
|
+
from mcp_proxy_adapter.core.logging import get_global_logger # noqa: F401
|
|
22
|
+
from mcp_proxy_adapter.core.path_utils import ( # noqa: F401
|
|
23
|
+
ensure_application_path,
|
|
24
|
+
ensure_registered_modules_paths,
|
|
25
|
+
)
|
|
26
|
+
from mcp_proxy_adapter.integrations.queuemgr_integration import ( # noqa: F401
|
|
27
|
+
QUEUE_MANAGER_ENABLED_DEFAULT,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
from ..registration_manager import ( # noqa: F401
|
|
31
|
+
RegistrationManager,
|
|
32
|
+
RegistrationSetupError,
|
|
33
|
+
set_stop_flag_sync,
|
|
34
|
+
)
|
|
35
|
+
from .manager import LifespanManager # noqa: F401
|
|
36
|
+
from .queue_config import _resolve_queue_config_dict # noqa: F401
|
|
37
|
+
from .signal_registration import _make_signal_registration # noqa: F401
|
|
38
|
+
|
|
39
|
+
# The submodules stay reachable as attributes of the package but are not
|
|
40
|
+
# part of its star-import surface, exactly as in the original single module.
|
|
41
|
+
for _name in ("manager", "queue_config", "signal_registration"):
|
|
42
|
+
globals().pop(_name, None)
|
|
43
|
+
del _name
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def __getattr__(name: str) -> Any:
|
|
47
|
+
"""Return a live module global or an imported submodule by attribute name."""
|
|
48
|
+
import sys as _sys
|
|
49
|
+
|
|
50
|
+
if name in ("manager", "queue_config", "signal_registration"):
|
|
51
|
+
return _sys.modules[f"{__name__}.{name}"]
|
|
52
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|