mcp-proxy-adapter 3.1.5__py3-none-any.whl → 4.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.
- mcp_proxy_adapter/api/app.py +86 -27
- mcp_proxy_adapter/api/handlers.py +1 -1
- mcp_proxy_adapter/api/middleware/error_handling.py +11 -10
- mcp_proxy_adapter/api/tool_integration.py +5 -2
- mcp_proxy_adapter/api/tools.py +3 -3
- mcp_proxy_adapter/commands/base.py +19 -1
- mcp_proxy_adapter/commands/command_registry.py +258 -6
- mcp_proxy_adapter/commands/help_command.py +54 -65
- mcp_proxy_adapter/commands/hooks.py +260 -0
- mcp_proxy_adapter/commands/reload_command.py +211 -0
- mcp_proxy_adapter/commands/reload_settings_command.py +125 -0
- mcp_proxy_adapter/commands/settings_command.py +189 -0
- mcp_proxy_adapter/config.py +16 -1
- mcp_proxy_adapter/core/__init__.py +44 -0
- mcp_proxy_adapter/core/logging.py +87 -34
- mcp_proxy_adapter/core/settings.py +376 -0
- mcp_proxy_adapter/core/utils.py +2 -2
- mcp_proxy_adapter/custom_openapi.py +81 -2
- mcp_proxy_adapter/examples/README.md +124 -0
- mcp_proxy_adapter/examples/__init__.py +7 -0
- mcp_proxy_adapter/examples/basic_server/README.md +60 -0
- mcp_proxy_adapter/examples/basic_server/__init__.py +7 -0
- mcp_proxy_adapter/examples/basic_server/basic_custom_settings.json +39 -0
- mcp_proxy_adapter/examples/basic_server/config.json +35 -0
- mcp_proxy_adapter/examples/basic_server/custom_settings_example.py +238 -0
- mcp_proxy_adapter/examples/basic_server/server.py +98 -0
- mcp_proxy_adapter/examples/custom_commands/README.md +127 -0
- mcp_proxy_adapter/examples/custom_commands/__init__.py +27 -0
- mcp_proxy_adapter/examples/custom_commands/advanced_hooks.py +250 -0
- mcp_proxy_adapter/examples/custom_commands/auto_commands/__init__.py +6 -0
- mcp_proxy_adapter/examples/custom_commands/auto_commands/auto_echo_command.py +103 -0
- mcp_proxy_adapter/examples/custom_commands/auto_commands/auto_info_command.py +111 -0
- mcp_proxy_adapter/examples/custom_commands/config.json +62 -0
- mcp_proxy_adapter/examples/custom_commands/custom_health_command.py +169 -0
- mcp_proxy_adapter/examples/custom_commands/custom_help_command.py +215 -0
- mcp_proxy_adapter/examples/custom_commands/custom_openapi_generator.py +76 -0
- mcp_proxy_adapter/examples/custom_commands/custom_settings.json +96 -0
- mcp_proxy_adapter/examples/custom_commands/custom_settings_manager.py +241 -0
- mcp_proxy_adapter/examples/custom_commands/data_transform_command.py +135 -0
- mcp_proxy_adapter/examples/custom_commands/echo_command.py +122 -0
- mcp_proxy_adapter/examples/custom_commands/hooks.py +230 -0
- mcp_proxy_adapter/examples/custom_commands/intercept_command.py +123 -0
- mcp_proxy_adapter/examples/custom_commands/manual_echo_command.py +103 -0
- mcp_proxy_adapter/examples/custom_commands/server.py +223 -0
- mcp_proxy_adapter/examples/custom_commands/test_hooks.py +176 -0
- mcp_proxy_adapter/examples/deployment/README.md +49 -0
- mcp_proxy_adapter/examples/deployment/__init__.py +7 -0
- mcp_proxy_adapter/examples/deployment/config.development.json +8 -0
- {examples/basic_example → mcp_proxy_adapter/examples/deployment}/config.json +11 -7
- mcp_proxy_adapter/examples/deployment/config.production.json +12 -0
- mcp_proxy_adapter/examples/deployment/config.staging.json +11 -0
- mcp_proxy_adapter/examples/deployment/docker-compose.yml +31 -0
- mcp_proxy_adapter/examples/deployment/run.sh +43 -0
- mcp_proxy_adapter/examples/deployment/run_docker.sh +84 -0
- mcp_proxy_adapter/openapi.py +3 -2
- mcp_proxy_adapter/tests/api/test_custom_openapi.py +617 -0
- mcp_proxy_adapter/tests/api/test_handlers.py +522 -0
- mcp_proxy_adapter/tests/api/test_schemas.py +546 -0
- mcp_proxy_adapter/tests/api/test_tool_integration.py +531 -0
- mcp_proxy_adapter/tests/commands/test_help_command.py +8 -5
- mcp_proxy_adapter/tests/integration/test_cmd_integration.py +4 -5
- mcp_proxy_adapter/tests/test_command_registry.py +37 -1
- mcp_proxy_adapter/tests/unit/test_base_command.py +391 -85
- mcp_proxy_adapter/version.py +1 -1
- {mcp_proxy_adapter-3.1.5.dist-info → mcp_proxy_adapter-4.0.0.dist-info}/METADATA +1 -1
- mcp_proxy_adapter-4.0.0.dist-info/RECORD +110 -0
- {mcp_proxy_adapter-3.1.5.dist-info → mcp_proxy_adapter-4.0.0.dist-info}/WHEEL +1 -1
- {mcp_proxy_adapter-3.1.5.dist-info → mcp_proxy_adapter-4.0.0.dist-info}/top_level.txt +0 -1
- examples/__init__.py +0 -19
- examples/anti_patterns/README.md +0 -51
- examples/anti_patterns/__init__.py +0 -9
- examples/anti_patterns/bad_design/README.md +0 -72
- examples/anti_patterns/bad_design/global_state.py +0 -170
- examples/anti_patterns/bad_design/monolithic_command.py +0 -272
- examples/basic_example/README.md +0 -245
- examples/basic_example/__init__.py +0 -8
- examples/basic_example/commands/__init__.py +0 -5
- examples/basic_example/commands/echo_command.py +0 -95
- examples/basic_example/commands/math_command.py +0 -151
- examples/basic_example/commands/time_command.py +0 -152
- examples/basic_example/docs/EN/README.md +0 -177
- examples/basic_example/docs/RU/README.md +0 -177
- examples/basic_example/server.py +0 -151
- examples/basic_example/tests/conftest.py +0 -243
- examples/check_vstl_schema.py +0 -106
- examples/commands/echo_command.py +0 -52
- examples/commands/echo_command_di.py +0 -152
- examples/commands/echo_result.py +0 -65
- examples/commands/get_date_command.py +0 -98
- examples/commands/new_uuid4_command.py +0 -91
- examples/complete_example/Dockerfile +0 -24
- examples/complete_example/README.md +0 -92
- examples/complete_example/__init__.py +0 -8
- examples/complete_example/commands/__init__.py +0 -5
- examples/complete_example/commands/system_command.py +0 -328
- examples/complete_example/config.json +0 -41
- examples/complete_example/configs/config.dev.yaml +0 -40
- examples/complete_example/configs/config.docker.yaml +0 -40
- examples/complete_example/docker-compose.yml +0 -35
- examples/complete_example/requirements.txt +0 -20
- examples/complete_example/server.py +0 -113
- examples/di_example/.pytest_cache/README.md +0 -8
- examples/di_example/server.py +0 -249
- examples/fix_vstl_help.py +0 -123
- examples/minimal_example/README.md +0 -65
- examples/minimal_example/__init__.py +0 -8
- examples/minimal_example/config.json +0 -14
- examples/minimal_example/main.py +0 -136
- examples/minimal_example/simple_server.py +0 -163
- examples/minimal_example/tests/conftest.py +0 -171
- examples/minimal_example/tests/test_hello_command.py +0 -111
- examples/minimal_example/tests/test_integration.py +0 -181
- examples/patch_vstl_service.py +0 -105
- examples/patch_vstl_service_mcp.py +0 -108
- examples/server.py +0 -69
- examples/simple_server.py +0 -128
- examples/test_package_3.1.4.py +0 -177
- examples/test_server.py +0 -134
- examples/tool_description_example.py +0 -82
- mcp_proxy_adapter/py.typed +0 -0
- mcp_proxy_adapter-3.1.5.dist-info/RECORD +0 -118
- {mcp_proxy_adapter-3.1.5.dist-info → mcp_proxy_adapter-4.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,98 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Module for the get_date command implementation.
|
3
|
-
"""
|
4
|
-
|
5
|
-
from datetime import datetime
|
6
|
-
from typing import Any, Dict
|
7
|
-
|
8
|
-
from mcp_proxy_adapter.commands.base import Command
|
9
|
-
from mcp_proxy_adapter.commands.result import CommandResult
|
10
|
-
from mcp_proxy_adapter.commands.command_registry import registry
|
11
|
-
from mcp_proxy_adapter.core.logging import logger
|
12
|
-
|
13
|
-
|
14
|
-
class GetDateResult(CommandResult):
|
15
|
-
"""Result of getting current date"""
|
16
|
-
|
17
|
-
def __init__(self, date: str):
|
18
|
-
"""
|
19
|
-
Initialize the GetDateResult.
|
20
|
-
|
21
|
-
Args:
|
22
|
-
date: Date in ISO 8601 format
|
23
|
-
"""
|
24
|
-
self.date = date
|
25
|
-
|
26
|
-
def to_dict(self) -> Dict[str, Any]:
|
27
|
-
"""
|
28
|
-
Convert the result to a dictionary.
|
29
|
-
|
30
|
-
Returns:
|
31
|
-
Dictionary with the date
|
32
|
-
"""
|
33
|
-
return {"date": self.date}
|
34
|
-
|
35
|
-
@classmethod
|
36
|
-
def get_schema(cls) -> Dict[str, Any]:
|
37
|
-
"""
|
38
|
-
Get the JSON schema for this result.
|
39
|
-
|
40
|
-
Returns:
|
41
|
-
JSON schema
|
42
|
-
"""
|
43
|
-
return {
|
44
|
-
"type": "object",
|
45
|
-
"required": ["date"],
|
46
|
-
"properties": {
|
47
|
-
"date": {
|
48
|
-
"type": "string",
|
49
|
-
"description": "Current date and time in ISO 8601 format",
|
50
|
-
"pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}[+-]\\d{2}:?\\d{2}$"
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
|
56
|
-
class GetDateCommand(Command):
|
57
|
-
"""
|
58
|
-
Command that returns the current date and time in ISO 8601 format.
|
59
|
-
"""
|
60
|
-
|
61
|
-
name = "get_date"
|
62
|
-
|
63
|
-
async def execute(self) -> GetDateResult:
|
64
|
-
"""
|
65
|
-
Execute the get_date command.
|
66
|
-
|
67
|
-
Returns:
|
68
|
-
GetDateResult: Result with date in ISO 8601 format
|
69
|
-
"""
|
70
|
-
# Get current time with timezone info
|
71
|
-
now = datetime.now().astimezone()
|
72
|
-
|
73
|
-
# Format to ISO 8601
|
74
|
-
date_str = now.strftime("%Y-%m-%dT%H:%M:%S%z")
|
75
|
-
|
76
|
-
# Insert colon in timezone offset (e.g. +0300 -> +03:00)
|
77
|
-
if len(date_str) >= 6:
|
78
|
-
date_str = date_str[:-2] + ":" + date_str[-2:]
|
79
|
-
|
80
|
-
logger.debug(f"Generated date: {date_str}")
|
81
|
-
return GetDateResult(date=date_str)
|
82
|
-
|
83
|
-
@classmethod
|
84
|
-
def get_schema(cls) -> Dict[str, Any]:
|
85
|
-
"""
|
86
|
-
Get the JSON schema for this command.
|
87
|
-
|
88
|
-
Returns:
|
89
|
-
JSON schema
|
90
|
-
"""
|
91
|
-
return {
|
92
|
-
"type": "object",
|
93
|
-
"properties": {}
|
94
|
-
}
|
95
|
-
|
96
|
-
|
97
|
-
# Register the command
|
98
|
-
registry.register(GetDateCommand)
|
@@ -1,91 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Module for the new_uuid4 command implementation.
|
3
|
-
"""
|
4
|
-
|
5
|
-
import uuid
|
6
|
-
from typing import Any, Dict
|
7
|
-
|
8
|
-
from mcp_proxy_adapter.commands.base import Command
|
9
|
-
from mcp_proxy_adapter.commands.result import CommandResult
|
10
|
-
from mcp_proxy_adapter.commands.command_registry import registry
|
11
|
-
from mcp_proxy_adapter.core.logging import logger
|
12
|
-
|
13
|
-
|
14
|
-
class NewUuid4Result(CommandResult):
|
15
|
-
"""Result of UUID4 generation"""
|
16
|
-
|
17
|
-
def __init__(self, uuid_str: str):
|
18
|
-
"""
|
19
|
-
Initialize the NewUuid4Result.
|
20
|
-
|
21
|
-
Args:
|
22
|
-
uuid_str: UUID in string format
|
23
|
-
"""
|
24
|
-
self.uuid = uuid_str
|
25
|
-
|
26
|
-
def to_dict(self) -> Dict[str, Any]:
|
27
|
-
"""
|
28
|
-
Convert the result to a dictionary.
|
29
|
-
|
30
|
-
Returns:
|
31
|
-
Dictionary with the UUID
|
32
|
-
"""
|
33
|
-
return {"uuid": self.uuid}
|
34
|
-
|
35
|
-
@classmethod
|
36
|
-
def get_schema(cls) -> Dict[str, Any]:
|
37
|
-
"""
|
38
|
-
Get the JSON schema for this result.
|
39
|
-
|
40
|
-
Returns:
|
41
|
-
JSON schema
|
42
|
-
"""
|
43
|
-
return {
|
44
|
-
"type": "object",
|
45
|
-
"required": ["uuid"],
|
46
|
-
"properties": {
|
47
|
-
"uuid": {
|
48
|
-
"type": "string",
|
49
|
-
"description": "Generated UUID4 in string format",
|
50
|
-
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
|
56
|
-
class NewUuid4Command(Command):
|
57
|
-
"""
|
58
|
-
Command that generates a new UUID version 4 (random).
|
59
|
-
"""
|
60
|
-
|
61
|
-
name = "new_uuid4"
|
62
|
-
|
63
|
-
async def execute(self) -> NewUuid4Result:
|
64
|
-
"""
|
65
|
-
Execute the new_uuid4 command.
|
66
|
-
|
67
|
-
Returns:
|
68
|
-
NewUuid4Result: Result with UUID in string format
|
69
|
-
"""
|
70
|
-
# Generate a UUID4
|
71
|
-
uuid_str = str(uuid.uuid4())
|
72
|
-
|
73
|
-
logger.debug(f"Generated UUID4: {uuid_str}")
|
74
|
-
return NewUuid4Result(uuid_str=uuid_str)
|
75
|
-
|
76
|
-
@classmethod
|
77
|
-
def get_schema(cls) -> Dict[str, Any]:
|
78
|
-
"""
|
79
|
-
Get the JSON schema for this command.
|
80
|
-
|
81
|
-
Returns:
|
82
|
-
JSON schema
|
83
|
-
"""
|
84
|
-
return {
|
85
|
-
"type": "object",
|
86
|
-
"properties": {}
|
87
|
-
}
|
88
|
-
|
89
|
-
|
90
|
-
# Register the command
|
91
|
-
registry.register(NewUuid4Command)
|
@@ -1,24 +0,0 @@
|
|
1
|
-
FROM python:3.11-slim
|
2
|
-
|
3
|
-
# Set working directory
|
4
|
-
WORKDIR /app
|
5
|
-
|
6
|
-
# Install dependencies
|
7
|
-
COPY requirements.txt .
|
8
|
-
RUN pip install --no-cache-dir -r requirements.txt
|
9
|
-
|
10
|
-
# Create necessary directories
|
11
|
-
RUN mkdir -p /app/logs /app/cache /app/data
|
12
|
-
|
13
|
-
# Copy application files
|
14
|
-
COPY . .
|
15
|
-
|
16
|
-
# Set environment variables
|
17
|
-
ENV PYTHONUNBUFFERED=1
|
18
|
-
ENV CONFIG_PATH=/app/configs/config.docker.yaml
|
19
|
-
|
20
|
-
# Expose API port
|
21
|
-
EXPOSE 8000
|
22
|
-
|
23
|
-
# Run the application
|
24
|
-
CMD ["python", "server.py", "--config", "/app/configs/config.docker.yaml"]
|
@@ -1,92 +0,0 @@
|
|
1
|
-
# Complete MCP Proxy Adapter Example
|
2
|
-
|
3
|
-
This example demonstrates a complete MCP Proxy Adapter application with Docker support,
|
4
|
-
environment-specific configuration, and multiple commands.
|
5
|
-
|
6
|
-
## Structure
|
7
|
-
|
8
|
-
```
|
9
|
-
complete_example/
|
10
|
-
├── cache/ # Cache directory
|
11
|
-
├── commands/ # Commands directory
|
12
|
-
│ ├── __init__.py # Package initialization
|
13
|
-
│ ├── db_command.py # Database command
|
14
|
-
│ ├── file_command.py # File operations command
|
15
|
-
│ └── system_command.py # System information command
|
16
|
-
├── configs/ # Configuration files
|
17
|
-
│ ├── config.dev.yaml # Development config
|
18
|
-
│ └── config.docker.yaml # Docker config
|
19
|
-
├── docker-compose.yml # Docker Compose file
|
20
|
-
├── Dockerfile # Docker image definition
|
21
|
-
├── logs/ # Logs directory
|
22
|
-
├── README.md # This documentation file
|
23
|
-
├── requirements.txt # Python dependencies
|
24
|
-
└── server.py # Server startup file
|
25
|
-
```
|
26
|
-
|
27
|
-
## Features
|
28
|
-
|
29
|
-
- Multiple commands in separate files
|
30
|
-
- Environment-specific configuration
|
31
|
-
- Docker support
|
32
|
-
- Volume mounting for logs, cache, and config
|
33
|
-
- Network configuration
|
34
|
-
|
35
|
-
## Running Locally
|
36
|
-
|
37
|
-
```bash
|
38
|
-
# Navigate to the project directory
|
39
|
-
cd examples/complete_example
|
40
|
-
|
41
|
-
# Create virtual environment (optional)
|
42
|
-
python -m venv venv
|
43
|
-
source venv/bin/activate # Linux/Mac
|
44
|
-
# or
|
45
|
-
# venv\Scripts\activate # Windows
|
46
|
-
|
47
|
-
# Install dependencies
|
48
|
-
pip install -r requirements.txt
|
49
|
-
pip install -e ../.. # Install mcp_proxy_adapter from parent directory
|
50
|
-
|
51
|
-
# Run the server with development config
|
52
|
-
python server.py --config configs/config.dev.yaml
|
53
|
-
```
|
54
|
-
|
55
|
-
The server will be available at [http://localhost:8000](http://localhost:8000).
|
56
|
-
|
57
|
-
## Running with Docker
|
58
|
-
|
59
|
-
```bash
|
60
|
-
# Navigate to the project directory
|
61
|
-
cd examples/complete_example
|
62
|
-
|
63
|
-
# Build the Docker image
|
64
|
-
docker build -t mcp-proxy-adapter-example .
|
65
|
-
|
66
|
-
# Run with Docker Compose
|
67
|
-
docker-compose up
|
68
|
-
```
|
69
|
-
|
70
|
-
The server will be available at [http://localhost:8000](http://localhost:8000).
|
71
|
-
|
72
|
-
## Available Commands
|
73
|
-
|
74
|
-
The microservice includes several commands that demonstrate different features:
|
75
|
-
|
76
|
-
1. `system_info` - Returns system information
|
77
|
-
2. `file_operations` - Performs file operations
|
78
|
-
3. `db_query` - Executes database queries
|
79
|
-
|
80
|
-
For details on each command, see the API documentation at [http://localhost:8000/docs](http://localhost:8000/docs)
|
81
|
-
when the server is running.
|
82
|
-
|
83
|
-
## Docker Configuration
|
84
|
-
|
85
|
-
The Docker setup includes:
|
86
|
-
|
87
|
-
- Volume mounts for logs, cache, and configuration
|
88
|
-
- Network configuration for integration with other services
|
89
|
-
- User mapping to avoid permission issues
|
90
|
-
- Port forwarding
|
91
|
-
|
92
|
-
For details, see the `docker-compose.yml` file.
|
@@ -1,328 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
System information command module.
|
3
|
-
|
4
|
-
This module contains a command that returns detailed information about the system.
|
5
|
-
"""
|
6
|
-
|
7
|
-
import os
|
8
|
-
import sys
|
9
|
-
import socket
|
10
|
-
import platform
|
11
|
-
import datetime
|
12
|
-
from typing import Dict, Any, Optional, List
|
13
|
-
|
14
|
-
import psutil
|
15
|
-
import pytz
|
16
|
-
|
17
|
-
from mcp_proxy_adapter import Command, SuccessResult
|
18
|
-
|
19
|
-
|
20
|
-
class SystemInfoResult(SuccessResult):
|
21
|
-
"""
|
22
|
-
Result of system_info command.
|
23
|
-
|
24
|
-
Attributes:
|
25
|
-
system (dict): System information
|
26
|
-
cpu (dict): CPU information
|
27
|
-
memory (dict): Memory information
|
28
|
-
disk (dict): Disk information
|
29
|
-
python (dict): Python information
|
30
|
-
network (dict): Network information
|
31
|
-
time (dict): Time information
|
32
|
-
"""
|
33
|
-
|
34
|
-
def __init__(
|
35
|
-
self,
|
36
|
-
system: Dict[str, Any],
|
37
|
-
cpu: Dict[str, Any],
|
38
|
-
memory: Dict[str, Any],
|
39
|
-
disk: Dict[str, Any],
|
40
|
-
python: Dict[str, Any],
|
41
|
-
network: Dict[str, Any],
|
42
|
-
time: Dict[str, Any]
|
43
|
-
):
|
44
|
-
"""
|
45
|
-
Initialize result.
|
46
|
-
|
47
|
-
Args:
|
48
|
-
system: System information
|
49
|
-
cpu: CPU information
|
50
|
-
memory: Memory information
|
51
|
-
disk: Disk information
|
52
|
-
python: Python information
|
53
|
-
network: Network information
|
54
|
-
time: Time information
|
55
|
-
"""
|
56
|
-
self.system = system
|
57
|
-
self.cpu = cpu
|
58
|
-
self.memory = memory
|
59
|
-
self.disk = disk
|
60
|
-
self.python = python
|
61
|
-
self.network = network
|
62
|
-
self.time = time
|
63
|
-
|
64
|
-
def to_dict(self) -> Dict[str, Any]:
|
65
|
-
"""
|
66
|
-
Convert result to dictionary.
|
67
|
-
|
68
|
-
Returns:
|
69
|
-
Dictionary representation
|
70
|
-
"""
|
71
|
-
return {
|
72
|
-
"system": self.system,
|
73
|
-
"cpu": self.cpu,
|
74
|
-
"memory": self.memory,
|
75
|
-
"disk": self.disk,
|
76
|
-
"python": self.python,
|
77
|
-
"network": self.network,
|
78
|
-
"time": self.time
|
79
|
-
}
|
80
|
-
|
81
|
-
@classmethod
|
82
|
-
def get_schema(cls) -> Dict[str, Any]:
|
83
|
-
"""
|
84
|
-
Get JSON schema for result.
|
85
|
-
|
86
|
-
Returns:
|
87
|
-
JSON schema
|
88
|
-
"""
|
89
|
-
return {
|
90
|
-
"type": "object",
|
91
|
-
"properties": {
|
92
|
-
"system": {
|
93
|
-
"type": "object",
|
94
|
-
"description": "System information",
|
95
|
-
"properties": {
|
96
|
-
"platform": {"type": "string"},
|
97
|
-
"system": {"type": "string"},
|
98
|
-
"node": {"type": "string"},
|
99
|
-
"release": {"type": "string"},
|
100
|
-
"version": {"type": "string"},
|
101
|
-
"machine": {"type": "string"},
|
102
|
-
"processor": {"type": "string"},
|
103
|
-
"uptime": {"type": "number"}
|
104
|
-
}
|
105
|
-
},
|
106
|
-
"cpu": {
|
107
|
-
"type": "object",
|
108
|
-
"description": "CPU information",
|
109
|
-
"properties": {
|
110
|
-
"count_physical": {"type": "integer"},
|
111
|
-
"count_logical": {"type": "integer"},
|
112
|
-
"usage_percent": {"type": "number"},
|
113
|
-
"frequency": {"type": "object"}
|
114
|
-
}
|
115
|
-
},
|
116
|
-
"memory": {
|
117
|
-
"type": "object",
|
118
|
-
"description": "Memory information",
|
119
|
-
"properties": {
|
120
|
-
"total": {"type": "integer"},
|
121
|
-
"available": {"type": "integer"},
|
122
|
-
"used": {"type": "integer"},
|
123
|
-
"percent": {"type": "number"}
|
124
|
-
}
|
125
|
-
},
|
126
|
-
"disk": {
|
127
|
-
"type": "object",
|
128
|
-
"description": "Disk information",
|
129
|
-
"properties": {
|
130
|
-
"partitions": {"type": "array"},
|
131
|
-
"usage": {"type": "object"}
|
132
|
-
}
|
133
|
-
},
|
134
|
-
"python": {
|
135
|
-
"type": "object",
|
136
|
-
"description": "Python information",
|
137
|
-
"properties": {
|
138
|
-
"version": {"type": "string"},
|
139
|
-
"implementation": {"type": "string"},
|
140
|
-
"executable": {"type": "string"},
|
141
|
-
"packages": {"type": "array"}
|
142
|
-
}
|
143
|
-
},
|
144
|
-
"network": {
|
145
|
-
"type": "object",
|
146
|
-
"description": "Network information",
|
147
|
-
"properties": {
|
148
|
-
"interfaces": {"type": "array"},
|
149
|
-
"connections": {"type": "integer"}
|
150
|
-
}
|
151
|
-
},
|
152
|
-
"time": {
|
153
|
-
"type": "object",
|
154
|
-
"description": "Time information",
|
155
|
-
"properties": {
|
156
|
-
"current": {"type": "string"},
|
157
|
-
"utc": {"type": "string"},
|
158
|
-
"timezone": {"type": "string"},
|
159
|
-
"timestamp": {"type": "number"}
|
160
|
-
}
|
161
|
-
}
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
|
166
|
-
class SystemInfoCommand(Command):
|
167
|
-
"""
|
168
|
-
Command that returns detailed system information.
|
169
|
-
|
170
|
-
This command demonstrates gathering and formatting complex system data.
|
171
|
-
"""
|
172
|
-
|
173
|
-
name = "system_info"
|
174
|
-
result_class = SystemInfoResult
|
175
|
-
|
176
|
-
async def execute(
|
177
|
-
self,
|
178
|
-
include_python_packages: bool = False,
|
179
|
-
include_network_interfaces: bool = True
|
180
|
-
) -> SystemInfoResult:
|
181
|
-
"""
|
182
|
-
Execute command.
|
183
|
-
|
184
|
-
Args:
|
185
|
-
include_python_packages: Whether to include installed Python packages
|
186
|
-
include_network_interfaces: Whether to include network interfaces
|
187
|
-
|
188
|
-
Returns:
|
189
|
-
System information result
|
190
|
-
"""
|
191
|
-
# Gather system information
|
192
|
-
system_info = {
|
193
|
-
"platform": platform.platform(),
|
194
|
-
"system": platform.system(),
|
195
|
-
"node": platform.node(),
|
196
|
-
"release": platform.release(),
|
197
|
-
"version": platform.version(),
|
198
|
-
"machine": platform.machine(),
|
199
|
-
"processor": platform.processor(),
|
200
|
-
"uptime": psutil.boot_time()
|
201
|
-
}
|
202
|
-
|
203
|
-
# CPU information
|
204
|
-
cpu_info = {
|
205
|
-
"count_physical": psutil.cpu_count(logical=False),
|
206
|
-
"count_logical": psutil.cpu_count(logical=True),
|
207
|
-
"usage_percent": psutil.cpu_percent(interval=0.1),
|
208
|
-
"frequency": {
|
209
|
-
"current": psutil.cpu_freq().current if psutil.cpu_freq() else 0,
|
210
|
-
"min": psutil.cpu_freq().min if psutil.cpu_freq() and psutil.cpu_freq().min else 0,
|
211
|
-
"max": psutil.cpu_freq().max if psutil.cpu_freq() and psutil.cpu_freq().max else 0
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
# Memory information
|
216
|
-
memory = psutil.virtual_memory()
|
217
|
-
memory_info = {
|
218
|
-
"total": memory.total,
|
219
|
-
"available": memory.available,
|
220
|
-
"used": memory.used,
|
221
|
-
"percent": memory.percent
|
222
|
-
}
|
223
|
-
|
224
|
-
# Disk information
|
225
|
-
disk_info = {
|
226
|
-
"partitions": [],
|
227
|
-
"usage": {}
|
228
|
-
}
|
229
|
-
|
230
|
-
for partition in psutil.disk_partitions():
|
231
|
-
try:
|
232
|
-
usage = psutil.disk_usage(partition.mountpoint)
|
233
|
-
disk_info["partitions"].append({
|
234
|
-
"device": partition.device,
|
235
|
-
"mountpoint": partition.mountpoint,
|
236
|
-
"fstype": partition.fstype,
|
237
|
-
"opts": partition.opts
|
238
|
-
})
|
239
|
-
disk_info["usage"][partition.mountpoint] = {
|
240
|
-
"total": usage.total,
|
241
|
-
"used": usage.used,
|
242
|
-
"free": usage.free,
|
243
|
-
"percent": usage.percent
|
244
|
-
}
|
245
|
-
except (PermissionError, FileNotFoundError):
|
246
|
-
# Some mountpoints may not be accessible
|
247
|
-
pass
|
248
|
-
|
249
|
-
# Python information
|
250
|
-
python_info = {
|
251
|
-
"version": platform.python_version(),
|
252
|
-
"implementation": platform.python_implementation(),
|
253
|
-
"executable": sys.executable,
|
254
|
-
"packages": []
|
255
|
-
}
|
256
|
-
|
257
|
-
if include_python_packages:
|
258
|
-
try:
|
259
|
-
import pkg_resources
|
260
|
-
python_info["packages"] = [
|
261
|
-
{"name": pkg.key, "version": pkg.version}
|
262
|
-
for pkg in pkg_resources.working_set
|
263
|
-
]
|
264
|
-
except ImportError:
|
265
|
-
pass
|
266
|
-
|
267
|
-
# Network information
|
268
|
-
network_info = {
|
269
|
-
"interfaces": [],
|
270
|
-
"connections": len(psutil.net_connections())
|
271
|
-
}
|
272
|
-
|
273
|
-
if include_network_interfaces:
|
274
|
-
for interface, addresses in psutil.net_if_addrs().items():
|
275
|
-
for address in addresses:
|
276
|
-
if address.family == socket.AF_INET: # IPv4
|
277
|
-
network_info["interfaces"].append({
|
278
|
-
"interface": interface,
|
279
|
-
"address": address.address,
|
280
|
-
"netmask": address.netmask,
|
281
|
-
"broadcast": address.broadcast
|
282
|
-
})
|
283
|
-
|
284
|
-
# Time information
|
285
|
-
now = datetime.datetime.now()
|
286
|
-
utc_now = datetime.datetime.now(pytz.UTC)
|
287
|
-
|
288
|
-
time_info = {
|
289
|
-
"current": now.isoformat(),
|
290
|
-
"utc": utc_now.isoformat(),
|
291
|
-
"timezone": str(datetime.datetime.now().astimezone().tzinfo),
|
292
|
-
"timestamp": now.timestamp()
|
293
|
-
}
|
294
|
-
|
295
|
-
return SystemInfoResult(
|
296
|
-
system=system_info,
|
297
|
-
cpu=cpu_info,
|
298
|
-
memory=memory_info,
|
299
|
-
disk=disk_info,
|
300
|
-
python=python_info,
|
301
|
-
network=network_info,
|
302
|
-
time=time_info
|
303
|
-
)
|
304
|
-
|
305
|
-
@classmethod
|
306
|
-
def get_schema(cls) -> Dict[str, Any]:
|
307
|
-
"""
|
308
|
-
Get JSON schema for command parameters.
|
309
|
-
|
310
|
-
Returns:
|
311
|
-
JSON schema
|
312
|
-
"""
|
313
|
-
return {
|
314
|
-
"type": "object",
|
315
|
-
"properties": {
|
316
|
-
"include_python_packages": {
|
317
|
-
"type": "boolean",
|
318
|
-
"description": "Whether to include installed Python packages",
|
319
|
-
"default": False
|
320
|
-
},
|
321
|
-
"include_network_interfaces": {
|
322
|
-
"type": "boolean",
|
323
|
-
"description": "Whether to include network interfaces",
|
324
|
-
"default": True
|
325
|
-
}
|
326
|
-
},
|
327
|
-
"additionalProperties": False
|
328
|
-
}
|
@@ -1,41 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"service": {
|
3
|
-
"name": "Complete Example",
|
4
|
-
"version": "1.0.0",
|
5
|
-
"description": "Полный пример MCP Proxy Adapter"
|
6
|
-
},
|
7
|
-
"server": {
|
8
|
-
"host": "0.0.0.0",
|
9
|
-
"port": 8000,
|
10
|
-
"debug": false,
|
11
|
-
"log_level": "info",
|
12
|
-
"workers": 4
|
13
|
-
},
|
14
|
-
"logging": {
|
15
|
-
"level": "INFO",
|
16
|
-
"file": "logs/complete_example.log",
|
17
|
-
"rotation": {
|
18
|
-
"type": "time",
|
19
|
-
"when": "D",
|
20
|
-
"interval": 1,
|
21
|
-
"backup_count": 30
|
22
|
-
}
|
23
|
-
},
|
24
|
-
"auth": {
|
25
|
-
"enabled": false,
|
26
|
-
"token_expiration": 3600,
|
27
|
-
"secret_key": "change_this_to_a_secure_key_in_production"
|
28
|
-
},
|
29
|
-
"database": {
|
30
|
-
"url": "sqlite:///./data/database.db",
|
31
|
-
"echo": false,
|
32
|
-
"pool_size": 5,
|
33
|
-
"max_overflow": 10
|
34
|
-
},
|
35
|
-
"cache": {
|
36
|
-
"enabled": true,
|
37
|
-
"ttl": 300,
|
38
|
-
"type": "memory",
|
39
|
-
"max_size": 1000
|
40
|
-
}
|
41
|
-
}
|