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,159 @@
|
|
|
1
|
+
"""Bidirectional WebSocket channel of the job-status client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import json
|
|
7
|
+
from typing import Any, AsyncIterator, Callable, Dict, Optional
|
|
8
|
+
|
|
9
|
+
import aiohttp
|
|
10
|
+
|
|
11
|
+
from mcp_proxy_adapter.client.jsonrpc_client.exceptions import classify_transport_error
|
|
12
|
+
from mcp_proxy_adapter.client.jsonrpc_client.transport import JsonRpcTransport
|
|
13
|
+
from mcp_proxy_adapter.client.jsonrpc_client.ws_job_status_parts.helpers import (
|
|
14
|
+
_dispatch_inbound_message_hook,
|
|
15
|
+
_raise_websocket_closed,
|
|
16
|
+
logger,
|
|
17
|
+
resolve_ws,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class BidirectionalWsChannel:
|
|
22
|
+
"""
|
|
23
|
+
Bidirectional WebSocket channel: send and receive JSON messages over /ws.
|
|
24
|
+
|
|
25
|
+
Use as async context manager. Same auth (headers, TLS) as transport.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
transport: JsonRpcTransport,
|
|
31
|
+
receive_timeout: Optional[float] = None,
|
|
32
|
+
heartbeat: Optional[float] = None,
|
|
33
|
+
on_inbound_message: Optional[Callable[[Dict[str, Any]], Any]] = None,
|
|
34
|
+
close_timeout: Optional[float] = None,
|
|
35
|
+
) -> None:
|
|
36
|
+
"""
|
|
37
|
+
Initialize bidirectional WebSocket channel.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
transport: JSON-RPC transport for connection details.
|
|
41
|
+
receive_timeout: Single-receive cap in seconds (``None`` resolves
|
|
42
|
+
through the client config and constants; 0 = no cap).
|
|
43
|
+
heartbeat: Heartbeat interval in seconds (same resolution; 0 = off).
|
|
44
|
+
close_timeout: Bound of the close handshake (same resolution).
|
|
45
|
+
"""
|
|
46
|
+
self._close_timeout = close_timeout
|
|
47
|
+
self._transport = transport
|
|
48
|
+
self._receive_timeout = receive_timeout
|
|
49
|
+
self._heartbeat = heartbeat
|
|
50
|
+
self._on_inbound_message = on_inbound_message
|
|
51
|
+
self._ws: Any = None
|
|
52
|
+
self._session: Any = None
|
|
53
|
+
|
|
54
|
+
async def __aenter__(self) -> "BidirectionalWsChannel":
|
|
55
|
+
"""Enter async context and establish WebSocket connection.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
Self for use in async with statement.
|
|
59
|
+
"""
|
|
60
|
+
ws_url = self._transport.ws_url
|
|
61
|
+
headers = {
|
|
62
|
+
k: v
|
|
63
|
+
for k, v in self._transport.headers.items()
|
|
64
|
+
if k.lower() != "content-type"
|
|
65
|
+
}
|
|
66
|
+
ssl = self._transport.get_ws_ssl_context()
|
|
67
|
+
hb = resolve_ws(self._transport, "heartbeat_interval", self._heartbeat)
|
|
68
|
+
rt = resolve_ws(self._transport, "receive_timeout", self._receive_timeout)
|
|
69
|
+
if rt is not None:
|
|
70
|
+
rt += resolve_ws(self._transport, "receive_timeout_buffer", None) or 0.0
|
|
71
|
+
self._session = await self._transport.get_ws_session()
|
|
72
|
+
try:
|
|
73
|
+
self._ws = await self._session.ws_connect(
|
|
74
|
+
ws_url,
|
|
75
|
+
ssl=ssl,
|
|
76
|
+
headers=headers,
|
|
77
|
+
heartbeat=hb,
|
|
78
|
+
receive_timeout=rt,
|
|
79
|
+
)
|
|
80
|
+
except asyncio.CancelledError:
|
|
81
|
+
raise
|
|
82
|
+
except (aiohttp.ClientError, OSError) as exc:
|
|
83
|
+
# aiohttp has several provider-specific connection exceptions;
|
|
84
|
+
# the shared classifier preserves their cause and emits the
|
|
85
|
+
# documented client category.
|
|
86
|
+
raise classify_transport_error(
|
|
87
|
+
exc,
|
|
88
|
+
operation="websocket.connect",
|
|
89
|
+
url=ws_url,
|
|
90
|
+
websocket=True,
|
|
91
|
+
) from exc
|
|
92
|
+
return self
|
|
93
|
+
|
|
94
|
+
async def __aexit__(self, *args: Any) -> None:
|
|
95
|
+
"""Exit async context and close WebSocket connection."""
|
|
96
|
+
if self._ws:
|
|
97
|
+
close_timeout = resolve_ws(
|
|
98
|
+
self._transport, "close_timeout", self._close_timeout
|
|
99
|
+
)
|
|
100
|
+
try:
|
|
101
|
+
await asyncio.wait_for(self._ws.close(), timeout=close_timeout)
|
|
102
|
+
except asyncio.TimeoutError:
|
|
103
|
+
logger.warning(
|
|
104
|
+
"WebSocket close timed out after %.1f seconds; "
|
|
105
|
+
"connection may not have fully shut down",
|
|
106
|
+
close_timeout,
|
|
107
|
+
)
|
|
108
|
+
self._ws = None
|
|
109
|
+
# Session is shared and owned by the transport; do not close it here.
|
|
110
|
+
# Just release the reference.
|
|
111
|
+
self._session = None
|
|
112
|
+
|
|
113
|
+
async def send_json(self, payload: Dict[str, Any]) -> None:
|
|
114
|
+
"""Send a JSON object to the server."""
|
|
115
|
+
if self._ws is None:
|
|
116
|
+
raise RuntimeError("Channel not connected; use async with first")
|
|
117
|
+
await self._ws.send_str(json.dumps(payload))
|
|
118
|
+
|
|
119
|
+
async def receive_iter(self) -> AsyncIterator[Dict[str, Any]]:
|
|
120
|
+
"""
|
|
121
|
+
Async iterator over incoming JSON messages (server -> client).
|
|
122
|
+
|
|
123
|
+
Yields each parsed JSON object. Stops when the connection closes or errors.
|
|
124
|
+
"""
|
|
125
|
+
if self._ws is None:
|
|
126
|
+
raise RuntimeError("Channel not connected; use async with first")
|
|
127
|
+
while True:
|
|
128
|
+
try:
|
|
129
|
+
msg = await self._ws.receive()
|
|
130
|
+
except asyncio.CancelledError:
|
|
131
|
+
raise
|
|
132
|
+
except Exception as exc:
|
|
133
|
+
raise classify_transport_error(
|
|
134
|
+
exc,
|
|
135
|
+
operation="websocket.receive",
|
|
136
|
+
url=self._transport.ws_url,
|
|
137
|
+
websocket=True,
|
|
138
|
+
) from exc
|
|
139
|
+
if msg.type == aiohttp.WSMsgType.TEXT:
|
|
140
|
+
try:
|
|
141
|
+
parsed = json.loads(msg.data)
|
|
142
|
+
await _dispatch_inbound_message_hook(
|
|
143
|
+
self._on_inbound_message, parsed
|
|
144
|
+
)
|
|
145
|
+
yield parsed
|
|
146
|
+
except json.JSONDecodeError:
|
|
147
|
+
logger.warning("WS non-JSON: %s", msg.data[:200])
|
|
148
|
+
elif msg.type in (
|
|
149
|
+
aiohttp.WSMsgType.CLOSE,
|
|
150
|
+
aiohttp.WSMsgType.CLOSING,
|
|
151
|
+
aiohttp.WSMsgType.CLOSED,
|
|
152
|
+
aiohttp.WSMsgType.ERROR,
|
|
153
|
+
):
|
|
154
|
+
_raise_websocket_closed(
|
|
155
|
+
msg,
|
|
156
|
+
message="WebSocket closed before a terminal message",
|
|
157
|
+
operation="websocket.receive",
|
|
158
|
+
url=self._transport.ws_url,
|
|
159
|
+
)
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"""Transport-owned command sockets of the job-status client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import contextlib
|
|
7
|
+
from typing import Any, AsyncIterator, Dict, Optional
|
|
8
|
+
|
|
9
|
+
from mcp_proxy_adapter.client.jsonrpc_client.ws_job_status_parts.channel import (
|
|
10
|
+
BidirectionalWsChannel,
|
|
11
|
+
)
|
|
12
|
+
from mcp_proxy_adapter.client.jsonrpc_client.ws_job_status_parts.helpers import (
|
|
13
|
+
resolve_ws,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class _CommandWsConnection:
|
|
18
|
+
"""Transport-owned socket; at most one active command owns its lifecycle."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, channel: BidirectionalWsChannel) -> None:
|
|
21
|
+
self.channel = channel
|
|
22
|
+
self.loop = asyncio.get_running_loop()
|
|
23
|
+
self.lock = asyncio.Lock()
|
|
24
|
+
self.leases: Dict[str, Any] = {}
|
|
25
|
+
self.reader: Optional[asyncio.Task[Any]] = None
|
|
26
|
+
|
|
27
|
+
async def acquire(self, lease: Any) -> None:
|
|
28
|
+
async with self.lock:
|
|
29
|
+
if self.reader is None or self.reader.done():
|
|
30
|
+
await self.channel.__aenter__()
|
|
31
|
+
self.reader = asyncio.create_task(self._read())
|
|
32
|
+
self.leases[lease.request_id] = lease
|
|
33
|
+
lease._ws = self.channel._ws
|
|
34
|
+
|
|
35
|
+
async def _read(self) -> None:
|
|
36
|
+
try:
|
|
37
|
+
async for message in self.channel.receive_iter():
|
|
38
|
+
rid = str(message.get("request_id") or "")
|
|
39
|
+
jid = str(message.get("job_id") or "")
|
|
40
|
+
for lease in tuple(self.leases.values()):
|
|
41
|
+
if rid == lease.request_id or (jid and jid == lease.job_id):
|
|
42
|
+
if jid:
|
|
43
|
+
lease.job_id = jid
|
|
44
|
+
if message.get("event") in {
|
|
45
|
+
"command_completed",
|
|
46
|
+
"command_failed",
|
|
47
|
+
"command_cancelled",
|
|
48
|
+
"command_error",
|
|
49
|
+
} or (
|
|
50
|
+
message.get("action") == "cancel_command"
|
|
51
|
+
and message.get("success") is True
|
|
52
|
+
):
|
|
53
|
+
lease.terminal = True
|
|
54
|
+
lease.queue.put_nowait(message)
|
|
55
|
+
except asyncio.CancelledError:
|
|
56
|
+
raise
|
|
57
|
+
except Exception as exc:
|
|
58
|
+
for lease in tuple(self.leases.values()):
|
|
59
|
+
lease.queue.put_nowait(exc)
|
|
60
|
+
finally:
|
|
61
|
+
await self.channel.__aexit__(None, None, None)
|
|
62
|
+
|
|
63
|
+
async def close(self) -> None:
|
|
64
|
+
if self.reader is not None:
|
|
65
|
+
self.reader.cancel()
|
|
66
|
+
with contextlib.suppress(asyncio.CancelledError, Exception):
|
|
67
|
+
await self.reader
|
|
68
|
+
await self.channel.__aexit__(None, None, None)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class _CommandWsChannel(BidirectionalWsChannel):
|
|
72
|
+
"""Exclusive command lease, reusing an idle socket after terminal/detach."""
|
|
73
|
+
|
|
74
|
+
def __init__(self, channel: BidirectionalWsChannel, request_id: str) -> None:
|
|
75
|
+
self._transport = channel._transport
|
|
76
|
+
self._template = channel
|
|
77
|
+
self.request_id = request_id
|
|
78
|
+
self.job_id = ""
|
|
79
|
+
self.terminal = False
|
|
80
|
+
self.detached = False
|
|
81
|
+
self.queue: asyncio.Queue[Any] = asyncio.Queue()
|
|
82
|
+
self._ws: Any = None
|
|
83
|
+
self.connection: Optional[_CommandWsConnection] = None
|
|
84
|
+
|
|
85
|
+
async def __aenter__(self) -> "_CommandWsChannel":
|
|
86
|
+
transport = self._transport
|
|
87
|
+
pools = getattr(transport, "_command_ws_connections", None)
|
|
88
|
+
if pools is None:
|
|
89
|
+
pools = transport._command_ws_connections = {}
|
|
90
|
+
# Never share across loops, authentication, TLS policy or receive caps.
|
|
91
|
+
key = (
|
|
92
|
+
asyncio.get_running_loop(),
|
|
93
|
+
transport.ws_url,
|
|
94
|
+
tuple(sorted(transport.headers.items())),
|
|
95
|
+
id(transport.get_ws_ssl_context()),
|
|
96
|
+
resolve_ws(transport, "receive_timeout", self._template._receive_timeout),
|
|
97
|
+
resolve_ws(transport, "heartbeat_interval", self._template._heartbeat),
|
|
98
|
+
resolve_ws(transport, "close_timeout", self._template._close_timeout),
|
|
99
|
+
)
|
|
100
|
+
candidates = pools.setdefault(key, [])
|
|
101
|
+
connection = next((item for item in candidates if not item.leases), None)
|
|
102
|
+
if connection is None:
|
|
103
|
+
connection = _CommandWsConnection(self._template)
|
|
104
|
+
candidates.append(connection)
|
|
105
|
+
self.connection = connection
|
|
106
|
+
# Reserve before the first await so a concurrent opener cannot claim it.
|
|
107
|
+
connection.leases[self.request_id] = self
|
|
108
|
+
try:
|
|
109
|
+
await connection.acquire(self)
|
|
110
|
+
except BaseException:
|
|
111
|
+
connection.leases.pop(self.request_id, None)
|
|
112
|
+
raise
|
|
113
|
+
return self
|
|
114
|
+
|
|
115
|
+
async def __aexit__(self, *args: Any) -> None:
|
|
116
|
+
connection = self.connection
|
|
117
|
+
if connection is not None:
|
|
118
|
+
if not self.terminal and not self.detached:
|
|
119
|
+
# A premature close must reach the server's existing per-socket
|
|
120
|
+
# caller-loss policy. No active sibling shares this connection.
|
|
121
|
+
await connection.close()
|
|
122
|
+
elif self.job_id and self._ws is not None and not self._ws.closed:
|
|
123
|
+
with contextlib.suppress(Exception):
|
|
124
|
+
await self.send_json(
|
|
125
|
+
{
|
|
126
|
+
"action": "unsubscribe",
|
|
127
|
+
"job_id": self.job_id,
|
|
128
|
+
"subscription_type": "command_session",
|
|
129
|
+
}
|
|
130
|
+
)
|
|
131
|
+
connection.leases.pop(self.request_id, None)
|
|
132
|
+
self._ws = None
|
|
133
|
+
|
|
134
|
+
async def _close_idle_connection(self) -> None:
|
|
135
|
+
"""Honor explicit close without disturbing a subsequently acquired lease."""
|
|
136
|
+
connection = self.connection
|
|
137
|
+
if connection is not None:
|
|
138
|
+
async with connection.lock:
|
|
139
|
+
if not connection.leases:
|
|
140
|
+
await connection.close()
|
|
141
|
+
|
|
142
|
+
async def send_json(self, payload: Dict[str, Any]) -> None:
|
|
143
|
+
if self.connection is None:
|
|
144
|
+
raise RuntimeError("Channel not connected; use async with first")
|
|
145
|
+
await self.connection.channel.send_json(payload)
|
|
146
|
+
if payload.get("caller_loss") == "detach":
|
|
147
|
+
self.detached = True
|
|
148
|
+
|
|
149
|
+
async def receive_iter(self) -> AsyncIterator[Dict[str, Any]]:
|
|
150
|
+
while True:
|
|
151
|
+
item = await self.queue.get()
|
|
152
|
+
if isinstance(item, Exception):
|
|
153
|
+
raise item
|
|
154
|
+
yield item
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Shared helpers of the WebSocket job-status client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import contextlib
|
|
7
|
+
import logging
|
|
8
|
+
from typing import Any, AsyncIterator, Callable, Dict, NoReturn, Optional
|
|
9
|
+
|
|
10
|
+
import aiohttp
|
|
11
|
+
|
|
12
|
+
from mcp_proxy_adapter.client.jsonrpc_client.exceptions import (
|
|
13
|
+
ClientWebSocketClosedError,
|
|
14
|
+
)
|
|
15
|
+
from mcp_proxy_adapter.core import constants as _constants
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger("mcp_proxy_adapter.client.jsonrpc_client.ws_job_status")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@contextlib.asynccontextmanager
|
|
21
|
+
async def _connect(session: Any, url: str, **kwargs: Any) -> AsyncIterator[Any]:
|
|
22
|
+
"""Open ``session.ws_connect(url, **kwargs)`` whether it is awaitable or a context manager."""
|
|
23
|
+
opened = session.ws_connect(url, **kwargs)
|
|
24
|
+
if hasattr(opened, "__aenter__"):
|
|
25
|
+
async with opened as ws:
|
|
26
|
+
yield ws
|
|
27
|
+
return
|
|
28
|
+
ws = await opened
|
|
29
|
+
try:
|
|
30
|
+
yield ws
|
|
31
|
+
finally:
|
|
32
|
+
await ws.close()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def ws_config_of(transport: Any) -> Any:
|
|
36
|
+
"""Return the ``ws_config`` mapping carried by ``transport`` (or ``None``)."""
|
|
37
|
+
return getattr(transport, "ws_config", None)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def resolve_ws(transport: Any, name: str, per_call: Any) -> Optional[float]:
|
|
41
|
+
"""Resolve websocket timeout ``name`` through per-call, client config, constant."""
|
|
42
|
+
return _constants.resolve_ws_timeout(name, per_call, ws_config_of(transport))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _raise_websocket_closed(
|
|
46
|
+
msg: aiohttp.WSMessage,
|
|
47
|
+
*,
|
|
48
|
+
message: str,
|
|
49
|
+
operation: str,
|
|
50
|
+
url: str,
|
|
51
|
+
) -> NoReturn:
|
|
52
|
+
"""Raise the public close error from stable aiohttp protocol evidence."""
|
|
53
|
+
close_code = msg.data if isinstance(msg.data, int) else 1006
|
|
54
|
+
provider_cause = (
|
|
55
|
+
msg.data
|
|
56
|
+
if isinstance(msg.data, BaseException)
|
|
57
|
+
else aiohttp.WebSocketError(close_code, "WebSocket peer closed the connection")
|
|
58
|
+
)
|
|
59
|
+
raise ClientWebSocketClosedError(
|
|
60
|
+
message,
|
|
61
|
+
operation=operation,
|
|
62
|
+
url=url,
|
|
63
|
+
details={"close_type": str(msg.type), "close_code": close_code},
|
|
64
|
+
) from provider_cause
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
async def _dispatch_inbound_message_hook(
|
|
68
|
+
hook: Optional[Callable[[Dict[str, Any]], Any]],
|
|
69
|
+
data: Dict[str, Any],
|
|
70
|
+
) -> None:
|
|
71
|
+
"""Invoke *hook* with *data*; await if it returns a coroutine."""
|
|
72
|
+
if hook is None:
|
|
73
|
+
return
|
|
74
|
+
out = hook(data)
|
|
75
|
+
if asyncio.iscoroutine(out):
|
|
76
|
+
await out
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Lightweight asynchronous client library for registry (proxy) server used in examples.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Any, Dict, List, Optional
|
|
9
|
+
|
|
10
|
+
import httpx
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ProxyClient:
|
|
14
|
+
"""Asynchronous client for proxy server."""
|
|
15
|
+
|
|
16
|
+
def __init__(self, base_url: str):
|
|
17
|
+
"""
|
|
18
|
+
Initialize proxy client.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
base_url: Base URL of the proxy server
|
|
22
|
+
"""
|
|
23
|
+
self.base_url = base_url.rstrip("/")
|
|
24
|
+
self._client: Optional[httpx.AsyncClient] = None
|
|
25
|
+
|
|
26
|
+
async def _get_client(self) -> httpx.AsyncClient:
|
|
27
|
+
"""Get or create async HTTP client."""
|
|
28
|
+
if self._client is None:
|
|
29
|
+
self._client = httpx.AsyncClient(timeout=5.0)
|
|
30
|
+
return self._client
|
|
31
|
+
|
|
32
|
+
async def close(self) -> None:
|
|
33
|
+
"""Close the HTTP client."""
|
|
34
|
+
if self._client:
|
|
35
|
+
await self._client.aclose()
|
|
36
|
+
self._client = None
|
|
37
|
+
|
|
38
|
+
async def _get_json(self, path: str) -> Dict[str, Any]:
|
|
39
|
+
"""GET ``path`` on the proxy and return its decoded JSON body."""
|
|
40
|
+
client = await self._get_client()
|
|
41
|
+
r = await client.get(f"{self.base_url}{path}")
|
|
42
|
+
r.raise_for_status()
|
|
43
|
+
return r.json() # type: ignore[no-any-return]
|
|
44
|
+
|
|
45
|
+
async def health(self) -> Dict[str, Any]:
|
|
46
|
+
"""
|
|
47
|
+
Get proxy server health status.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
Health status information
|
|
51
|
+
"""
|
|
52
|
+
return await self._get_json("/proxy/health")
|
|
53
|
+
|
|
54
|
+
async def register(
|
|
55
|
+
self,
|
|
56
|
+
name: str,
|
|
57
|
+
url: str,
|
|
58
|
+
capabilities: Optional[List[str]] = None,
|
|
59
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
60
|
+
) -> Dict[str, Any]:
|
|
61
|
+
"""
|
|
62
|
+
Register a server with the proxy.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
name: Server name
|
|
66
|
+
url: Server URL
|
|
67
|
+
capabilities: Optional list of capabilities
|
|
68
|
+
metadata: Optional metadata dictionary
|
|
69
|
+
|
|
70
|
+
Returns:
|
|
71
|
+
Registration result
|
|
72
|
+
"""
|
|
73
|
+
payload = {
|
|
74
|
+
"name": name,
|
|
75
|
+
"url": url,
|
|
76
|
+
"capabilities": capabilities or [],
|
|
77
|
+
"metadata": metadata or {},
|
|
78
|
+
}
|
|
79
|
+
client = await self._get_client()
|
|
80
|
+
r = await client.post(f"{self.base_url}/register", json=payload)
|
|
81
|
+
r.raise_for_status()
|
|
82
|
+
return r.json() # type: ignore[no-any-return]
|
|
83
|
+
|
|
84
|
+
async def unregister(self, name: str) -> Dict[str, Any]:
|
|
85
|
+
"""
|
|
86
|
+
Unregister a server from the proxy.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
name: Server name
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
Unregistration result
|
|
93
|
+
"""
|
|
94
|
+
payload = {"name": name, "url": "", "capabilities": [], "metadata": {}}
|
|
95
|
+
client = await self._get_client()
|
|
96
|
+
r = await client.post(f"{self.base_url}/unregister", json=payload)
|
|
97
|
+
r.raise_for_status()
|
|
98
|
+
return r.json() # type: ignore[no-any-return]
|
|
99
|
+
|
|
100
|
+
async def list_servers(self) -> Dict[str, Any]:
|
|
101
|
+
"""
|
|
102
|
+
List all servers registered with the proxy.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
List of registered servers
|
|
106
|
+
"""
|
|
107
|
+
return await self._get_json("/proxy/list")
|
|
108
|
+
|
|
109
|
+
async def heartbeat(self, name: str, url: str) -> Dict[str, Any]:
|
|
110
|
+
"""
|
|
111
|
+
Send heartbeat to the proxy.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
name: Server name
|
|
115
|
+
url: Server URL
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
Heartbeat result
|
|
119
|
+
"""
|
|
120
|
+
payload = {"name": name, "url": url, "capabilities": [], "metadata": {}}
|
|
121
|
+
client = await self._get_client()
|
|
122
|
+
r = await client.post(f"{self.base_url}/proxy/heartbeat", json=payload)
|
|
123
|
+
r.raise_for_status()
|
|
124
|
+
return r.json() # type: ignore[no-any-return]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Commands module initialization file.
|
|
3
|
+
|
|
4
|
+
Command classes are not re-exported here: built-in commands are registered
|
|
5
|
+
through ``builtin_commands.register_builtin_commands()``, and embedder
|
|
6
|
+
commands through the registry/hooks. Only the framework primitives every
|
|
7
|
+
consumer needs are exported.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from mcp_proxy_adapter.commands.base import Command
|
|
11
|
+
from mcp_proxy_adapter.commands.command_registry import CommandRegistry, registry
|
|
12
|
+
from mcp_proxy_adapter.commands.dependency_container import (
|
|
13
|
+
DependencyContainer,
|
|
14
|
+
container,
|
|
15
|
+
)
|
|
16
|
+
from mcp_proxy_adapter.commands.result import CommandResult, ErrorResult, SuccessResult
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"Command",
|
|
20
|
+
"CommandResult",
|
|
21
|
+
"SuccessResult",
|
|
22
|
+
"ErrorResult",
|
|
23
|
+
"registry",
|
|
24
|
+
"CommandRegistry",
|
|
25
|
+
"container",
|
|
26
|
+
"DependencyContainer",
|
|
27
|
+
]
|