mcp-proxy-adapter 2.1.10__tar.gz → 2.1.15__tar.gz

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 (58) hide show
  1. mcp_proxy_adapter-2.1.15/PKG-INFO +341 -0
  2. mcp_proxy_adapter-2.1.15/README.md +309 -0
  3. mcp_proxy_adapter-2.1.15/docs/RU/FAQ_HOWTO.md +95 -0
  4. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/adapter.py +2 -2
  5. mcp_proxy_adapter-2.1.15/mcp_proxy_adapter/analyzers/__init__.py +1 -0
  6. mcp_proxy_adapter-2.1.15/mcp_proxy_adapter/dispatchers/__init__.py +1 -0
  7. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/dispatchers/base_dispatcher.py +2 -2
  8. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/dispatchers/json_rpc_dispatcher.py +65 -28
  9. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/basic_integration.py +2 -8
  10. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/docstring_and_schema_example.py +14 -5
  11. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/extension_example.py +17 -5
  12. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/openapi_server.py +78 -91
  13. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/project_structure_example.py +7 -2
  14. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/testing_example.py +25 -3
  15. mcp_proxy_adapter-2.1.15/mcp_proxy_adapter/models.py +47 -0
  16. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/registry.py +8 -10
  17. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/testing_utils.py +11 -3
  18. mcp_proxy_adapter-2.1.15/mcp_proxy_adapter.egg-info/PKG-INFO +341 -0
  19. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter.egg-info/SOURCES.txt +1 -1
  20. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/pyproject.toml +1 -1
  21. mcp_proxy_adapter-2.1.15/requirements.txt +10 -0
  22. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/setup.py +1 -2
  23. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_adapter.py +116 -60
  24. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_adapter_coverage.py +11 -12
  25. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_basic_dispatcher.py +17 -11
  26. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_command_registry.py +11 -7
  27. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_mcp_proxy_adapter.py +64 -66
  28. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_simple_adapter.py +7 -3
  29. mcp_proxy_adapter-2.1.10/PKG-INFO +0 -402
  30. mcp_proxy_adapter-2.1.10/README.md +0 -370
  31. mcp_proxy_adapter-2.1.10/mcp_proxy_adapter/__init__.py +0 -17
  32. mcp_proxy_adapter-2.1.10/mcp_proxy_adapter/analyzers/__init__.py +0 -14
  33. mcp_proxy_adapter-2.1.10/mcp_proxy_adapter/dispatchers/__init__.py +0 -14
  34. mcp_proxy_adapter-2.1.10/mcp_proxy_adapter/models.py +0 -47
  35. mcp_proxy_adapter-2.1.10/mcp_proxy_adapter.egg-info/PKG-INFO +0 -402
  36. mcp_proxy_adapter-2.1.10/requirements.txt +0 -5
  37. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/LICENSE +0 -0
  38. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/MANIFEST.in +0 -0
  39. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/code_index.yaml +0 -0
  40. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/analyzers/docstring_analyzer.py +0 -0
  41. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/analyzers/type_analyzer.py +0 -0
  42. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/analyze_config.py +0 -0
  43. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/help_best_practices.py +0 -0
  44. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/help_usage.py +0 -0
  45. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/examples/mcp_proxy_client.py +0 -0
  46. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/schema.py +0 -0
  47. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/validators/docstring_validator.py +0 -0
  48. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter/validators/metadata_validator.py +0 -0
  49. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter.egg-info/dependency_links.txt +0 -0
  50. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter.egg-info/requires.txt +0 -0
  51. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/mcp_proxy_adapter.egg-info/top_level.txt +0 -0
  52. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/setup.cfg +0 -0
  53. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/conftest.py +0 -0
  54. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_examples.py +0 -0
  55. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_mcp_proxy_adapter_basic.py +0 -0
  56. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_part1.py +0 -0
  57. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_part2.py +0 -0
  58. {mcp_proxy_adapter-2.1.10 → mcp_proxy_adapter-2.1.15}/tests/test_schema.py +0 -0
