mcp-proxy-adapter 6.6.1__py3-none-any.whl → 6.6.4__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.
Files changed (27) hide show
  1. mcp_proxy_adapter/api/app.py +61 -55
  2. mcp_proxy_adapter/commands/command_registry.py +27 -13
  3. mcp_proxy_adapter/config.py +1 -8
  4. mcp_proxy_adapter/core/proxy_registration.py +80 -7
  5. mcp_proxy_adapter/core/server_adapter.py +1 -1
  6. mcp_proxy_adapter/examples/check_config.py +1 -1
  7. mcp_proxy_adapter/examples/config_builder.py +13 -19
  8. mcp_proxy_adapter/examples/{generate_certificates_bugfix.py → generate_certificates.py} +11 -0
  9. mcp_proxy_adapter/examples/generate_config.py +3 -3
  10. mcp_proxy_adapter/examples/run_full_test_suite.py +3 -3
  11. mcp_proxy_adapter/examples/security_test_client.py +6 -5
  12. mcp_proxy_adapter/examples/test_chk_hostname_automated.py +7 -10
  13. mcp_proxy_adapter/examples/test_framework_complete.py +269 -0
  14. mcp_proxy_adapter/examples/test_mcp_server.py +188 -0
  15. mcp_proxy_adapter/main.py +19 -18
  16. mcp_proxy_adapter/version.py +1 -1
  17. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.4.dist-info}/METADATA +1 -1
  18. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.4.dist-info}/RECORD +21 -25
  19. mcp_proxy_adapter/examples/config_builder_simple.py +0 -271
  20. mcp_proxy_adapter/examples/generate_all_certificates.py +0 -487
  21. mcp_proxy_adapter/examples/generate_certificates_cli.py +0 -406
  22. mcp_proxy_adapter/examples/generate_certificates_fixed.py +0 -313
  23. mcp_proxy_adapter/examples/generate_certificates_framework.py +0 -366
  24. mcp_proxy_adapter/examples/generate_certificates_openssl.py +0 -391
  25. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.4.dist-info}/WHEEL +0 -0
  26. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.4.dist-info}/entry_points.txt +0 -0
  27. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.4.dist-info}/top_level.txt +0 -0
