mcp-proxy-adapter 2.1.16__py3-none-any.whl → 3.0.0__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 (84) hide show
  1. examples/__init__.py +19 -0
  2. examples/anti_patterns/README.md +51 -0
  3. examples/anti_patterns/__init__.py +9 -0
  4. examples/anti_patterns/bad_design/README.md +72 -0
  5. examples/anti_patterns/bad_design/global_state.py +170 -0
  6. examples/anti_patterns/bad_design/monolithic_command.py +272 -0
  7. examples/basic_example/README.md +131 -0
  8. examples/basic_example/__init__.py +8 -0
  9. examples/basic_example/commands/__init__.py +5 -0
  10. examples/basic_example/commands/echo_command.py +95 -0
  11. examples/basic_example/commands/math_command.py +151 -0
  12. examples/basic_example/commands/time_command.py +152 -0
  13. examples/basic_example/config.json +21 -0
  14. examples/basic_example/config.yaml +20 -0
  15. examples/basic_example/docs/EN/README.md +136 -0
  16. examples/basic_example/docs/RU/README.md +136 -0
  17. examples/basic_example/main.py +50 -0
  18. examples/basic_example/server.py +45 -0
  19. examples/basic_example/tests/conftest.py +243 -0
  20. examples/commands/echo_command.py +52 -0
  21. examples/commands/echo_result.py +65 -0
  22. examples/commands/get_date_command.py +98 -0
  23. examples/commands/new_uuid4_command.py +91 -0
  24. examples/complete_example/Dockerfile +24 -0
  25. examples/complete_example/README.md +92 -0
  26. examples/complete_example/__init__.py +8 -0
  27. examples/complete_example/commands/__init__.py +5 -0
  28. examples/complete_example/commands/system_command.py +327 -0
  29. examples/complete_example/config.json +41 -0
  30. examples/complete_example/configs/config.dev.yaml +40 -0
  31. examples/complete_example/configs/config.docker.yaml +40 -0
  32. examples/complete_example/docker-compose.yml +35 -0
  33. examples/complete_example/main.py +67 -0
  34. examples/complete_example/requirements.txt +20 -0
  35. examples/complete_example/server.py +85 -0
  36. examples/minimal_example/README.md +51 -0
  37. examples/minimal_example/__init__.py +8 -0
  38. examples/minimal_example/config.json +21 -0
  39. examples/minimal_example/config.yaml +26 -0
  40. examples/minimal_example/main.py +67 -0
  41. examples/minimal_example/simple_server.py +124 -0
  42. examples/minimal_example/tests/conftest.py +171 -0
  43. examples/minimal_example/tests/test_hello_command.py +111 -0
  44. examples/minimal_example/tests/test_integration.py +183 -0
  45. examples/server.py +69 -0
  46. examples/simple_server.py +137 -0
  47. examples/test_server.py +126 -0
  48. mcp_proxy_adapter/__init__.py +33 -1
  49. mcp_proxy_adapter/config.py +186 -0
  50. mcp_proxy_adapter/custom_openapi.py +125 -0
  51. mcp_proxy_adapter/framework.py +109 -0
  52. mcp_proxy_adapter/openapi.py +403 -0
  53. mcp_proxy_adapter/version.py +3 -0
  54. mcp_proxy_adapter-3.0.0.dist-info/METADATA +200 -0
  55. mcp_proxy_adapter-3.0.0.dist-info/RECORD +58 -0
  56. {mcp_proxy_adapter-2.1.16.dist-info → mcp_proxy_adapter-3.0.0.dist-info}/top_level.txt +1 -0
  57. mcp_proxy_adapter/adapter.py +0 -697
  58. mcp_proxy_adapter/analyzers/__init__.py +0 -1
  59. mcp_proxy_adapter/analyzers/docstring_analyzer.py +0 -199
  60. mcp_proxy_adapter/analyzers/type_analyzer.py +0 -151
  61. mcp_proxy_adapter/dispatchers/__init__.py +0 -1
  62. mcp_proxy_adapter/dispatchers/base_dispatcher.py +0 -85
  63. mcp_proxy_adapter/dispatchers/json_rpc_dispatcher.py +0 -235
  64. mcp_proxy_adapter/examples/analyze_config.py +0 -141
  65. mcp_proxy_adapter/examples/basic_integration.py +0 -155
  66. mcp_proxy_adapter/examples/docstring_and_schema_example.py +0 -69
  67. mcp_proxy_adapter/examples/extension_example.py +0 -72
  68. mcp_proxy_adapter/examples/help_best_practices.py +0 -67
  69. mcp_proxy_adapter/examples/help_usage.py +0 -64
  70. mcp_proxy_adapter/examples/mcp_proxy_client.py +0 -131
  71. mcp_proxy_adapter/examples/openapi_server.py +0 -383
  72. mcp_proxy_adapter/examples/project_structure_example.py +0 -47
  73. mcp_proxy_adapter/examples/testing_example.py +0 -64
  74. mcp_proxy_adapter/models.py +0 -47
  75. mcp_proxy_adapter/registry.py +0 -439
  76. mcp_proxy_adapter/schema.py +0 -257
  77. mcp_proxy_adapter/testing_utils.py +0 -112
  78. mcp_proxy_adapter/validators/__init__.py +0 -1
  79. mcp_proxy_adapter/validators/docstring_validator.py +0 -75
  80. mcp_proxy_adapter/validators/metadata_validator.py +0 -76
  81. mcp_proxy_adapter-2.1.16.dist-info/METADATA +0 -341
  82. mcp_proxy_adapter-2.1.16.dist-info/RECORD +0 -30
  83. {mcp_proxy_adapter-2.1.16.dist-info → mcp_proxy_adapter-3.0.0.dist-info}/WHEEL +0 -0
  84. {mcp_proxy_adapter-2.1.16.dist-info → mcp_proxy_adapter-3.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,112 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
-
@@ -1,75 +0,0 @@
1
- """
2
- Validator for checking the correspondence between docstrings and function signatures.
3
- """
4
- import inspect
5
- from typing import Dict, Any, Optional, Callable, List, Tuple, get_type_hints
6
- import docstring_parser
7
-
8
- class DocstringValidator:
9
- """
10
- Validator for checking the correspondence between docstrings and handler functions.
11
-
12
- This class verifies that function docstrings match their signatures,
13
- contain all necessary sections, and describe all parameters.
14
- """
15
-
16
- def validate(self, handler: Callable, command_name: str, metadata: Dict[str, Any]) -> Tuple[bool, List[str]]:
17
- """
18
- Validates the function's docstring against its formal parameters.
19
-
20
- Args:
21
- handler: Command handler function
22
- command_name: Command name
23
- metadata: Command metadata
24
-
25
- Returns:
26
- Tuple[bool, List[str]]: Validity flag and list of errors
27
- """
28
- errors = []
29
-
30
- # Get formal parameters of the function
31
- sig = inspect.signature(handler)
32
- formal_params = list(sig.parameters.keys())
33
-
34
- # Skip self parameter for methods
35
- if formal_params and formal_params[0] == 'self':
36
- formal_params = formal_params[1:]
37
-
38
- # Parse docstring
39
- docstring = handler.__doc__ or ""
40
- parsed_doc = docstring_parser.parse(docstring)
41
-
42
- # Check for function description
43
- if not parsed_doc.short_description and not parsed_doc.long_description:
44
- errors.append(f"Missing function description")
45
-
46
- # Get parameters from docstring
47
- doc_params = {param.arg_name: param for param in parsed_doc.params}
48
-
49
- # Check that all formal parameters are described in the docstring
50
- for param in formal_params:
51
- # Skip special parameters
52
- if param in ('params', 'kwargs'):
53
- continue
54
-
55
- if param not in doc_params:
56
- errors.append(f"Parameter '{param}' is not described in the function docstring")
57
-
58
- # Check for returns in docstring
59
- if not parsed_doc.returns and not any(t.type_name == 'Returns' for t in parsed_doc.meta):
60
- errors.append(f"Missing return value description in the function docstring")
61
-
62
- # Check for type annotations
63
- try:
64
- type_hints = get_type_hints(handler)
65
- for param in formal_params:
66
- # Skip special parameters
67
- if param in ('params', 'kwargs'):
68
- continue
69
-
70
- if param not in type_hints:
71
- errors.append(f"Missing type annotation for parameter '{param}' in function {command_name}")
72
- except Exception as e:
73
- errors.append(f"Error getting type hints: {str(e)}")
74
-
75
- return len(errors) == 0, errors
@@ -1,76 +0,0 @@
1
- """
2
- Validator for checking command metadata against function signatures.
3
- """
4
- import inspect
5
- from typing import Dict, Any, Optional, Callable, List, Tuple
6
-
7
- class MetadataValidator:
8
- """
9
- Validator for checking handler function metadata.
10
-
11
- This class verifies that command metadata matches function signatures,
12
- and all parameters are correctly described.
13
- """
14
-
15
- def validate(self, handler: Callable, command_name: str, metadata: Dict[str, Any]) -> Tuple[bool, List[str]]:
16
- """
17
- Checks if metadata matches function's formal parameters.
18
-
19
- Args:
20
- handler: Command handler function
21
- command_name: Command name
22
- metadata: Command metadata
23
-
24
- Returns:
25
- Tuple[bool, List[str]]: Validity flag and list of errors
26
- """
27
- errors = []
28
-
29
- # Check presence of main fields in metadata
30
- if not metadata.get('description'):
31
- errors.append(f"Missing description for command '{command_name}'")
32
-
33
- # Get function's formal parameters
34
- sig = inspect.signature(handler)
35
- formal_params = list(sig.parameters.keys())
36
-
37
- # Skip self parameter for methods
38
- if formal_params and formal_params[0] == 'self':
39
- formal_params = formal_params[1:]
40
-
41
- # Check presence of parameters in metadata
42
- if 'parameters' not in metadata or not isinstance(metadata['parameters'], dict):
43
- errors.append(f"Parameters are missing or incorrectly defined in metadata for command '{command_name}'")
44
- return False, errors
45
-
46
- meta_params = metadata['parameters']
47
-
48
- # Check that all formal parameters are in metadata
49
- for param in formal_params:
50
- # Skip special parameters
51
- if param in ('params', 'kwargs'):
52
- continue
53
-
54
- if param not in meta_params:
55
- errors.append(f"Parameter '{param}' is not described in metadata for command '{command_name}'")
56
- continue
57
-
58
- param_info = meta_params[param]
59
-
60
- # Check presence of required fields for parameter
61
- if not isinstance(param_info, dict):
62
- errors.append(f"Incorrect format for parameter '{param}' description in metadata for command '{command_name}'")
63
- continue
64
-
65
- if 'type' not in param_info:
66
- errors.append(f"Type is not specified for parameter '{param}' in metadata for command '{command_name}'")
67
-
68
- if 'description' not in param_info:
69
- errors.append(f"Description is not specified for parameter '{param}' in metadata for command '{command_name}'")
70
-
71
- # Check that there are no extra parameters in metadata
72
- for param in meta_params:
73
- if param not in formal_params and param not in ('params', 'kwargs'):
74
- errors.append(f"Extra parameter '{param}' in metadata for command '{command_name}'")
75
-
76
- return len(errors) == 0, errors
@@ -1,341 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: mcp-proxy-adapter
3
- Version: 2.1.16
4
- Summary: Adapter for exposing Command Registry commands as tools for AI models via MCP Proxy.
5
- Home-page: https://github.com/vasilyvz/mcp-proxy-adapter
6
- Author: Vasiliy VZ
7
- Author-email: Vasiliy VZ <vasilyvz@example.com>
8
- License: MIT
9
- Project-URL: Homepage, https://github.com/vasilyvz/mcp-proxy-adapter
10
- Project-URL: Bug Tracker, https://github.com/vasilyvz/mcp-proxy-adapter/issues
11
- Project-URL: Documentation, https://github.com/vasilyvz/mcp-proxy-adapter/tree/main/docs
12
- Classifier: Development Status :: 4 - Beta
13
- Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: MIT License
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.9
17
- Classifier: Programming Language :: Python :: 3.10
18
- Classifier: Programming Language :: Python :: 3.11
19
- Classifier: Programming Language :: Python :: 3.12
20
- Requires-Python: >=3.9, <4
21
- Description-Content-Type: text/markdown
22
- License-File: LICENSE
23
- Requires-Dist: fastapi<1.0.0,>=0.95.0
24
- Requires-Dist: pydantic>=2.0.0
25
- Requires-Dist: uvicorn<1.0.0,>=0.22.0
26
- Requires-Dist: docstring-parser<1.0.0,>=0.15
27
- Requires-Dist: typing-extensions<5.0.0,>=4.5.0
28
- Dynamic: author
29
- Dynamic: home-page
30
- Dynamic: license-file
31
- Dynamic: requires-python
32
-
33
- # MCP Proxy Adapter
34
-
35
- Adapter for integrating [Command Registry](docs/README.md) with MCP Proxy, allowing you to use commands as tools for AI models.
36
-
37
- ## Overview
38
-
39
- MCP Proxy Adapter transforms commands registered in the Command Registry into a format compatible with MCP Proxy. This enables:
40
-
41
- 1. Using existing commands as tools for AI models
42
- 2. Creating a hybrid REST/JSON-RPC API for command execution
43
- 3. Automatic generation of OpenAPI schemas optimized for MCP Proxy
44
- 4. Managing tool metadata for better AI system integration
45
-
46
- ## Installation
47
-
48
- ```bash
49
- pip install mcp-proxy-adapter
50
- ```
51
-
52
- ## Quick Start
53
-
54
- ```python
55
- from mcp_proxy_adapter import MCPProxyAdapter, CommandRegistry
56
- from fastapi import FastAPI
57
-
58
- # Create a command registry instance
59
- registry = CommandRegistry()
60
-
61
- # Register commands
62
- def calculate_total(prices: list[float], discount: float = 0.0) -> float:
63
- """
64
- Calculates the total price with discount.
65
- Args:
66
- prices: List of item prices
67
- discount: Discount percentage (0-100)
68
- Returns:
69
- Total price with discount
70
- """
71
- subtotal = sum(prices)
72
- return subtotal * (1 - discount / 100)
73
-
74
- registry.register_command("calculate_total", calculate_total)
75
-
76
- # Create FastAPI app
77
- app = FastAPI()
78
-
79
- # Create and configure MCP Proxy adapter
80
- adapter = MCPProxyAdapter(registry)
81
-
82
- # Register endpoints in FastAPI app
83
- adapter.register_endpoints(app)
84
-
85
- # Generate and save MCP Proxy config
86
- adapter.save_config_to_file("mcp_proxy_config.json")
87
- ```
88
-
89
- ## Supported Request Formats
90
-
91
- The adapter supports three request formats for command execution:
92
-
93
- ### 1. JSON-RPC format
94
-
95
- ```json
96
- {
97
- "jsonrpc": "2.0",
98
- "method": "command_name",
99
- "params": {
100
- "param1": "value1",
101
- "param2": "value2"
102
- },
103
- "id": 1
104
- }
105
- ```
106
-
107
- Example request to `/cmd` endpoint:
108
-
109
- ```bash
110
- curl -X POST -H "Content-Type: application/json" -d '{
111
- "jsonrpc": "2.0",
112
- "method": "calculate_total",
113
- "params": {
114
- "prices": [100, 200, 300],
115
- "discount": 10
116
- },
117
- "id": 1
118
- }' http://localhost:8000/cmd
119
- ```
120
-
121
- Response:
122
-
123
- ```json
124
- {
125
- "jsonrpc": "2.0",
126
- "result": 540.0,
127
- "id": 1
128
- }
129
- ```
130
-
131
- ### 2. MCP Proxy format
132
-
133
- ```json
134
- {
135
- "command": "command_name",
136
- "params": {
137
- "param1": "value1",
138
- "param2": "value2"
139
- }
140
- }
141
- ```
142
-
143
- Example request:
144
-
145
- ```bash
146
- curl -X POST -H "Content-Type: application/json" -d '{
147
- "command": "calculate_total",
148
- "params": {
149
- "prices": [100, 200, 300],
150
- "discount": 10
151
- }
152
- }' http://localhost:8000/cmd
153
- ```
154
-
155
- Response:
156
-
157
- ```json
158
- {
159
- "result": 540.0
160
- }
161
- ```
162
-
163
- ### 3. Params-only format
164
-
165
- ```json
166
- {
167
- "params": {
168
- "command": "command_name",
169
- "param1": "value1",
170
- "param2": "value2"
171
- }
172
- }
173
- ```
174
-
175
- or
176
-
177
- ```json
178
- {
179
- "params": {
180
- "query": "command_name",
181
- "param1": "value1",
182
- "param2": "value2"
183
- }
184
- }
185
- ```
186
-
187
- Example request:
188
-
189
- ```bash
190
- curl -X POST -H "Content-Type: application/json" -d '{
191
- "params": {
192
- "command": "calculate_total",
193
- "prices": [100, 200, 300],
194
- "discount": 10
195
- }
196
- }' http://localhost:8000/cmd
197
- ```
198
-
199
- Response:
200
-
201
- ```json
202
- {
203
- "result": 540.0
204
- }
205
- ```
206
-
207
- ## Full Example: Integration with FastAPI
208
-
209
- ```python
210
- import logging
211
- from fastapi import FastAPI, APIRouter
212
- from mcp_proxy_adapter import CommandRegistry, MCPProxyAdapter, configure_logger
213
-
214
- # Configure logging
215
- logging.basicConfig(level=logging.INFO)
216
- project_logger = logging.getLogger("my_project")
217
-
218
- # Create FastAPI app
219
- app = FastAPI(title="My API with MCP Proxy Integration")
220
-
221
- # Create existing API router
222
- router = APIRouter()
223
-
224
- @router.get("/items")
225
- async def get_items():
226
- """Returns a list of items."""
227
- return [
228
- {"id": 1, "name": "Smartphone X", "price": 999.99},
229
- {"id": 2, "name": "Laptop Y", "price": 1499.99},
230
- ]
231
-
232
- app.include_router(router)
233
-
234
- # Register commands
235
- registry = CommandRegistry()
236
-
237
- def get_discounted_price(price: float, discount: float = 0.0) -> float:
238
- """
239
- Returns the price after applying a discount.
240
- """
241
- return price * (1 - discount / 100)
242
-
243
- registry.register_command("get_discounted_price", get_discounted_price)
244
-
245
- # Create and register MCP Proxy adapter
246
- adapter = MCPProxyAdapter(registry)
247
- adapter.register_endpoints(app)
248
-
249
- # Save MCP Proxy config
250
- adapter.save_config_to_file("mcp_proxy_config.json")
251
- ```
252
-
253
- ## Features
254
- - Universal JSON-RPC endpoint for command execution
255
- - Automatic OpenAPI schema generation and optimization for MCP Proxy
256
- - Tool metadata for AI models
257
- - Customizable endpoints and logging
258
- - Full test coverage and examples
259
-
260
- ## FAQ
261
-
262
- **Q: Почему не удаётся использовать декоратор @registry.command для регистрации команд?**
263
- A: В последних версиях пакета декоратор @registry.command больше не поддерживается. Теперь команды регистрируются только явно, через вызов метода:
264
-
265
- ```python
266
- registry.register_command("имя_команды", функция)
267
- ```
268
-
269
- **Q: Почему не удаётся импортировать CommandRegistry напрямую из mcp_proxy_adapter?**
270
- A: Класс CommandRegistry находится в подмодуле registry. Используйте:
271
-
272
- ```python
273
- from mcp_proxy_adapter.registry import CommandRegistry
274
- ```
275
-
276
- **Q: Какой способ импорта MCPProxyAdapter и configure_logger?**
277
- A: Импортируйте их из подмодуля adapter:
278
-
279
- ```python
280
- from mcp_proxy_adapter.adapter import MCPProxyAdapter, configure_logger
281
- ```
282
-
283
- **Q: Как добавить свою команду?**
284
- A: Зарегистрируйте функцию через registry.register_command или декоратор (см. примеры выше).
285
-
286
- **Q: Как получить OpenAPI-схему?**
287
- A: После регистрации адаптера вызовите /openapi.json в вашем FastAPI-приложении.
288
-
289
- **Q: Какой формат запроса поддерживается?**
290
- A: JSON-RPC, MCP Proxy и params-only (см. раздел Supported Request Formats).
291
-
292
- ## HOWTO
293
-
294
- **Как интегрировать MCP Proxy Adapter с FastAPI:**
295
- 1. Установите пакет:
296
- ```bash
297
- pip install mcp-proxy-adapter
298
- ```
299
- 2. Импортируйте нужные классы:
300
- ```python
301
- from mcp_proxy_adapter.registry import CommandRegistry
302
- from mcp_proxy_adapter.adapter import MCPProxyAdapter
303
- ```
304
- 3. Зарегистрируйте команды и настройте FastAPI:
305
- ```python
306
- registry = CommandRegistry()
307
- registry.register_command("my_command", my_function)
308
- app = FastAPI()
309
- adapter = MCPProxyAdapter(registry)
310
- adapter.register_endpoints(app)
311
- ```
312
- 4. (Опционально) Сохраните конфиг для MCP Proxy:
313
- ```python
314
- adapter.save_config_to_file("mcp_proxy_config.json")
315
- ```
316
-
317
- **Как добавить поддержку кастомного логгера:**
318
- ```python
319
- import logging
320
- from mcp_proxy_adapter.adapter import configure_logger
321
- logger = logging.getLogger("my_project")
322
- adapter_logger = configure_logger(logger)
323
- ```
324
-
325
- **Как получить список всех команд через API:**
326
- Вызовите GET `/api/commands` на вашем сервере FastAPI.
327
-
328
- ## License
329
- MIT
330
-
331
- ## Documentation
332
- See [docs/](docs/) for detailed guides, architecture, and examples.
333
-
334
- ## CI/CD & PyPI automation
335
-
336
- This project uses GitHub Actions for continuous integration and automated publishing to PyPI.
337
-
338
- - All tests are run on every push and pull request.
339
- - On push of a new tag (vX.Y.Z), the package is built and published to PyPI automatically.
340
-
341
- See `.github/workflows/publish.yml` for details.
@@ -1,30 +0,0 @@
1
- mcp_proxy_adapter/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
2
- mcp_proxy_adapter/adapter.py,sha256=76dkVeDuqLsJ5AhuftzLlwy2M6yr_PfNbmNfo9dXVhc,28844
3
- mcp_proxy_adapter/models.py,sha256=8zVWU6ly18pWozOnKQ2gsGpmTgL37-fFE_Fr1SDW-Nk,2530
4
- mcp_proxy_adapter/registry.py,sha256=jgC4TKaPbMbAsoxvGp2ToaOE4drD-VfZug7WJbm4IW4,15853
5
- mcp_proxy_adapter/schema.py,sha256=HZM0TTQTSi8ha1TEeVevdCyGZOUPoT1soB7Nex0hV50,10947
6
- mcp_proxy_adapter/testing_utils.py,sha256=RWjQFNSUtVkeP0qNzp6_jrT6_tub3w_052DrRmvxVk0,4243
7
- mcp_proxy_adapter/analyzers/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
8
- mcp_proxy_adapter/analyzers/docstring_analyzer.py,sha256=T3FLJEo_uChShfiEKRl8GpVoHvh5HiudZkxnj4KixfA,7541
9
- mcp_proxy_adapter/analyzers/type_analyzer.py,sha256=6Wac7osKwF03waFSwQ8ZM0Wqn_zAP2D-I4WMEpR0hQM,5230
10
- mcp_proxy_adapter/dispatchers/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
11
- mcp_proxy_adapter/dispatchers/base_dispatcher.py,sha256=S5_Xri058jAmOWeit1tedB_GMZQ9RLcNcYabA83ZF6k,2288
12
- mcp_proxy_adapter/dispatchers/json_rpc_dispatcher.py,sha256=HO3RY5AzCQF3UPqnOIauB7Sq9rJC9jv7h7FTM1eDR90,8054
13
- mcp_proxy_adapter/examples/analyze_config.py,sha256=vog7TNHDw5ZoYhQLbAvZvEoufmQwH54KJzQBJrSq5w4,4283
14
- mcp_proxy_adapter/examples/basic_integration.py,sha256=mtRval4VSUgTb_C2p8U_DPPSEKA08dZYKZk-bOrE4H4,4470
15
- mcp_proxy_adapter/examples/docstring_and_schema_example.py,sha256=wFg3Cf2Jgve0J5kFzApvFSII8JOsOGaych64hIC7FqQ,2183
16
- mcp_proxy_adapter/examples/extension_example.py,sha256=W5fcvPHjpDSPQnmhAWDJqZtLoUfY7h58ZzFoFXDF3Fc,2525
17
- mcp_proxy_adapter/examples/help_best_practices.py,sha256=ByHMDiBT9V-cHoSMr2q0PmbteKELY8mTGeJrvAxOWpY,2646
18
- mcp_proxy_adapter/examples/help_usage.py,sha256=pEwb8-QhiWuBPCK9cbHW-oMKxk4WMo345SHIAl-dosg,2577
19
- mcp_proxy_adapter/examples/mcp_proxy_client.py,sha256=z4IzFlGigVTQSb8TpcrQ_a0migsmC58LnNwc8wZmTfw,3811
20
- mcp_proxy_adapter/examples/openapi_server.py,sha256=HUcnv_XEEur1kLuAotHuwwAhykApVXgVj4miOgk8DYA,13229
21
- mcp_proxy_adapter/examples/project_structure_example.py,sha256=sswTo6FZb1F5juHa0FYG3cgvrh3wfgGfJu2bBy5tCm4,1460
22
- mcp_proxy_adapter/examples/testing_example.py,sha256=OxFUhGP9OXiu9eWjSpytpQ5MzoR9uww3M4jYb0_v7dc,2004
23
- mcp_proxy_adapter/validators/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
24
- mcp_proxy_adapter/validators/docstring_validator.py,sha256=Onpq2iNJ1qF4ejkJJIlBkLROuSNIVALHVmXIgkCpaFI,2934
25
- mcp_proxy_adapter/validators/metadata_validator.py,sha256=uCrn38-VYYn89l6f5CC_GoTAHAweaOW2Z6Esro1rtGw,3155
26
- mcp_proxy_adapter-2.1.16.dist-info/licenses/LICENSE,sha256=OkApFEwdgMCt_mbvUI-eIwKMSTe38K3XnU2DT5ub-wI,1072
27
- mcp_proxy_adapter-2.1.16.dist-info/METADATA,sha256=ww2i2m0f6txplRMYCb65rU1h9tDAm-FL-4hq2ZBzlUE,8886
28
- mcp_proxy_adapter-2.1.16.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
29
- mcp_proxy_adapter-2.1.16.dist-info/top_level.txt,sha256=JZT7vPLBYrtroX-ij68JBhJYbjDdghcV-DFySRy-Nnw,18
30
- mcp_proxy_adapter-2.1.16.dist-info/RECORD,,