mcp-proxy-adapter 2.0.2__py3-none-any.whl → 2.1.1__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 (67) hide show
  1. docs/README.md +172 -0
  2. docs/README_ru.md +172 -0
  3. docs/architecture.md +251 -0
  4. docs/architecture_ru.md +343 -0
  5. docs/command_development.md +250 -0
  6. docs/command_development_ru.md +593 -0
  7. docs/deployment.md +251 -0
  8. docs/deployment_ru.md +1298 -0
  9. docs/examples.md +254 -0
  10. docs/examples_ru.md +401 -0
  11. docs/mcp_proxy_adapter.md +251 -0
  12. docs/mcp_proxy_adapter_ru.md +405 -0
  13. docs/quickstart.md +251 -0
  14. docs/quickstart_ru.md +397 -0
  15. docs/testing.md +255 -0
  16. docs/testing_ru.md +469 -0
  17. docs/validation_ru.md +287 -0
  18. examples/analyze_config.py +141 -0
  19. examples/basic_integration.py +161 -0
  20. examples/docstring_and_schema_example.py +60 -0
  21. examples/extension_example.py +60 -0
  22. examples/help_best_practices.py +67 -0
  23. examples/help_usage.py +64 -0
  24. examples/mcp_proxy_client.py +131 -0
  25. examples/mcp_proxy_config.json +175 -0
  26. examples/openapi_server.py +369 -0
  27. examples/project_structure_example.py +47 -0
  28. examples/testing_example.py +53 -0
  29. mcp_proxy_adapter/__init__.py +1 -1
  30. mcp_proxy_adapter/models.py +19 -19
  31. {mcp_proxy_adapter-2.0.2.dist-info → mcp_proxy_adapter-2.1.1.dist-info}/METADATA +47 -13
  32. mcp_proxy_adapter-2.1.1.dist-info/RECORD +61 -0
  33. {mcp_proxy_adapter-2.0.2.dist-info → mcp_proxy_adapter-2.1.1.dist-info}/WHEEL +1 -1
  34. mcp_proxy_adapter-2.1.1.dist-info/top_level.txt +5 -0
  35. scripts/code_analyzer/code_analyzer.py +328 -0
  36. scripts/code_analyzer/register_commands.py +446 -0
  37. scripts/publish.py +85 -0
  38. tests/conftest.py +12 -0
  39. tests/test_adapter.py +529 -0
  40. tests/test_adapter_coverage.py +274 -0
  41. tests/test_basic_dispatcher.py +169 -0
  42. tests/test_command_registry.py +328 -0
  43. tests/test_examples.py +32 -0
  44. tests/test_mcp_proxy_adapter.py +568 -0
  45. tests/test_mcp_proxy_adapter_basic.py +262 -0
  46. tests/test_part1.py +348 -0
  47. tests/test_part2.py +524 -0
  48. tests/test_schema.py +358 -0
  49. tests/test_simple_adapter.py +251 -0
  50. mcp_proxy_adapter/adapters/__init__.py +0 -16
  51. mcp_proxy_adapter/cli/__init__.py +0 -12
  52. mcp_proxy_adapter/cli/__main__.py +0 -79
  53. mcp_proxy_adapter/cli/command_runner.py +0 -233
  54. mcp_proxy_adapter/generators/__init__.py +0 -14
  55. mcp_proxy_adapter/generators/endpoint_generator.py +0 -172
  56. mcp_proxy_adapter/generators/openapi_generator.py +0 -254
  57. mcp_proxy_adapter/generators/rest_api_generator.py +0 -207
  58. mcp_proxy_adapter/openapi_schema/__init__.py +0 -38
  59. mcp_proxy_adapter/openapi_schema/command_registry.py +0 -312
  60. mcp_proxy_adapter/openapi_schema/rest_schema.py +0 -510
  61. mcp_proxy_adapter/openapi_schema/rpc_generator.py +0 -307
  62. mcp_proxy_adapter/openapi_schema/rpc_schema.py +0 -416
  63. mcp_proxy_adapter/validators/__init__.py +0 -14
  64. mcp_proxy_adapter/validators/base_validator.py +0 -23
  65. mcp_proxy_adapter-2.0.2.dist-info/RECORD +0 -33
  66. mcp_proxy_adapter-2.0.2.dist-info/top_level.txt +0 -1
  67. {mcp_proxy_adapter-2.0.2.dist-info → mcp_proxy_adapter-2.1.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,416 +0,0 @@
1
- """
2
- Модуль для создания RPC части OpenAPI схемы.
3
- Содержит описание единого RPC эндпоинта для вызова команд.
4
- """
5
- from typing import Dict, Any
6
-
7
- def get_rpc_schema() -> Dict[str, Any]:
8
- """
9
- Возвращает RPC часть OpenAPI схемы.
10
-
11
- Returns:
12
- dict: RPC часть OpenAPI схемы
13
- """
14
- return {
15
- "paths": {
16
- "/cmd": {
17
- "post": {
18
- "summary": "Универсальный RPC эндпоинт для выполнения команд",
19
- "description": "**Основной интерфейс взаимодействия с системой**. Эндпоинт принимает структурированный JSON-RPC 2.0 запрос с командой и параметрами, выполняет указанную операцию и возвращает результат. Поддерживает работу только с векторами размерности 384.",
20
- "operationId": "executeCommand",
21
- "requestBody": {
22
- "required": True,
23
- "content": {
24
- "application/json": {
25
- "schema": {
26
- "$ref": "#/components/schemas/CommandRequest"
27
- }
28
- }
29
- }
30
- },
31
- "responses": {
32
- "200": {
33
- "description": "Результат выполнения команды (независимо от успеха или ошибки). API всегда возвращает код 200 и использует поле 'success' для индикации успеха операции.",
34
- "content": {
35
- "application/json": {
36
- "schema": {
37
- "$ref": "#/components/schemas/ApiResponse"
38
- }
39
- }
40
- }
41
- }
42
- }
43
- }
44
- }
45
- },
46
- "components": {
47
- "schemas": {
48
- "CommandRequest": {
49
- "properties": {
50
- "command": {
51
- "type": "string",
52
- "title": "Command",
53
- "description": "Название команды для выполнения",
54
- "enum": [
55
- "health", "status", "help", "get_metadata", "get_text",
56
- "create_record", "add_vector", "create_text_record", "add_text",
57
- "search_records", "search_by_vector", "search_text_records",
58
- "search_by_text", "filter_records", "filter", "delete_records",
59
- "delete", "get_by_session_message"
60
- ]
61
- },
62
- "params": {
63
- "title": "Params",
64
- "description": "Параметры команды",
65
- "type": "object",
66
- "additionalProperties": True
67
- },
68
- "jsonrpc": {
69
- "type": "string",
70
- "description": "Версия JSON-RPC протокола",
71
- "enum": ["2.0"],
72
- "default": "2.0"
73
- },
74
- "id": {
75
- "type": "string",
76
- "description": "Идентификатор запроса (опционально)"
77
- }
78
- },
79
- "type": "object",
80
- "required": ["command"],
81
- "title": "CommandRequest",
82
- "description": "Модель для запроса выполнения команды векторного хранилища"
83
- },
84
- "JsonRpcResponse": {
85
- "type": "object",
86
- "required": ["jsonrpc", "success"],
87
- "properties": {
88
- "jsonrpc": {
89
- "type": "string",
90
- "description": "Версия JSON-RPC протокола",
91
- "enum": ["2.0"],
92
- "default": "2.0"
93
- },
94
- "success": {
95
- "type": "boolean",
96
- "description": "Индикатор успешности операции",
97
- "default": False
98
- },
99
- "result": {
100
- "description": "Результат операции. Присутствует только при успешном выполнении (success=True). Формат результата зависит от выполненной команды."
101
- },
102
- "error": {
103
- "description": "Информация об ошибке. Присутствует только при возникновении ошибки (success=\"false\").",
104
- "type": "object",
105
- "required": ["code", "message"],
106
- "properties": {
107
- "code": {
108
- "type": "integer",
109
- "description": "Код ошибки (внутренний код, не HTTP-статус)",
110
- "example": 400
111
- },
112
- "message": {
113
- "type": "string",
114
- "description": "Текстовое описание ошибки",
115
- "example": "Запись не существует: ID 12345"
116
- }
117
- }
118
- },
119
- "id": {
120
- "type": "string",
121
- "description": "Идентификатор запроса (если был указан в запросе)"
122
- }
123
- },
124
- "example": {
125
- "jsonrpc": "2.0",
126
- "success": True,
127
- "result": {"id": "550e8400-e29b-41d4-a716-446655440000"}
128
- }
129
- },
130
- "HealthParams": {
131
- "type": "object",
132
- "properties": {},
133
- "title": "HealthParams",
134
- "description": "Параметры для команды health"
135
- },
136
- "StatusParams": {
137
- "type": "object",
138
- "properties": {},
139
- "title": "StatusParams",
140
- "description": "Параметры для команды status"
141
- },
142
- "HelpParams": {
143
- "type": "object",
144
- "properties": {},
145
- "title": "HelpParams",
146
- "description": "Параметры для команды help"
147
- },
148
- "GetMetadataParams": {
149
- "type": "object",
150
- "properties": {
151
- "id": {
152
- "type": "string",
153
- "format": "uuid",
154
- "description": "UUID4 идентификатор записи"
155
- }
156
- },
157
- "required": ["id"],
158
- "title": "GetMetadataParams",
159
- "description": "Параметры для команды get_metadata"
160
- },
161
- "GetTextParams": {
162
- "type": "object",
163
- "properties": {
164
- "id": {
165
- "type": "string",
166
- "format": "uuid",
167
- "description": "UUID4 идентификатор записи"
168
- }
169
- },
170
- "required": ["id"],
171
- "title": "GetTextParams",
172
- "description": "Параметры для команды get_text"
173
- },
174
- "CreateRecordParams": {
175
- "type": "object",
176
- "properties": {
177
- "vector": {
178
- "$ref": "#/components/schemas/Vector"
179
- },
180
- "metadata": {
181
- "type": "object",
182
- "description": "Метаданные записи"
183
- },
184
- "session_id": {
185
- "type": "string",
186
- "format": "uuid",
187
- "description": "UUID4 идентификатор сессии (опционально)"
188
- },
189
- "message_id": {
190
- "type": "string",
191
- "format": "uuid",
192
- "description": "UUID4 идентификатор сообщения (опционально)"
193
- },
194
- "timestamp": {
195
- "type": "string",
196
- "format": "date-time",
197
- "description": "Временная метка в формате ISO 8601 (опционально)"
198
- }
199
- },
200
- "required": ["vector"],
201
- "title": "CreateRecordParams",
202
- "description": "Параметры для создания новой векторной записи"
203
- },
204
- "CreateTextRecordParams": {
205
- "type": "object",
206
- "properties": {
207
- "text": {
208
- "type": "string",
209
- "description": "Текст для векторизации"
210
- },
211
- "metadata": {
212
- "type": "object",
213
- "description": "Метаданные записи"
214
- },
215
- "model": {
216
- "type": "string",
217
- "description": "Модель для векторизации (опционально)"
218
- },
219
- "session_id": {
220
- "type": "string",
221
- "format": "uuid",
222
- "description": "UUID4 идентификатор сессии (опционально)"
223
- },
224
- "message_id": {
225
- "type": "string",
226
- "format": "uuid",
227
- "description": "UUID4 идентификатор сообщения (опционально)"
228
- },
229
- "timestamp": {
230
- "type": "string",
231
- "format": "date-time",
232
- "description": "Временная метка в формате ISO 8601 (опционально)"
233
- }
234
- },
235
- "required": ["text"],
236
- "title": "CreateTextRecordParams",
237
- "description": "Параметры для создания новой текстовой записи"
238
- },
239
- "SearchRecordsParams": {
240
- "type": "object",
241
- "properties": {
242
- "vector": {
243
- "$ref": "#/components/schemas/Vector"
244
- },
245
- "limit": {
246
- "type": "integer",
247
- "description": "Максимальное количество результатов",
248
- "default": 10
249
- },
250
- "threshold": {
251
- "type": "number",
252
- "description": "Порог схожести (от 0 до 1)",
253
- "default": 0.7
254
- }
255
- },
256
- "required": ["vector"],
257
- "title": "SearchRecordsParams",
258
- "description": "Параметры для поиска векторных записей"
259
- },
260
- "SearchTextRecordsParams": {
261
- "type": "object",
262
- "properties": {
263
- "text": {
264
- "type": "string",
265
- "description": "Текст для поиска"
266
- },
267
- "limit": {
268
- "type": "integer",
269
- "description": "Максимальное количество результатов",
270
- "default": 10
271
- },
272
- "threshold": {
273
- "type": "number",
274
- "description": "Порог схожести (от 0 до 1)",
275
- "default": 0.7
276
- }
277
- },
278
- "required": ["text"],
279
- "title": "SearchTextRecordsParams",
280
- "description": "Параметры для поиска текстовых записей"
281
- },
282
- "FilterRecordsParams": {
283
- "type": "object",
284
- "properties": {
285
- "metadata": {
286
- "type": "object",
287
- "description": "Критерии фильтрации по метаданным"
288
- },
289
- "limit": {
290
- "type": "integer",
291
- "description": "Максимальное количество результатов",
292
- "default": 10
293
- }
294
- },
295
- "required": ["metadata"],
296
- "title": "FilterRecordsParams",
297
- "description": "Параметры для фильтрации записей"
298
- },
299
- "DeleteRecordsParams": {
300
- "type": "object",
301
- "properties": {
302
- "ids": {
303
- "type": "array",
304
- "items": {
305
- "type": "string",
306
- "format": "uuid"
307
- },
308
- "description": "Список UUID4 идентификаторов записей для удаления"
309
- }
310
- },
311
- "required": ["ids"],
312
- "title": "DeleteRecordsParams",
313
- "description": "Параметры для удаления записей"
314
- },
315
- "GetBySessionMessageParams": {
316
- "type": "object",
317
- "properties": {
318
- "session_id": {
319
- "type": "string",
320
- "format": "uuid",
321
- "description": "UUID4 идентификатор сессии"
322
- },
323
- "message_id": {
324
- "type": "string",
325
- "format": "uuid",
326
- "description": "UUID4 идентификатор сообщения"
327
- }
328
- },
329
- "required": ["session_id", "message_id"],
330
- "title": "GetBySessionMessageParams",
331
- "description": "Параметры для получения записи по идентификаторам сессии и сообщения"
332
- }
333
- },
334
- "examples": {
335
- "health_check": {
336
- "summary": "Проверка доступности сервиса",
337
- "value": {
338
- "jsonrpc": "2.0",
339
- "command": "health",
340
- "id": "1"
341
- }
342
- },
343
- "create_vector": {
344
- "summary": "Создание векторной записи",
345
- "value": {
346
- "jsonrpc": "2.0",
347
- "command": "create_record",
348
- "params": {
349
- "vector": [0.1] * 384,
350
- "metadata": {"source": "test"}
351
- },
352
- "id": "2"
353
- }
354
- },
355
- "search_by_vector": {
356
- "summary": "Поиск по вектору",
357
- "value": {
358
- "jsonrpc": "2.0",
359
- "command": "search_records",
360
- "params": {
361
- "vector": [0.1] * 384,
362
- "limit": 5
363
- },
364
- "id": "3"
365
- }
366
- },
367
- "search_by_text": {
368
- "summary": "Поиск по тексту",
369
- "value": {
370
- "jsonrpc": "2.0",
371
- "command": "search_text_records",
372
- "params": {
373
- "text": "пример поиска",
374
- "limit": 5
375
- },
376
- "id": "4"
377
- }
378
- },
379
- "filter_records": {
380
- "summary": "Фильтрация записей",
381
- "value": {
382
- "jsonrpc": "2.0",
383
- "command": "filter_records",
384
- "params": {
385
- "metadata": {"source": "test"},
386
- "limit": 10
387
- },
388
- "id": "5"
389
- }
390
- },
391
- "delete_records": {
392
- "summary": "Удаление записей",
393
- "value": {
394
- "jsonrpc": "2.0",
395
- "command": "delete_records",
396
- "params": {
397
- "ids": ["550e8400-e29b-41d4-a716-446655440000"]
398
- },
399
- "id": "6"
400
- }
401
- },
402
- "get_by_session_message": {
403
- "summary": "Получение записи по идентификаторам",
404
- "value": {
405
- "jsonrpc": "2.0",
406
- "command": "get_by_session_message",
407
- "params": {
408
- "session_id": "550e8400-e29b-41d4-a716-446655440000",
409
- "message_id": "660e8400-e29b-41d4-a716-446655440000"
410
- },
411
- "id": "7"
412
- }
413
- }
414
- }
415
- }
416
- }
@@ -1,14 +0,0 @@
1
- """
2
- Validators for checking the correspondence between metadata and function signatures.
3
-
4
- This module contains classes for validating the correspondence between command metadata
5
- and signatures and docstrings of handler functions.
6
- """
7
-
8
- from .docstring_validator import DocstringValidator
9
- from .metadata_validator import MetadataValidator
10
-
11
- __all__ = [
12
- 'DocstringValidator',
13
- 'MetadataValidator',
14
- ]
@@ -1,23 +0,0 @@
1
- """
2
- Base class for command validators.
3
- """
4
- from abc import ABC, abstractmethod
5
- from typing import Any, Callable, Dict, List, Tuple
6
-
7
- class BaseValidator(ABC):
8
- """
9
- Base class for all command validators.
10
-
11
- Defines a common interface for validating command handler functions,
12
- their docstrings, metadata, and other aspects.
13
- """
14
-
15
- @abstractmethod
16
- def validate(self, *args, **kwargs) -> Tuple[bool, List[str]]:
17
- """
18
- Main validation method.
19
-
20
- Returns:
21
- Tuple[bool, List[str]]: Validity flag and list of errors
22
- """
23
- pass
@@ -1,33 +0,0 @@
1
- mcp_proxy_adapter/__init__.py,sha256=9qzzMqbq2lbVI4wGAsFSLqTKMGDfnfaCXb5YPKqFt3s,463
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/adapters/__init__.py,sha256=7QraK1j5y29KFSRF4mVxTiWC2Y3IYZLd6GhxUCtjyhg,790
7
- mcp_proxy_adapter/analyzers/__init__.py,sha256=2rcYZDP-bXq078MQpxP32lAwYYyRhOwAQGBcefBfBzY,368
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/cli/__init__.py,sha256=vJ0VTT7D4KRIOi9nQSgBLub7xywq68i2R1zYQkdA0Uk,416
11
- mcp_proxy_adapter/cli/__main__.py,sha256=qtjEOB4vkeMASjTppyRFok4IFihRrVOqjk6vLx8OW1g,2400
12
- mcp_proxy_adapter/cli/command_runner.py,sha256=4d0BZKRG9k4CLk3ZE26jfSxwwrls2e-KsflRoVimfyE,8328
13
- mcp_proxy_adapter/dispatchers/__init__.py,sha256=FWgimgInGphIjCEnvA3-ZExiapUzYAVis2H9C5IWivU,365
14
- mcp_proxy_adapter/dispatchers/base_dispatcher.py,sha256=S5_Xri058jAmOWeit1tedB_GMZQ9RLcNcYabA83ZF6k,2288
15
- mcp_proxy_adapter/dispatchers/json_rpc_dispatcher.py,sha256=ffu1M32E1AdC7IB44mlbV2L56eJQMsp-7fYi_r4rmHc,6331
16
- mcp_proxy_adapter/generators/__init__.py,sha256=KC8p2HcIBqdyCY1wHnN_c1EfbnPM39YhZLNBDcuv3vA,538
17
- mcp_proxy_adapter/generators/endpoint_generator.py,sha256=fhEInY3JPwdc5EENesN9VrrONwVZMpsledVpubouJLA,6513
18
- mcp_proxy_adapter/generators/openapi_generator.py,sha256=0Iqsn0fRr10sTWUK9-MU5MXOXKDHccxKYnmaiQPkKFw,9773
19
- mcp_proxy_adapter/generators/rest_api_generator.py,sha256=Zg9HVeIuspowXd6aBlyho4UXz-te_Hd4egGzjjIVF48,9159
20
- mcp_proxy_adapter/openapi_schema/__init__.py,sha256=S_lEg-VtlgDdhFxB_u9ZUM1dWKbzW_L_FM-6OCT4EXM,1334
21
- mcp_proxy_adapter/openapi_schema/command_registry.py,sha256=VqqdsVCcd5neqZ-bsfeKTHeLBeputwUZHxvNxVuvqZs,12075
22
- mcp_proxy_adapter/openapi_schema/rest_schema.py,sha256=nfF9axtmEA-B-Rw8TCnpmRf6Br3MfQ3TJVx-QHUHoy8,24103
23
- mcp_proxy_adapter/openapi_schema/rpc_generator.py,sha256=5FGMqjMXcaW0Ej6oey5mgiIxtEKTtA87dc-_kWLWqb0,13640
24
- mcp_proxy_adapter/openapi_schema/rpc_schema.py,sha256=pebSNt9rKyP2dyHpbjSllak6pQe5AnllReKHhR3UIaI,20162
25
- mcp_proxy_adapter/validators/__init__.py,sha256=s6zd5oZ3V2pXtzONoH3CiZYLzSVtCoLXpETMFUQfwWY,403
26
- mcp_proxy_adapter/validators/base_validator.py,sha256=qTEcXnfGqsgKKtc-lnttLiPTuq6vOHfDpZrQ5oP5Fi0,602
27
- mcp_proxy_adapter/validators/docstring_validator.py,sha256=Onpq2iNJ1qF4ejkJJIlBkLROuSNIVALHVmXIgkCpaFI,2934
28
- mcp_proxy_adapter/validators/metadata_validator.py,sha256=uCrn38-VYYn89l6f5CC_GoTAHAweaOW2Z6Esro1rtGw,3155
29
- mcp_proxy_adapter-2.0.2.dist-info/licenses/LICENSE,sha256=OkApFEwdgMCt_mbvUI-eIwKMSTe38K3XnU2DT5ub-wI,1072
30
- mcp_proxy_adapter-2.0.2.dist-info/METADATA,sha256=3-LXLlAgg1swHpgFqA015-zEi_kQ9jAfNoe6e-ExKPk,6076
31
- mcp_proxy_adapter-2.0.2.dist-info/WHEEL,sha256=ooBFpIzZCPdw3uqIQsOo4qqbA4ZRPxHnOH7peeONza0,91
32
- mcp_proxy_adapter-2.0.2.dist-info/top_level.txt,sha256=JZT7vPLBYrtroX-ij68JBhJYbjDdghcV-DFySRy-Nnw,18
33
- mcp_proxy_adapter-2.0.2.dist-info/RECORD,,
@@ -1 +0,0 @@
1
- mcp_proxy_adapter