mcp-proxy-adapter 2.1.17__py3-none-any.whl → 3.0.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.
- examples/__init__.py +19 -0
- examples/anti_patterns/README.md +51 -0
- examples/anti_patterns/__init__.py +9 -0
- examples/anti_patterns/bad_design/README.md +72 -0
- examples/anti_patterns/bad_design/global_state.py +170 -0
- examples/anti_patterns/bad_design/monolithic_command.py +272 -0
- examples/basic_example/README.md +245 -0
- examples/basic_example/__init__.py +8 -0
- examples/basic_example/commands/__init__.py +5 -0
- examples/basic_example/commands/echo_command.py +95 -0
- examples/basic_example/commands/math_command.py +151 -0
- examples/basic_example/commands/time_command.py +152 -0
- examples/basic_example/config.json +25 -0
- examples/basic_example/docs/EN/README.md +177 -0
- examples/basic_example/docs/RU/README.md +177 -0
- examples/basic_example/server.py +151 -0
- examples/basic_example/tests/conftest.py +243 -0
- examples/commands/echo_command.py +52 -0
- examples/commands/echo_result.py +65 -0
- examples/commands/get_date_command.py +98 -0
- examples/commands/new_uuid4_command.py +91 -0
- examples/complete_example/Dockerfile +24 -0
- examples/complete_example/README.md +92 -0
- examples/complete_example/__init__.py +8 -0
- examples/complete_example/commands/__init__.py +5 -0
- examples/complete_example/commands/system_command.py +328 -0
- examples/complete_example/config.json +41 -0
- examples/complete_example/configs/config.dev.yaml +40 -0
- examples/complete_example/configs/config.docker.yaml +40 -0
- examples/complete_example/docker-compose.yml +35 -0
- examples/complete_example/requirements.txt +20 -0
- examples/complete_example/server.py +139 -0
- examples/minimal_example/README.md +65 -0
- examples/minimal_example/__init__.py +8 -0
- examples/minimal_example/config.json +14 -0
- examples/minimal_example/main.py +136 -0
- examples/minimal_example/simple_server.py +163 -0
- examples/minimal_example/tests/conftest.py +171 -0
- examples/minimal_example/tests/test_hello_command.py +111 -0
- examples/minimal_example/tests/test_integration.py +181 -0
- examples/server.py +69 -0
- examples/simple_server.py +128 -0
- examples/test_server.py +134 -0
- examples/tool_description_example.py +82 -0
- mcp_proxy_adapter/__init__.py +33 -1
- mcp_proxy_adapter/api/__init__.py +0 -0
- mcp_proxy_adapter/api/app.py +391 -0
- mcp_proxy_adapter/api/handlers.py +229 -0
- mcp_proxy_adapter/api/middleware/__init__.py +49 -0
- mcp_proxy_adapter/api/middleware/auth.py +146 -0
- mcp_proxy_adapter/api/middleware/base.py +79 -0
- mcp_proxy_adapter/api/middleware/error_handling.py +198 -0
- mcp_proxy_adapter/api/middleware/logging.py +96 -0
- mcp_proxy_adapter/api/middleware/performance.py +83 -0
- mcp_proxy_adapter/api/middleware/rate_limit.py +152 -0
- mcp_proxy_adapter/api/schemas.py +305 -0
- mcp_proxy_adapter/api/tool_integration.py +223 -0
- mcp_proxy_adapter/api/tools.py +198 -0
- mcp_proxy_adapter/commands/__init__.py +19 -0
- mcp_proxy_adapter/commands/base.py +301 -0
- mcp_proxy_adapter/commands/command_registry.py +231 -0
- mcp_proxy_adapter/commands/config_command.py +113 -0
- mcp_proxy_adapter/commands/health_command.py +136 -0
- mcp_proxy_adapter/commands/help_command.py +193 -0
- mcp_proxy_adapter/commands/result.py +215 -0
- mcp_proxy_adapter/config.py +195 -0
- mcp_proxy_adapter/core/__init__.py +0 -0
- mcp_proxy_adapter/core/errors.py +173 -0
- mcp_proxy_adapter/core/logging.py +205 -0
- mcp_proxy_adapter/core/utils.py +138 -0
- mcp_proxy_adapter/custom_openapi.py +125 -0
- mcp_proxy_adapter/openapi.py +403 -0
- mcp_proxy_adapter/py.typed +0 -0
- mcp_proxy_adapter/schemas/base_schema.json +114 -0
- mcp_proxy_adapter/schemas/openapi_schema.json +314 -0
- mcp_proxy_adapter/tests/__init__.py +0 -0
- mcp_proxy_adapter/tests/api/__init__.py +3 -0
- mcp_proxy_adapter/tests/api/test_cmd_endpoint.py +115 -0
- mcp_proxy_adapter/tests/api/test_middleware.py +336 -0
- mcp_proxy_adapter/tests/commands/__init__.py +3 -0
- mcp_proxy_adapter/tests/commands/test_config_command.py +211 -0
- mcp_proxy_adapter/tests/commands/test_echo_command.py +127 -0
- mcp_proxy_adapter/tests/commands/test_help_command.py +133 -0
- mcp_proxy_adapter/tests/conftest.py +131 -0
- mcp_proxy_adapter/tests/functional/__init__.py +3 -0
- mcp_proxy_adapter/tests/functional/test_api.py +235 -0
- mcp_proxy_adapter/tests/integration/__init__.py +3 -0
- mcp_proxy_adapter/tests/integration/test_cmd_integration.py +130 -0
- mcp_proxy_adapter/tests/integration/test_integration.py +255 -0
- mcp_proxy_adapter/tests/performance/__init__.py +3 -0
- mcp_proxy_adapter/tests/performance/test_performance.py +189 -0
- mcp_proxy_adapter/tests/stubs/__init__.py +10 -0
- mcp_proxy_adapter/tests/stubs/echo_command.py +104 -0
- mcp_proxy_adapter/tests/test_api_endpoints.py +271 -0
- mcp_proxy_adapter/tests/test_api_handlers.py +289 -0
- mcp_proxy_adapter/tests/test_base_command.py +123 -0
- mcp_proxy_adapter/tests/test_batch_requests.py +117 -0
- mcp_proxy_adapter/tests/test_command_registry.py +245 -0
- mcp_proxy_adapter/tests/test_config.py +127 -0
- mcp_proxy_adapter/tests/test_utils.py +65 -0
- mcp_proxy_adapter/tests/unit/__init__.py +3 -0
- mcp_proxy_adapter/tests/unit/test_base_command.py +130 -0
- mcp_proxy_adapter/tests/unit/test_config.py +217 -0
- mcp_proxy_adapter/version.py +3 -0
- mcp_proxy_adapter-3.0.1.dist-info/METADATA +200 -0
- mcp_proxy_adapter-3.0.1.dist-info/RECORD +109 -0
- {mcp_proxy_adapter-2.1.17.dist-info → mcp_proxy_adapter-3.0.1.dist-info}/top_level.txt +1 -0
- mcp_proxy_adapter/adapter.py +0 -697
- mcp_proxy_adapter/analyzers/__init__.py +0 -1
- mcp_proxy_adapter/analyzers/docstring_analyzer.py +0 -199
- mcp_proxy_adapter/analyzers/type_analyzer.py +0 -151
- mcp_proxy_adapter/dispatchers/__init__.py +0 -1
- mcp_proxy_adapter/dispatchers/base_dispatcher.py +0 -85
- mcp_proxy_adapter/dispatchers/json_rpc_dispatcher.py +0 -262
- mcp_proxy_adapter/examples/analyze_config.py +0 -141
- mcp_proxy_adapter/examples/basic_integration.py +0 -155
- mcp_proxy_adapter/examples/docstring_and_schema_example.py +0 -69
- mcp_proxy_adapter/examples/extension_example.py +0 -72
- mcp_proxy_adapter/examples/help_best_practices.py +0 -67
- mcp_proxy_adapter/examples/help_usage.py +0 -64
- mcp_proxy_adapter/examples/mcp_proxy_client.py +0 -131
- mcp_proxy_adapter/examples/openapi_server.py +0 -383
- mcp_proxy_adapter/examples/project_structure_example.py +0 -47
- mcp_proxy_adapter/examples/testing_example.py +0 -64
- mcp_proxy_adapter/models.py +0 -47
- mcp_proxy_adapter/registry.py +0 -439
- mcp_proxy_adapter/schema.py +0 -257
- mcp_proxy_adapter/testing_utils.py +0 -112
- mcp_proxy_adapter/validators/__init__.py +0 -1
- mcp_proxy_adapter/validators/docstring_validator.py +0 -75
- mcp_proxy_adapter/validators/metadata_validator.py +0 -76
- mcp_proxy_adapter-2.1.17.dist-info/METADATA +0 -376
- mcp_proxy_adapter-2.1.17.dist-info/RECORD +0 -30
- {mcp_proxy_adapter-2.1.17.dist-info → mcp_proxy_adapter-3.0.1.dist-info}/WHEEL +0 -0
- {mcp_proxy_adapter-2.1.17.dist-info → mcp_proxy_adapter-3.0.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,217 @@
|
|
1
|
+
"""
|
2
|
+
Unit tests for configuration module.
|
3
|
+
"""
|
4
|
+
|
5
|
+
import json
|
6
|
+
import os
|
7
|
+
import tempfile
|
8
|
+
from typing import Generator
|
9
|
+
|
10
|
+
import pytest
|
11
|
+
|
12
|
+
from mcp_proxy_adapter.config import Config
|
13
|
+
|
14
|
+
|
15
|
+
@pytest.fixture
|
16
|
+
def temp_config_file() -> Generator[str, None, None]:
|
17
|
+
"""
|
18
|
+
Creates temporary configuration file for tests.
|
19
|
+
|
20
|
+
Returns:
|
21
|
+
Path to temporary configuration file.
|
22
|
+
"""
|
23
|
+
# Create temporary file
|
24
|
+
fd, path = tempfile.mkstemp(suffix=".json")
|
25
|
+
|
26
|
+
# Write test configuration
|
27
|
+
test_config = {
|
28
|
+
"server": {
|
29
|
+
"host": "127.0.0.1",
|
30
|
+
"port": 8000
|
31
|
+
},
|
32
|
+
"logging": {
|
33
|
+
"level": "DEBUG",
|
34
|
+
"file": "test.log"
|
35
|
+
},
|
36
|
+
"test_section": {
|
37
|
+
"test_key": "test_value",
|
38
|
+
"nested": {
|
39
|
+
"key1": "value1",
|
40
|
+
"key2": 42
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
with os.fdopen(fd, "w") as f:
|
46
|
+
json.dump(test_config, f)
|
47
|
+
|
48
|
+
yield path
|
49
|
+
|
50
|
+
# Remove temporary file after tests
|
51
|
+
os.unlink(path)
|
52
|
+
|
53
|
+
|
54
|
+
@pytest.mark.unit
|
55
|
+
def test_config_load_from_file(temp_config_file: str):
|
56
|
+
"""
|
57
|
+
Test loading configuration from file.
|
58
|
+
|
59
|
+
Args:
|
60
|
+
temp_config_file: Path to temporary configuration file.
|
61
|
+
"""
|
62
|
+
config = Config(temp_config_file)
|
63
|
+
|
64
|
+
# Check loaded values
|
65
|
+
assert config.get("server.host") == "127.0.0.1"
|
66
|
+
assert config.get("server.port") == 8000
|
67
|
+
assert config.get("logging.level") == "DEBUG"
|
68
|
+
assert config.get("logging.file") == "test.log"
|
69
|
+
assert config.get("test_section.test_key") == "test_value"
|
70
|
+
|
71
|
+
|
72
|
+
@pytest.mark.unit
|
73
|
+
def test_config_get_nested_values(temp_config_file: str):
|
74
|
+
"""
|
75
|
+
Test getting nested values from configuration.
|
76
|
+
|
77
|
+
Args:
|
78
|
+
temp_config_file: Path to temporary configuration file.
|
79
|
+
"""
|
80
|
+
config = Config(temp_config_file)
|
81
|
+
|
82
|
+
# Get nested values
|
83
|
+
assert config.get("test_section.nested.key1") == "value1"
|
84
|
+
assert config.get("test_section.nested.key2") == 42
|
85
|
+
|
86
|
+
|
87
|
+
@pytest.mark.unit
|
88
|
+
def test_config_get_with_default(temp_config_file: str):
|
89
|
+
"""
|
90
|
+
Test getting configuration values with default.
|
91
|
+
|
92
|
+
Args:
|
93
|
+
temp_config_file: Path to temporary configuration file.
|
94
|
+
"""
|
95
|
+
config = Config(temp_config_file)
|
96
|
+
|
97
|
+
# Get non-existent values with defaults
|
98
|
+
assert config.get("non_existent", default="default") == "default"
|
99
|
+
assert config.get("server.non_existent", default=123) == 123
|
100
|
+
assert config.get("test_section.nested.non_existent", default=False) is False
|
101
|
+
|
102
|
+
|
103
|
+
@pytest.mark.unit
|
104
|
+
def test_config_get_without_default(temp_config_file: str):
|
105
|
+
"""
|
106
|
+
Test getting non-existent configuration values without default.
|
107
|
+
|
108
|
+
Args:
|
109
|
+
temp_config_file: Path to temporary configuration file.
|
110
|
+
"""
|
111
|
+
config = Config(temp_config_file)
|
112
|
+
|
113
|
+
# Get non-existent values without defaults
|
114
|
+
assert config.get("non_existent") is None
|
115
|
+
assert config.get("server.non_existent") is None
|
116
|
+
assert config.get("test_section.nested.non_existent") is None
|
117
|
+
|
118
|
+
|
119
|
+
@pytest.mark.unit
|
120
|
+
def test_config_set_value(temp_config_file: str):
|
121
|
+
"""
|
122
|
+
Test setting configuration values.
|
123
|
+
|
124
|
+
Args:
|
125
|
+
temp_config_file: Path to temporary configuration file.
|
126
|
+
"""
|
127
|
+
config = Config(temp_config_file)
|
128
|
+
|
129
|
+
# Set values
|
130
|
+
config.set("server.host", "localhost")
|
131
|
+
config.set("logging.level", "INFO")
|
132
|
+
config.set("new_section.new_key", "new_value")
|
133
|
+
|
134
|
+
# Check set values
|
135
|
+
assert config.get("server.host") == "localhost"
|
136
|
+
assert config.get("logging.level") == "INFO"
|
137
|
+
assert config.get("new_section.new_key") == "new_value"
|
138
|
+
|
139
|
+
|
140
|
+
@pytest.mark.unit
|
141
|
+
def test_config_save_and_load(temp_config_file: str):
|
142
|
+
"""
|
143
|
+
Test saving and loading configuration.
|
144
|
+
|
145
|
+
Args:
|
146
|
+
temp_config_file: Path to temporary configuration file.
|
147
|
+
"""
|
148
|
+
# Create and modify configuration
|
149
|
+
config1 = Config(temp_config_file)
|
150
|
+
config1.set("server.host", "localhost")
|
151
|
+
config1.set("new_section.new_key", "new_value")
|
152
|
+
|
153
|
+
# Save configuration
|
154
|
+
config1.save()
|
155
|
+
|
156
|
+
# Load configuration again
|
157
|
+
config2 = Config(temp_config_file)
|
158
|
+
|
159
|
+
# Check values
|
160
|
+
assert config2.get("server.host") == "localhost"
|
161
|
+
assert config2.get("new_section.new_key") == "new_value"
|
162
|
+
|
163
|
+
|
164
|
+
@pytest.mark.unit
|
165
|
+
def test_config_load_updated_file(temp_config_file: str):
|
166
|
+
"""
|
167
|
+
Test loading updated configuration from file.
|
168
|
+
|
169
|
+
Args:
|
170
|
+
temp_config_file: Path to temporary configuration file.
|
171
|
+
"""
|
172
|
+
# Load configuration
|
173
|
+
config = Config(temp_config_file)
|
174
|
+
original_host = config.get("server.host")
|
175
|
+
|
176
|
+
# Modify file directly
|
177
|
+
with open(temp_config_file, "r+") as f:
|
178
|
+
data = json.load(f)
|
179
|
+
data["server"]["host"] = "new_host"
|
180
|
+
f.seek(0)
|
181
|
+
f.truncate()
|
182
|
+
json.dump(data, f)
|
183
|
+
|
184
|
+
# Create new config instance to load updated file
|
185
|
+
updated_config = Config(temp_config_file)
|
186
|
+
|
187
|
+
# Check that value was updated
|
188
|
+
assert updated_config.get("server.host") == "new_host"
|
189
|
+
assert updated_config.get("server.host") != original_host
|
190
|
+
|
191
|
+
|
192
|
+
@pytest.mark.unit
|
193
|
+
def test_config_access_nested_sections(temp_config_file: str):
|
194
|
+
"""
|
195
|
+
Test accessing nested configuration sections directly.
|
196
|
+
|
197
|
+
Args:
|
198
|
+
temp_config_file: Path to temporary configuration file.
|
199
|
+
"""
|
200
|
+
config = Config(temp_config_file)
|
201
|
+
|
202
|
+
# Get parent key then access nested keys
|
203
|
+
server = config.get("server")
|
204
|
+
logging = config.get("logging")
|
205
|
+
test_section = config.get("test_section")
|
206
|
+
|
207
|
+
# Check sections
|
208
|
+
assert isinstance(server, dict)
|
209
|
+
assert isinstance(logging, dict)
|
210
|
+
assert isinstance(test_section, dict)
|
211
|
+
|
212
|
+
assert server["host"] == "127.0.0.1"
|
213
|
+
assert server["port"] == 8000
|
214
|
+
assert logging["level"] == "DEBUG"
|
215
|
+
assert logging["file"] == "test.log"
|
216
|
+
assert test_section["test_key"] == "test_value"
|
217
|
+
assert test_section["nested"]["key1"] == "value1"
|
@@ -0,0 +1,200 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: mcp_proxy_adapter
|
3
|
+
Version: 3.0.1
|
4
|
+
Summary: Reliable microservice with unified JSON-RPC endpoint
|
5
|
+
Home-page: https://github.com/yourusername/mcp-proxy-adapter
|
6
|
+
Author: MCP Team
|
7
|
+
Author-email: Vasiliy Zubarev <vasiliy.zubarev@example.com>
|
8
|
+
License: MIT License
|
9
|
+
|
10
|
+
Copyright (c) 2023-2024 Vasiliy VZ
|
11
|
+
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
14
|
+
in the Software without restriction, including without limitation the rights
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
17
|
+
furnished to do so, subject to the following conditions:
|
18
|
+
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
20
|
+
copies or substantial portions of the Software.
|
21
|
+
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
28
|
+
SOFTWARE.
|
29
|
+
Project-URL: Documentation, https://github.com/maverikod/vvz-mcp-proxy-adapter/tree/main/docs/RU/README.md
|
30
|
+
Project-URL: Source, https://github.com/maverikod/vvz-mcp-proxy-adapter
|
31
|
+
Project-URL: Bug Reports, https://github.com/maverikod/vvz-mcp-proxy-adapter/issues
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
34
|
+
Classifier: Operating System :: OS Independent
|
35
|
+
Classifier: Framework :: FastAPI
|
36
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
37
|
+
Classifier: Intended Audience :: Developers
|
38
|
+
Requires-Python: >=3.9
|
39
|
+
Description-Content-Type: text/markdown
|
40
|
+
License-File: LICENSE
|
41
|
+
Requires-Dist: fastapi<1.0.0,>=0.95.0
|
42
|
+
Requires-Dist: pydantic>=2.0.0
|
43
|
+
Requires-Dist: uvicorn<1.0.0,>=0.22.0
|
44
|
+
Requires-Dist: docstring-parser<1.0.0,>=0.15
|
45
|
+
Requires-Dist: typing-extensions<5.0.0,>=4.5.0
|
46
|
+
Requires-Dist: jsonrpc>=1.2.0
|
47
|
+
Requires-Dist: psutil>=5.9.0
|
48
|
+
Dynamic: author
|
49
|
+
Dynamic: home-page
|
50
|
+
Dynamic: license-file
|
51
|
+
Dynamic: requires-python
|
52
|
+
|
53
|
+
# MCP Proxy Adapter
|
54
|
+
|
55
|
+
**MCP Proxy Adapter** - это фреймворк для создания микросервисов на основе JSON-RPC. Он предоставляет базовую инфраструктуру для создания команд, обработки запросов и возвращения ответов через JSON-RPC API.
|
56
|
+
|
57
|
+
**MCP Proxy Adapter** - это фреймворк для создания микросервисов на основе JSON-RPC. Он предоставляет базовую инфраструктуру для создания команд, обработки запросов и возвращения ответов через JSON-RPC API.
|
58
|
+
|
59
|
+
## Установка
|
60
|
+
|
61
|
+
```bash
|
62
|
+
pip install mcp-proxy-adapter
|
63
|
+
```
|
64
|
+
|
65
|
+
## Использование
|
66
|
+
|
67
|
+
1. Создайте свой проект и установите зависимость:
|
68
|
+
|
69
|
+
```bash
|
70
|
+
pip install mcp-proxy-adapter
|
71
|
+
```
|
72
|
+
|
73
|
+
2. Создайте свои команды:
|
74
|
+
|
75
|
+
```python
|
76
|
+
from mcp_proxy_adapter.commands.base import Command
|
77
|
+
from mcp_proxy_adapter.commands.result import SuccessResult
|
78
|
+
|
79
|
+
class YourCommand(Command):
|
80
|
+
name = "your_command"
|
81
|
+
|
82
|
+
async def execute(self, param1: str, param2: int = 0) -> SuccessResult:
|
83
|
+
# Ваша логика
|
84
|
+
result_data = {"param1": param1, "param2": param2}
|
85
|
+
return SuccessResult(data=result_data)
|
86
|
+
```
|
87
|
+
|
88
|
+
3. Запустите сервер:
|
89
|
+
|
90
|
+
```python
|
91
|
+
import uvicorn
|
92
|
+
from mcp_proxy_adapter.api.app import create_app
|
93
|
+
|
94
|
+
# Регистрация ваших команд происходит автоматически
|
95
|
+
app = create_app()
|
96
|
+
|
97
|
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
98
|
+
```
|
99
|
+
|
100
|
+
## Структура проекта
|
101
|
+
|
102
|
+
Проект представляет собой фреймворк с базовой инфраструктурой:
|
103
|
+
|
104
|
+
* **mcp_proxy_adapter/** - основной модуль фреймворка
|
105
|
+
* **api/** - модуль API
|
106
|
+
* **commands/** - базовые классы команд
|
107
|
+
* **core/** - ядро фреймворка
|
108
|
+
* **schemas/** - JSON-схемы
|
109
|
+
* **examples/** - примеры использования фреймворка
|
110
|
+
* **basic_example/** - базовый пример
|
111
|
+
* **minimal_example/** - минимальный пример
|
112
|
+
* **complete_example/** - полный пример с Docker
|
113
|
+
|
114
|
+
## Базовые команды
|
115
|
+
|
116
|
+
Фреймворк включает следующие базовые команды:
|
117
|
+
|
118
|
+
- `help` - получение справки по доступным командам
|
119
|
+
- `health` - проверка состояния сервиса
|
120
|
+
|
121
|
+
## API
|
122
|
+
|
123
|
+
Фреймворк предоставляет следующие эндпоинты:
|
124
|
+
|
125
|
+
- `POST /api/jsonrpc` - основной JSON-RPC эндпоинт для выполнения команд
|
126
|
+
- `POST /api/command/{command_name}` - REST эндпоинт для выполнения конкретной команды
|
127
|
+
- `GET /api/commands` - получение списка доступных команд
|
128
|
+
- `GET /api/commands/{command_name}` - получение информации о конкретной команде
|
129
|
+
- `GET /health` - проверка состояния сервиса
|
130
|
+
|
131
|
+
## Запуск примеров
|
132
|
+
|
133
|
+
```bash
|
134
|
+
# Базовый пример
|
135
|
+
cd examples/basic_example
|
136
|
+
python main.py
|
137
|
+
|
138
|
+
# Минимальный пример
|
139
|
+
cd examples/minimal_example
|
140
|
+
python main.py
|
141
|
+
|
142
|
+
# Полный пример с Docker
|
143
|
+
cd examples/complete_example
|
144
|
+
docker-compose up -d
|
145
|
+
```
|
146
|
+
|
147
|
+
## Создание новой команды
|
148
|
+
|
149
|
+
Пример создания новой команды:
|
150
|
+
|
151
|
+
```python
|
152
|
+
from typing import Dict, Any, ClassVar, Type
|
153
|
+
from mcp_proxy_adapter.commands.base import Command
|
154
|
+
from mcp_proxy_adapter.commands.result import SuccessResult
|
155
|
+
|
156
|
+
class CustomResult(SuccessResult):
|
157
|
+
"""
|
158
|
+
Пользовательский класс результата.
|
159
|
+
"""
|
160
|
+
|
161
|
+
def __init__(self, value: str):
|
162
|
+
super().__init__(data={"value": value})
|
163
|
+
|
164
|
+
@classmethod
|
165
|
+
def get_schema(cls) -> Dict[str, Any]:
|
166
|
+
return {
|
167
|
+
"type": "object",
|
168
|
+
"properties": {
|
169
|
+
"data": {
|
170
|
+
"type": "object",
|
171
|
+
"properties": {
|
172
|
+
"value": {"type": "string"}
|
173
|
+
},
|
174
|
+
"required": ["value"]
|
175
|
+
}
|
176
|
+
},
|
177
|
+
"required": ["data"]
|
178
|
+
}
|
179
|
+
|
180
|
+
class CustomCommand(Command):
|
181
|
+
"""
|
182
|
+
Пользовательская команда.
|
183
|
+
"""
|
184
|
+
|
185
|
+
name: ClassVar[str] = "custom"
|
186
|
+
result_class: ClassVar[Type[SuccessResult]] = CustomResult
|
187
|
+
|
188
|
+
async def execute(self, input_text: str) -> CustomResult:
|
189
|
+
return CustomResult(value=f"Processed: {input_text}")
|
190
|
+
|
191
|
+
@classmethod
|
192
|
+
def get_schema(cls) -> Dict[str, Any]:
|
193
|
+
return {
|
194
|
+
"type": "object",
|
195
|
+
"properties": {
|
196
|
+
"input_text": {"type": "string"}
|
197
|
+
},
|
198
|
+
"required": ["input_text"],
|
199
|
+
"additionalProperties": False
|
200
|
+
}
|
@@ -0,0 +1,109 @@
|
|
1
|
+
examples/__init__.py,sha256=sLYNpeoiE-X5q7fmJb7NFMmhiIn0543mgJj16q1qmk0,593
|
2
|
+
examples/server.py,sha256=gnRTE_k7C0A255dLyaJWyA4YU0H6Elc7osr_JQvsQhQ,2286
|
3
|
+
examples/simple_server.py,sha256=Bkczmz5Qs473xJ0_AJjBpqWT-oWctwED98A067z05zQ,3768
|
4
|
+
examples/test_server.py,sha256=cKWJ4tlHqZsRKyeuXbZ1dQ7TU9riJWcDan__wK7YH_Y,3729
|
5
|
+
examples/tool_description_example.py,sha256=blamrx_1oHCG4NnvIiYnQxphAEDqb7-TALPALJFj51s,3280
|
6
|
+
examples/anti_patterns/README.md,sha256=1-Hby6Wf3kAC0XOV_jOvuHL-kmTypWOUfE_rEU3Knu8,2045
|
7
|
+
examples/anti_patterns/__init__.py,sha256=xbgoTIMM2LNt4P8h0jTaenUxXkA_l9I7JL_9d4BhoDU,261
|
8
|
+
examples/anti_patterns/bad_design/README.md,sha256=SJDMXZfvNMajN0JyvPBm5GtzxyiZZdtMfHslW3-LOII,2422
|
9
|
+
examples/anti_patterns/bad_design/global_state.py,sha256=UnpMCWDfl-DaZSPhWl8C9fGifXkG_sYKhjx3_HvTiSI,5161
|
10
|
+
examples/anti_patterns/bad_design/monolithic_command.py,sha256=gdp1Ok4h4dKto7nfJmhjoWTtjdCfwI-MtcKpn6il7Yo,8815
|
11
|
+
examples/basic_example/README.md,sha256=H2Q5D8XcINpHZoX9fS0UDBFZyd3shNa5PEd6EOckHQQ,8274
|
12
|
+
examples/basic_example/__init__.py,sha256=SXYCM5mPlVpEMdahhukXSYVepNiPNddhgypwAlhJjDU,191
|
13
|
+
examples/basic_example/config.json,sha256=xln79S29iS-borOL61lR3Hw4V5vg83FMs-Ke3j4YqZQ,425
|
14
|
+
examples/basic_example/server.py,sha256=0qoV59ofWBwCGxQX3jefr5WSyvZsEY0X18USh7x-s2s,4900
|
15
|
+
examples/basic_example/commands/__init__.py,sha256=jD5tBWpkxH1Yk9kBHS_V3bBIMxwqqY4skr7RGuRru9s,115
|
16
|
+
examples/basic_example/commands/echo_command.py,sha256=EoXMHEf5ouKjvxvZAEiNH6hqyD6ktyyEDWYP-6Oa2D4,2128
|
17
|
+
examples/basic_example/commands/math_command.py,sha256=apJuU5EXlR965rGmAd2h8zcPWgLUSROtPeZ7Ml0H6nw,4423
|
18
|
+
examples/basic_example/commands/time_command.py,sha256=REw-8RCgq9iVUdQxnIFPmeYO_9_6-7QVLzLKLGq0Lb0,4345
|
19
|
+
examples/basic_example/docs/EN/README.md,sha256=grOp0Adr3h9m-XZLCgLO6haBdUOjc4_VosirNaLl7dU,4637
|
20
|
+
examples/basic_example/docs/RU/README.md,sha256=8jBObIj_3-eDmFt35ufIRw6mm41FyUXJD7olHmKS2QM,6736
|
21
|
+
examples/basic_example/tests/conftest.py,sha256=6e85QRE50P9PMV1RXXVgtBQxy49hVLbevZ6dHFBrxRU,5917
|
22
|
+
examples/commands/echo_command.py,sha256=7RuUZfP0YlKl9gks02NiuiYEiiNPa_8lk9CAZmzijyo,1569
|
23
|
+
examples/commands/echo_result.py,sha256=q5IUEeFoi4PunzOhYD0zju2ZwETdGl35yj4DVXZfX68,1635
|
24
|
+
examples/commands/get_date_command.py,sha256=ePQzZCV-n3tLf4IYv6Gn75t0AXXplXtikCDmrIMD2Q4,2537
|
25
|
+
examples/commands/new_uuid4_command.py,sha256=lJQiPuVHtKCnOEUQukji6dwe0VOkddJ7sZXZ7XUsY6Y,2240
|
26
|
+
examples/complete_example/Dockerfile,sha256=MpwyUpA2wMeLtEVQ2ay98z-l8EX5aEFvwUSxZCCxg64,499
|
27
|
+
examples/complete_example/README.md,sha256=EupIC8DhC7dVsObbXjuERpwheVzfLR2i0y3LzCRHLYs,2784
|
28
|
+
examples/complete_example/__init__.py,sha256=JQDNMNOrQAvbQyEV7tV3XrVKBxZRYy3ODMCVyOxU404,216
|
29
|
+
examples/complete_example/config.json,sha256=KbfZnu4SMYH6B7ENQaZ_sZXrWdkmCdMcWgy47nAHh_Q,814
|
30
|
+
examples/complete_example/docker-compose.yml,sha256=kBXjXFeswZCZ4-UhI0vC0OMR_nMRRoDt3PltCi-RGb8,924
|
31
|
+
examples/complete_example/requirements.txt,sha256=QHeMbXMHgkISmFoXfO09kiaXAMkg0nNBdCfwThKiHDc,403
|
32
|
+
examples/complete_example/server.py,sha256=JzJPIHI6EJFMRqYw-ZhxIRkYGH-Mdm2UdGiizt04Q0M,4146
|
33
|
+
examples/complete_example/commands/__init__.py,sha256=cZDiwz3nLaeSCwR4oK7xlGgVsXt2WyAlIEMWCxSJPAE,121
|
34
|
+
examples/complete_example/commands/system_command.py,sha256=CwcBRWMODG7Ynr9Syaildu3APuuUdJ_yvQOggAAidg8,10717
|
35
|
+
examples/complete_example/configs/config.dev.yaml,sha256=ASIwU8xzB-kinAsLGghv8-LCER1SUC1ed6K8BktOYPQ,1282
|
36
|
+
examples/complete_example/configs/config.docker.yaml,sha256=DZWxauz5fcaiVFaphvf7zpvLI3oXjUUiXdX_bGlcBds,1389
|
37
|
+
examples/minimal_example/README.md,sha256=VFKjDgpNjFowYNLD3sHHGsc1CVhCm30BWPGBqpLFKAc,2569
|
38
|
+
examples/minimal_example/__init__.py,sha256=EloOqdgVLp7YA2DJOWMw0ZxFbVUCH2LqvZVq5RSfSbg,165
|
39
|
+
examples/minimal_example/config.json,sha256=FSL0q_dAyGHJXp37bLesUvvNgrCiFXkQ8_P7nuUhIcQ,250
|
40
|
+
examples/minimal_example/main.py,sha256=5JAoUz_Gy56kcRTxlpuj27PThU6o6R-lKiySIpwsR7s,4770
|
41
|
+
examples/minimal_example/simple_server.py,sha256=IrS32z5G3Z8Ck7pcqwPmrMMA157sFtHM7brP465q54Y,5372
|
42
|
+
examples/minimal_example/tests/conftest.py,sha256=8kRuZws9twR6D4WX9OoSjtK4NwSCAvENPgp9uX3Dg58,4165
|
43
|
+
examples/minimal_example/tests/test_hello_command.py,sha256=C48o7Hh_gy2NlLqb2KKm2HX37df8eIop0IQfOxWPVS0,3485
|
44
|
+
examples/minimal_example/tests/test_integration.py,sha256=mW9LEXX5yOCxP3uIpGMiTEMci7DE8PDDCiE8rKJn4ds,6213
|
45
|
+
mcp_proxy_adapter/__init__.py,sha256=B7m1YWyv_Wb87-Q-JqVpHQgwajnfIgDyZ_iIxzdTbBY,1021
|
46
|
+
mcp_proxy_adapter/config.py,sha256=MjgZAld6TiD0F5oCyEaJhYhfEXVZxc5G5ke2SLKCV9A,5748
|
47
|
+
mcp_proxy_adapter/custom_openapi.py,sha256=EFEjeQ3DudgTfb4870PWkF1upWM5RaY1PY9jxTSOwU8,4142
|
48
|
+
mcp_proxy_adapter/openapi.py,sha256=jyl5EPXcFhzFKEEMXxHeqF1U-SsYvtdlaKGU2QrekpU,13889
|
49
|
+
mcp_proxy_adapter/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
50
|
+
mcp_proxy_adapter/version.py,sha256=dJk-xMDB6JeaL5chSa3I4Y6cpYWyK2dbuJHiHLtX4Og,71
|
51
|
+
mcp_proxy_adapter/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
52
|
+
mcp_proxy_adapter/api/app.py,sha256=q3yYsNEBFXYr2TOJFxfh6bbF53NkmmgfzSFOtVq7xdc,14353
|
53
|
+
mcp_proxy_adapter/api/handlers.py,sha256=4oAkc-szU3tggkLehqvTW2P5c3HTLIiqXQMwCY0ua2Q,7043
|
54
|
+
mcp_proxy_adapter/api/schemas.py,sha256=xOmiSwHaapY6myEFnLu7o-LWVPM7vwmLYZXFo2c6NfE,12381
|
55
|
+
mcp_proxy_adapter/api/tool_integration.py,sha256=4nnE9I4XIHrsE5vN-I4e5xYJhHrHBDM-vMHT5lD9HWo,10137
|
56
|
+
mcp_proxy_adapter/api/tools.py,sha256=nSDXD4rGlFV_NlB91Y0x3N8WeWvWZ76B32-s-VAFARw,8084
|
57
|
+
mcp_proxy_adapter/api/middleware/__init__.py,sha256=RpaA5hbZ7XIjKaQK0PJpZNqc9tFISe5w7ZmqNgwC6FE,1556
|
58
|
+
mcp_proxy_adapter/api/middleware/auth.py,sha256=bic-ez4o4xh74ZczLXSNafrk_m2qk82GF9MHmfDpf9w,4891
|
59
|
+
mcp_proxy_adapter/api/middleware/base.py,sha256=aMV9YPLHkUnJECuQWYbnlEGaj6xUJFHZR_hJb0OKvu8,2282
|
60
|
+
mcp_proxy_adapter/api/middleware/error_handling.py,sha256=ShguFRn9GBBprevKO7n77ENw4PwYhvBNFu4ptLyjxYQ,6876
|
61
|
+
mcp_proxy_adapter/api/middleware/logging.py,sha256=wGtw4BqKMLgn5zqYd84DnVPtO3evfx2X-TxOCyAmysM,3679
|
62
|
+
mcp_proxy_adapter/api/middleware/performance.py,sha256=dHBxTF43LEGXMKHMH3A8ybKmwAWURd_zswqq_oC4xbw,2454
|
63
|
+
mcp_proxy_adapter/api/middleware/rate_limit.py,sha256=DIv_-ZUVmL-jEo_A5BlfnasZf25zT84AiIJDUUnXkpM,5041
|
64
|
+
mcp_proxy_adapter/commands/__init__.py,sha256=cbds-RqRNyF-BM1PMa_j6OfyTENXzh54Z1aI2b3XpCU,475
|
65
|
+
mcp_proxy_adapter/commands/base.py,sha256=NF7Xvssc6T3rb0s-LcDzjxG4IisNR0911EQpc-LbDyk,10670
|
66
|
+
mcp_proxy_adapter/commands/command_registry.py,sha256=fNPsD1fQGDCp6qMnG3uMa-bDkPTAEw-GgFfoW0Sfwd8,8015
|
67
|
+
mcp_proxy_adapter/commands/config_command.py,sha256=-Z6BGaEQTf859l56zZpHYBeZFeIVdpMYybDrd7LOPIg,3553
|
68
|
+
mcp_proxy_adapter/commands/health_command.py,sha256=_tzxHwB_8vo53VBC6HnBv5fSfZL1pEuwlbrCcy_K78c,4087
|
69
|
+
mcp_proxy_adapter/commands/help_command.py,sha256=UguKpvnmyW6qXZZyzdcJSVqKzLYi-AvaXo_UKyLR8js,6836
|
70
|
+
mcp_proxy_adapter/commands/result.py,sha256=2WjftiAuhlyzOKmPJlQHo_b08ZCzWoK7cquUHFLVE-E,5534
|
71
|
+
mcp_proxy_adapter/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
72
|
+
mcp_proxy_adapter/core/errors.py,sha256=s34OxiIR4NCJu_pYSigKXqrIvRjUUK2OWw0X4dpDjIA,5151
|
73
|
+
mcp_proxy_adapter/core/logging.py,sha256=bvvT1ouSyyT1B9za506W-ASW4AoxYnyU_OeGgSgOFsQ,7102
|
74
|
+
mcp_proxy_adapter/core/utils.py,sha256=WJZYNxOXLCPhTF0OH0bzMFYWW6SWwo6XaWG-S5za7u0,3249
|
75
|
+
mcp_proxy_adapter/schemas/base_schema.json,sha256=v9G9cGMd4dRhCZsOQ_FMqOi5VFyVbI6Cf3fyIvOT9dc,2881
|
76
|
+
mcp_proxy_adapter/schemas/openapi_schema.json,sha256=C3yLkwmDsvnLW9B5gnKKdBGl4zxkeU-rEmjTrNVsQU0,8405
|
77
|
+
mcp_proxy_adapter/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
78
|
+
mcp_proxy_adapter/tests/conftest.py,sha256=VBA2wLeYfp9XAGSq4c489PVBIqMGAJiQPrT0k3kyzXw,2999
|
79
|
+
mcp_proxy_adapter/tests/test_api_endpoints.py,sha256=ePtWCf0szD1JeY9WdHAhcKnuOzoSCpUcqZ_2DVhlC-A,10280
|
80
|
+
mcp_proxy_adapter/tests/test_api_handlers.py,sha256=LeHO0o6eCxan6mt_8ZkUwSbeY7qYfoYMJ-bT_sSgdxc,11011
|
81
|
+
mcp_proxy_adapter/tests/test_base_command.py,sha256=Oa-W3Z_758hLobsUcWMdZU2YxTueLusrzzRY1ZwSRY4,3778
|
82
|
+
mcp_proxy_adapter/tests/test_batch_requests.py,sha256=9-gvhPq48AcEwGlhwgn3DWNhpleLA0f4luZNYMrqlXY,4103
|
83
|
+
mcp_proxy_adapter/tests/test_command_registry.py,sha256=o5HHxlQ-D2ML0ufJK-lXQv-qYWccvalOHGVvpc8QFTU,6285
|
84
|
+
mcp_proxy_adapter/tests/test_config.py,sha256=i4YbFhB3WI1wWKCxkG6l-UpFv2LAbhh4hmGipmYG1d0,3928
|
85
|
+
mcp_proxy_adapter/tests/test_utils.py,sha256=K8DqdWDAV-cXjjeykehHpG5phfq5ydu2HLJzaAL282Y,1653
|
86
|
+
mcp_proxy_adapter/tests/api/__init__.py,sha256=QzjeBIhrRLqfUKYmxVSCbMOoni5MAXgyAx9HxxB6JRs,27
|
87
|
+
mcp_proxy_adapter/tests/api/test_cmd_endpoint.py,sha256=RFg_N7Ut1l_pncUPMaqVg85XV4KTpVe03yI_VA0Z47o,3843
|
88
|
+
mcp_proxy_adapter/tests/api/test_middleware.py,sha256=A_-rpW0Kifg4SgjV3NxjQhOhFUSbnUWJjVJAAQWjEeQ,12063
|
89
|
+
mcp_proxy_adapter/tests/commands/__init__.py,sha256=DZxhtyr__AleyXN1s8Ef887tK5nsoHKfW4QXyzLaP0E,36
|
90
|
+
mcp_proxy_adapter/tests/commands/test_config_command.py,sha256=ud0Y57xUhFiyrUKDyA0eBZ8IOKiGDpioijtwY-detC4,6522
|
91
|
+
mcp_proxy_adapter/tests/commands/test_echo_command.py,sha256=c2dmqfx3ZfvDedy5vuxArFv7iHsReepMmD2Lchg4l3E,3437
|
92
|
+
mcp_proxy_adapter/tests/commands/test_help_command.py,sha256=OJCZMS0BqUUNNSecipd3dOFokUATiET3gpCoVAxPXPA,4116
|
93
|
+
mcp_proxy_adapter/tests/functional/__init__.py,sha256=muVNR6LD5o7DsDaLrbLTFsavUNcnyM608-mr-dqzgDU,59
|
94
|
+
mcp_proxy_adapter/tests/functional/test_api.py,sha256=Vsn4IsZ5uEa7g4G5IIyyhvdx6Xa0FuWSPd7XVxVMTP8,6554
|
95
|
+
mcp_proxy_adapter/tests/integration/__init__.py,sha256=JZpeNG1PBRZ3k5zfq6NH3GyzDc1Yx1ZUgwi6eLBxs1o,60
|
96
|
+
mcp_proxy_adapter/tests/integration/test_cmd_integration.py,sha256=OqBxh52WPijKaRrIHA54QDJQLBz_nwlCywF9k5jxa_Y,3430
|
97
|
+
mcp_proxy_adapter/tests/integration/test_integration.py,sha256=Rf8GTxdZOvZzrtgqWN2fp-36qUU5rpHdV9zhN1JxNw8,6619
|
98
|
+
mcp_proxy_adapter/tests/performance/__init__.py,sha256=2kHf6g4LmYnFuV4EALXzo7Qk9vHGA9DXZFt7nORRFjM,60
|
99
|
+
mcp_proxy_adapter/tests/performance/test_performance.py,sha256=Djrnu-SsXRrc_Prj1Aw8OoPzPUwHJds-Itk3aX6o01w,5730
|
100
|
+
mcp_proxy_adapter/tests/stubs/__init__.py,sha256=qJ_gqvLdt68rAfLOeJpjVcLWyWdhEg6RkKheyV2yjJs,178
|
101
|
+
mcp_proxy_adapter/tests/stubs/echo_command.py,sha256=Y7SA4IB5Lo_ncn78SDm9iRZvJSKy2pXi2nBQjIUPrvg,2620
|
102
|
+
mcp_proxy_adapter/tests/unit/__init__.py,sha256=RS-5UoSCcLKtr2jrAaZw_NG9MquA6BZmxq-P6cTw9ok,53
|
103
|
+
mcp_proxy_adapter/tests/unit/test_base_command.py,sha256=ldDXQYk2eijbTgZioSBAhHzSAa_SuBKYqCutCEzUYTE,3924
|
104
|
+
mcp_proxy_adapter/tests/unit/test_config.py,sha256=SZ62LXFOv_fsV0fmSIBdHWvapEyexKrioFRQo0I4pkg,5900
|
105
|
+
mcp_proxy_adapter-3.0.1.dist-info/licenses/LICENSE,sha256=OkApFEwdgMCt_mbvUI-eIwKMSTe38K3XnU2DT5ub-wI,1072
|
106
|
+
mcp_proxy_adapter-3.0.1.dist-info/METADATA,sha256=IQfUDUcgTOvLRjUNzcEwp6knWzfaJxYxhS9DEYblork,7537
|
107
|
+
mcp_proxy_adapter-3.0.1.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
108
|
+
mcp_proxy_adapter-3.0.1.dist-info/top_level.txt,sha256=kxq3OC7vBtsFdy9dDVse4cOl-SV_QlvcTeSkuw_jw3I,27
|
109
|
+
mcp_proxy_adapter-3.0.1.dist-info/RECORD,,
|