mcp-proxy-adapter 6.9.28__py3-none-any.whl → 6.9.29__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 +10 -0
- mcp_proxy_adapter/__main__.py +8 -21
- mcp_proxy_adapter/api/app.py +10 -913
- mcp_proxy_adapter/api/core/__init__.py +18 -0
- mcp_proxy_adapter/api/core/app_factory.py +243 -0
- mcp_proxy_adapter/api/core/lifespan_manager.py +55 -0
- mcp_proxy_adapter/api/core/registration_manager.py +166 -0
- mcp_proxy_adapter/api/core/ssl_context_factory.py +88 -0
- mcp_proxy_adapter/api/handlers.py +78 -199
- mcp_proxy_adapter/api/middleware/__init__.py +1 -44
- mcp_proxy_adapter/api/middleware/base.py +0 -42
- mcp_proxy_adapter/api/middleware/command_permission_middleware.py +0 -85
- mcp_proxy_adapter/api/middleware/error_handling.py +1 -127
- mcp_proxy_adapter/api/middleware/factory.py +0 -94
- mcp_proxy_adapter/api/middleware/logging.py +0 -112
- mcp_proxy_adapter/api/middleware/performance.py +0 -35
- mcp_proxy_adapter/api/middleware/protocol_middleware.py +2 -98
- mcp_proxy_adapter/api/middleware/transport_middleware.py +0 -37
- mcp_proxy_adapter/api/middleware/unified_security.py +10 -10
- mcp_proxy_adapter/api/middleware/user_info_middleware.py +0 -118
- 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 +0 -61
- mcp_proxy_adapter/api/tool_integration.py +0 -117
- mcp_proxy_adapter/api/tools.py +0 -46
- 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 +21 -0
- mcp_proxy_adapter/cli/commands/config_validate.py +36 -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 +128 -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 +324 -0
- mcp_proxy_adapter/cli/validators.py +231 -0
- mcp_proxy_adapter/client/jsonrpc_client.py +406 -0
- mcp_proxy_adapter/client/proxy.py +45 -0
- mcp_proxy_adapter/commands/__init__.py +44 -28
- mcp_proxy_adapter/commands/auth_validation_command.py +7 -344
- mcp_proxy_adapter/commands/base.py +19 -43
- mcp_proxy_adapter/commands/builtin_commands.py +0 -75
- 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 +58 -928
- mcp_proxy_adapter/commands/cert_monitor_command.py +0 -88
- mcp_proxy_adapter/commands/certificate_management_command.py +0 -45
- mcp_proxy_adapter/commands/command_registry.py +172 -904
- mcp_proxy_adapter/commands/config_command.py +0 -28
- mcp_proxy_adapter/commands/dependency_container.py +1 -70
- mcp_proxy_adapter/commands/dependency_manager.py +0 -128
- mcp_proxy_adapter/commands/echo_command.py +0 -34
- mcp_proxy_adapter/commands/health_command.py +0 -3
- mcp_proxy_adapter/commands/help_command.py +0 -159
- mcp_proxy_adapter/commands/hooks.py +0 -137
- mcp_proxy_adapter/commands/key_management_command.py +0 -25
- mcp_proxy_adapter/commands/load_command.py +7 -78
- mcp_proxy_adapter/commands/plugins_command.py +0 -16
- mcp_proxy_adapter/commands/protocol_management_command.py +0 -28
- mcp_proxy_adapter/commands/proxy_registration_command.py +0 -88
- mcp_proxy_adapter/commands/queue_commands.py +750 -0
- mcp_proxy_adapter/commands/registration_status_command.py +0 -43
- 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 +0 -80
- mcp_proxy_adapter/commands/result.py +25 -77
- mcp_proxy_adapter/commands/role_test_command.py +0 -44
- mcp_proxy_adapter/commands/roles_management_command.py +0 -199
- mcp_proxy_adapter/commands/security_command.py +0 -30
- mcp_proxy_adapter/commands/settings_command.py +0 -68
- mcp_proxy_adapter/commands/ssl_setup_command.py +0 -42
- mcp_proxy_adapter/commands/token_management_command.py +0 -1
- mcp_proxy_adapter/commands/transport_management_command.py +0 -20
- mcp_proxy_adapter/commands/unload_command.py +0 -71
- mcp_proxy_adapter/config.py +15 -626
- mcp_proxy_adapter/core/__init__.py +5 -39
- mcp_proxy_adapter/core/app_factory.py +14 -36
- mcp_proxy_adapter/core/app_runner.py +0 -27
- mcp_proxy_adapter/core/auth_validator.py +1 -93
- mcp_proxy_adapter/core/certificate/__init__.py +20 -0
- mcp_proxy_adapter/core/certificate/certificate_creator.py +371 -0
- mcp_proxy_adapter/core/certificate/certificate_extractor.py +183 -0
- mcp_proxy_adapter/core/certificate/certificate_utils.py +249 -0
- mcp_proxy_adapter/core/certificate/certificate_validator.py +110 -0
- mcp_proxy_adapter/core/certificate/ssl_context_manager.py +70 -0
- mcp_proxy_adapter/core/certificate_utils.py +64 -903
- mcp_proxy_adapter/core/client.py +0 -6
- mcp_proxy_adapter/core/client_manager.py +0 -19
- mcp_proxy_adapter/core/client_security.py +0 -2
- mcp_proxy_adapter/core/config/__init__.py +18 -0
- mcp_proxy_adapter/core/config/config.py +195 -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 +112 -0
- mcp_proxy_adapter/core/config/simple_config_generator.py +50 -0
- mcp_proxy_adapter/core/config/simple_config_validator.py +96 -0
- mcp_proxy_adapter/core/config_converter.py +0 -186
- mcp_proxy_adapter/core/config_validator.py +96 -1238
- mcp_proxy_adapter/core/errors.py +7 -42
- mcp_proxy_adapter/core/job_manager.py +54 -0
- mcp_proxy_adapter/core/logging.py +2 -22
- mcp_proxy_adapter/core/mtls_asgi.py +0 -20
- mcp_proxy_adapter/core/mtls_asgi_app.py +0 -12
- mcp_proxy_adapter/core/mtls_proxy.py +0 -80
- mcp_proxy_adapter/core/mtls_server.py +3 -173
- mcp_proxy_adapter/core/protocol_manager.py +1 -191
- mcp_proxy_adapter/core/proxy/__init__.py +22 -0
- mcp_proxy_adapter/core/proxy/auth_manager.py +27 -0
- mcp_proxy_adapter/core/proxy/proxy_registration_manager.py +137 -0
- mcp_proxy_adapter/core/proxy/registration_client.py +60 -0
- mcp_proxy_adapter/core/proxy/ssl_manager.py +101 -0
- mcp_proxy_adapter/core/proxy_client.py +0 -1
- mcp_proxy_adapter/core/proxy_registration.py +36 -913
- mcp_proxy_adapter/core/role_utils.py +0 -308
- mcp_proxy_adapter/core/security_adapter.py +1 -36
- mcp_proxy_adapter/core/security_factory.py +1 -150
- mcp_proxy_adapter/core/security_integration.py +0 -33
- mcp_proxy_adapter/core/server_adapter.py +1 -40
- mcp_proxy_adapter/core/server_engine.py +2 -173
- mcp_proxy_adapter/core/settings.py +0 -127
- mcp_proxy_adapter/core/signal_handler.py +0 -65
- mcp_proxy_adapter/core/ssl_utils.py +19 -137
- mcp_proxy_adapter/core/transport_manager.py +0 -151
- mcp_proxy_adapter/core/unified_config_adapter.py +1 -193
- mcp_proxy_adapter/core/utils.py +1 -182
- mcp_proxy_adapter/core/validation/__init__.py +21 -0
- mcp_proxy_adapter/core/validation/config_validator.py +211 -0
- mcp_proxy_adapter/core/validation/file_validator.py +73 -0
- mcp_proxy_adapter/core/validation/protocol_validator.py +191 -0
- mcp_proxy_adapter/core/validation/security_validator.py +58 -0
- mcp_proxy_adapter/core/validation/validation_result.py +27 -0
- mcp_proxy_adapter/custom_openapi.py +33 -652
- mcp_proxy_adapter/examples/bugfix_certificate_config.py +0 -23
- mcp_proxy_adapter/examples/check_config.py +0 -2
- mcp_proxy_adapter/examples/client_usage_example.py +164 -0
- mcp_proxy_adapter/examples/config_builder.py +13 -2
- mcp_proxy_adapter/examples/config_cli.py +0 -1
- mcp_proxy_adapter/examples/create_test_configs.py +0 -46
- mcp_proxy_adapter/examples/debug_request_state.py +0 -1
- mcp_proxy_adapter/examples/full_application/commands/custom_echo_command.py +0 -47
- mcp_proxy_adapter/examples/full_application/commands/dynamic_calculator_command.py +0 -45
- mcp_proxy_adapter/examples/full_application/commands/echo_command.py +0 -12
- mcp_proxy_adapter/examples/full_application/commands/help_command.py +0 -12
- mcp_proxy_adapter/examples/full_application/commands/list_command.py +0 -7
- mcp_proxy_adapter/examples/full_application/hooks/__init__.py +0 -2
- mcp_proxy_adapter/examples/full_application/hooks/application_hooks.py +0 -59
- mcp_proxy_adapter/examples/full_application/hooks/builtin_command_hooks.py +0 -54
- mcp_proxy_adapter/examples/full_application/main.py +186 -150
- mcp_proxy_adapter/examples/full_application/proxy_endpoints.py +0 -107
- mcp_proxy_adapter/examples/full_application/test_minimal_server.py +0 -24
- mcp_proxy_adapter/examples/full_application/test_server.py +0 -58
- mcp_proxy_adapter/examples/generate_config.py +65 -11
- 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 +0 -2
- mcp_proxy_adapter/examples/run_full_test_suite.py +0 -29
- mcp_proxy_adapter/examples/run_proxy_server.py +31 -71
- mcp_proxy_adapter/examples/run_security_tests_fixed.py +0 -27
- 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 +24 -1075
- 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 +133 -1425
- mcp_proxy_adapter/examples/test_config.py +0 -3
- mcp_proxy_adapter/examples/test_config_builder.py +25 -405
- mcp_proxy_adapter/examples/test_examples.py +0 -1
- mcp_proxy_adapter/examples/test_framework_complete.py +0 -2
- mcp_proxy_adapter/examples/test_mcp_server.py +0 -1
- mcp_proxy_adapter/examples/test_protocol_examples.py +0 -1
- mcp_proxy_adapter/examples/universal_client.py +0 -6
- mcp_proxy_adapter/examples/update_config_certificates.py +0 -1
- mcp_proxy_adapter/examples/validate_generator_compatibility.py +0 -1
- mcp_proxy_adapter/examples/validate_generator_compatibility_simple.py +0 -187
- mcp_proxy_adapter/integrations/__init__.py +25 -0
- mcp_proxy_adapter/integrations/queuemgr_integration.py +462 -0
- mcp_proxy_adapter/main.py +70 -62
- mcp_proxy_adapter/openapi.py +0 -22
- mcp_proxy_adapter/version.py +1 -1
- {mcp_proxy_adapter-6.9.28.dist-info → mcp_proxy_adapter-6.9.29.dist-info}/METADATA +2 -1
- mcp_proxy_adapter-6.9.29.dist-info/RECORD +235 -0
- {mcp_proxy_adapter-6.9.28.dist-info → mcp_proxy_adapter-6.9.29.dist-info}/entry_points.txt +1 -1
- mcp_proxy_adapter-6.9.28.dist-info/RECORD +0 -149
- {mcp_proxy_adapter-6.9.28.dist-info → mcp_proxy_adapter-6.9.29.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-6.9.28.dist-info → mcp_proxy_adapter-6.9.29.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Simple synchronous JSON-RPC client for MCP alternatives Adapter.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Dict, List, Optional
|
|
10
|
+
|
|
11
|
+
import requests
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class JsonRpcClient:
|
|
15
|
+
"""Simple synchronous JSON-RPC client."""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
protocol: str = "http",
|
|
20
|
+
host: str = "127.0.0.1",
|
|
21
|
+
port: int = 8080,
|
|
22
|
+
token_header: Optional[str] = None,
|
|
23
|
+
token: Optional[str] = None,
|
|
24
|
+
cert: Optional[str] = None,
|
|
25
|
+
key: Optional[str] = None,
|
|
26
|
+
ca: Optional[str] = None,
|
|
27
|
+
):
|
|
28
|
+
"""
|
|
29
|
+
Initialize JSON-RPC client.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
protocol: Protocol (http or https)
|
|
33
|
+
host: Server host
|
|
34
|
+
port: Server port
|
|
35
|
+
token_header: Token header name (e.g., "X-API-Key")
|
|
36
|
+
token: Token value
|
|
37
|
+
cert: Client certificate file path
|
|
38
|
+
key: Client key file path
|
|
39
|
+
ca: CA certificate file path
|
|
40
|
+
"""
|
|
41
|
+
scheme = "https" if protocol == "https" else "http"
|
|
42
|
+
self.base_url = f"{scheme}://{host}:{port}"
|
|
43
|
+
|
|
44
|
+
self.headers: Dict[str, str] = {"Content-Type": "application/json"}
|
|
45
|
+
if token_header and token:
|
|
46
|
+
self.headers[token_header] = token
|
|
47
|
+
|
|
48
|
+
self.verify = True
|
|
49
|
+
self.cert: Optional[tuple[str, str] | None] = None
|
|
50
|
+
|
|
51
|
+
if protocol == "https":
|
|
52
|
+
if cert and key:
|
|
53
|
+
self.cert = (str(Path(cert)), str(Path(key)))
|
|
54
|
+
if ca:
|
|
55
|
+
self.verify = str(Path(ca))
|
|
56
|
+
else:
|
|
57
|
+
self.verify = False # Allow self-signed for examples
|
|
58
|
+
|
|
59
|
+
self.timeout = 30
|
|
60
|
+
|
|
61
|
+
def health(self) -> Dict[str, Any]:
|
|
62
|
+
"""Get server health status."""
|
|
63
|
+
r = requests.get(f"{self.base_url}/health", headers=self.headers, timeout=self.timeout, verify=self.verify, cert=self.cert)
|
|
64
|
+
r.raise_for_status()
|
|
65
|
+
return r.json()
|
|
66
|
+
|
|
67
|
+
def jsonrpc_call(self, method: str, params: Dict[str, Any], req_id: int = 1) -> Dict[str, Any]:
|
|
68
|
+
"""
|
|
69
|
+
Make JSON-RPC call.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
method: Method name
|
|
73
|
+
params: Method parameters
|
|
74
|
+
req_id: Request ID
|
|
75
|
+
|
|
76
|
+
Returns:
|
|
77
|
+
JSON-RPC response
|
|
78
|
+
"""
|
|
79
|
+
payload: Dict[str, Any] = {
|
|
80
|
+
"jsonrpc": "2.0",
|
|
81
|
+
"method": method,
|
|
82
|
+
"params": params,
|
|
83
|
+
"id": req_id,
|
|
84
|
+
}
|
|
85
|
+
r = requests.post(
|
|
86
|
+
f"{self.base_url}/api/jsonrpc",
|
|
87
|
+
json=payload,
|
|
88
|
+
headers=self.headers,
|
|
89
|
+
timeout=self.timeout,
|
|
90
|
+
verify=self.verify,
|
|
91
|
+
cert=self.cert,
|
|
92
|
+
)
|
|
93
|
+
r.raise_for_status()
|
|
94
|
+
return r.json()
|
|
95
|
+
|
|
96
|
+
def _extract_result(self, response: Dict[str, Any]) -> Dict[str, Any]:
|
|
97
|
+
"""Extract result from JSON-RPC response, raising on error."""
|
|
98
|
+
if "error" in response:
|
|
99
|
+
error = response["error"]
|
|
100
|
+
raise RuntimeError(
|
|
101
|
+
f"JSON-RPC error: {error.get('message', 'Unknown error')} (code: {error.get('code', -1)})"
|
|
102
|
+
)
|
|
103
|
+
return response.get("result", {})
|
|
104
|
+
|
|
105
|
+
# Built-in commands
|
|
106
|
+
|
|
107
|
+
def echo(self, message: str = "Hello, World!", timestamp: Optional[str] = None) -> Dict[str, Any]:
|
|
108
|
+
"""
|
|
109
|
+
Execute echo command.
|
|
110
|
+
|
|
111
|
+
Args:
|
|
112
|
+
message: Message to echo
|
|
113
|
+
timestamp: Optional timestamp
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
Echo command result
|
|
117
|
+
"""
|
|
118
|
+
params = {"message": message}
|
|
119
|
+
if timestamp:
|
|
120
|
+
params["timestamp"] = timestamp
|
|
121
|
+
response = self.jsonrpc_call("echo", params)
|
|
122
|
+
return self._extract_result(response)
|
|
123
|
+
|
|
124
|
+
def help(self, command_name: Optional[str] = None) -> Dict[str, Any]:
|
|
125
|
+
"""
|
|
126
|
+
Get help information.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
command_name: Optional command name to get help for
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
Help information
|
|
133
|
+
"""
|
|
134
|
+
params = {}
|
|
135
|
+
if command_name:
|
|
136
|
+
params["command"] = command_name
|
|
137
|
+
response = self.jsonrpc_call("help", params)
|
|
138
|
+
return self._extract_result(response)
|
|
139
|
+
|
|
140
|
+
def get_config(self) -> Dict[str, Any]:
|
|
141
|
+
"""
|
|
142
|
+
Get server configuration.
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
Server configuration
|
|
146
|
+
"""
|
|
147
|
+
response = self.jsonrpc_call("config", {})
|
|
148
|
+
return self._extract_result(response)
|
|
149
|
+
|
|
150
|
+
def long_task(self, seconds: int) -> Dict[str, Any]:
|
|
151
|
+
"""
|
|
152
|
+
Start a long-running task.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
seconds: Task duration in seconds
|
|
156
|
+
|
|
157
|
+
Returns:
|
|
158
|
+
Task result with job_id
|
|
159
|
+
"""
|
|
160
|
+
response = self.jsonrpc_call("long_task", {"seconds": seconds})
|
|
161
|
+
return self._extract_result(response)
|
|
162
|
+
|
|
163
|
+
def job_status(self, job_id: str) -> Dict[str, Any]:
|
|
164
|
+
"""
|
|
165
|
+
Get job status.
|
|
166
|
+
|
|
167
|
+
Args:
|
|
168
|
+
job_id: Job identifier
|
|
169
|
+
|
|
170
|
+
Returns:
|
|
171
|
+
Job status information
|
|
172
|
+
"""
|
|
173
|
+
response = self.jsonrpc_call("job_status", {"job_id": job_id})
|
|
174
|
+
return self._extract_result(response)
|
|
175
|
+
|
|
176
|
+
# Queue management commands
|
|
177
|
+
|
|
178
|
+
def queue_health(self) -> Dict[str, Any]:
|
|
179
|
+
"""
|
|
180
|
+
Get queue manager health status.
|
|
181
|
+
|
|
182
|
+
Returns:
|
|
183
|
+
Queue health information
|
|
184
|
+
"""
|
|
185
|
+
response = self.jsonrpc_call("queue_health", {})
|
|
186
|
+
return self._extract_result(response)
|
|
187
|
+
|
|
188
|
+
def queue_add_job(
|
|
189
|
+
self,
|
|
190
|
+
job_type: str,
|
|
191
|
+
job_id: str,
|
|
192
|
+
params: Dict[str, Any],
|
|
193
|
+
) -> Dict[str, Any]:
|
|
194
|
+
"""
|
|
195
|
+
Add a job to the queue.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
job_type: Type of job (data_processing, file_operation, api_call, custom, long_running, batch_processing, file_download)
|
|
199
|
+
job_id: Unique job identifier
|
|
200
|
+
params: Job-specific parameters
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
Job addition result
|
|
204
|
+
"""
|
|
205
|
+
response = self.jsonrpc_call(
|
|
206
|
+
"queue_add_job",
|
|
207
|
+
{
|
|
208
|
+
"job_type": job_type,
|
|
209
|
+
"job_id": job_id,
|
|
210
|
+
"params": params,
|
|
211
|
+
},
|
|
212
|
+
)
|
|
213
|
+
return self._extract_result(response)
|
|
214
|
+
|
|
215
|
+
def queue_start_job(self, job_id: str) -> Dict[str, Any]:
|
|
216
|
+
"""
|
|
217
|
+
Start a job in the queue.
|
|
218
|
+
|
|
219
|
+
Args:
|
|
220
|
+
job_id: Job identifier
|
|
221
|
+
|
|
222
|
+
Returns:
|
|
223
|
+
Job start result
|
|
224
|
+
"""
|
|
225
|
+
response = self.jsonrpc_call("queue_start_job", {"job_id": job_id})
|
|
226
|
+
return self._extract_result(response)
|
|
227
|
+
|
|
228
|
+
def queue_stop_job(self, job_id: str) -> Dict[str, Any]:
|
|
229
|
+
"""
|
|
230
|
+
Stop a running job.
|
|
231
|
+
|
|
232
|
+
Args:
|
|
233
|
+
job_id: Job identifier
|
|
234
|
+
|
|
235
|
+
Returns:
|
|
236
|
+
Job stop result
|
|
237
|
+
"""
|
|
238
|
+
response = self.jsonrpc_call("queue_stop_job", {"job_id": job_id})
|
|
239
|
+
return self._extract_result(response)
|
|
240
|
+
|
|
241
|
+
def queue_delete_job(self, job_id: str) -> Dict[str, Any]:
|
|
242
|
+
"""
|
|
243
|
+
Delete a job from the queue.
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
job_id: Job identifier
|
|
247
|
+
|
|
248
|
+
Returns:
|
|
249
|
+
Job deletion result
|
|
250
|
+
"""
|
|
251
|
+
response = self.jsonrpc_call("queue_delete_job", {"job_id": job_id})
|
|
252
|
+
return self._extract_result(response)
|
|
253
|
+
|
|
254
|
+
def queue_get_job_status(self, job_id: str) -> Dict[str, Any]:
|
|
255
|
+
"""
|
|
256
|
+
Get status of a specific job.
|
|
257
|
+
|
|
258
|
+
Args:
|
|
259
|
+
job_id: Job identifier
|
|
260
|
+
|
|
261
|
+
Returns:
|
|
262
|
+
Job status information
|
|
263
|
+
"""
|
|
264
|
+
response = self.jsonrpc_call("queue_get_job_status", {"job_id": job_id})
|
|
265
|
+
return self._extract_result(response)
|
|
266
|
+
|
|
267
|
+
def queue_list_jobs(self, status: Optional[str] = None, job_type: Optional[str] = None) -> Dict[str, Any]:
|
|
268
|
+
"""
|
|
269
|
+
List all jobs in the queue.
|
|
270
|
+
|
|
271
|
+
Args:
|
|
272
|
+
status: Optional filter by status (pending, running, completed, failed, stopped)
|
|
273
|
+
job_type: Optional filter by job type
|
|
274
|
+
|
|
275
|
+
Returns:
|
|
276
|
+
List of jobs
|
|
277
|
+
"""
|
|
278
|
+
params = {}
|
|
279
|
+
if status:
|
|
280
|
+
params["status"] = status
|
|
281
|
+
if job_type:
|
|
282
|
+
params["job_type"] = job_type
|
|
283
|
+
response = self.jsonrpc_call("queue_list_jobs", params)
|
|
284
|
+
return self._extract_result(response)
|
|
285
|
+
|
|
286
|
+
# Proxy registration methods
|
|
287
|
+
|
|
288
|
+
def register_with_proxy(
|
|
289
|
+
self,
|
|
290
|
+
proxy_url: str,
|
|
291
|
+
server_name: str,
|
|
292
|
+
server_url: str,
|
|
293
|
+
capabilities: Optional[List[str]] = None,
|
|
294
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
295
|
+
) -> Dict[str, Any]:
|
|
296
|
+
"""
|
|
297
|
+
Register this server with a proxy server.
|
|
298
|
+
|
|
299
|
+
Args:
|
|
300
|
+
proxy_url: URL of the proxy server (e.g., "http://localhost:3005")
|
|
301
|
+
server_name: Name/ID of this server
|
|
302
|
+
server_url: URL where this server is accessible
|
|
303
|
+
capabilities: Optional list of server capabilities
|
|
304
|
+
metadata: Optional metadata dictionary
|
|
305
|
+
|
|
306
|
+
Returns:
|
|
307
|
+
Registration result
|
|
308
|
+
"""
|
|
309
|
+
payload = {
|
|
310
|
+
"name": server_name,
|
|
311
|
+
"url": server_url,
|
|
312
|
+
"capabilities": capabilities or [],
|
|
313
|
+
"metadata": metadata or {},
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
proxy_base = proxy_url.rstrip("/")
|
|
317
|
+
r = requests.post(f"{proxy_base}/register", json=payload, timeout=10)
|
|
318
|
+
r.raise_for_status()
|
|
319
|
+
return r.json()
|
|
320
|
+
|
|
321
|
+
def unregister_from_proxy(self, proxy_url: str, server_name: str) -> Dict[str, Any]:
|
|
322
|
+
"""
|
|
323
|
+
Unregister this server from a proxy server.
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
proxy_url: URL of the proxy server (e.g., "http://localhost:3005")
|
|
327
|
+
server_name: Name/ID of this server
|
|
328
|
+
|
|
329
|
+
Returns:
|
|
330
|
+
Unregistration result
|
|
331
|
+
"""
|
|
332
|
+
payload = {
|
|
333
|
+
"name": server_name,
|
|
334
|
+
"url": "",
|
|
335
|
+
"capabilities": [],
|
|
336
|
+
"metadata": {},
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
proxy_base = proxy_url.rstrip("/")
|
|
340
|
+
r = requests.post(f"{proxy_base}/unregister", json=payload, timeout=10)
|
|
341
|
+
r.raise_for_status()
|
|
342
|
+
return r.json()
|
|
343
|
+
|
|
344
|
+
def heartbeat_to_proxy(
|
|
345
|
+
self,
|
|
346
|
+
proxy_url: str,
|
|
347
|
+
server_name: str,
|
|
348
|
+
server_url: str,
|
|
349
|
+
capabilities: Optional[List[str]] = None,
|
|
350
|
+
metadata: Optional[Dict[str, Any]] = None,
|
|
351
|
+
) -> Dict[str, Any]:
|
|
352
|
+
"""
|
|
353
|
+
Send heartbeat to proxy server.
|
|
354
|
+
|
|
355
|
+
Args:
|
|
356
|
+
proxy_url: URL of the proxy server (e.g., "http://localhost:3005")
|
|
357
|
+
server_name: Name/ID of this server
|
|
358
|
+
server_url: URL where this server is accessible
|
|
359
|
+
capabilities: Optional list of server capabilities
|
|
360
|
+
metadata: Optional metadata dictionary
|
|
361
|
+
|
|
362
|
+
Returns:
|
|
363
|
+
Heartbeat result
|
|
364
|
+
"""
|
|
365
|
+
payload = {
|
|
366
|
+
"name": server_name,
|
|
367
|
+
"url": server_url,
|
|
368
|
+
"capabilities": capabilities or [],
|
|
369
|
+
"metadata": metadata or {},
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
proxy_base = proxy_url.rstrip("/")
|
|
373
|
+
r = requests.post(f"{proxy_base}/proxy/heartbeat", json=payload, timeout=10)
|
|
374
|
+
r.raise_for_status()
|
|
375
|
+
return r.json()
|
|
376
|
+
|
|
377
|
+
def list_proxy_servers(self, proxy_url: str) -> Dict[str, Any]:
|
|
378
|
+
"""
|
|
379
|
+
List all servers registered on a proxy server.
|
|
380
|
+
|
|
381
|
+
Args:
|
|
382
|
+
proxy_url: URL of the proxy server (e.g., "http://localhost:3005")
|
|
383
|
+
|
|
384
|
+
Returns:
|
|
385
|
+
List of registered servers
|
|
386
|
+
"""
|
|
387
|
+
proxy_base = proxy_url.rstrip("/")
|
|
388
|
+
r = requests.get(f"{proxy_base}/proxy/list", timeout=10)
|
|
389
|
+
r.raise_for_status()
|
|
390
|
+
return r.json()
|
|
391
|
+
|
|
392
|
+
def get_proxy_health(self, proxy_url: str) -> Dict[str, Any]:
|
|
393
|
+
"""
|
|
394
|
+
Get proxy server health status.
|
|
395
|
+
|
|
396
|
+
Args:
|
|
397
|
+
proxy_url: URL of the proxy server (e.g., "http://localhost:3005")
|
|
398
|
+
|
|
399
|
+
Returns:
|
|
400
|
+
Proxy health status
|
|
401
|
+
"""
|
|
402
|
+
proxy_base = proxy_url.rstrip("/")
|
|
403
|
+
r = requests.get(f"{proxy_base}/proxy/health", timeout=10)
|
|
404
|
+
r.raise_for_status()
|
|
405
|
+
return r.json()
|
|
406
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Author: Vasiliy Zdanovskiy
|
|
3
|
+
email: vasilyvz@gmail.com
|
|
4
|
+
|
|
5
|
+
Lightweight client library for registry (proxy) server used in examples.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from typing import Any, Dict, List, Optional
|
|
9
|
+
|
|
10
|
+
import requests
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ProxyClient:
|
|
14
|
+
def __init__(self, base_url: str):
|
|
15
|
+
self.base_url = base_url.rstrip("/")
|
|
16
|
+
|
|
17
|
+
def health(self) -> Dict[str, Any]:
|
|
18
|
+
r = requests.get(f"{self.base_url}/proxy/health", timeout=5)
|
|
19
|
+
r.raise_for_status()
|
|
20
|
+
return r.json()
|
|
21
|
+
|
|
22
|
+
def register(self, name: str, url: str, capabilities: Optional[List[str]] = None, metadata: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
23
|
+
payload = {"name": name, "url": url, "capabilities": capabilities or [], "metadata": metadata or {}}
|
|
24
|
+
r = requests.post(f"{self.base_url}/register", json=payload, timeout=5)
|
|
25
|
+
r.raise_for_status()
|
|
26
|
+
return r.json()
|
|
27
|
+
|
|
28
|
+
def unregister(self, name: str) -> Dict[str, Any]:
|
|
29
|
+
payload = {"name": name, "url": "", "capabilities": [], "metadata": {}}
|
|
30
|
+
r = requests.post(f"{self.base_url}/unregister", json=payload, timeout=5)
|
|
31
|
+
r.raise_for_status()
|
|
32
|
+
return r.json()
|
|
33
|
+
|
|
34
|
+
def list_servers(self) -> Dict[str, Any]:
|
|
35
|
+
r = requests.get(f"{self.base_url}/proxy/list", timeout=5)
|
|
36
|
+
r.raise_for_status()
|
|
37
|
+
return r.json()
|
|
38
|
+
|
|
39
|
+
def heartbeat(self, name: str, url: str) -> Dict[str, Any]:
|
|
40
|
+
payload = {"name": name, "url": url, "capabilities": [], "metadata": {}}
|
|
41
|
+
r = requests.post(f"{self.base_url}/proxy/heartbeat", json=payload, timeout=5)
|
|
42
|
+
r.raise_for_status()
|
|
43
|
+
return r.json()
|
|
44
|
+
|
|
45
|
+
|
|
@@ -9,24 +9,33 @@ from mcp_proxy_adapter.commands.dependency_container import (
|
|
|
9
9
|
DependencyContainer,
|
|
10
10
|
)
|
|
11
11
|
from mcp_proxy_adapter.commands.result import CommandResult, SuccessResult, ErrorResult
|
|
12
|
-
from mcp_proxy_adapter.commands.auth_validation_command import AuthValidationCommand
|
|
13
|
-
from mcp_proxy_adapter.commands.ssl_setup_command import SSLSetupCommand
|
|
14
|
-
from mcp_proxy_adapter.commands.certificate_management_command import (
|
|
15
|
-
|
|
16
|
-
)
|
|
17
|
-
from mcp_proxy_adapter.commands.key_management_command import KeyManagementCommand
|
|
18
|
-
from mcp_proxy_adapter.commands.cert_monitor_command import CertMonitorCommand
|
|
19
|
-
from mcp_proxy_adapter.commands.transport_management_command import (
|
|
20
|
-
|
|
21
|
-
)
|
|
22
|
-
from mcp_proxy_adapter.commands.role_test_command import RoleTestCommand
|
|
23
|
-
from mcp_proxy_adapter.commands.echo_command import EchoCommand
|
|
24
|
-
from mcp_proxy_adapter.commands.proxy_registration_command import (
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
from mcp_proxy_adapter.commands.registration_status_command import (
|
|
28
|
-
|
|
29
|
-
)
|
|
12
|
+
# from mcp_proxy_adapter.commands.auth_validation_command import AuthValidationCommand
|
|
13
|
+
# from mcp_proxy_adapter.commands.ssl_setup_command import SSLSetupCommand
|
|
14
|
+
# from mcp_proxy_adapter.commands.certificate_management_command import (
|
|
15
|
+
# CertificateManagementCommand,
|
|
16
|
+
# )
|
|
17
|
+
# from mcp_proxy_adapter.commands.key_management_command import KeyManagementCommand
|
|
18
|
+
# from mcp_proxy_adapter.commands.cert_monitor_command import CertMonitorCommand
|
|
19
|
+
# from mcp_proxy_adapter.commands.transport_management_command import (
|
|
20
|
+
# TransportManagementCommand,
|
|
21
|
+
# )
|
|
22
|
+
# from mcp_proxy_adapter.commands.role_test_command import RoleTestCommand
|
|
23
|
+
# from mcp_proxy_adapter.commands.echo_command import EchoCommand
|
|
24
|
+
# from mcp_proxy_adapter.commands.proxy_registration_command import (
|
|
25
|
+
# ProxyRegistrationCommand,
|
|
26
|
+
# )
|
|
27
|
+
# from mcp_proxy_adapter.commands.registration_status_command import (
|
|
28
|
+
# RegistrationStatusCommand,
|
|
29
|
+
# )
|
|
30
|
+
# from mcp_proxy_adapter.commands.queue_commands import (
|
|
31
|
+
# QueueAddJobCommand,
|
|
32
|
+
# QueueStartJobCommand,
|
|
33
|
+
# QueueStopJobCommand,
|
|
34
|
+
# QueueDeleteJobCommand,
|
|
35
|
+
# QueueGetJobStatusCommand,
|
|
36
|
+
# QueueListJobsCommand,
|
|
37
|
+
# QueueHealthCommand,
|
|
38
|
+
# )
|
|
30
39
|
|
|
31
40
|
__all__ = [
|
|
32
41
|
"Command",
|
|
@@ -37,14 +46,21 @@ __all__ = [
|
|
|
37
46
|
"CommandRegistry",
|
|
38
47
|
"container",
|
|
39
48
|
"DependencyContainer",
|
|
40
|
-
"AuthValidationCommand",
|
|
41
|
-
"SSLSetupCommand",
|
|
42
|
-
"CertificateManagementCommand",
|
|
43
|
-
"KeyManagementCommand",
|
|
44
|
-
"CertMonitorCommand",
|
|
45
|
-
"TransportManagementCommand",
|
|
46
|
-
"RoleTestCommand",
|
|
47
|
-
"EchoCommand",
|
|
48
|
-
"ProxyRegistrationCommand",
|
|
49
|
-
"RegistrationStatusCommand",
|
|
49
|
+
# "AuthValidationCommand",
|
|
50
|
+
# "SSLSetupCommand",
|
|
51
|
+
# "CertificateManagementCommand",
|
|
52
|
+
# "KeyManagementCommand",
|
|
53
|
+
# "CertMonitorCommand",
|
|
54
|
+
# "TransportManagementCommand",
|
|
55
|
+
# "RoleTestCommand",
|
|
56
|
+
# "EchoCommand",
|
|
57
|
+
# "ProxyRegistrationCommand",
|
|
58
|
+
# "RegistrationStatusCommand",
|
|
59
|
+
# "QueueAddJobCommand",
|
|
60
|
+
# "QueueStartJobCommand",
|
|
61
|
+
# "QueueStopJobCommand",
|
|
62
|
+
# "QueueDeleteJobCommand",
|
|
63
|
+
# "QueueGetJobStatusCommand",
|
|
64
|
+
# "QueueListJobsCommand",
|
|
65
|
+
# "QueueHealthCommand",
|
|
50
66
|
]
|