@@ -1,271 +0,0 @@
1
- """
2
- Simplified configuration builder for MCP Proxy Adapter.
3
-
4
- Author: Vasiliy Zdanovskiy
5
- email: vasilyvz@gmail.com
6
- """
7
-
8
- import json
9
- import uuid
10
- from enum import Enum
11
- from typing import Dict, List, Optional, Any
12
-
13
-
14
- class Protocol(Enum):
15
- """Supported protocols."""
16
- HTTP = "http"
17
- HTTPS = "https"
18
- MTLS = "mtls"
19
-
20
-
21
- class AuthMethod(Enum):
22
- """Authentication methods."""
23
- NONE = "none"
24
- TOKEN = "token"
25
- TOKEN_ROLES = "token_roles"
26
-
27
-
28
- class ConfigBuilder:
29
- """Simplified configuration builder."""
30
-
31
- def __init__(self):
32
- """Initialize the configuration builder."""
33
- self._reset_to_defaults()
34
-
35
- def _reset_to_defaults(self):
36
- """Reset configuration to default values."""
37
- self.config = {
38
- "uuid": str(uuid.uuid4()),
39
- "server": {
40
- "host": "0.0.0.0",
41
- "port": 8000,
42
- "protocol": "http",
43
- "debug": False,
44
- "log_level": "INFO"
45
- },
46
- "logging": {
47
- "level": "INFO",
48
- "file": None,
49
- "log_dir": "./logs",
50
- "log_file": "mcp_proxy_adapter.log",
51
- "max_size": 10,
52
- "backup_count": 5,
53
- "console_output": True,
54
- "json_format": False
55
- },
56
- "security": {
57
- "enabled": False,
58
- "tokens": {
59
- "admin": "admin-secret-key",
60
- "user": "user-secret-key",
61
- "readonly": "readonly-secret-key"
62
- },
63
- "roles": {
64
- "admin": ["read", "write", "delete", "admin"],
65
- "user": ["read", "write"],
66
- "readonly": ["read"]
67
- },
68
- "roles_file": None
69
- },
70
- "debug": {
71
- "enabled": False,
72
- "log_level": "DEBUG",
73
- "trace_requests": False,
74
- "trace_responses": False
75
- }
76
- }
77
-
78
- def set_protocol(self, protocol: Protocol, cert_dir: str = "./certs", key_dir: str = "./keys"):
79
- """Set protocol configuration (HTTP, HTTPS, or mTLS)."""
80
- self.config["server"]["protocol"] = protocol.value
81
-
82
- if protocol == Protocol.HTTP:
83
- # HTTP - no SSL
84
- pass
85
-
86
- elif protocol == Protocol.HTTPS:
87
- # HTTPS - server SSL only
88
- # SSL configuration will be handled by the server based on protocol
89
- pass
90
-
91
- elif protocol == Protocol.MTLS:
92
- # mTLS - server SSL + client certificates
93
- # SSL configuration will be handled by the server based on protocol
94
- pass
95
-
96
- return self
97
-
98
- def set_auth(self, auth_method: AuthMethod, api_keys: Optional[Dict[str, str]] = None, roles: Optional[Dict[str, List[str]]] = None):
99
- """Set authentication configuration."""
100
- if auth_method == AuthMethod.NONE:
101
- self.config["security"]["enabled"] = False
102
- self.config["security"]["tokens"] = {}
103
- self.config["security"]["roles"] = {}
104
- self.config["security"]["roles_file"] = None
105
-
106
- elif auth_method == AuthMethod.TOKEN:
107
- self.config["security"]["enabled"] = True
108
- self.config["security"]["tokens"] = api_keys or {
109
- "admin": "admin-secret-key",
110
- "user": "user-secret-key"
111
- }
112
- self.config["security"]["roles"] = {}
113
- self.config["security"]["roles_file"] = None
114
-
115
- elif auth_method == AuthMethod.TOKEN_ROLES:
116
- self.config["security"]["enabled"] = True
117
- self.config["security"]["tokens"] = api_keys or {
118
- "admin": "admin-secret-key",
119
- "user": "user-secret-key",
120
- "readonly": "readonly-secret-key"
121
- }
122
- self.config["security"]["roles"] = roles or {
123
- "admin": ["read", "write", "delete", "admin"],
124
- "user": ["read", "write"],
125
- "readonly": ["read"]
126
- }
127
- self.config["security"]["roles_file"] = "configs/roles.json"
128
-
129
- return self
130
-
131
- def set_server(self, host: str = "0.0.0.0", port: int = 8000):
132
- """Set server configuration."""
133
- self.config["server"]["host"] = host
134
- self.config["server"]["port"] = port
135
- return self
136
-
137
- def set_roles_file(self, roles_file: str):
138
- """Set roles file path."""
139
- self.config["security"]["roles_file"] = roles_file
140
- return self
141
-
142
- def build(self) -> Dict[str, Any]:
143
- """Build and return the configuration."""
144
- return self.config.copy()
145
-
146
- def save(self, file_path: str) -> None:
147
- """Save configuration to file."""
148
- with open(file_path, 'w', encoding='utf-8') as f:
149
- json.dump(self.config, f, indent=2, ensure_ascii=False)
150
-
151
-
152
- class ConfigFactory:
153
- """Factory for creating common configurations."""
154
-
155
- @staticmethod
156
- def create_http_config(port: int = 8000) -> Dict[str, Any]:
157
- """Create HTTP configuration."""
158
- return (ConfigBuilder()
159
- .set_protocol(Protocol.HTTP)
160
- .set_server(port=port)
161
- .build())
162
-
163
- @staticmethod
164
- def create_http_token_config(port: int = 8001) -> Dict[str, Any]:
165
- """Create HTTP with token authentication configuration."""
166
- return (ConfigBuilder()
167
- .set_protocol(Protocol.HTTP)
168
- .set_auth(AuthMethod.TOKEN)
169
- .set_server(port=port)
170
- .build())
171
-
172
- @staticmethod
173
- def create_http_token_roles_config(port: int = 8002) -> Dict[str, Any]:
174
- """Create HTTP with token and roles configuration."""
175
- return (ConfigBuilder()
176
- .set_protocol(Protocol.HTTP)
177
- .set_auth(AuthMethod.TOKEN_ROLES)
178
- .set_server(port=port)
179
- .build())
180
-
181
- @staticmethod
182
- def create_https_config(port: int = 8003) -> Dict[str, Any]:
183
- """Create HTTPS configuration."""
184
- return (ConfigBuilder()
185
- .set_protocol(Protocol.HTTPS)
186
- .set_server(port=port)
187
- .build())
188
-
189
- @staticmethod
190
- def create_https_token_config(port: int = 8004) -> Dict[str, Any]:
191
- """Create HTTPS with token authentication configuration."""
192
- return (ConfigBuilder()
193
- .set_protocol(Protocol.HTTPS)
194
- .set_auth(AuthMethod.TOKEN)
195
- .set_server(port=port)
196
- .build())
197
-
198
- @staticmethod
199
- def create_https_token_roles_config(port: int = 8005) -> Dict[str, Any]:
200
- """Create HTTPS with token and roles configuration."""
201
- return (ConfigBuilder()
202
- .set_protocol(Protocol.HTTPS)
203
- .set_auth(AuthMethod.TOKEN_ROLES)
204
- .set_server(port=port)
205
- .build())
206
-
207
- @staticmethod
208
- def create_mtls_config(port: int = 8006) -> Dict[str, Any]:
209
- """Create mTLS configuration."""
210
- return (ConfigBuilder()
211
- .set_protocol(Protocol.MTLS)
212
- .set_server(port=port)
213
- .build())
214
-
215
- @staticmethod
216
- def create_mtls_token_config(port: int = 8007) -> Dict[str, Any]:
217
- """Create mTLS with token authentication configuration."""
218
- return (ConfigBuilder()
219
- .set_protocol(Protocol.MTLS)
220
- .set_auth(AuthMethod.TOKEN)
221
- .set_server(port=port)
222
- .build())
223
-
224
- @staticmethod
225
- def create_mtls_token_roles_config(port: int = 8008) -> Dict[str, Any]:
226
- """Create mTLS with token and roles configuration."""
227
- return (ConfigBuilder()
228
- .set_protocol(Protocol.MTLS)
229
- .set_auth(AuthMethod.TOKEN_ROLES)
230
- .set_server(port=port)
231
- .build())
232
-
233
-
234
- def create_config_from_flags(protocol: str, token: bool = False, roles: bool = False, port: int = 8000) -> Dict[str, Any]:
235
- """
236
- Create configuration from command line flags.
237
-
238
- Args:
239
- protocol: Protocol type (http, https, mtls)
240
- token: Enable token authentication
241
- roles: Enable role-based access control
242
- port: Server port
243
-
244
- Returns:
245
- Configuration dictionary
246
- """
247
- protocol_map = {
248
- "http": Protocol.HTTP,
249
- "https": Protocol.HTTPS,
250
- "mtls": Protocol.MTLS
251
- }
252
-
253
- if protocol not in protocol_map:
254
- raise ValueError(f"Unsupported protocol: {protocol}")
255
-
256
- builder = ConfigBuilder().set_protocol(protocol_map[protocol]).set_server(port=port)
257
-
258
- if roles:
259
- builder.set_auth(AuthMethod.TOKEN_ROLES)
260
- elif token:
261
- builder.set_auth(AuthMethod.TOKEN)
262
- else:
263
- builder.set_auth(AuthMethod.NONE)
264
-
265
- return builder.build()
266
-
267
-
268
- if __name__ == "__main__":
269
- # Example usage
270
- config = create_config_from_flags("http", token=True, port=8001)
271
- print(json.dumps(config, indent=2))