mcp-proxy-adapter 6.6.1__py3-none-any.whl → 6.6.3__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 (25) hide show
  1. mcp_proxy_adapter/api/app.py +28 -26
  2. mcp_proxy_adapter/config.py +2 -9
  3. mcp_proxy_adapter/core/server_adapter.py +1 -1
  4. mcp_proxy_adapter/examples/check_config.py +1 -1
  5. mcp_proxy_adapter/examples/config_builder.py +11 -17
  6. mcp_proxy_adapter/examples/{generate_certificates_bugfix.py → generate_certificates.py} +11 -0
  7. mcp_proxy_adapter/examples/generate_config.py +3 -3
  8. mcp_proxy_adapter/examples/run_full_test_suite.py +3 -3
  9. mcp_proxy_adapter/examples/security_test_client.py +6 -5
  10. mcp_proxy_adapter/examples/test_chk_hostname_automated.py +7 -10
  11. mcp_proxy_adapter/examples/test_framework_complete.py +269 -0
  12. mcp_proxy_adapter/examples/test_mcp_server.py +188 -0
  13. mcp_proxy_adapter/main.py +11 -18
  14. mcp_proxy_adapter/version.py +1 -1
  15. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.3.dist-info}/METADATA +1 -1
  16. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.3.dist-info}/RECORD +19 -23
  17. mcp_proxy_adapter/examples/config_builder_simple.py +0 -271
  18. mcp_proxy_adapter/examples/generate_all_certificates.py +0 -487
  19. mcp_proxy_adapter/examples/generate_certificates_cli.py +0 -406
  20. mcp_proxy_adapter/examples/generate_certificates_fixed.py +0 -313
  21. mcp_proxy_adapter/examples/generate_certificates_framework.py +0 -366
  22. mcp_proxy_adapter/examples/generate_certificates_openssl.py +0 -391
  23. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.3.dist-info}/WHEEL +0 -0
  24. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.3.dist-info}/entry_points.txt +0 -0
  25. {mcp_proxy_adapter-6.6.1.dist-info → mcp_proxy_adapter-6.6.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,188 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Test MCP Server for framework validation.
4
+
5
+ Author: Vasiliy Zdanovskiy
6
+ email: vasilyvz@gmail.com
7
+ """
8
+
9
+ import asyncio
10
+ import json
11
+ import logging
12
+ from typing import Any, Dict, List, Optional
13
+ from mcp import types
14
+ from mcp.server import Server
15
+ from mcp.server.stdio import stdio_server
16
+
17
+ # Configure logging
18
+ logging.basicConfig(level=logging.INFO)
19
+ logger = logging.getLogger(__name__)
20
+
21
+ class TestMCPServer:
22
+ """Test MCP Server for framework validation."""
23
+
24
+ def __init__(self):
25
+ self.server = Server("test-mcp-server")
26
+ self._setup_handlers()
27
+
28
+ def _setup_handlers(self):
29
+ """Setup MCP server handlers."""
30
+
31
+ @self.server.list_tools()
32
+ async def list_tools() -> List[types.Tool]:
33
+ """List available tools."""
34
+ return [
35
+ types.Tool(
36
+ name="echo",
37
+ description="Echo back the input message",
38
+ inputSchema={
39
+ "type": "object",
40
+ "properties": {
41
+ "message": {
42
+ "type": "string",
43
+ "description": "Message to echo back"
44
+ }
45
+ },
46
+ "required": ["message"]
47
+ }
48
+ ),
49
+ types.Tool(
50
+ name="add",
51
+ description="Add two numbers",
52
+ inputSchema={
53
+ "type": "object",
54
+ "properties": {
55
+ "a": {
56
+ "type": "number",
57
+ "description": "First number"
58
+ },
59
+ "b": {
60
+ "type": "number",
61
+ "description": "Second number"
62
+ }
63
+ },
64
+ "required": ["a", "b"]
65
+ }
66
+ ),
67
+ types.Tool(
68
+ name="get_info",
69
+ description="Get server information",
70
+ inputSchema={
71
+ "type": "object",
72
+ "properties": {}
73
+ }
74
+ )
75
+ ]
76
+
77
+ @self.server.call_tool()
78
+ async def call_tool(name: str, arguments: Dict[str, Any]) -> List[types.TextContent]:
79
+ """Handle tool calls."""
80
+ logger.info(f"Tool called: {name} with args: {arguments}")
81
+
82
+ if name == "echo":
83
+ message = arguments.get("message", "")
84
+ return [types.TextContent(type="text", text=f"Echo: {message}")]
85
+
86
+ elif name == "add":
87
+ a = arguments.get("a", 0)
88
+ b = arguments.get("b", 0)
89
+ result = a + b
90
+ return [types.TextContent(type="text", text=f"Result: {a} + {b} = {result}")]
91
+
92
+ elif name == "get_info":
93
+ info = {
94
+ "server_name": "test-mcp-server",
95
+ "version": "1.0.0",
96
+ "status": "running",
97
+ "tools_count": 3
98
+ }
99
+ return [types.TextContent(type="text", text=json.dumps(info, indent=2))]
100
+
101
+ else:
102
+ return [types.TextContent(type="text", text=f"Unknown tool: {name}")]
103
+
104
+ @self.server.list_resources()
105
+ async def list_resources() -> List[types.Resource]:
106
+ """List available resources."""
107
+ return [
108
+ types.Resource(
109
+ uri="test://config",
110
+ name="Server Configuration",
111
+ description="Current server configuration",
112
+ mimeType="application/json"
113
+ ),
114
+ types.Resource(
115
+ uri="test://status",
116
+ name="Server Status",
117
+ description="Current server status",
118
+ mimeType="application/json"
119
+ )
120
+ ]
121
+
122
+ @self.server.read_resource()
123
+ async def read_resource(uri: str) -> str:
124
+ """Read resource content."""
125
+ if uri == "test://config":
126
+ config = {
127
+ "server_name": "test-mcp-server",
128
+ "port": 3001,
129
+ "protocol": "stdio",
130
+ "features": ["tools", "resources"]
131
+ }
132
+ return json.dumps(config, indent=2)
133
+
134
+ elif uri == "test://status":
135
+ status = {
136
+ "status": "running",
137
+ "uptime": "0s",
138
+ "requests_handled": 0,
139
+ "last_request": None
140
+ }
141
+ return json.dumps(status, indent=2)
142
+
143
+ else:
144
+ raise ValueError(f"Unknown resource: {uri}")
145
+
146
+ @self.server.list_prompts()
147
+ async def list_prompts() -> List[types.Prompt]:
148
+ """List available prompts."""
149
+ return [
150
+ types.Prompt(
151
+ name="greeting",
152
+ description="Generate a greeting message",
153
+ arguments=[
154
+ types.PromptArgument(
155
+ name="name",
156
+ description="Name to greet",
157
+ required=True
158
+ )
159
+ ]
160
+ )
161
+ ]
162
+
163
+ @self.server.get_prompt()
164
+ async def get_prompt(name: str, arguments: Dict[str, str]) -> List[types.TextContent]:
165
+ """Get prompt content."""
166
+ if name == "greeting":
167
+ user_name = arguments.get("name", "User")
168
+ greeting = f"Hello, {user_name}! Welcome to the test MCP server."
169
+ return [types.TextContent(type="text", text=greeting)]
170
+
171
+ else:
172
+ raise ValueError(f"Unknown prompt: {name}")
173
+
174
+ async def main():
175
+ """Main server function."""
176
+ logger.info("Starting Test MCP Server...")
177
+
178
+ server_instance = TestMCPServer()
179
+
180
+ async with stdio_server() as (read_stream, write_stream):
181
+ await server_instance.server.run(
182
+ read_stream,
183
+ write_stream,
184
+ server_instance.server.create_initialization_options()
185
+ )
186
+
187
+ if __name__ == "__main__":
188
+ asyncio.run(main())
mcp_proxy_adapter/main.py CHANGED
@@ -61,30 +61,23 @@ def main():
61
61
 
62
62
  # Get protocol and SSL configuration
63
63
  protocol = config.get("server.protocol", "http")
64
- ssl_enabled = protocol in ["https", "mtls"]
64
+ verify_client = config.get("transport.verify_client", False)
65
+ chk_hostname = config.get("transport.chk_hostname", False)
66
+
67
+ # SSL enabled if protocol is HTTPS or mTLS (verify_client=True)
68
+ ssl_enabled = protocol in ["https", "mtls"] or verify_client
65
69
 
66
70
  # SSL configuration based on protocol
67
71
  ssl_cert_file = None
68
72
  ssl_key_file = None
69
73
  ssl_ca_cert = None
70
- verify_client = False
71
74
 
72
75
  if ssl_enabled:
73
- # Configure SSL based on protocol
74
- if protocol == "https":
75
- # HTTPS - server SSL only
76
- ssl_cert_file = "../../certs/server.crt"
77
- ssl_key_file = "../../certs/server.key"
78
- ssl_ca_cert = "../../certs/localhost_server.crt"
79
- verify_client = False
80
-
81
- elif protocol == "mtls":
82
- # mTLS - server SSL + client certificate verification
83
- # Use server.crt and server.key for server, and localhost_server.crt as CA
84
- ssl_cert_file = "../../certs/server.crt"
85
- ssl_key_file = "../../certs/server.key"
86
- ssl_ca_cert = "../../certs/localhost_server.crt"
87
- verify_client = False # Disable client cert verification for testing
76
+ # Configure SSL certificates - use absolute paths
77
+ project_root = Path(__file__).parent.parent
78
+ ssl_cert_file = str(project_root / "certs" / "server_cert.pem")
79
+ ssl_key_file = str(project_root / "keys" / "server_key.pem")
80
+ ssl_ca_cert = str(project_root / "certs" / "localhost_server.crt")
88
81
 
89
82
  print("🔍 Debug config:")
90
83
  print(f" protocol: {protocol}")
@@ -116,7 +109,7 @@ def main():
116
109
  "key_file": ssl_key_file,
117
110
  "ca_cert": ssl_ca_cert,
118
111
  "verify_client": verify_client,
119
- "chk_hostname": config.get("transport.ssl.chk_hostname", True)
112
+ "chk_hostname": chk_hostname
120
113
  }
121
114
 
122
115
  hypercorn_ssl = ServerConfigAdapter.convert_ssl_config_for_engine(ssl_config, "hypercorn")
@@ -2,4 +2,4 @@
2
2
  Version information for MCP Proxy Adapter.
3
3
  """
4
4
 
5
- __version__ = "6.6.1"
5
+ __version__ = "6.6.3"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-proxy-adapter
3
- Version: 6.6.1
3
+ Version: 6.6.3
4
4
  Summary: Powerful JSON-RPC microservices framework with built-in security, authentication, and proxy registration
5
5
  Home-page: https://github.com/maverikod/mcp-proxy-adapter
6
6
  Author: Vasiliy Zdanovskiy
@@ -1,12 +1,12 @@
1
1
  mcp_proxy_adapter/__init__.py,sha256=iH0EBBsRj_cfZJpAIsgN_8tTdfefhnl6uUKHjLHhWDQ,1037
2
2
  mcp_proxy_adapter/__main__.py,sha256=sq3tANRuTd18euamt0Bmn1sJeAyzXENZ5VvsMwbrDFA,579
3
- mcp_proxy_adapter/config.py,sha256=NmwYJPfnAFWmGsOlyYkMDfuqA-SeduuvTSjZKJbzbKc,20424
3
+ mcp_proxy_adapter/config.py,sha256=sYyqmWGCWSiFy4q0zdlkJKxz2IbNIbjCfEhqxdVvjbI,20157
4
4
  mcp_proxy_adapter/custom_openapi.py,sha256=XRviX-C-ZkSKdBhORhDTdeN_1FWyEfXZADiASft3t9I,28149
5
- mcp_proxy_adapter/main.py,sha256=I9fYgMD8_RNYuSHn-paeTSr9coAuVlEkfLaWeYbZors,5724
5
+ mcp_proxy_adapter/main.py,sha256=E3K2vDnnZ44ODdSWDqAdaIG-55NIyYbcpxNGEQLQlPg,5461
6
6
  mcp_proxy_adapter/openapi.py,sha256=2UZOI09ZDRJuBYBjKbMyb2U4uASszoCMD5o_4ktRpvg,13480
7
- mcp_proxy_adapter/version.py,sha256=Mh_TTmFK-EgbYu8AwRu8Ax1MTsScWluXVsIKkST5imU,74
7
+ mcp_proxy_adapter/version.py,sha256=2s9mmkrnxOAjp6hsHf5RXfk463sH55FUntKrzYuyXJY,74
8
8
  mcp_proxy_adapter/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- mcp_proxy_adapter/api/app.py,sha256=cxjavhNTtaYg2ea-UeHSDnKh8edKVNQ2NbXUDYbufFU,34183
9
+ mcp_proxy_adapter/api/app.py,sha256=chGxUMfWQXqn4wRC7Ar4X9uMF7JxI5EmQNVPEr0TQZI,34573
10
10
  mcp_proxy_adapter/api/handlers.py,sha256=X-hcMNVeTAu4yVkKJEChEsj2bFptUS6sLNN-Wysjkow,10011
11
11
  mcp_proxy_adapter/api/schemas.py,sha256=mevUvQnYgWQfkJAs3-vq3HalBzh6-Saa-Au1VVf0peE,12377
12
12
  mcp_proxy_adapter/api/tool_integration.py,sha256=AeUyvJVN-c3FrX5fHdagHL51saRH5d1ZKqc2YEx0rTE,10147
@@ -75,7 +75,7 @@ mcp_proxy_adapter/core/role_utils.py,sha256=YwRenGoXI5YrHVbFjKFAH2DJs2miyqhcr9LW
75
75
  mcp_proxy_adapter/core/security_adapter.py,sha256=MAtNthsp7Qj4-oLFzSi7Pr3vWQbWS_uelqa5LGgrXIE,12957
76
76
  mcp_proxy_adapter/core/security_factory.py,sha256=M-1McwUOmuV7Eo-m_P2undtJVNK_KIjDx8o_uRY8rLo,8005
77
77
  mcp_proxy_adapter/core/security_integration.py,sha256=-5I4i9so_yMjc-zuGO-7zzIsMXemLvrch1q8WFVbIfg,14167
78
- mcp_proxy_adapter/core/server_adapter.py,sha256=-Tta9BzFCNO2TtdNmA8rd6ubzSGKiIoICpit_fczg1c,9748
78
+ mcp_proxy_adapter/core/server_adapter.py,sha256=jz8ztIfe82N5DE3XHRYpD6CwNcJy7ksh0l8l-towHBE,9755
79
79
  mcp_proxy_adapter/core/server_engine.py,sha256=qmxdkBv-YsQsvxVVQ-_xiAyDshxtnrKBquPJoUjo2fw,9471
80
80
  mcp_proxy_adapter/core/settings.py,sha256=D6cF4R_5gJ0XFGxzXUIzeqe-_muu6HL561TAei9wwZ0,10521
81
81
  mcp_proxy_adapter/core/ssl_utils.py,sha256=Rjl79d5LdhDzxiMtaIRd9OFh0hTeRANItYFXk-7c5pA,9498
@@ -85,34 +85,30 @@ mcp_proxy_adapter/core/utils.py,sha256=wBdDYBDWQ6zbwrnl9tykHjo0FjJVsLT_x8Bjk1lZX
85
85
  mcp_proxy_adapter/examples/__init__.py,sha256=k1F-EotAFbJ3JvK_rNgiH4bUztmxIWtYn0AfbAZ1ZGs,450
86
86
  mcp_proxy_adapter/examples/bugfix_certificate_config.py,sha256=YGBE_SI6wYZUJLWl7-fP1OWXiSH4mHJAZHApgQWvG7s,10529
87
87
  mcp_proxy_adapter/examples/cert_manager_bugfix.py,sha256=UWUwItjqHqSnOMHocsz40_3deoZE8-vdROLW9y2fEns,7259
88
- mcp_proxy_adapter/examples/check_config.py,sha256=W6gS6stP-WfE71YmIemvbmolf04FiR7mvJYSJqDFdzQ,14090
89
- mcp_proxy_adapter/examples/config_builder.py,sha256=kd3-donlGuDgZwJYsy_rjzrydBg_A1GaaJuJ8jj4VDc,9696
90
- mcp_proxy_adapter/examples/config_builder_simple.py,sha256=qTG3tIIu8eUW8gb06snaWHOTp0BFRRim38VqKrP2Ezo,9109
88
+ mcp_proxy_adapter/examples/check_config.py,sha256=oDP3cymq76TqEpPztPihH-_sBktiEb2cG0MdVrY1Sj8,14104
89
+ mcp_proxy_adapter/examples/config_builder.py,sha256=eIn_kxoM_Q7oNrqV2lpn4a_jrJrJxfhCfpFHdzibHvs,9648
91
90
  mcp_proxy_adapter/examples/config_cli.py,sha256=ZhVG6XEpTFe5-MzELByVsUh0AD4bHPBZeoXnGWbqifs,11059
92
91
  mcp_proxy_adapter/examples/create_test_configs.py,sha256=9TrvLa4-bWLPu0SB1JXwWuCsjj-4Vz3yAdowcHtCSSA,8228
93
92
  mcp_proxy_adapter/examples/debug_request_state.py,sha256=Z3Gy2-fWtu7KIV9OkzGDLVz7TpL_h9V_99ica40uQBU,4489
94
93
  mcp_proxy_adapter/examples/debug_role_chain.py,sha256=GLVXC2fJUwP8UJnXHchd1t-H53cjWLJI3RqTPrKmaak,8750
95
94
  mcp_proxy_adapter/examples/demo_client.py,sha256=en2Rtb70B1sQmhL-vdQ4PDpKNNl_mfll2YCFT_jFCAg,10191
96
- mcp_proxy_adapter/examples/generate_all_certificates.py,sha256=lLP5RKmJwpSyprvrxQXFt_xcN4aiUzlIxk5WVdXx2Fk,19024
97
- mcp_proxy_adapter/examples/generate_certificates_bugfix.py,sha256=LskoIezj67PZqqrB8WgCO9bFPqPLRuNwUAt8I3bDT4o,15768
98
- mcp_proxy_adapter/examples/generate_certificates_cli.py,sha256=jb5bdNhoODL6qTWBdx4bNR9BVKo_lbzfWK91u5XuWXA,16986
99
- mcp_proxy_adapter/examples/generate_certificates_fixed.py,sha256=6zJj9xdEuwj-ZO2clMoB7pNj5hW4IgwK-qsLPzuq8VQ,12566
100
- mcp_proxy_adapter/examples/generate_certificates_framework.py,sha256=TGLyy4AJNI0w-Dd2FUQyX2sOXt05o_q4zkjoapzG1Wc,15017
101
- mcp_proxy_adapter/examples/generate_certificates_openssl.py,sha256=5V4B8Ys_-FZsDh-CH7BNf1XXkMtpidkm4iecY0XCFuE,16891
102
- mcp_proxy_adapter/examples/generate_config.py,sha256=4WcyCMuQKqr5qtGekoqy-jrQ-71F-ZYdDYftwLrjJNg,11461
95
+ mcp_proxy_adapter/examples/generate_certificates.py,sha256=cIfTHBziGiOTy9vldAmaULD6bXBpl2a5KfB8MLIRSww,16391
96
+ mcp_proxy_adapter/examples/generate_config.py,sha256=hkjfCY7OdgMcqAJZH6I3JSKWI1VB64IEyT7RaokTb48,11461
103
97
  mcp_proxy_adapter/examples/proxy_registration_example.py,sha256=vemRhftnjbiOBCJkmtDGqlWQ8syTG0a8755GCOnaQsg,12503
104
98
  mcp_proxy_adapter/examples/required_certificates.py,sha256=YW9-V78oFiZ-FmHlGP-8FQFS569VdDVyq9hfvCv31pk,7133
105
99
  mcp_proxy_adapter/examples/run_example.py,sha256=yp-a6HIrSk3ddQmbn0KkuKwErId0aNfj028TE6U-zmY,2626
106
- mcp_proxy_adapter/examples/run_full_test_suite.py,sha256=Zd7SINqi4UdiwDWaZrerh4e35XTqAUVApulEYtZx39M,25613
100
+ mcp_proxy_adapter/examples/run_full_test_suite.py,sha256=AovcAWbaVsx1eMLAgIPZXRqv_Lz77pbvMq0huak4G78,25703
107
101
  mcp_proxy_adapter/examples/run_proxy_server.py,sha256=SBLSSY2F_VEBQD3MsCE_Pa9xFE6Sszr3vHdE9QOEN4Y,5242
108
102
  mcp_proxy_adapter/examples/run_security_tests_fixed.py,sha256=aIf57LcAlNUEoroRueZ9hRrnVkg0cRgr58vP2T-ZEXM,18328
109
- mcp_proxy_adapter/examples/security_test_client.py,sha256=HL0AhmmHZ9SHlUx6aJ32jTHJonjKmGil74ifLbsGkZA,48660
103
+ mcp_proxy_adapter/examples/security_test_client.py,sha256=ukrzMSJz6AhXp-ZKSMfS53u2SfGQnopvJDh7lj7cxLk,48815
110
104
  mcp_proxy_adapter/examples/setup_test_environment.py,sha256=JkMqLpH5ZmkNKE7-WT52_kYMxEKLFOyQWbtip29TeiU,51629
111
105
  mcp_proxy_adapter/examples/simple_protocol_test.py,sha256=BzFUZvK9Fih3aG4IFLQTZPyPe_s6YjpZfB6uZmQ76rw,3969
112
- mcp_proxy_adapter/examples/test_chk_hostname_automated.py,sha256=9n3V2rk3WdC9yPj40o_3MyRlVRM6jGBBgpyJ5PL2Fd8,7178
106
+ mcp_proxy_adapter/examples/test_chk_hostname_automated.py,sha256=nN0FEevzP6UP3q40zq4lw_GiT050FYomu7rWFPOMF2U,7002
113
107
  mcp_proxy_adapter/examples/test_config.py,sha256=ekEoUZe9q484vU_0IxOVhQdNMVJXG3IpmQpP--VmuDI,6491
114
108
  mcp_proxy_adapter/examples/test_config_builder.py,sha256=SAcWIC54vzO0mrb1L9xZKK2IhNkZuSx7_cMEkC1Lm60,21607
115
109
  mcp_proxy_adapter/examples/test_examples.py,sha256=CYlVatdHUVC_rwv4NsvxFG3GXiKIyxPDUH43BOJHjrU,12330
110
+ mcp_proxy_adapter/examples/test_framework_complete.py,sha256=9EvJL9hgjYddzGTavjp7M7xlcO8SJvDvbobOHDxRHs8,9622
111
+ mcp_proxy_adapter/examples/test_mcp_server.py,sha256=K4wol6H7gfviYuc8ygH4vhzc8mWsf-0xHyG6OJNaecU,6585
116
112
  mcp_proxy_adapter/examples/test_protocol_examples.py,sha256=yCZzZrJ9ICXMkF1bAMozpin2QeTMI653bggPAZTRAUE,12138
117
113
  mcp_proxy_adapter/examples/universal_client.py,sha256=n1-cBPOiCipA86Zcc_mI_jMywDMZS1p3u5JT3AqTsrQ,27577
118
114
  mcp_proxy_adapter/examples/update_config_certificates.py,sha256=ObGF5oNQ9OStryUvFDXxrN-olRMKdSOrl5KSwARF7EY,4608
@@ -134,8 +130,8 @@ mcp_proxy_adapter/schemas/base_schema.json,sha256=v9G9cGMd4dRhCZsOQ_FMqOi5VFyVbI
134
130
  mcp_proxy_adapter/schemas/openapi_schema.json,sha256=C3yLkwmDsvnLW9B5gnKKdBGl4zxkeU-rEmjTrNVsQU0,8405
135
131
  mcp_proxy_adapter/schemas/roles.json,sha256=pgf_ZyqKyXbfGUxvobpiLiSJz9zzxrMuoVWEkEpz3N8,764
136
132
  mcp_proxy_adapter/schemas/roles_schema.json,sha256=deHgI7L6GwfBXacOlNtDgDJelDThppClC3Ti4Eh8rJY,5659
137
- mcp_proxy_adapter-6.6.1.dist-info/METADATA,sha256=b7eTkQKOdUxqilzA8AMTgJRr3f6SrnBwrhgRmAzML04,8510
138
- mcp_proxy_adapter-6.6.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
139
- mcp_proxy_adapter-6.6.1.dist-info/entry_points.txt,sha256=Bf-O5Aq80n22Ayu9fI9BgidzWqwzIVaqextAddTuHZw,563
140
- mcp_proxy_adapter-6.6.1.dist-info/top_level.txt,sha256=JZT7vPLBYrtroX-ij68JBhJYbjDdghcV-DFySRy-Nnw,18
141
- mcp_proxy_adapter-6.6.1.dist-info/RECORD,,
133
+ mcp_proxy_adapter-6.6.3.dist-info/METADATA,sha256=lLweBJ6i0eno3-C5RYfQCTuzycn0Q0k0NJSwCxFl0m4,8510
134
+ mcp_proxy_adapter-6.6.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
135
+ mcp_proxy_adapter-6.6.3.dist-info/entry_points.txt,sha256=Bf-O5Aq80n22Ayu9fI9BgidzWqwzIVaqextAddTuHZw,563
136
+ mcp_proxy_adapter-6.6.3.dist-info/top_level.txt,sha256=JZT7vPLBYrtroX-ij68JBhJYbjDdghcV-DFySRy-Nnw,18
137
+ mcp_proxy_adapter-6.6.3.dist-info/RECORD,,
@@ -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))