@@ -0,0 +1,341 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-proxy-adapter
3
+ Version: 2.1.15
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.
@@ -0,0 +1,309 @@
1
+ # MCP Proxy Adapter
2
+
3
+ Adapter for integrating [Command Registry](docs/README.md) with MCP Proxy, allowing you to use commands as tools for AI models.
4
+
5
+ ## Overview
6
+
7
+ MCP Proxy Adapter transforms commands registered in the Command Registry into a format compatible with MCP Proxy. This enables:
8
+
9
+ 1. Using existing commands as tools for AI models
10
+ 2. Creating a hybrid REST/JSON-RPC API for command execution
11
+ 3. Automatic generation of OpenAPI schemas optimized for MCP Proxy
12
+ 4. Managing tool metadata for better AI system integration
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install mcp-proxy-adapter
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ```python
23
+ from mcp_proxy_adapter import MCPProxyAdapter, CommandRegistry
24
+ from fastapi import FastAPI
25
+
26
+ # Create a command registry instance
27
+ registry = CommandRegistry()
28
+
29
+ # Register commands
30
+ def calculate_total(prices: list[float], discount: float = 0.0) -> float:
31
+ """
32
+ Calculates the total price with discount.
33
+ Args:
34
+ prices: List of item prices
35
+ discount: Discount percentage (0-100)
36
+ Returns:
37
+ Total price with discount
38
+ """
39
+ subtotal = sum(prices)
40
+ return subtotal * (1 - discount / 100)
41
+
42
+ registry.register_command("calculate_total", calculate_total)
43
+
44
+ # Create FastAPI app
45
+ app = FastAPI()
46
+
47
+ # Create and configure MCP Proxy adapter
48
+ adapter = MCPProxyAdapter(registry)
49
+
50
+ # Register endpoints in FastAPI app
51
+ adapter.register_endpoints(app)
52
+
53
+ # Generate and save MCP Proxy config
54
+ adapter.save_config_to_file("mcp_proxy_config.json")
55
+ ```
56
+
57
+ ## Supported Request Formats
58
+
59
+ The adapter supports three request formats for command execution:
60
+
61
+ ### 1. JSON-RPC format
62
+
63
+ ```json
64
+ {
65
+ "jsonrpc": "2.0",
66
+ "method": "command_name",
67
+ "params": {
68
+ "param1": "value1",
69
+ "param2": "value2"
70
+ },
71
+ "id": 1
72
+ }
73
+ ```
74
+
75
+ Example request to `/cmd` endpoint:
76
+
77
+ ```bash
78
+ curl -X POST -H "Content-Type: application/json" -d '{
79
+ "jsonrpc": "2.0",
80
+ "method": "calculate_total",
81
+ "params": {
82
+ "prices": [100, 200, 300],
83
+ "discount": 10
84
+ },
85
+ "id": 1
86
+ }' http://localhost:8000/cmd
87
+ ```
88
+
89
+ Response:
90
+
91
+ ```json
92
+ {
93
+ "jsonrpc": "2.0",
94
+ "result": 540.0,
95
+ "id": 1
96
+ }
97
+ ```
98
+
99
+ ### 2. MCP Proxy format
100
+
101
+ ```json
102
+ {
103
+ "command": "command_name",
104
+ "params": {
105
+ "param1": "value1",
106
+ "param2": "value2"
107
+ }
108
+ }
109
+ ```
110
+
111
+ Example request:
112
+
113
+ ```bash
114
+ curl -X POST -H "Content-Type: application/json" -d '{
115
+ "command": "calculate_total",
116
+ "params": {
117
+ "prices": [100, 200, 300],
118
+ "discount": 10
119
+ }
120
+ }' http://localhost:8000/cmd
121
+ ```
122
+
123
+ Response:
124
+
125
+ ```json
126
+ {
127
+ "result": 540.0
128
+ }
129
+ ```
130
+
131
+ ### 3. Params-only format
132
+
133
+ ```json
134
+ {
135
+ "params": {
136
+ "command": "command_name",
137
+ "param1": "value1",
138
+ "param2": "value2"
139
+ }
140
+ }
141
+ ```
142
+
143
+ or
144
+
145
+ ```json
146
+ {
147
+ "params": {
148
+ "query": "command_name",
149
+ "param1": "value1",
150
+ "param2": "value2"
151
+ }
152
+ }
153
+ ```
154
+
155
+ Example request:
156
+
157
+ ```bash
158
+ curl -X POST -H "Content-Type: application/json" -d '{
159
+ "params": {
160
+ "command": "calculate_total",
161
+ "prices": [100, 200, 300],
162
+ "discount": 10
163
+ }
164
+ }' http://localhost:8000/cmd
165
+ ```
166
+
167
+ Response:
168
+
169
+ ```json
170
+ {
171
+ "result": 540.0
172
+ }
173
+ ```
174
+
175
+ ## Full Example: Integration with FastAPI
176
+
177
+ ```python
178
+ import logging
179
+ from fastapi import FastAPI, APIRouter
180
+ from mcp_proxy_adapter import CommandRegistry, MCPProxyAdapter, configure_logger
181
+
182
+ # Configure logging
183
+ logging.basicConfig(level=logging.INFO)
184
+ project_logger = logging.getLogger("my_project")
185
+
186
+ # Create FastAPI app
187
+ app = FastAPI(title="My API with MCP Proxy Integration")
188
+
189
+ # Create existing API router
190
+ router = APIRouter()
191
+
192
+ @router.get("/items")
193
+ async def get_items():
194
+ """Returns a list of items."""
195
+ return [
196
+ {"id": 1, "name": "Smartphone X", "price": 999.99},
197
+ {"id": 2, "name": "Laptop Y", "price": 1499.99},
198
+ ]
199
+
200
+ app.include_router(router)
201
+
202
+ # Register commands
203
+ registry = CommandRegistry()
204
+
205
+ def get_discounted_price(price: float, discount: float = 0.0) -> float:
206
+ """
207
+ Returns the price after applying a discount.
208
+ """
209
+ return price * (1 - discount / 100)
210
+
211
+ registry.register_command("get_discounted_price", get_discounted_price)
212
+
213
+ # Create and register MCP Proxy adapter
214
+ adapter = MCPProxyAdapter(registry)
215
+ adapter.register_endpoints(app)
216
+
217
+ # Save MCP Proxy config
218
+ adapter.save_config_to_file("mcp_proxy_config.json")
219
+ ```
220
+
221
+ ## Features
222
+ - Universal JSON-RPC endpoint for command execution
223
+ - Automatic OpenAPI schema generation and optimization for MCP Proxy
224
+ - Tool metadata for AI models
225
+ - Customizable endpoints and logging
226
+ - Full test coverage and examples
227
+
228
+ ## FAQ
229
+
230
+ **Q: Почему не удаётся использовать декоратор @registry.command для регистрации команд?**
231
+ A: В последних версиях пакета декоратор @registry.command больше не поддерживается. Теперь команды регистрируются только явно, через вызов метода:
232
+
233
+ ```python
234
+ registry.register_command("имя_команды", функция)
235
+ ```
236
+
237
+ **Q: Почему не удаётся импортировать CommandRegistry напрямую из mcp_proxy_adapter?**
238
+ A: Класс CommandRegistry находится в подмодуле registry. Используйте:
239
+
240
+ ```python
241
+ from mcp_proxy_adapter.registry import CommandRegistry
242
+ ```
243
+
244
+ **Q: Какой способ импорта MCPProxyAdapter и configure_logger?**
245
+ A: Импортируйте их из подмодуля adapter:
246
+
247
+ ```python
248
+ from mcp_proxy_adapter.adapter import MCPProxyAdapter, configure_logger
249
+ ```
250
+
251
+ **Q: Как добавить свою команду?**
252
+ A: Зарегистрируйте функцию через registry.register_command или декоратор (см. примеры выше).
253
+
254
+ **Q: Как получить OpenAPI-схему?**
255
+ A: После регистрации адаптера вызовите /openapi.json в вашем FastAPI-приложении.
256
+
257
+ **Q: Какой формат запроса поддерживается?**
258
+ A: JSON-RPC, MCP Proxy и params-only (см. раздел Supported Request Formats).
259
+
260
+ ## HOWTO
261
+
262
+ **Как интегрировать MCP Proxy Adapter с FastAPI:**
263
+ 1. Установите пакет:
264
+ ```bash
265
+ pip install mcp-proxy-adapter
266
+ ```
267
+ 2. Импортируйте нужные классы:
268
+ ```python
269
+ from mcp_proxy_adapter.registry import CommandRegistry
270
+ from mcp_proxy_adapter.adapter import MCPProxyAdapter
271
+ ```
272
+ 3. Зарегистрируйте команды и настройте FastAPI:
273
+ ```python
274
+ registry = CommandRegistry()
275
+ registry.register_command("my_command", my_function)
276
+ app = FastAPI()
277
+ adapter = MCPProxyAdapter(registry)
278
+ adapter.register_endpoints(app)
279
+ ```
280
+ 4. (Опционально) Сохраните конфиг для MCP Proxy:
281
+ ```python
282
+ adapter.save_config_to_file("mcp_proxy_config.json")
283
+ ```
284
+
285
+ **Как добавить поддержку кастомного логгера:**
286
+ ```python
287
+ import logging
288
+ from mcp_proxy_adapter.adapter import configure_logger
289
+ logger = logging.getLogger("my_project")
290
+ adapter_logger = configure_logger(logger)
291
+ ```
292
+
293
+ **Как получить список всех команд через API:**
294
+ Вызовите GET `/api/commands` на вашем сервере FastAPI.
295
+
296
+ ## License
297
+ MIT
298
+
299
+ ## Documentation
300
+ See [docs/](docs/) for detailed guides, architecture, and examples.
301
+
302
+ ## CI/CD & PyPI automation
303
+
304
+ This project uses GitHub Actions for continuous integration and automated publishing to PyPI.
305
+
306
+ - All tests are run on every push and pull request.
307
+ - On push of a new tag (vX.Y.Z), the package is built and published to PyPI automatically.
308
+
309
+ See `.github/workflows/publish.yml` for details.