mcp-proxy-adapter 2.0.1__py3-none-any.whl → 6.9.50__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.
Potentially problematic release.
This version of mcp-proxy-adapter might be problematic. Click here for more details.
- mcp_proxy_adapter/__init__.py +47 -0
- mcp_proxy_adapter/__main__.py +13 -0
- mcp_proxy_adapter/api/__init__.py +0 -0
- mcp_proxy_adapter/api/app.py +66 -0
- mcp_proxy_adapter/api/core/__init__.py +18 -0
- mcp_proxy_adapter/api/core/app_factory.py +400 -0
- mcp_proxy_adapter/api/core/lifespan_manager.py +55 -0
- mcp_proxy_adapter/api/core/registration_context.py +356 -0
- mcp_proxy_adapter/api/core/registration_manager.py +307 -0
- mcp_proxy_adapter/api/core/registration_tasks.py +84 -0
- mcp_proxy_adapter/api/core/ssl_context_factory.py +88 -0
- mcp_proxy_adapter/api/handlers.py +181 -0
- mcp_proxy_adapter/api/middleware/__init__.py +21 -0
- mcp_proxy_adapter/api/middleware/base.py +54 -0
- mcp_proxy_adapter/api/middleware/command_permission_middleware.py +73 -0
- mcp_proxy_adapter/api/middleware/error_handling.py +76 -0
- mcp_proxy_adapter/api/middleware/factory.py +147 -0
- mcp_proxy_adapter/api/middleware/logging.py +31 -0
- mcp_proxy_adapter/api/middleware/performance.py +51 -0
- mcp_proxy_adapter/api/middleware/protocol_middleware.py +140 -0
- mcp_proxy_adapter/api/middleware/transport_middleware.py +87 -0
- mcp_proxy_adapter/api/middleware/unified_security.py +223 -0
- mcp_proxy_adapter/api/middleware/user_info_middleware.py +132 -0
- mcp_proxy_adapter/api/openapi/__init__.py +21 -0
- mcp_proxy_adapter/api/openapi/command_integration.py +105 -0
- mcp_proxy_adapter/api/openapi/openapi_generator.py +40 -0
- mcp_proxy_adapter/api/openapi/openapi_registry.py +62 -0
- mcp_proxy_adapter/api/openapi/schema_loader.py +116 -0
- mcp_proxy_adapter/api/schemas.py +270 -0
- mcp_proxy_adapter/api/tool_integration.py +131 -0
- mcp_proxy_adapter/api/tools.py +163 -0
- mcp_proxy_adapter/cli/__init__.py +12 -0
- mcp_proxy_adapter/cli/commands/__init__.py +15 -0
- mcp_proxy_adapter/cli/commands/client.py +100 -0
- mcp_proxy_adapter/cli/commands/config_generate.py +105 -0
- mcp_proxy_adapter/cli/commands/config_validate.py +94 -0
- mcp_proxy_adapter/cli/commands/generate.py +259 -0
- mcp_proxy_adapter/cli/commands/server.py +174 -0
- mcp_proxy_adapter/cli/commands/sets.py +132 -0
- mcp_proxy_adapter/cli/commands/testconfig.py +177 -0
- mcp_proxy_adapter/cli/examples/__init__.py +8 -0
- mcp_proxy_adapter/cli/examples/http_basic.py +82 -0
- mcp_proxy_adapter/cli/examples/https_token.py +96 -0
- mcp_proxy_adapter/cli/examples/mtls_roles.py +103 -0
- mcp_proxy_adapter/cli/main.py +63 -0
- mcp_proxy_adapter/cli/parser.py +338 -0
- mcp_proxy_adapter/cli/validators.py +231 -0
- mcp_proxy_adapter/client/jsonrpc_client/__init__.py +9 -0
- mcp_proxy_adapter/client/jsonrpc_client/client.py +42 -0
- mcp_proxy_adapter/client/jsonrpc_client/command_api.py +45 -0
- mcp_proxy_adapter/client/jsonrpc_client/proxy_api.py +224 -0
- mcp_proxy_adapter/client/jsonrpc_client/queue_api.py +60 -0
- mcp_proxy_adapter/client/jsonrpc_client/transport.py +108 -0
- mcp_proxy_adapter/client/proxy.py +123 -0
- mcp_proxy_adapter/commands/__init__.py +66 -0
- mcp_proxy_adapter/commands/auth_validation_command.py +69 -0
- mcp_proxy_adapter/commands/base.py +389 -0
- mcp_proxy_adapter/commands/builtin_commands.py +30 -0
- mcp_proxy_adapter/commands/catalog/__init__.py +20 -0
- mcp_proxy_adapter/commands/catalog/catalog_loader.py +34 -0
- mcp_proxy_adapter/commands/catalog/catalog_manager.py +122 -0
- mcp_proxy_adapter/commands/catalog/catalog_syncer.py +149 -0
- mcp_proxy_adapter/commands/catalog/command_catalog.py +43 -0
- mcp_proxy_adapter/commands/catalog/dependency_manager.py +37 -0
- mcp_proxy_adapter/commands/catalog_manager.py +97 -0
- mcp_proxy_adapter/commands/cert_monitor_command.py +552 -0
- mcp_proxy_adapter/commands/certificate_management_command.py +562 -0
- mcp_proxy_adapter/commands/command_registry.py +298 -0
- mcp_proxy_adapter/commands/config_command.py +102 -0
- mcp_proxy_adapter/commands/dependency_container.py +40 -0
- mcp_proxy_adapter/commands/dependency_manager.py +143 -0
- mcp_proxy_adapter/commands/echo_command.py +48 -0
- mcp_proxy_adapter/commands/health_command.py +142 -0
- mcp_proxy_adapter/commands/help_command.py +175 -0
- mcp_proxy_adapter/commands/hooks.py +172 -0
- mcp_proxy_adapter/commands/key_management_command.py +484 -0
- mcp_proxy_adapter/commands/load_command.py +123 -0
- mcp_proxy_adapter/commands/plugins_command.py +246 -0
- mcp_proxy_adapter/commands/protocol_management_command.py +216 -0
- mcp_proxy_adapter/commands/proxy_registration_command.py +319 -0
- mcp_proxy_adapter/commands/queue_commands.py +750 -0
- mcp_proxy_adapter/commands/registration_status_command.py +76 -0
- mcp_proxy_adapter/commands/registry/__init__.py +18 -0
- mcp_proxy_adapter/commands/registry/command_info.py +103 -0
- mcp_proxy_adapter/commands/registry/command_loader.py +207 -0
- mcp_proxy_adapter/commands/registry/command_manager.py +119 -0
- mcp_proxy_adapter/commands/registry/command_registry.py +217 -0
- mcp_proxy_adapter/commands/reload_command.py +136 -0
- mcp_proxy_adapter/commands/result.py +157 -0
- mcp_proxy_adapter/commands/role_test_command.py +99 -0
- mcp_proxy_adapter/commands/roles_management_command.py +502 -0
- mcp_proxy_adapter/commands/security_command.py +472 -0
- mcp_proxy_adapter/commands/settings_command.py +113 -0
- mcp_proxy_adapter/commands/ssl_setup_command.py +306 -0
- mcp_proxy_adapter/commands/token_management_command.py +500 -0
- mcp_proxy_adapter/commands/transport_management_command.py +129 -0
- mcp_proxy_adapter/commands/unload_command.py +92 -0
- mcp_proxy_adapter/config.py +32 -0
- mcp_proxy_adapter/core/__init__.py +8 -0
- mcp_proxy_adapter/core/app_factory.py +560 -0
- mcp_proxy_adapter/core/app_runner.py +318 -0
- mcp_proxy_adapter/core/auth_validator.py +508 -0
- mcp_proxy_adapter/core/certificate/__init__.py +20 -0
- mcp_proxy_adapter/core/certificate/certificate_creator.py +372 -0
- mcp_proxy_adapter/core/certificate/certificate_extractor.py +185 -0
- mcp_proxy_adapter/core/certificate/certificate_utils.py +249 -0
- mcp_proxy_adapter/core/certificate/certificate_validator.py +481 -0
- mcp_proxy_adapter/core/certificate/ssl_context_manager.py +65 -0
- mcp_proxy_adapter/core/certificate_utils.py +249 -0
- mcp_proxy_adapter/core/client.py +608 -0
- mcp_proxy_adapter/core/client_manager.py +271 -0
- mcp_proxy_adapter/core/client_security.py +411 -0
- mcp_proxy_adapter/core/config/__init__.py +18 -0
- mcp_proxy_adapter/core/config/config.py +237 -0
- mcp_proxy_adapter/core/config/config_factory.py +22 -0
- mcp_proxy_adapter/core/config/config_loader.py +66 -0
- mcp_proxy_adapter/core/config/feature_manager.py +31 -0
- mcp_proxy_adapter/core/config/simple_config.py +204 -0
- mcp_proxy_adapter/core/config/simple_config_generator.py +131 -0
- mcp_proxy_adapter/core/config/simple_config_validator.py +476 -0
- mcp_proxy_adapter/core/config_converter.py +252 -0
- mcp_proxy_adapter/core/config_validator.py +211 -0
- mcp_proxy_adapter/core/crl_utils.py +362 -0
- mcp_proxy_adapter/core/errors.py +276 -0
- mcp_proxy_adapter/core/job_manager.py +54 -0
- mcp_proxy_adapter/core/logging.py +250 -0
- mcp_proxy_adapter/core/mtls_asgi.py +140 -0
- mcp_proxy_adapter/core/mtls_asgi_app.py +187 -0
- mcp_proxy_adapter/core/mtls_proxy.py +229 -0
- mcp_proxy_adapter/core/mtls_server.py +154 -0
- mcp_proxy_adapter/core/protocol_manager.py +232 -0
- mcp_proxy_adapter/core/proxy/__init__.py +19 -0
- mcp_proxy_adapter/core/proxy/auth_manager.py +26 -0
- mcp_proxy_adapter/core/proxy/proxy_registration_manager.py +160 -0
- mcp_proxy_adapter/core/proxy/registration_client.py +186 -0
- mcp_proxy_adapter/core/proxy/ssl_manager.py +101 -0
- mcp_proxy_adapter/core/proxy_client.py +184 -0
- mcp_proxy_adapter/core/proxy_registration.py +80 -0
- mcp_proxy_adapter/core/role_utils.py +103 -0
- mcp_proxy_adapter/core/security_adapter.py +343 -0
- mcp_proxy_adapter/core/security_factory.py +96 -0
- mcp_proxy_adapter/core/security_integration.py +342 -0
- mcp_proxy_adapter/core/server_adapter.py +251 -0
- mcp_proxy_adapter/core/server_engine.py +217 -0
- mcp_proxy_adapter/core/settings.py +260 -0
- mcp_proxy_adapter/core/signal_handler.py +107 -0
- mcp_proxy_adapter/core/ssl_utils.py +161 -0
- mcp_proxy_adapter/core/transport_manager.py +153 -0
- mcp_proxy_adapter/core/unified_config_adapter.py +471 -0
- mcp_proxy_adapter/core/utils.py +101 -0
- mcp_proxy_adapter/core/validation/__init__.py +21 -0
- mcp_proxy_adapter/core/validation/config_validator.py +219 -0
- mcp_proxy_adapter/core/validation/file_validator.py +131 -0
- mcp_proxy_adapter/core/validation/protocol_validator.py +205 -0
- mcp_proxy_adapter/core/validation/security_validator.py +140 -0
- mcp_proxy_adapter/core/validation/validation_result.py +27 -0
- mcp_proxy_adapter/custom_openapi.py +58 -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/hooks/__init__.py +4 -0
- mcp_proxy_adapter/examples/basic_framework/main.py +52 -0
- mcp_proxy_adapter/examples/bugfix_certificate_config.py +261 -0
- mcp_proxy_adapter/examples/cert_manager_bugfix.py +203 -0
- mcp_proxy_adapter/examples/check_config.py +413 -0
- mcp_proxy_adapter/examples/client_usage_example.py +164 -0
- mcp_proxy_adapter/examples/commands/__init__.py +5 -0
- mcp_proxy_adapter/examples/config_builder.py +234 -0
- mcp_proxy_adapter/examples/config_cli.py +282 -0
- mcp_proxy_adapter/examples/create_test_configs.py +174 -0
- mcp_proxy_adapter/examples/debug_request_state.py +130 -0
- mcp_proxy_adapter/examples/debug_role_chain.py +191 -0
- mcp_proxy_adapter/examples/demo_client.py +287 -0
- mcp_proxy_adapter/examples/full_application/__init__.py +12 -0
- mcp_proxy_adapter/examples/full_application/commands/__init__.py +8 -0
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +45 -0
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +52 -0
- mcp_proxy_adapter/examples/full_application/commands/echo_command.py +32 -0
- mcp_proxy_adapter/examples/full_application/commands/help_command.py +54 -0
- mcp_proxy_adapter/examples/full_application/commands/list_command.py +57 -0
- mcp_proxy_adapter/examples/full_application/hooks/__init__.py +5 -0
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +29 -0
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +27 -0
- mcp_proxy_adapter/examples/full_application/main.py +311 -0
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +161 -0
- mcp_proxy_adapter/examples/full_application/run_mtls.py +252 -0
- mcp_proxy_adapter/examples/full_application/run_simple.py +152 -0
- mcp_proxy_adapter/examples/full_application/test_minimal_server.py +45 -0
- mcp_proxy_adapter/examples/full_application/test_server.py +163 -0
- mcp_proxy_adapter/examples/full_application/test_simple_server.py +62 -0
- mcp_proxy_adapter/examples/generate_config.py +502 -0
- mcp_proxy_adapter/examples/proxy_registration_example.py +335 -0
- mcp_proxy_adapter/examples/queue_demo_simple.py +632 -0
- mcp_proxy_adapter/examples/queue_integration_example.py +578 -0
- mcp_proxy_adapter/examples/queue_server_demo.py +82 -0
- mcp_proxy_adapter/examples/queue_server_example.py +85 -0
- mcp_proxy_adapter/examples/queue_server_simple.py +173 -0
- mcp_proxy_adapter/examples/required_certificates.py +208 -0
- mcp_proxy_adapter/examples/run_example.py +77 -0
- mcp_proxy_adapter/examples/run_full_test_suite.py +619 -0
- mcp_proxy_adapter/examples/run_proxy_server.py +153 -0
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +435 -0
- mcp_proxy_adapter/examples/security_test/__init__.py +18 -0
- mcp_proxy_adapter/examples/security_test/auth_manager.py +14 -0
- mcp_proxy_adapter/examples/security_test/ssl_context_manager.py +28 -0
- mcp_proxy_adapter/examples/security_test/test_client.py +159 -0
- mcp_proxy_adapter/examples/security_test/test_result.py +22 -0
- mcp_proxy_adapter/examples/security_test_client.py +72 -0
- mcp_proxy_adapter/examples/setup/__init__.py +24 -0
- mcp_proxy_adapter/examples/setup/certificate_manager.py +215 -0
- mcp_proxy_adapter/examples/setup/config_generator.py +12 -0
- mcp_proxy_adapter/examples/setup/config_validator.py +118 -0
- mcp_proxy_adapter/examples/setup/environment_setup.py +62 -0
- mcp_proxy_adapter/examples/setup/test_files_generator.py +10 -0
- mcp_proxy_adapter/examples/setup/test_runner.py +89 -0
- mcp_proxy_adapter/examples/setup_test_environment.py +235 -0
- mcp_proxy_adapter/examples/simple_protocol_test.py +125 -0
- mcp_proxy_adapter/examples/test_chk_hostname_automated.py +211 -0
- mcp_proxy_adapter/examples/test_config.py +205 -0
- mcp_proxy_adapter/examples/test_config_builder.py +110 -0
- mcp_proxy_adapter/examples/test_examples.py +308 -0
- mcp_proxy_adapter/examples/test_framework_complete.py +267 -0
- mcp_proxy_adapter/examples/test_mcp_server.py +187 -0
- mcp_proxy_adapter/examples/test_protocol_examples.py +337 -0
- mcp_proxy_adapter/examples/universal_client.py +674 -0
- mcp_proxy_adapter/examples/update_config_certificates.py +135 -0
- mcp_proxy_adapter/examples/validate_generator_compatibility.py +385 -0
- mcp_proxy_adapter/examples/validate_generator_compatibility_simple.py +61 -0
- mcp_proxy_adapter/integrations/__init__.py +25 -0
- mcp_proxy_adapter/integrations/queuemgr_integration.py +462 -0
- mcp_proxy_adapter/main.py +311 -0
- mcp_proxy_adapter/openapi.py +375 -0
- mcp_proxy_adapter/schemas/base_schema.json +114 -0
- mcp_proxy_adapter/schemas/openapi_schema.json +314 -0
- mcp_proxy_adapter/schemas/roles.json +37 -0
- mcp_proxy_adapter/schemas/roles_schema.json +162 -0
- mcp_proxy_adapter/version.py +5 -0
- mcp_proxy_adapter-6.9.50.dist-info/METADATA +1088 -0
- mcp_proxy_adapter-6.9.50.dist-info/RECORD +242 -0
- {mcp_proxy_adapter-2.0.1.dist-info → mcp_proxy_adapter-6.9.50.dist-info}/WHEEL +1 -1
- mcp_proxy_adapter-6.9.50.dist-info/entry_points.txt +14 -0
- mcp_proxy_adapter-6.9.50.dist-info/top_level.txt +1 -0
- adapters/__init__.py +0 -16
- analyzers/__init__.py +0 -14
- analyzers/docstring_analyzer.py +0 -199
- analyzers/type_analyzer.py +0 -151
- cli/__init__.py +0 -12
- cli/__main__.py +0 -79
- cli/command_runner.py +0 -233
- dispatchers/__init__.py +0 -14
- dispatchers/base_dispatcher.py +0 -85
- dispatchers/json_rpc_dispatcher.py +0 -198
- generators/__init__.py +0 -14
- generators/endpoint_generator.py +0 -172
- generators/openapi_generator.py +0 -254
- generators/rest_api_generator.py +0 -207
- mcp_proxy_adapter-2.0.1.dist-info/METADATA +0 -272
- mcp_proxy_adapter-2.0.1.dist-info/RECORD +0 -28
- mcp_proxy_adapter-2.0.1.dist-info/licenses/LICENSE +0 -21
- mcp_proxy_adapter-2.0.1.dist-info/top_level.txt +0 -7
- openapi_schema/__init__.py +0 -38
- openapi_schema/command_registry.py +0 -312
- openapi_schema/rest_schema.py +0 -510
- openapi_schema/rpc_generator.py +0 -307
- openapi_schema/rpc_schema.py +0 -416
- validators/__init__.py +0 -14
- validators/base_validator.py +0 -23
- validators/docstring_validator.py +0 -75
- validators/metadata_validator.py +0 -76
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
CLI Argument Parser for MCP Proxy Adapter
|
|
4
|
+
Multi-level help system with detailed parameter descriptions
|
|
5
|
+
|
|
6
|
+
Author: Vasiliy Zdanovskiy
|
|
7
|
+
email: vasilyvz@gmail.com
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def create_main_parser() -> argparse.ArgumentParser:
|
|
14
|
+
"""Create top-level CLI parser with subcommands."""
|
|
15
|
+
parser = argparse.ArgumentParser(prog="mcp-cli", description="MCP Proxy Adapter CLI")
|
|
16
|
+
subparsers = parser.add_subparsers(dest='command', metavar='command')
|
|
17
|
+
|
|
18
|
+
# generate
|
|
19
|
+
generate_parser = subparsers.add_parser('generate', help='Generate configuration (legacy)')
|
|
20
|
+
_setup_generate_parser(generate_parser)
|
|
21
|
+
|
|
22
|
+
# testconfig
|
|
23
|
+
testconfig_parser = subparsers.add_parser('testconfig', help='Validate configuration (legacy)')
|
|
24
|
+
_setup_testconfig_parser(testconfig_parser)
|
|
25
|
+
|
|
26
|
+
# sets
|
|
27
|
+
sets_parser = subparsers.add_parser('sets', help='Generate preset configuration set (legacy)')
|
|
28
|
+
_setup_sets_parser(sets_parser)
|
|
29
|
+
|
|
30
|
+
# server
|
|
31
|
+
server_parser = subparsers.add_parser('server', help='Run server (legacy)')
|
|
32
|
+
_setup_server_parser(server_parser)
|
|
33
|
+
|
|
34
|
+
# simple config commands (new)
|
|
35
|
+
config_parser = subparsers.add_parser('config', help='Simple config utilities')
|
|
36
|
+
config_sub = config_parser.add_subparsers(dest='config_command')
|
|
37
|
+
|
|
38
|
+
# config generate
|
|
39
|
+
cfg_gen = config_sub.add_parser('generate', help='Generate simple configuration')
|
|
40
|
+
cfg_gen.add_argument('--protocol', required=True, choices=['http', 'https', 'mtls'], help='Server/proxy protocol')
|
|
41
|
+
cfg_gen.add_argument('--with-proxy', action='store_true', help='Include proxy_client section')
|
|
42
|
+
cfg_gen.add_argument('--out', default='config.json', help='Output config path (default: config.json)')
|
|
43
|
+
|
|
44
|
+
# Server parameters
|
|
45
|
+
cfg_gen.add_argument('--server-host', help='Server host (default: 0.0.0.0)')
|
|
46
|
+
cfg_gen.add_argument('--server-port', type=int, help='Server port (default: 8080)')
|
|
47
|
+
cfg_gen.add_argument('--server-cert-file', help='Server certificate file path')
|
|
48
|
+
cfg_gen.add_argument('--server-key-file', help='Server key file path')
|
|
49
|
+
cfg_gen.add_argument('--server-ca-cert-file', help='Server CA certificate file path')
|
|
50
|
+
|
|
51
|
+
# Proxy parameters
|
|
52
|
+
cfg_gen.add_argument('--proxy-host', help='Proxy host (default: localhost)')
|
|
53
|
+
cfg_gen.add_argument('--proxy-port', type=int, help='Proxy port (default: 3005)')
|
|
54
|
+
cfg_gen.add_argument('--proxy-cert-file', help='Proxy client certificate file path')
|
|
55
|
+
cfg_gen.add_argument('--proxy-key-file', help='Proxy client key file path')
|
|
56
|
+
cfg_gen.add_argument('--proxy-ca-cert-file', help='Proxy CA certificate file path')
|
|
57
|
+
|
|
58
|
+
# config validate
|
|
59
|
+
cfg_val = config_sub.add_parser('validate', help='Validate simple configuration file')
|
|
60
|
+
cfg_val.add_argument('--file', required=True, help='Path to configuration file')
|
|
61
|
+
|
|
62
|
+
# client
|
|
63
|
+
client_parser = subparsers.add_parser('client', help='HTTP/HTTPS/mTLS client for health and JSON-RPC')
|
|
64
|
+
_setup_client_parser(client_parser)
|
|
65
|
+
|
|
66
|
+
return parser
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _setup_generate_parser(parser: argparse.ArgumentParser):
|
|
70
|
+
"""Setup generate command parser"""
|
|
71
|
+
|
|
72
|
+
# Protocol selection
|
|
73
|
+
protocol_group = parser.add_argument_group(
|
|
74
|
+
'Protocol Configuration',
|
|
75
|
+
'Select the communication protocol and security level'
|
|
76
|
+
)
|
|
77
|
+
protocol_group.add_argument(
|
|
78
|
+
'--protocol',
|
|
79
|
+
choices=['http', 'https', 'mtls'],
|
|
80
|
+
required=True,
|
|
81
|
+
help='''Communication protocol:
|
|
82
|
+
http - Plain HTTP (no encryption)
|
|
83
|
+
https - HTTP with SSL/TLS encryption
|
|
84
|
+
mtls - Mutual TLS with client certificate verification'''
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# Security options
|
|
88
|
+
security_group = parser.add_argument_group(
|
|
89
|
+
'Security Configuration',
|
|
90
|
+
'Configure authentication and authorization'
|
|
91
|
+
)
|
|
92
|
+
security_group.add_argument(
|
|
93
|
+
'--token',
|
|
94
|
+
action='store_true',
|
|
95
|
+
help='Enable token-based authentication (API keys)'
|
|
96
|
+
)
|
|
97
|
+
security_group.add_argument(
|
|
98
|
+
'--roles',
|
|
99
|
+
action='store_true',
|
|
100
|
+
help='Enable role-based access control (requires --token)'
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# Server configuration
|
|
104
|
+
server_group = parser.add_argument_group(
|
|
105
|
+
'Server Configuration',
|
|
106
|
+
'Configure server host and port settings'
|
|
107
|
+
)
|
|
108
|
+
server_group.add_argument(
|
|
109
|
+
'--host',
|
|
110
|
+
default='127.0.0.1',
|
|
111
|
+
help='Server host address (default: 127.0.0.1)'
|
|
112
|
+
)
|
|
113
|
+
server_group.add_argument(
|
|
114
|
+
'--port',
|
|
115
|
+
type=int,
|
|
116
|
+
default=8000,
|
|
117
|
+
help='Server port number (default: 8000)'
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# SSL/TLS configuration
|
|
121
|
+
ssl_group = parser.add_argument_group(
|
|
122
|
+
'SSL/TLS Configuration',
|
|
123
|
+
'Configure SSL certificates and keys (required for https/mtls)'
|
|
124
|
+
)
|
|
125
|
+
ssl_group.add_argument(
|
|
126
|
+
'--cert-dir',
|
|
127
|
+
default='./certs',
|
|
128
|
+
help='Directory containing SSL certificates (default: ./certs)'
|
|
129
|
+
)
|
|
130
|
+
ssl_group.add_argument(
|
|
131
|
+
'--key-dir',
|
|
132
|
+
default='./keys',
|
|
133
|
+
help='Directory containing SSL private keys (default: ./keys)'
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
# Proxy registration
|
|
137
|
+
proxy_group = parser.add_argument_group(
|
|
138
|
+
'Proxy Registration',
|
|
139
|
+
'Configure automatic registration with MCP proxy'
|
|
140
|
+
)
|
|
141
|
+
proxy_group.add_argument(
|
|
142
|
+
'--proxy-registration',
|
|
143
|
+
action='store_true',
|
|
144
|
+
help='Enable automatic proxy registration'
|
|
145
|
+
)
|
|
146
|
+
proxy_group.add_argument(
|
|
147
|
+
'--proxy-url',
|
|
148
|
+
help='Proxy URL for registration (required with --proxy-registration)'
|
|
149
|
+
)
|
|
150
|
+
proxy_group.add_argument(
|
|
151
|
+
'--server-id',
|
|
152
|
+
default='mcp_proxy_adapter',
|
|
153
|
+
help='Server ID for proxy registration (default: mcp_proxy_adapter)'
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Output options
|
|
157
|
+
output_group = parser.add_argument_group(
|
|
158
|
+
'Output Configuration',
|
|
159
|
+
'Configure output file and directory settings'
|
|
160
|
+
)
|
|
161
|
+
output_group.add_argument(
|
|
162
|
+
'--output-dir',
|
|
163
|
+
default='./configs',
|
|
164
|
+
help='Output directory for configuration files (default: ./configs)'
|
|
165
|
+
)
|
|
166
|
+
output_group.add_argument(
|
|
167
|
+
'--output',
|
|
168
|
+
help='Output filename (without extension, auto-generated if not specified)'
|
|
169
|
+
)
|
|
170
|
+
output_group.add_argument(
|
|
171
|
+
'--stdout',
|
|
172
|
+
action='store_true',
|
|
173
|
+
help='Output configuration to stdout instead of file'
|
|
174
|
+
)
|
|
175
|
+
output_group.add_argument(
|
|
176
|
+
'--no-validate',
|
|
177
|
+
action='store_true',
|
|
178
|
+
help='Skip configuration validation after generation'
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def _setup_testconfig_parser(parser: argparse.ArgumentParser):
|
|
183
|
+
"""Setup testconfig command parser"""
|
|
184
|
+
|
|
185
|
+
parser.add_argument(
|
|
186
|
+
'--config',
|
|
187
|
+
required=True,
|
|
188
|
+
help='Path to configuration file to validate'
|
|
189
|
+
)
|
|
190
|
+
parser.add_argument(
|
|
191
|
+
'--verbose',
|
|
192
|
+
action='store_true',
|
|
193
|
+
help='Enable verbose output with detailed validation results'
|
|
194
|
+
)
|
|
195
|
+
parser.add_argument(
|
|
196
|
+
'--fix',
|
|
197
|
+
action='store_true',
|
|
198
|
+
help='Attempt to fix common configuration issues automatically'
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _setup_sets_parser(parser: argparse.ArgumentParser):
|
|
203
|
+
"""Setup sets command parser"""
|
|
204
|
+
|
|
205
|
+
# Mode selection (positional argument)
|
|
206
|
+
parser.add_argument(
|
|
207
|
+
'set_name',
|
|
208
|
+
choices=['http', 'https', 'mtls'],
|
|
209
|
+
help='''Configuration mode:
|
|
210
|
+
http - HTTP basic configuration
|
|
211
|
+
https - HTTPS with SSL/TLS
|
|
212
|
+
mtls - Mutual TLS with client certificates'''
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
# Modifiers
|
|
216
|
+
parser.add_argument(
|
|
217
|
+
'--modifiers',
|
|
218
|
+
nargs='+',
|
|
219
|
+
choices=['token', 'roles'],
|
|
220
|
+
help='''Configuration modifiers:
|
|
221
|
+
token - Add token authentication
|
|
222
|
+
roles - Add role-based access control (requires token)'''
|
|
223
|
+
)
|
|
224
|
+
parser.add_argument(
|
|
225
|
+
'--no-dns-check',
|
|
226
|
+
action='store_true',
|
|
227
|
+
help='Disable DNS hostname checking (useful for Docker networks)'
|
|
228
|
+
)
|
|
229
|
+
|
|
230
|
+
# SSL configuration for https/mtls
|
|
231
|
+
ssl_group = parser.add_argument_group('SSL Configuration')
|
|
232
|
+
ssl_group.add_argument(
|
|
233
|
+
'--cert-dir',
|
|
234
|
+
default='./mtls_certificates/server',
|
|
235
|
+
help='Directory containing SSL certificates (default: ./mtls_certificates/server)'
|
|
236
|
+
)
|
|
237
|
+
ssl_group.add_argument(
|
|
238
|
+
'--key-dir',
|
|
239
|
+
default='./mtls_certificates/server',
|
|
240
|
+
help='Directory containing SSL private keys (default: ./mtls_certificates/server)'
|
|
241
|
+
)
|
|
242
|
+
|
|
243
|
+
# Output options
|
|
244
|
+
output_group = parser.add_argument_group('Output Options')
|
|
245
|
+
output_group.add_argument(
|
|
246
|
+
'--output-dir',
|
|
247
|
+
default='./configs',
|
|
248
|
+
help='Output directory for configuration files (default: ./configs)'
|
|
249
|
+
)
|
|
250
|
+
output_group.add_argument(
|
|
251
|
+
'--host',
|
|
252
|
+
default='127.0.0.1',
|
|
253
|
+
help='Server host address (default: 127.0.0.1)'
|
|
254
|
+
)
|
|
255
|
+
output_group.add_argument(
|
|
256
|
+
'--port',
|
|
257
|
+
type=int,
|
|
258
|
+
default=8000,
|
|
259
|
+
help='Server port number (default: 8000)'
|
|
260
|
+
)
|
|
261
|
+
output_group.add_argument(
|
|
262
|
+
'--proxy-url',
|
|
263
|
+
help='Proxy URL for registration (auto-generated if not specified)'
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
def _setup_server_parser(parser: argparse.ArgumentParser):
|
|
268
|
+
"""Setup server command parser"""
|
|
269
|
+
|
|
270
|
+
parser.add_argument(
|
|
271
|
+
'--config',
|
|
272
|
+
required=True,
|
|
273
|
+
help='Path to configuration file'
|
|
274
|
+
)
|
|
275
|
+
parser.add_argument(
|
|
276
|
+
'--host',
|
|
277
|
+
help='Override server host from configuration'
|
|
278
|
+
)
|
|
279
|
+
parser.add_argument(
|
|
280
|
+
'--port',
|
|
281
|
+
type=int,
|
|
282
|
+
help='Override server port from configuration'
|
|
283
|
+
)
|
|
284
|
+
parser.add_argument(
|
|
285
|
+
'--debug',
|
|
286
|
+
action='store_true',
|
|
287
|
+
help='Enable debug mode with verbose logging'
|
|
288
|
+
)
|
|
289
|
+
parser.add_argument(
|
|
290
|
+
'--reload',
|
|
291
|
+
action='store_true',
|
|
292
|
+
help='Enable auto-reload on configuration changes'
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def _setup_client_parser(parser: argparse.ArgumentParser):
|
|
297
|
+
"""Setup client command parser"""
|
|
298
|
+
|
|
299
|
+
sub = parser.add_subparsers(dest='client_command')
|
|
300
|
+
|
|
301
|
+
# health
|
|
302
|
+
health = sub.add_parser('health', help='Call GET /health')
|
|
303
|
+
health.add_argument('--protocol', choices=['http', 'https'], required=True, help='Connection protocol')
|
|
304
|
+
health.add_argument('--host', default='127.0.0.1', help='Server host (default: 127.0.0.1)')
|
|
305
|
+
health.add_argument('--port', type=int, required=True, help='Server port')
|
|
306
|
+
health.add_argument('--token-header', default='X-API-Key', help='API key header name (default: X-API-Key)')
|
|
307
|
+
health.add_argument('--token', help='API key token value')
|
|
308
|
+
health.add_argument('--cert', help='Client cert path (for mTLS/HTTPS testing)')
|
|
309
|
+
health.add_argument('--key', help='Client key path (for mTLS/HTTPS testing)')
|
|
310
|
+
health.add_argument('--ca', help='CA cert path (verify server with this CA)')
|
|
311
|
+
|
|
312
|
+
# jsonrpc
|
|
313
|
+
j = sub.add_parser('jsonrpc', help='Call POST /api/jsonrpc')
|
|
314
|
+
j.add_argument('--protocol', choices=['http', 'https'], required=True, help='Connection protocol')
|
|
315
|
+
j.add_argument('--host', default='127.0.0.1', help='Server host (default: 127.0.0.1)')
|
|
316
|
+
j.add_argument('--port', type=int, required=True, help='Server port')
|
|
317
|
+
j.add_argument('--token-header', default='X-API-Key', help='API key header name (default: X-API-Key)')
|
|
318
|
+
j.add_argument('--token', help='API key token value')
|
|
319
|
+
j.add_argument('--cert', help='Client cert path (for mTLS/HTTPS testing)')
|
|
320
|
+
j.add_argument('--key', help='Client key path (for mTLS/HTTPS testing)')
|
|
321
|
+
j.add_argument('--ca', help='CA cert path (verify server with this CA)')
|
|
322
|
+
j.add_argument('--method', required=True, help='JSON-RPC method')
|
|
323
|
+
j.add_argument('--params', help='JSON string with params, default {}')
|
|
324
|
+
j.add_argument('--id', type=int, default=1, help='Request id (default: 1)')
|
|
325
|
+
|
|
326
|
+
# proxy register/unregister/list
|
|
327
|
+
preg = sub.add_parser('proxy-register', help='Register adapter on registry')
|
|
328
|
+
preg.add_argument('--proxy-url', required=True, help='Registry base URL, e.g. http://localhost:3005')
|
|
329
|
+
preg.add_argument('--name', required=True, help='Adapter name')
|
|
330
|
+
preg.add_argument('--url', required=True, help='Adapter base URL')
|
|
331
|
+
preg.add_argument('--capabilities', nargs='*', help='Capabilities list')
|
|
332
|
+
|
|
333
|
+
punreg = sub.add_parser('proxy-unregister', help='Unregister adapter from registry')
|
|
334
|
+
punreg.add_argument('--proxy-url', required=True)
|
|
335
|
+
punreg.add_argument('--name', required=True)
|
|
336
|
+
|
|
337
|
+
plist = sub.add_parser('proxy-list', help='List registered adapters')
|
|
338
|
+
plist.add_argument('--proxy-url', required=True)
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CLI Parameter Validators
|
|
3
|
+
|
|
4
|
+
This module provides validation functions for CLI parameters and their combinations.
|
|
5
|
+
|
|
6
|
+
Author: Vasiliy Zdanovskiy
|
|
7
|
+
email: vasilyvz@gmail.com
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import sys
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ValidationError(Exception):
|
|
15
|
+
"""Exception raised when parameter validation fails."""
|
|
16
|
+
pass
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ParameterValidator:
|
|
20
|
+
"""Validates CLI parameters and their combinations."""
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def validate_protocol(protocol: str) -> bool:
|
|
24
|
+
"""
|
|
25
|
+
Validate protocol parameter.
|
|
26
|
+
|
|
27
|
+
Args:
|
|
28
|
+
protocol: Protocol string to validate
|
|
29
|
+
|
|
30
|
+
Returns:
|
|
31
|
+
True if valid
|
|
32
|
+
|
|
33
|
+
Raises:
|
|
34
|
+
ValidationError: If protocol is invalid
|
|
35
|
+
"""
|
|
36
|
+
valid_protocols = ['http', 'https', 'mtls']
|
|
37
|
+
if protocol not in valid_protocols:
|
|
38
|
+
raise ValidationError(
|
|
39
|
+
f"Invalid protocol '{protocol}'. Must be one of: {', '.join(valid_protocols)}"
|
|
40
|
+
)
|
|
41
|
+
return True
|
|
42
|
+
|
|
43
|
+
@staticmethod
|
|
44
|
+
def validate_token_with_protocol(token: bool, protocol: str) -> bool:
|
|
45
|
+
"""
|
|
46
|
+
Validate token parameter with protocol.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
token: Whether token authentication is enabled
|
|
50
|
+
protocol: Protocol being used
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
True if valid
|
|
54
|
+
|
|
55
|
+
Raises:
|
|
56
|
+
ValidationError: If token is not compatible with protocol
|
|
57
|
+
"""
|
|
58
|
+
if token and protocol == 'mtls':
|
|
59
|
+
raise ValidationError(
|
|
60
|
+
"Token authentication is not supported with mTLS protocol. "
|
|
61
|
+
"mTLS uses client certificates for authentication."
|
|
62
|
+
)
|
|
63
|
+
return True
|
|
64
|
+
|
|
65
|
+
@staticmethod
|
|
66
|
+
def validate_roles_with_auth(roles: bool, token: bool, protocol: str) -> bool:
|
|
67
|
+
"""
|
|
68
|
+
Validate roles parameter with authentication method.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
roles: Whether roles are enabled
|
|
72
|
+
token: Whether token authentication is enabled
|
|
73
|
+
protocol: Protocol being used
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
True if valid
|
|
77
|
+
|
|
78
|
+
Raises:
|
|
79
|
+
ValidationError: If roles are not compatible with authentication method
|
|
80
|
+
"""
|
|
81
|
+
if roles and protocol in ['http', 'https'] and not token:
|
|
82
|
+
raise ValidationError(
|
|
83
|
+
f"Roles require token authentication for {protocol} protocol. "
|
|
84
|
+
"Use --token flag when enabling --roles."
|
|
85
|
+
)
|
|
86
|
+
return True
|
|
87
|
+
|
|
88
|
+
@staticmethod
|
|
89
|
+
def validate_port(port: int) -> bool:
|
|
90
|
+
"""
|
|
91
|
+
Validate port number.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
port: Port number to validate
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
True if valid
|
|
98
|
+
|
|
99
|
+
Raises:
|
|
100
|
+
ValidationError: If port is invalid
|
|
101
|
+
"""
|
|
102
|
+
if not isinstance(port, int) or port < 1 or port > 65535:
|
|
103
|
+
raise ValidationError(f"Invalid port '{port}'. Must be an integer between 1 and 65535.")
|
|
104
|
+
return True
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def validate_host(host: str) -> bool:
|
|
108
|
+
"""
|
|
109
|
+
Validate host address.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
host: Host address to validate
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
True if valid
|
|
116
|
+
|
|
117
|
+
Raises:
|
|
118
|
+
ValidationError: If host is invalid
|
|
119
|
+
"""
|
|
120
|
+
if not host or not isinstance(host, str):
|
|
121
|
+
raise ValidationError("Host must be a non-empty string.")
|
|
122
|
+
return True
|
|
123
|
+
|
|
124
|
+
@staticmethod
|
|
125
|
+
def validate_file_path(file_path: str, must_exist: bool = False) -> bool:
|
|
126
|
+
"""
|
|
127
|
+
Validate file path.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
file_path: File path to validate
|
|
131
|
+
must_exist: Whether file must exist
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
True if valid
|
|
135
|
+
|
|
136
|
+
Raises:
|
|
137
|
+
ValidationError: If file path is invalid
|
|
138
|
+
"""
|
|
139
|
+
if not file_path or not isinstance(file_path, str):
|
|
140
|
+
raise ValidationError("File path must be a non-empty string.")
|
|
141
|
+
|
|
142
|
+
if must_exist and not Path(file_path).exists():
|
|
143
|
+
raise ValidationError(f"File does not exist: {file_path}")
|
|
144
|
+
|
|
145
|
+
return True
|
|
146
|
+
|
|
147
|
+
@staticmethod
|
|
148
|
+
def validate_directory_path(dir_path: str, must_exist: bool = False) -> bool:
|
|
149
|
+
"""
|
|
150
|
+
Validate directory path.
|
|
151
|
+
|
|
152
|
+
Args:
|
|
153
|
+
dir_path: Directory path to validate
|
|
154
|
+
must_exist: Whether directory must exist
|
|
155
|
+
|
|
156
|
+
Returns:
|
|
157
|
+
True if valid
|
|
158
|
+
|
|
159
|
+
Raises:
|
|
160
|
+
ValidationError: If directory path is invalid
|
|
161
|
+
"""
|
|
162
|
+
if not dir_path or not isinstance(dir_path, str):
|
|
163
|
+
raise ValidationError("Directory path must be a non-empty string.")
|
|
164
|
+
|
|
165
|
+
if must_exist and not Path(dir_path).exists():
|
|
166
|
+
raise ValidationError(f"Directory does not exist: {dir_path}")
|
|
167
|
+
|
|
168
|
+
return True
|
|
169
|
+
|
|
170
|
+
@staticmethod
|
|
171
|
+
def validate_url(url: str) -> bool:
|
|
172
|
+
"""
|
|
173
|
+
Validate URL format.
|
|
174
|
+
|
|
175
|
+
Args:
|
|
176
|
+
url: URL to validate
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
True if valid
|
|
180
|
+
|
|
181
|
+
Raises:
|
|
182
|
+
ValidationError: If URL is invalid
|
|
183
|
+
"""
|
|
184
|
+
if not url or not isinstance(url, str):
|
|
185
|
+
raise ValidationError("URL must be a non-empty string.")
|
|
186
|
+
|
|
187
|
+
# Basic URL validation
|
|
188
|
+
if not (url.startswith('http://') or url.startswith('https://')):
|
|
189
|
+
raise ValidationError("URL must start with 'http://' or 'https://'")
|
|
190
|
+
|
|
191
|
+
return True
|
|
192
|
+
|
|
193
|
+
@staticmethod
|
|
194
|
+
def validate_server_id(server_id: str) -> bool:
|
|
195
|
+
"""
|
|
196
|
+
Validate server ID.
|
|
197
|
+
|
|
198
|
+
Args:
|
|
199
|
+
server_id: Server ID to validate
|
|
200
|
+
|
|
201
|
+
Returns:
|
|
202
|
+
True if valid
|
|
203
|
+
|
|
204
|
+
Raises:
|
|
205
|
+
ValidationError: If server ID is invalid
|
|
206
|
+
"""
|
|
207
|
+
if not server_id or not isinstance(server_id, str):
|
|
208
|
+
raise ValidationError("Server ID must be a non-empty string.")
|
|
209
|
+
|
|
210
|
+
# Check for valid characters (alphanumeric, hyphens, underscores)
|
|
211
|
+
import re
|
|
212
|
+
if not re.match(r'^[a-zA-Z0-9_-]+$', server_id):
|
|
213
|
+
raise ValidationError(
|
|
214
|
+
"Server ID must contain only alphanumeric characters, hyphens, and underscores."
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
return True
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
class ConfigurationValidator:
|
|
221
|
+
"""Validates configuration combinations and dependencies."""
|
|
222
|
+
|
|
223
|
+
@staticmethod
|
|
224
|
+
|
|
225
|
+
@staticmethod
|
|
226
|
+
|
|
227
|
+
@staticmethod
|
|
228
|
+
|
|
229
|
+
@staticmethod
|
|
230
|
+
|
|
231
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Facade JsonRpcClient combining transport and feature mixins.
|
|
2
|
+
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Optional
|
|
10
|
+
|
|
11
|
+
from mcp_proxy_adapter.client.jsonrpc_client.command_api import CommandApiMixin
|
|
12
|
+
from mcp_proxy_adapter.client.jsonrpc_client.proxy_api import ProxyApiMixin
|
|
13
|
+
from mcp_proxy_adapter.client.jsonrpc_client.queue_api import QueueApiMixin
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class JsonRpcClient(ProxyApiMixin, QueueApiMixin, CommandApiMixin):
|
|
17
|
+
"""High-level asynchronous JSON-RPC client facade."""
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
protocol: str = "http",
|
|
22
|
+
host: str = "127.0.0.1",
|
|
23
|
+
port: int = 8080,
|
|
24
|
+
token_header: Optional[str] = None,
|
|
25
|
+
token: Optional[str] = None,
|
|
26
|
+
cert: Optional[str] = None,
|
|
27
|
+
key: Optional[str] = None,
|
|
28
|
+
ca: Optional[str] = None,
|
|
29
|
+
) -> None:
|
|
30
|
+
super().__init__(
|
|
31
|
+
protocol=protocol,
|
|
32
|
+
host=host,
|
|
33
|
+
port=port,
|
|
34
|
+
token_header=token_header,
|
|
35
|
+
token=token,
|
|
36
|
+
cert=cert,
|
|
37
|
+
key=key,
|
|
38
|
+
ca=ca,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = ["JsonRpcClient"]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Command helpers for JsonRpcClient.
|
|
2
|
+
|
|
3
|
+
Author: Vasiliy Zdanovskiy
|
|
4
|
+
email: vasilyvz@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from typing import Any, Dict, Optional
|
|
10
|
+
|
|
11
|
+
from mcp_proxy_adapter.client.jsonrpc_client.transport import JsonRpcTransport
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CommandApiMixin(JsonRpcTransport):
|
|
15
|
+
"""Mixin providing standard JSON-RPC command helpers."""
|
|
16
|
+
|
|
17
|
+
async def echo(
|
|
18
|
+
self, message: str = "Hello, World!", timestamp: Optional[str] = None
|
|
19
|
+
) -> Dict[str, Any]:
|
|
20
|
+
params: Dict[str, Any] = {"message": message}
|
|
21
|
+
if timestamp:
|
|
22
|
+
params["timestamp"] = timestamp
|
|
23
|
+
response = await self.jsonrpc_call("echo", params)
|
|
24
|
+
return self._extract_result(response)
|
|
25
|
+
|
|
26
|
+
async def help(
|
|
27
|
+
self, command_name: Optional[str] = None
|
|
28
|
+
) -> Dict[str, Any]:
|
|
29
|
+
params: Dict[str, Any] = {}
|
|
30
|
+
if command_name:
|
|
31
|
+
params["command"] = command_name
|
|
32
|
+
response = await self.jsonrpc_call("help", params)
|
|
33
|
+
return self._extract_result(response)
|
|
34
|
+
|
|
35
|
+
async def get_config(self) -> Dict[str, Any]:
|
|
36
|
+
response = await self.jsonrpc_call("config", {})
|
|
37
|
+
return self._extract_result(response)
|
|
38
|
+
|
|
39
|
+
async def long_task(self, seconds: int) -> Dict[str, Any]:
|
|
40
|
+
response = await self.jsonrpc_call("long_task", {"seconds": seconds})
|
|
41
|
+
return self._extract_result(response)
|
|
42
|
+
|
|
43
|
+
async def job_status(self, job_id: str) -> Dict[str, Any]:
|
|
44
|
+
response = await self.jsonrpc_call("job_status", {"job_id": job_id})
|
|
45
|
+
return self._extract_result(response)
|