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,93 @@
|
|
|
1
|
+
"""Proxy registration helpers for JsonRpcClient.
|
|
2
|
+
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import re
|
|
10
|
+
from typing import Any, Dict, List, Optional, Tuple, Union, cast
|
|
11
|
+
from urllib.parse import urlparse
|
|
12
|
+
|
|
13
|
+
from mcp_proxy_adapter.client.jsonrpc_client.proxy_api_bases.lifecycle_base import (
|
|
14
|
+
ProxyApiLifecycleBase,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class ProxyApiMixin(ProxyApiLifecycleBase):
|
|
19
|
+
"""Mixin providing proxy registration helpers."""
|
|
20
|
+
|
|
21
|
+
async def _retry_registration_after_unregister_via_client(
|
|
22
|
+
self,
|
|
23
|
+
proxy_base: str,
|
|
24
|
+
register_url: str,
|
|
25
|
+
server_name: str,
|
|
26
|
+
server_url: str,
|
|
27
|
+
capabilities: Optional[List[str]],
|
|
28
|
+
metadata: Optional[Dict[str, Any]],
|
|
29
|
+
error_data: Dict[str, Any],
|
|
30
|
+
cert: Optional[Tuple[str, str]],
|
|
31
|
+
verify: Optional[Union[bool, str]],
|
|
32
|
+
) -> Dict[str, Any]:
|
|
33
|
+
"""Retry registration after unregister using JsonRpcClient."""
|
|
34
|
+
match = re.search(
|
|
35
|
+
r"already registered as ([^\s,]+)",
|
|
36
|
+
error_data.get("error", ""),
|
|
37
|
+
re.IGNORECASE,
|
|
38
|
+
)
|
|
39
|
+
if not match:
|
|
40
|
+
raise RuntimeError(
|
|
41
|
+
"Registration recovery response did not identify the registered server"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
registered_server_key = match.group(1)
|
|
45
|
+
original_server_id = (
|
|
46
|
+
re.sub(r"_\d+$", "", registered_server_key)
|
|
47
|
+
if "_" in registered_server_key
|
|
48
|
+
else registered_server_key
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Extract protocol, host, port from proxy_base
|
|
52
|
+
parsed = urlparse(proxy_base)
|
|
53
|
+
client_protocol = parsed.scheme or "http"
|
|
54
|
+
client_host = parsed.hostname or "localhost"
|
|
55
|
+
client_port = parsed.port or (443 if client_protocol == "https" else 80)
|
|
56
|
+
|
|
57
|
+
proxy_client = self._build_internal_proxy_client(
|
|
58
|
+
client_protocol, client_host, client_port, cert, verify
|
|
59
|
+
)
|
|
60
|
+
try:
|
|
61
|
+
# Use internal client from JsonRpcTransport
|
|
62
|
+
client = await proxy_client._get_client()
|
|
63
|
+
|
|
64
|
+
# Unregister
|
|
65
|
+
unregister_payload: Dict[str, Any] = {
|
|
66
|
+
"server_id": original_server_id,
|
|
67
|
+
"server_url": "",
|
|
68
|
+
"capabilities": [],
|
|
69
|
+
"metadata": {},
|
|
70
|
+
}
|
|
71
|
+
unregister_response = await client.post(
|
|
72
|
+
f"{proxy_base}/unregister",
|
|
73
|
+
json=unregister_payload,
|
|
74
|
+
)
|
|
75
|
+
if unregister_response.status_code != 200:
|
|
76
|
+
unregister_response.raise_for_status()
|
|
77
|
+
|
|
78
|
+
# Retry registration
|
|
79
|
+
# Extract and validate UUID from metadata
|
|
80
|
+
uuid_value = self._extract_and_validate_uuid(metadata)
|
|
81
|
+
|
|
82
|
+
retry_payload: Dict[str, Any] = {
|
|
83
|
+
"server_id": server_name,
|
|
84
|
+
"server_url": server_url,
|
|
85
|
+
"uuid": uuid_value, # UUID at root level - REQUIRED
|
|
86
|
+
"capabilities": capabilities or [],
|
|
87
|
+
"metadata": metadata or {},
|
|
88
|
+
}
|
|
89
|
+
retry_response = await client.post(register_url, json=retry_payload)
|
|
90
|
+
retry_response.raise_for_status()
|
|
91
|
+
return cast(Dict[str, Any], retry_response.json())
|
|
92
|
+
finally:
|
|
93
|
+
await proxy_client.close()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Base-class modules of ProxyApiMixin."""
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"""Internal proxy client construction of the proxy registration mixin.
|
|
2
|
+
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import TYPE_CHECKING, Optional, Tuple, Union
|
|
10
|
+
|
|
11
|
+
from mcp_proxy_adapter.client.jsonrpc_client.proxy_api_bases.uuid_base import (
|
|
12
|
+
ProxyApiUuidBase,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
# Imported from its leaf definition module (client.py), not the
|
|
17
|
+
# jsonrpc_client package __init__, to keep the package __init__ out of
|
|
18
|
+
# the static import cycle: __init__ imports client.py (runtime) and
|
|
19
|
+
# client.py imports this module (runtime), so a TYPE_CHECKING edge back
|
|
20
|
+
# through __init__ closed a 3-node cycle. The residual client.py <->
|
|
21
|
+
# proxy_api.py TYPE_CHECKING edge is the standard, unavoidable pattern
|
|
22
|
+
# for a mixin that returns the concrete composed class it is mixed into
|
|
23
|
+
# (JsonRpcClient(ProxyApiMixin, ...) at runtime); it never executes
|
|
24
|
+
# (TYPE_CHECKING is False at runtime) and mypy resolves such pairs fine.
|
|
25
|
+
from mcp_proxy_adapter.client.jsonrpc_client.client import JsonRpcClient
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ProxyApiClientBase(ProxyApiUuidBase):
|
|
29
|
+
"""Base of the proxy registration mixin: internal client construction."""
|
|
30
|
+
|
|
31
|
+
def _build_internal_proxy_client(
|
|
32
|
+
self,
|
|
33
|
+
protocol: str,
|
|
34
|
+
host: str,
|
|
35
|
+
port: int,
|
|
36
|
+
cert: Optional[Tuple[str, str]],
|
|
37
|
+
verify: Optional[Union[bool, str]],
|
|
38
|
+
) -> "JsonRpcClient":
|
|
39
|
+
"""Construct the internal ``JsonRpcClient`` used for a single proxy call.
|
|
40
|
+
|
|
41
|
+
``verify`` follows the tri-state contract also used by
|
|
42
|
+
``ProxyCredentials``/``JsonRpcTransport`` (see
|
|
43
|
+
``mcp_proxy_adapter/client/jsonrpc_client/transport.py``): a CA
|
|
44
|
+
certificate path pins verification to that CA; ``True`` requests
|
|
45
|
+
default verification (system trust store for a bare https/mtls-with-ca
|
|
46
|
+
connection); ``False`` is an explicit operator opt-out that disables
|
|
47
|
+
server certificate verification outright (e.g. a local self-signed
|
|
48
|
+
dev proxy). When the per-call ``cert``/``verify`` overrides are not
|
|
49
|
+
given (``None``), this client's own ``self.cert``/``self.verify`` are
|
|
50
|
+
inherited, matching every call site's previous "override or self"
|
|
51
|
+
fallback intent. The HOSTNAME policy is inherited the same way, from
|
|
52
|
+
``self._check_hostname``: there is no per-call override for it, and
|
|
53
|
+
``RegistrationManager`` configures only the outer client, so taking
|
|
54
|
+
the constructor default here would silently discard the operator's
|
|
55
|
+
``registration.ssl.check_hostname``/``dnscheck`` setting on the
|
|
56
|
+
client that actually reaches the proxy.
|
|
57
|
+
|
|
58
|
+
Bug 0079e279-ece9-4c8c-992d-bae93e1ac745: ``register_with_proxy``,
|
|
59
|
+
``unregister_from_proxy``, ``heartbeat_to_proxy`` and
|
|
60
|
+
``_retry_registration_after_unregister_via_client`` each duplicated an
|
|
61
|
+
internal-client construction that collapsed this tri-state to a bare
|
|
62
|
+
``client_ca`` extraction with ``elif verify is False: client_ca =
|
|
63
|
+
None`` - a no-op, since ``client_ca`` was already ``None`` on that
|
|
64
|
+
branch. Because ``JsonRpcClient`` has no ``verify_server``
|
|
65
|
+
passthrough (only the lower-level ``JsonRpcTransport`` does) and
|
|
66
|
+
defaults to verifying against the system trust store whenever ``ca``
|
|
67
|
+
is not supplied, ``verify=True`` and ``verify=False`` built an
|
|
68
|
+
IDENTICAL client: the explicit opt-out was silently ignored and the
|
|
69
|
+
live network call always attempted certificate verification,
|
|
70
|
+
regardless of what the caller asked for.
|
|
71
|
+
|
|
72
|
+
This helper is applied by setting the constructed client's public
|
|
73
|
+
``.verify`` attribute directly for the ``False`` case.
|
|
74
|
+
``JsonRpcTransport`` reads ``self.verify`` lazily (only when
|
|
75
|
+
``_get_client()``/``get_ws_ssl_context()`` first run), so setting it
|
|
76
|
+
immediately after construction, before any request is made, is safe
|
|
77
|
+
and takes effect exactly like a ``verify_server=False`` constructor
|
|
78
|
+
argument would.
|
|
79
|
+
|
|
80
|
+
Returns:
|
|
81
|
+
A new ``JsonRpcClient`` with ``.verify`` correctly reflecting the
|
|
82
|
+
resolved tri-state. The caller owns closing it.
|
|
83
|
+
"""
|
|
84
|
+
client_cert = None
|
|
85
|
+
client_key = None
|
|
86
|
+
if cert:
|
|
87
|
+
client_cert, client_key = cert
|
|
88
|
+
elif self.cert:
|
|
89
|
+
client_cert, client_key = self.cert
|
|
90
|
+
|
|
91
|
+
effective_verify: Union[bool, str] = (
|
|
92
|
+
verify if verify is not None else self.verify
|
|
93
|
+
)
|
|
94
|
+
client_ca = effective_verify if isinstance(effective_verify, str) else None
|
|
95
|
+
|
|
96
|
+
# Lazy import to avoid circular dependency
|
|
97
|
+
from mcp_proxy_adapter.client.jsonrpc_client import JsonRpcClient
|
|
98
|
+
|
|
99
|
+
proxy_client = JsonRpcClient(
|
|
100
|
+
protocol=protocol,
|
|
101
|
+
host=host,
|
|
102
|
+
port=port,
|
|
103
|
+
cert=client_cert,
|
|
104
|
+
key=client_key,
|
|
105
|
+
ca=client_ca,
|
|
106
|
+
# Inherit THIS client's hostname policy, the same "override or
|
|
107
|
+
# self" intent `cert`/`verify` already follow. RegistrationManager
|
|
108
|
+
# passes the configured registration.ssl.check_hostname (alias
|
|
109
|
+
# dnscheck) to the outer client only, so without this the
|
|
110
|
+
# operator's setting never reaches the client that actually talks
|
|
111
|
+
# to the proxy - it would silently take the constructor default
|
|
112
|
+
# instead (bugs 5c50cf21, 0ca1fac9).
|
|
113
|
+
check_hostname=self._check_hostname,
|
|
114
|
+
)
|
|
115
|
+
if effective_verify is False:
|
|
116
|
+
proxy_client.verify = False
|
|
117
|
+
return proxy_client
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"""Unregister, heartbeat, listing and health calls of the proxy registration mixin.
|
|
2
|
+
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any, Dict, List, Optional, Tuple, Union, cast
|
|
10
|
+
from urllib.parse import urlparse
|
|
11
|
+
|
|
12
|
+
import httpx
|
|
13
|
+
|
|
14
|
+
from mcp_proxy_adapter.client.jsonrpc_client.exceptions import ClientConnectionError
|
|
15
|
+
from mcp_proxy_adapter.client.jsonrpc_client.proxy_api_bases.register_base import (
|
|
16
|
+
ProxyApiRegisterBase,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ProxyApiLifecycleBase(ProxyApiRegisterBase):
|
|
21
|
+
"""Base of the proxy registration mixin: unregister, heartbeat, listing, health."""
|
|
22
|
+
|
|
23
|
+
async def unregister_from_proxy(
|
|
24
|
+
self,
|
|
25
|
+
proxy_url: str,
|
|
26
|
+
server_name: str,
|
|
27
|
+
cert: Optional[Tuple[str, str]] = None,
|
|
28
|
+
verify: Optional[Union[bool, str]] = None,
|
|
29
|
+
) -> Dict[str, Any]:
|
|
30
|
+
"""Unregister from proxy using JsonRpcClient (no direct httpx usage)."""
|
|
31
|
+
payload: Dict[str, Any] = {
|
|
32
|
+
"server_id": server_name,
|
|
33
|
+
"server_url": "",
|
|
34
|
+
"capabilities": [],
|
|
35
|
+
"metadata": {},
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
proxy_base = proxy_url.rstrip("/")
|
|
39
|
+
unregister_url = (
|
|
40
|
+
proxy_base
|
|
41
|
+
if proxy_base.endswith("/unregister")
|
|
42
|
+
else f"{proxy_base}/unregister"
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Extract protocol, host, port from proxy_url
|
|
46
|
+
parsed = urlparse(proxy_base)
|
|
47
|
+
client_protocol = parsed.scheme or "http"
|
|
48
|
+
client_host = parsed.hostname or "localhost"
|
|
49
|
+
client_port = parsed.port or (443 if client_protocol == "https" else 80)
|
|
50
|
+
|
|
51
|
+
proxy_client = self._build_internal_proxy_client(
|
|
52
|
+
client_protocol, client_host, client_port, cert, verify
|
|
53
|
+
)
|
|
54
|
+
try:
|
|
55
|
+
# Use internal client from JsonRpcTransport
|
|
56
|
+
client = await proxy_client._get_client()
|
|
57
|
+
response = await client.post(unregister_url, json=payload)
|
|
58
|
+
response.raise_for_status()
|
|
59
|
+
return cast(Dict[str, Any], response.json())
|
|
60
|
+
except httpx.HTTPStatusError:
|
|
61
|
+
raise
|
|
62
|
+
except httpx.TimeoutException as exc:
|
|
63
|
+
raise TimeoutError(f"Request timeout to {unregister_url}") from exc
|
|
64
|
+
except Exception as exc: # noqa: BLE001
|
|
65
|
+
# Bug a2b87028: match register_with_proxy's typed-error contract
|
|
66
|
+
# (see its except block for the full rationale) instead of
|
|
67
|
+
# letting a raw httpx.ConnectError/ssl error escape untyped.
|
|
68
|
+
raise ClientConnectionError(
|
|
69
|
+
f"Cannot connect to {unregister_url}: {type(exc).__name__}: {exc}",
|
|
70
|
+
url=unregister_url,
|
|
71
|
+
) from exc
|
|
72
|
+
finally:
|
|
73
|
+
await proxy_client.close()
|
|
74
|
+
|
|
75
|
+
async def heartbeat_to_proxy(
|
|
76
|
+
self,
|
|
77
|
+
proxy_url: str,
|
|
78
|
+
server_name: str,
|
|
79
|
+
server_url: str,
|
|
80
|
+
capabilities: Optional[List[str]] = None,
|
|
81
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
82
|
+
cert: Optional[Tuple[str, str]] = None,
|
|
83
|
+
verify: Optional[Union[bool, str]] = None,
|
|
84
|
+
) -> None:
|
|
85
|
+
"""Send heartbeat to proxy using JsonRpcClient (no direct httpx usage).
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
proxy_url: Full URL to heartbeat endpoint (e.g., "http://host:port/proxy/heartbeat")
|
|
89
|
+
server_name: Server identifier
|
|
90
|
+
server_url: Server URL
|
|
91
|
+
capabilities: Server capabilities
|
|
92
|
+
metadata: Server metadata
|
|
93
|
+
cert: Optional client certificate tuple (cert_file, key_file)
|
|
94
|
+
verify: Optional SSL verification (bool or CA cert path)
|
|
95
|
+
"""
|
|
96
|
+
uuid_value = self._extract_and_validate_uuid(metadata)
|
|
97
|
+
clean_metadata = dict(metadata or {})
|
|
98
|
+
clean_metadata.pop("uuid", None)
|
|
99
|
+
|
|
100
|
+
payload: Dict[str, Any] = {
|
|
101
|
+
"server_id": server_name,
|
|
102
|
+
"server_url": server_url,
|
|
103
|
+
"capabilities": capabilities or [],
|
|
104
|
+
"metadata": clean_metadata,
|
|
105
|
+
}
|
|
106
|
+
if uuid_value:
|
|
107
|
+
payload["uuid"] = uuid_value
|
|
108
|
+
|
|
109
|
+
# OpenAPI supports timestamp (recommended for observability)
|
|
110
|
+
import time
|
|
111
|
+
|
|
112
|
+
payload["timestamp"] = int(time.time())
|
|
113
|
+
|
|
114
|
+
# Extract protocol, host, port from proxy_url
|
|
115
|
+
parsed = urlparse(proxy_url)
|
|
116
|
+
client_protocol = parsed.scheme or "http"
|
|
117
|
+
client_host = parsed.hostname or "localhost"
|
|
118
|
+
client_port = parsed.port or (443 if client_protocol == "https" else 80)
|
|
119
|
+
|
|
120
|
+
proxy_client = self._build_internal_proxy_client(
|
|
121
|
+
client_protocol, client_host, client_port, cert, verify
|
|
122
|
+
)
|
|
123
|
+
try:
|
|
124
|
+
# Use internal client from JsonRpcTransport
|
|
125
|
+
client = await proxy_client._get_client()
|
|
126
|
+
response = await client.post(proxy_url, json=payload)
|
|
127
|
+
if response.status_code in (400, 422):
|
|
128
|
+
# Retry legacy uuid-at-root only when server complains
|
|
129
|
+
try:
|
|
130
|
+
body_text = getattr(response, "text", "")
|
|
131
|
+
if "uuid" in (body_text or "").lower() and (
|
|
132
|
+
"required" in (body_text or "").lower()
|
|
133
|
+
or "missing" in (body_text or "").lower()
|
|
134
|
+
):
|
|
135
|
+
legacy_payload = self._build_legacy_uuid_payload(
|
|
136
|
+
payload, uuid_value, clean_metadata
|
|
137
|
+
)
|
|
138
|
+
if legacy_payload is not None:
|
|
139
|
+
response2 = await client.post(
|
|
140
|
+
proxy_url, json=legacy_payload
|
|
141
|
+
)
|
|
142
|
+
response2.raise_for_status()
|
|
143
|
+
return
|
|
144
|
+
except Exception: # noqa: BLE001 # nosec B110 - legacy
|
|
145
|
+
# retry is a best-effort fallback attempt; if it fails
|
|
146
|
+
# for any reason, `response.raise_for_status()` below
|
|
147
|
+
# still raises for the original >=400 status, so nothing
|
|
148
|
+
# is masked.
|
|
149
|
+
pass
|
|
150
|
+
response.raise_for_status()
|
|
151
|
+
except httpx.HTTPStatusError:
|
|
152
|
+
raise
|
|
153
|
+
except httpx.TimeoutException as exc:
|
|
154
|
+
raise TimeoutError(f"Request timeout to {proxy_url}") from exc
|
|
155
|
+
except Exception as exc: # noqa: BLE001
|
|
156
|
+
# Bug a2b87028: match register_with_proxy's typed-error contract
|
|
157
|
+
# (see its except block for the full rationale) instead of
|
|
158
|
+
# letting a raw httpx.ConnectError/ssl error escape untyped.
|
|
159
|
+
raise ClientConnectionError(
|
|
160
|
+
f"Cannot connect to {proxy_url}: {type(exc).__name__}: {exc}",
|
|
161
|
+
url=proxy_url,
|
|
162
|
+
) from exc
|
|
163
|
+
finally:
|
|
164
|
+
await proxy_client.close()
|
|
165
|
+
|
|
166
|
+
async def list_proxy_servers(self, proxy_url: str) -> Dict[str, Any]:
|
|
167
|
+
"""List proxy servers using JsonRpcClient (no direct httpx usage)."""
|
|
168
|
+
proxy_base = proxy_url.rstrip("/")
|
|
169
|
+
|
|
170
|
+
# Extract protocol, host, port from proxy_url
|
|
171
|
+
parsed = urlparse(proxy_base)
|
|
172
|
+
client_protocol = parsed.scheme or "http"
|
|
173
|
+
client_host = parsed.hostname or "localhost"
|
|
174
|
+
client_port = parsed.port or (443 if client_protocol == "https" else 80)
|
|
175
|
+
|
|
176
|
+
# Bug 2d48b2a2: build the internal client via the shared helper (as
|
|
177
|
+
# every other call site in this mixin does) instead of referencing
|
|
178
|
+
# the bare ``JsonRpcClient`` name, which is only bound under
|
|
179
|
+
# ``TYPE_CHECKING`` and raises NameError at runtime. This also keeps
|
|
180
|
+
# the verify tri-state consistent with the rest of the mixin.
|
|
181
|
+
proxy_client = self._build_internal_proxy_client(
|
|
182
|
+
client_protocol, client_host, client_port, None, None
|
|
183
|
+
)
|
|
184
|
+
try:
|
|
185
|
+
# Use internal client from JsonRpcTransport
|
|
186
|
+
client = await proxy_client._get_client()
|
|
187
|
+
# OpenAPI: GET /list ; compatibility proxy: GET /servers
|
|
188
|
+
response = await client.get(f"{proxy_base}/list")
|
|
189
|
+
if response.status_code == 404:
|
|
190
|
+
response = await client.get(f"{proxy_base}/servers")
|
|
191
|
+
response.raise_for_status()
|
|
192
|
+
return cast(Dict[str, Any], response.json())
|
|
193
|
+
finally:
|
|
194
|
+
await proxy_client.close()
|
|
195
|
+
|
|
196
|
+
async def get_proxy_health(self, proxy_url: str) -> Dict[str, Any]:
|
|
197
|
+
"""Get proxy health using JsonRpcClient (no direct httpx usage)."""
|
|
198
|
+
proxy_base = proxy_url.rstrip("/")
|
|
199
|
+
|
|
200
|
+
# Extract protocol, host, port from proxy_url
|
|
201
|
+
parsed = urlparse(proxy_base)
|
|
202
|
+
client_protocol = parsed.scheme or "http"
|
|
203
|
+
client_host = parsed.hostname or "localhost"
|
|
204
|
+
client_port = parsed.port or (443 if client_protocol == "https" else 80)
|
|
205
|
+
|
|
206
|
+
# Bug 2d48b2a2: build the internal client via the shared helper (as
|
|
207
|
+
# every other call site in this mixin does) instead of referencing
|
|
208
|
+
# the bare ``JsonRpcClient`` name, which is only bound under
|
|
209
|
+
# ``TYPE_CHECKING`` and raises NameError at runtime. This also keeps
|
|
210
|
+
# the verify tri-state consistent with the rest of the mixin.
|
|
211
|
+
proxy_client = self._build_internal_proxy_client(
|
|
212
|
+
client_protocol, client_host, client_port, None, None
|
|
213
|
+
)
|
|
214
|
+
try:
|
|
215
|
+
# Use internal client from JsonRpcTransport
|
|
216
|
+
client = await proxy_client._get_client()
|
|
217
|
+
# OpenAPI: GET /health
|
|
218
|
+
response = await client.get(f"{proxy_base}/health")
|
|
219
|
+
response.raise_for_status()
|
|
220
|
+
return cast(Dict[str, Any], response.json())
|
|
221
|
+
finally:
|
|
222
|
+
await proxy_client.close()
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"""Registration call of the proxy registration mixin.
|
|
2
|
+
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union, cast
|
|
11
|
+
from urllib.parse import urlparse
|
|
12
|
+
|
|
13
|
+
import httpx
|
|
14
|
+
|
|
15
|
+
from mcp_proxy_adapter.client.jsonrpc_client.exceptions import ClientConnectionError
|
|
16
|
+
from mcp_proxy_adapter.client.jsonrpc_client.proxy_api_bases.client_base import (
|
|
17
|
+
ProxyApiClientBase,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ProxyApiRegisterBase(ProxyApiClientBase):
|
|
22
|
+
"""Base of the proxy registration mixin: registration."""
|
|
23
|
+
|
|
24
|
+
if TYPE_CHECKING:
|
|
25
|
+
|
|
26
|
+
async def _retry_registration_after_unregister_via_client(
|
|
27
|
+
self,
|
|
28
|
+
proxy_base: str,
|
|
29
|
+
register_url: str,
|
|
30
|
+
server_name: str,
|
|
31
|
+
server_url: str,
|
|
32
|
+
capabilities: Optional[List[str]],
|
|
33
|
+
metadata: Optional[Dict[str, Any]],
|
|
34
|
+
error_data: Dict[str, Any],
|
|
35
|
+
cert: Optional[Tuple[str, str]],
|
|
36
|
+
verify: Optional[Union[bool, str]],
|
|
37
|
+
) -> Dict[str, Any]:
|
|
38
|
+
"""Retry registration after unregister (defined in ProxyApiMixin)."""
|
|
39
|
+
...
|
|
40
|
+
|
|
41
|
+
async def register_with_proxy(
|
|
42
|
+
self,
|
|
43
|
+
proxy_url: str,
|
|
44
|
+
server_name: str,
|
|
45
|
+
server_url: str,
|
|
46
|
+
capabilities: Optional[List[str]] = None,
|
|
47
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
48
|
+
cert: Optional[Tuple[str, str]] = None,
|
|
49
|
+
verify: Optional[Union[bool, str]] = None,
|
|
50
|
+
) -> Dict[str, Any]:
|
|
51
|
+
"""Register with proxy using JsonRpcClient (no direct httpx usage)."""
|
|
52
|
+
# Extract UUID from metadata (required by MCP-Proxy and adapter proxy)
|
|
53
|
+
uuid_value = self._extract_and_validate_uuid(metadata)
|
|
54
|
+
|
|
55
|
+
# Remove UUID from metadata; it must be passed at root level of the payload.
|
|
56
|
+
clean_metadata = dict(metadata or {})
|
|
57
|
+
clean_metadata.pop("uuid", None)
|
|
58
|
+
|
|
59
|
+
payload: Dict[str, Any] = {
|
|
60
|
+
"server_id": server_name,
|
|
61
|
+
"server_url": server_url,
|
|
62
|
+
"capabilities": capabilities or [],
|
|
63
|
+
"metadata": clean_metadata,
|
|
64
|
+
}
|
|
65
|
+
if uuid_value:
|
|
66
|
+
payload["uuid"] = uuid_value
|
|
67
|
+
|
|
68
|
+
# Build register URL from proxy_url (OpenAPI: /register)
|
|
69
|
+
# proxy_url can be base URL or already include /register.
|
|
70
|
+
proxy_base = proxy_url.rstrip("/")
|
|
71
|
+
register_url = (
|
|
72
|
+
proxy_base if proxy_base.endswith("/register") else f"{proxy_base}/register"
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Determine if we should use configured client or create new JsonRpcClient
|
|
76
|
+
# Use configured client if:
|
|
77
|
+
# 1. No cert/verify override provided AND
|
|
78
|
+
# 2. proxy_url matches base_url (same host/port/protocol)
|
|
79
|
+
use_configured_client = (
|
|
80
|
+
cert is None and verify is None and proxy_url.startswith(self.base_url)
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
logger = logging.getLogger("mcp_proxy_adapter.client.jsonrpc_client.proxy_api")
|
|
84
|
+
logger.info("🔍 [REGISTRATION] Starting registration process")
|
|
85
|
+
logger.info("🔍 [REGISTRATION] Register URL: %s", register_url)
|
|
86
|
+
logger.info("🔍 [REGISTRATION] Base URL: %s", self.base_url)
|
|
87
|
+
logger.info(
|
|
88
|
+
"🔍 [REGISTRATION] Server name: %s, Server URL: %s", server_name, server_url
|
|
89
|
+
)
|
|
90
|
+
import json
|
|
91
|
+
|
|
92
|
+
logger.info("🔍 [REGISTRATION] Payload: %s", json.dumps(payload, indent=2))
|
|
93
|
+
logger.info("🔍 [REGISTRATION] Cert: %s, Verify: %s", cert is not None, verify)
|
|
94
|
+
logger.info(
|
|
95
|
+
"🔍 [REGISTRATION] Use configured client: %s", use_configured_client
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
def _needs_legacy_uuid_retry(status_code: int, body_text: str) -> bool:
|
|
99
|
+
"""
|
|
100
|
+
Check if registration response indicates legacy UUID format is needed.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
status_code: HTTP status code from registration response.
|
|
104
|
+
body_text: Response body text.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
True if legacy UUID retry is needed, False otherwise.
|
|
108
|
+
"""
|
|
109
|
+
# UUID is always sent at root level now; keep compatibility retry for older proxies.
|
|
110
|
+
if status_code not in (400, 422):
|
|
111
|
+
return False
|
|
112
|
+
lower = (body_text or "").lower()
|
|
113
|
+
return "uuid" in lower and ("required" in lower or "missing" in lower)
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
if use_configured_client:
|
|
117
|
+
# Use configured client from JsonRpcTransport
|
|
118
|
+
client = await self._get_client()
|
|
119
|
+
response = await client.post(register_url, json=payload)
|
|
120
|
+
else:
|
|
121
|
+
# Create new JsonRpcClient with explicit settings
|
|
122
|
+
# Extract protocol, host, port from proxy_url
|
|
123
|
+
parsed = urlparse(proxy_base)
|
|
124
|
+
client_protocol = parsed.scheme or "http"
|
|
125
|
+
client_host = parsed.hostname or "localhost"
|
|
126
|
+
client_port = parsed.port or (443 if client_protocol == "https" else 80)
|
|
127
|
+
|
|
128
|
+
proxy_client = self._build_internal_proxy_client(
|
|
129
|
+
client_protocol, client_host, client_port, cert, verify
|
|
130
|
+
)
|
|
131
|
+
try:
|
|
132
|
+
# Use internal client from JsonRpcTransport
|
|
133
|
+
client = await proxy_client._get_client()
|
|
134
|
+
response = await client.post(register_url, json=payload)
|
|
135
|
+
finally:
|
|
136
|
+
await proxy_client.close()
|
|
137
|
+
|
|
138
|
+
# Handle response
|
|
139
|
+
logger.info("🔍 [REGISTRATION] Response status: %s", response.status_code)
|
|
140
|
+
logger.info(
|
|
141
|
+
"🔍 [REGISTRATION] Response headers: %s", dict(response.headers)
|
|
142
|
+
)
|
|
143
|
+
try:
|
|
144
|
+
response_text = response.text
|
|
145
|
+
logger.info("🔍 [REGISTRATION] Response body: %s", response_text[:500])
|
|
146
|
+
except Exception: # nosec B110 - diagnostic logging only; the
|
|
147
|
+
# actual response handling (status code checks below) reads
|
|
148
|
+
# `response` directly and does not depend on this log line.
|
|
149
|
+
pass
|
|
150
|
+
|
|
151
|
+
# Handle response
|
|
152
|
+
if response.status_code == 400:
|
|
153
|
+
error_data = cast(Dict[str, Any], response.json())
|
|
154
|
+
error_msg = error_data.get("error", "").lower()
|
|
155
|
+
if "already registered" in error_msg:
|
|
156
|
+
# Retry registration after unregister
|
|
157
|
+
return await self._retry_registration_after_unregister_via_client(
|
|
158
|
+
proxy_base,
|
|
159
|
+
register_url,
|
|
160
|
+
server_name,
|
|
161
|
+
server_url,
|
|
162
|
+
capabilities,
|
|
163
|
+
metadata,
|
|
164
|
+
error_data,
|
|
165
|
+
cert,
|
|
166
|
+
verify,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
if response.status_code >= 400:
|
|
170
|
+
try:
|
|
171
|
+
error_data = cast(Dict[str, Any], response.json())
|
|
172
|
+
error_msg = error_data.get(
|
|
173
|
+
"error",
|
|
174
|
+
error_data.get("message", f"HTTP {response.status_code}"),
|
|
175
|
+
)
|
|
176
|
+
raise RuntimeError(f"Registration failed: {error_msg}")
|
|
177
|
+
except (ValueError, KeyError):
|
|
178
|
+
# Heuristic fallback: retry with legacy uuid-at-root if server demands it
|
|
179
|
+
try:
|
|
180
|
+
if _needs_legacy_uuid_retry(
|
|
181
|
+
response.status_code, getattr(response, "text", "")
|
|
182
|
+
):
|
|
183
|
+
legacy_payload = self._build_legacy_uuid_payload(
|
|
184
|
+
payload, uuid_value, clean_metadata
|
|
185
|
+
)
|
|
186
|
+
if legacy_payload is not None:
|
|
187
|
+
logger.warning(
|
|
188
|
+
"Proxy rejected OpenAPI payload (uuid required). Retrying with legacy uuid-at-root payload."
|
|
189
|
+
)
|
|
190
|
+
response2 = await client.post(
|
|
191
|
+
register_url, json=legacy_payload
|
|
192
|
+
)
|
|
193
|
+
response2.raise_for_status()
|
|
194
|
+
return cast(Dict[str, Any], response2.json())
|
|
195
|
+
except Exception: # noqa: BLE001 # nosec B110 - legacy
|
|
196
|
+
# retry is a best-effort fallback attempt; if it
|
|
197
|
+
# fails for any reason, `response.raise_for_status()`
|
|
198
|
+
# below still raises the ORIGINAL failure, so nothing
|
|
199
|
+
# is masked.
|
|
200
|
+
pass
|
|
201
|
+
response.raise_for_status()
|
|
202
|
+
|
|
203
|
+
response.raise_for_status()
|
|
204
|
+
result = cast(Dict[str, Any], response.json())
|
|
205
|
+
return result
|
|
206
|
+
except (RuntimeError, httpx.HTTPStatusError):
|
|
207
|
+
# HTTP-status failures (an explicit "Registration failed: ..."
|
|
208
|
+
# RuntimeError built from the parsed error body above, or a bare
|
|
209
|
+
# httpx.HTTPStatusError from response.raise_for_status()) already
|
|
210
|
+
# carry their own precise, typed information - re-raise as-is so
|
|
211
|
+
# callers (registration_manager/helpers.classify_registration_error)
|
|
212
|
+
# can tell an HTTP rejection apart from a connectivity/TLS failure.
|
|
213
|
+
raise
|
|
214
|
+
except httpx.TimeoutException as exc:
|
|
215
|
+
raise TimeoutError(f"Request timeout to {register_url}") from exc
|
|
216
|
+
except Exception as exc: # noqa: BLE001
|
|
217
|
+
# Bug a2b87028: every other failure - transport-level (host
|
|
218
|
+
# unreachable, connection refused) AND TLS verification failures
|
|
219
|
+
# (untrusted CA, hostname mismatch) alike - used to collapse into
|
|
220
|
+
# a bare ``ConnectionError`` here, discarding the real exception
|
|
221
|
+
# (including the underlying ``ssl.SSLCertVerificationError``
|
|
222
|
+
# text). Raising the client's typed ``ClientConnectionError``
|
|
223
|
+
# with the original exception chained (``from exc``) keeps that
|
|
224
|
+
# text reachable so ``registration_manager/helpers.py`` can
|
|
225
|
+
# classify TLS failures separately from "proxy unreachable"
|
|
226
|
+
# instead of discarding the distinction.
|
|
227
|
+
raise ClientConnectionError(
|
|
228
|
+
f"Cannot connect to {register_url}: {type(exc).__name__}: {exc}",
|
|
229
|
+
url=register_url,
|
|
230
|
+
) from exc
|