mcp-proxy-adapter 2.1.6__py3-none-any.whl → 2.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_proxy_adapter/examples/openapi_server.py +1 -1
- mcp_proxy_adapter/testing_utils.py +112 -0
- {mcp_proxy_adapter-2.1.6.dist-info → mcp_proxy_adapter-2.1.8.dist-info}/METADATA +1 -1
- {mcp_proxy_adapter-2.1.6.dist-info → mcp_proxy_adapter-2.1.8.dist-info}/RECORD +7 -6
- {mcp_proxy_adapter-2.1.6.dist-info → mcp_proxy_adapter-2.1.8.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-2.1.6.dist-info → mcp_proxy_adapter-2.1.8.dist-info}/licenses/LICENSE +0 -0
- {mcp_proxy_adapter-2.1.6.dist-info → mcp_proxy_adapter-2.1.8.dist-info}/top_level.txt +0 -0
@@ -26,7 +26,7 @@ from mcp_proxy_adapter.models import JsonRpcRequest, JsonRpcResponse
|
|
26
26
|
|
27
27
|
# Import MockRegistry from tests for example
|
28
28
|
# (in a real project, CommandRegistry would be used)
|
29
|
-
from
|
29
|
+
from mcp_proxy_adapter.testing_utils import MockRegistry
|
30
30
|
|
31
31
|
# Configure logging
|
32
32
|
logging.basicConfig(level=logging.DEBUG)
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
Test utilities for MCP Proxy Adapter: mock dispatcher, registry, and OpenAPI generator.
|
4
|
+
Can be used in examples and tests.
|
5
|
+
"""
|
6
|
+
|
7
|
+
def success_command(value: int = 1) -> dict:
|
8
|
+
return {"result": value * 2}
|
9
|
+
|
10
|
+
def error_command() -> None:
|
11
|
+
raise ValueError("Test error")
|
12
|
+
|
13
|
+
def param_command(required_param: str, optional_param: int = 0) -> dict:
|
14
|
+
return {"required": required_param, "optional": optional_param}
|
15
|
+
|
16
|
+
def complex_param_command(array_param: list, object_param: dict, bool_param: bool = True) -> dict:
|
17
|
+
return {
|
18
|
+
"array_length": len(array_param),
|
19
|
+
"object_keys": list(object_param.keys()),
|
20
|
+
"bool_value": bool_param
|
21
|
+
}
|
22
|
+
|
23
|
+
def type_error_command(param: int) -> dict:
|
24
|
+
return {"param": param + 1}
|
25
|
+
|
26
|
+
class MockDispatcher:
|
27
|
+
def __init__(self):
|
28
|
+
self.commands = {
|
29
|
+
"success": success_command,
|
30
|
+
"error": error_command,
|
31
|
+
"param": param_command,
|
32
|
+
"execute": self.execute_from_params
|
33
|
+
}
|
34
|
+
self.commands_info = {
|
35
|
+
"success": {
|
36
|
+
"description": "Successful command",
|
37
|
+
"params": {"value": {"type": "integer", "description": "Input value", "required": False, "default": 1}}
|
38
|
+
},
|
39
|
+
"error": {"description": "Command with error", "params": {}},
|
40
|
+
"param": {
|
41
|
+
"description": "Command with parameters",
|
42
|
+
"params": {
|
43
|
+
"required_param": {"type": "string", "description": "Required parameter", "required": True},
|
44
|
+
"optional_param": {"type": "integer", "description": "Optional parameter", "required": False, "default": 0}
|
45
|
+
}
|
46
|
+
},
|
47
|
+
"execute": {
|
48
|
+
"description": "Universal command for executing other commands",
|
49
|
+
"params": {"query": {"type": "string", "description": "Command or query to execute", "required": False}}
|
50
|
+
},
|
51
|
+
"complex_param": {
|
52
|
+
"description": "Command with complex parameters",
|
53
|
+
"params": {
|
54
|
+
"array_param": {"type": "array", "description": "Array of values", "required": True},
|
55
|
+
"object_param": {"type": "object", "description": "Object", "required": True},
|
56
|
+
"bool_param": {"type": "boolean", "description": "Boolean value", "required": False, "default": True}
|
57
|
+
}
|
58
|
+
},
|
59
|
+
"type_error": {
|
60
|
+
"description": "Command that will raise TypeError",
|
61
|
+
"params": {"param": {"type": "integer", "description": "Integer parameter", "required": True}}
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
def execute_from_params(self, **params):
|
66
|
+
if "query" in params and params["query"] in self.commands:
|
67
|
+
command = params.pop("query")
|
68
|
+
return self.execute(command, **params)
|
69
|
+
return {"available_commands": self.get_valid_commands(), "received_params": params}
|
70
|
+
|
71
|
+
def execute(self, command, **params):
|
72
|
+
if command not in self.commands:
|
73
|
+
raise KeyError(f"Unknown command: {command}")
|
74
|
+
return self.commands[command](**params)
|
75
|
+
|
76
|
+
def get_valid_commands(self):
|
77
|
+
return list(self.commands.keys())
|
78
|
+
|
79
|
+
def get_command_info(self, command):
|
80
|
+
return self.commands_info.get(command)
|
81
|
+
|
82
|
+
def get_commands_info(self):
|
83
|
+
return self.commands_info
|
84
|
+
|
85
|
+
class MockRegistry:
|
86
|
+
def __init__(self, use_openapi_generator=False):
|
87
|
+
self.dispatcher = MockDispatcher()
|
88
|
+
self.generators = []
|
89
|
+
self.use_openapi_generator = use_openapi_generator
|
90
|
+
|
91
|
+
def get_commands_info(self):
|
92
|
+
return self.dispatcher.get_commands_info()
|
93
|
+
|
94
|
+
def add_generator(self, generator):
|
95
|
+
self.generators.append(generator)
|
96
|
+
if hasattr(generator, 'set_dispatcher'):
|
97
|
+
generator.set_dispatcher(self.dispatcher)
|
98
|
+
|
99
|
+
class MockOpenApiGenerator:
|
100
|
+
def __init__(self, **kwargs):
|
101
|
+
self.dispatcher = None
|
102
|
+
self.kwargs = kwargs
|
103
|
+
|
104
|
+
def set_dispatcher(self, dispatcher):
|
105
|
+
self.dispatcher = dispatcher
|
106
|
+
|
107
|
+
def generate_schema(self):
|
108
|
+
return {
|
109
|
+
"openapi": "3.0.0",
|
110
|
+
"info": {"title": "Mock API", "version": "1.0.0"},
|
111
|
+
"paths": {}
|
112
|
+
}
|
@@ -3,6 +3,7 @@ mcp_proxy_adapter/adapter.py,sha256=76dkVeDuqLsJ5AhuftzLlwy2M6yr_PfNbmNfo9dXVhc,
|
|
3
3
|
mcp_proxy_adapter/models.py,sha256=acqVQBYAojHXeJ1MJyvpMyT6-J6aMxWuZMszn_-RsOU,2338
|
4
4
|
mcp_proxy_adapter/registry.py,sha256=jgC4TKaPbMbAsoxvGp2ToaOE4drD-VfZug7WJbm4IW4,15853
|
5
5
|
mcp_proxy_adapter/schema.py,sha256=HZM0TTQTSi8ha1TEeVevdCyGZOUPoT1soB7Nex0hV50,10947
|
6
|
+
mcp_proxy_adapter/testing_utils.py,sha256=RWjQFNSUtVkeP0qNzp6_jrT6_tub3w_052DrRmvxVk0,4243
|
6
7
|
mcp_proxy_adapter/analyzers/__init__.py,sha256=2rcYZDP-bXq078MQpxP32lAwYYyRhOwAQGBcefBfBzY,368
|
7
8
|
mcp_proxy_adapter/analyzers/docstring_analyzer.py,sha256=T3FLJEo_uChShfiEKRl8GpVoHvh5HiudZkxnj4KixfA,7541
|
8
9
|
mcp_proxy_adapter/analyzers/type_analyzer.py,sha256=6Wac7osKwF03waFSwQ8ZM0Wqn_zAP2D-I4WMEpR0hQM,5230
|
@@ -16,13 +17,13 @@ mcp_proxy_adapter/examples/extension_example.py,sha256=vnatnFdNTapMpPcQ79Ugitk92
|
|
16
17
|
mcp_proxy_adapter/examples/help_best_practices.py,sha256=wUtZRnAktnpfAc9vAvqSxUquHEr5ewaPDPyc6BoCqdQ,2637
|
17
18
|
mcp_proxy_adapter/examples/help_usage.py,sha256=UOd3HJeYlQpQkAyceGNm66jXX_h-T05pjIGD-b7-Pfg,2568
|
18
19
|
mcp_proxy_adapter/examples/mcp_proxy_client.py,sha256=z4IzFlGigVTQSb8TpcrQ_a0migsmC58LnNwc8wZmTfw,3811
|
19
|
-
mcp_proxy_adapter/examples/openapi_server.py,sha256=
|
20
|
+
mcp_proxy_adapter/examples/openapi_server.py,sha256=MXCr5qifI03oexgdY05SsnbhWCe2_6ebnYOfAdk_Uug,14027
|
20
21
|
mcp_proxy_adapter/examples/project_structure_example.py,sha256=sswTo6FZb1F5juHa0FYG3cgvrh3wfgGfJu2bBy5tCm4,1460
|
21
22
|
mcp_proxy_adapter/examples/testing_example.py,sha256=AB13c4C1bjs1145O-yriwyreeVXtMOlQLzs2BCGmprk,1719
|
22
23
|
mcp_proxy_adapter/validators/docstring_validator.py,sha256=Onpq2iNJ1qF4ejkJJIlBkLROuSNIVALHVmXIgkCpaFI,2934
|
23
24
|
mcp_proxy_adapter/validators/metadata_validator.py,sha256=uCrn38-VYYn89l6f5CC_GoTAHAweaOW2Z6Esro1rtGw,3155
|
24
|
-
mcp_proxy_adapter-2.1.
|
25
|
-
mcp_proxy_adapter-2.1.
|
26
|
-
mcp_proxy_adapter-2.1.
|
27
|
-
mcp_proxy_adapter-2.1.
|
28
|
-
mcp_proxy_adapter-2.1.
|
25
|
+
mcp_proxy_adapter-2.1.8.dist-info/licenses/LICENSE,sha256=OkApFEwdgMCt_mbvUI-eIwKMSTe38K3XnU2DT5ub-wI,1072
|
26
|
+
mcp_proxy_adapter-2.1.8.dist-info/METADATA,sha256=00u84DQvT9pK7oERFmMbyrOiBbCaMxeBiqOpx2NRgV8,12578
|
27
|
+
mcp_proxy_adapter-2.1.8.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
|
28
|
+
mcp_proxy_adapter-2.1.8.dist-info/top_level.txt,sha256=JZT7vPLBYrtroX-ij68JBhJYbjDdghcV-DFySRy-Nnw,18
|
29
|
+
mcp_proxy_adapter-2.1.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|