mcp-proxy-adapter 2.1.17__py3-none-any.whl → 3.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. examples/__init__.py +19 -0
  2. examples/anti_patterns/README.md +51 -0
  3. examples/anti_patterns/__init__.py +9 -0
  4. examples/anti_patterns/bad_design/README.md +72 -0
  5. examples/anti_patterns/bad_design/global_state.py +170 -0
  6. examples/anti_patterns/bad_design/monolithic_command.py +272 -0
  7. examples/basic_example/README.md +131 -0
  8. examples/basic_example/__init__.py +8 -0
  9. examples/basic_example/commands/__init__.py +5 -0
  10. examples/basic_example/commands/echo_command.py +95 -0
  11. examples/basic_example/commands/math_command.py +151 -0
  12. examples/basic_example/commands/time_command.py +152 -0
  13. examples/basic_example/config.json +21 -0
  14. examples/basic_example/config.yaml +20 -0
  15. examples/basic_example/docs/EN/README.md +136 -0
  16. examples/basic_example/docs/RU/README.md +136 -0
  17. examples/basic_example/main.py +50 -0
  18. examples/basic_example/server.py +45 -0
  19. examples/basic_example/tests/conftest.py +243 -0
  20. examples/commands/echo_command.py +52 -0
  21. examples/commands/echo_result.py +65 -0
  22. examples/commands/get_date_command.py +98 -0
  23. examples/commands/new_uuid4_command.py +91 -0
  24. examples/complete_example/Dockerfile +24 -0
  25. examples/complete_example/README.md +92 -0
  26. examples/complete_example/__init__.py +8 -0
  27. examples/complete_example/commands/__init__.py +5 -0
  28. examples/complete_example/commands/system_command.py +327 -0
  29. examples/complete_example/config.json +41 -0
  30. examples/complete_example/configs/config.dev.yaml +40 -0
  31. examples/complete_example/configs/config.docker.yaml +40 -0
  32. examples/complete_example/docker-compose.yml +35 -0
  33. examples/complete_example/main.py +67 -0
  34. examples/complete_example/requirements.txt +20 -0
  35. examples/complete_example/server.py +85 -0
  36. examples/minimal_example/README.md +51 -0
  37. examples/minimal_example/__init__.py +8 -0
  38. examples/minimal_example/config.json +21 -0
  39. examples/minimal_example/config.yaml +26 -0
  40. examples/minimal_example/main.py +67 -0
  41. examples/minimal_example/simple_server.py +124 -0
  42. examples/minimal_example/tests/conftest.py +171 -0
  43. examples/minimal_example/tests/test_hello_command.py +111 -0
  44. examples/minimal_example/tests/test_integration.py +183 -0
  45. examples/server.py +69 -0
  46. examples/simple_server.py +137 -0
  47. examples/test_server.py +126 -0
  48. mcp_proxy_adapter/__init__.py +33 -1
  49. mcp_proxy_adapter/config.py +186 -0
  50. mcp_proxy_adapter/custom_openapi.py +125 -0
  51. mcp_proxy_adapter/framework.py +109 -0
  52. mcp_proxy_adapter/openapi.py +403 -0
  53. mcp_proxy_adapter/version.py +3 -0
  54. mcp_proxy_adapter-3.0.0.dist-info/METADATA +200 -0
  55. mcp_proxy_adapter-3.0.0.dist-info/RECORD +58 -0
  56. {mcp_proxy_adapter-2.1.17.dist-info → mcp_proxy_adapter-3.0.0.dist-info}/top_level.txt +1 -0
  57. mcp_proxy_adapter/adapter.py +0 -697
  58. mcp_proxy_adapter/analyzers/__init__.py +0 -1
  59. mcp_proxy_adapter/analyzers/docstring_analyzer.py +0 -199
  60. mcp_proxy_adapter/analyzers/type_analyzer.py +0 -151
  61. mcp_proxy_adapter/dispatchers/__init__.py +0 -1
  62. mcp_proxy_adapter/dispatchers/base_dispatcher.py +0 -85
  63. mcp_proxy_adapter/dispatchers/json_rpc_dispatcher.py +0 -262
  64. mcp_proxy_adapter/examples/analyze_config.py +0 -141
  65. mcp_proxy_adapter/examples/basic_integration.py +0 -155
  66. mcp_proxy_adapter/examples/docstring_and_schema_example.py +0 -69
  67. mcp_proxy_adapter/examples/extension_example.py +0 -72
  68. mcp_proxy_adapter/examples/help_best_practices.py +0 -67
  69. mcp_proxy_adapter/examples/help_usage.py +0 -64
  70. mcp_proxy_adapter/examples/mcp_proxy_client.py +0 -131
  71. mcp_proxy_adapter/examples/openapi_server.py +0 -383
  72. mcp_proxy_adapter/examples/project_structure_example.py +0 -47
  73. mcp_proxy_adapter/examples/testing_example.py +0 -64
  74. mcp_proxy_adapter/models.py +0 -47
  75. mcp_proxy_adapter/registry.py +0 -439
  76. mcp_proxy_adapter/schema.py +0 -257
  77. mcp_proxy_adapter/testing_utils.py +0 -112
  78. mcp_proxy_adapter/validators/__init__.py +0 -1
  79. mcp_proxy_adapter/validators/docstring_validator.py +0 -75
  80. mcp_proxy_adapter/validators/metadata_validator.py +0 -76
  81. mcp_proxy_adapter-2.1.17.dist-info/METADATA +0 -376
  82. mcp_proxy_adapter-2.1.17.dist-info/RECORD +0 -30
  83. {mcp_proxy_adapter-2.1.17.dist-info → mcp_proxy_adapter-3.0.0.dist-info}/WHEEL +0 -0
  84. {mcp_proxy_adapter-2.1.17.dist-info → mcp_proxy_adapter-3.0.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,65 @@
1
+ """
2
+ Module with result class for echo command.
3
+ """
4
+
5
+ from typing import Any, Dict, ClassVar, Type
6
+ from pydantic import BaseModel, Field
7
+
8
+ from mcp_proxy_adapter.commands.result import CommandResult
9
+
10
+
11
+ class EchoResult(CommandResult, BaseModel):
12
+ """
13
+ Result of echo command execution.
14
+
15
+ Attributes:
16
+ params (Dict[str, Any]): Parameters that were passed to the command.
17
+ """
18
+
19
+ params: Dict[str, Any] = Field(..., description="Parameters that were passed to the command")
20
+
21
+ def to_dict(self) -> Dict[str, Any]:
22
+ """
23
+ Converts result to dictionary for serialization.
24
+
25
+ Returns:
26
+ Dictionary with result data.
27
+ """
28
+ return {
29
+ "params": self.params
30
+ }
31
+
32
+ @classmethod
33
+ def get_schema(cls) -> Dict[str, Any]:
34
+ """
35
+ Returns JSON schema for result validation.
36
+
37
+ Returns:
38
+ Dictionary with JSON schema.
39
+ """
40
+ return {
41
+ "type": "object",
42
+ "properties": {
43
+ "params": {
44
+ "type": "object",
45
+ "description": "Parameters that were passed to the command",
46
+ "additionalProperties": True
47
+ }
48
+ },
49
+ "required": ["params"]
50
+ }
51
+
52
+ @classmethod
53
+ def from_dict(cls, data: Dict[str, Any]) -> "EchoResult":
54
+ """
55
+ Creates result instance from dictionary.
56
+
57
+ Args:
58
+ data: Dictionary with result data.
59
+
60
+ Returns:
61
+ EchoResult instance.
62
+ """
63
+ return cls(
64
+ params=data.get("params", {})
65
+ )
@@ -0,0 +1,98 @@
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)
@@ -0,0 +1,91 @@
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)
@@ -0,0 +1,24 @@
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"]
@@ -0,0 +1,92 @@
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.
@@ -0,0 +1,8 @@
1
+ """
2
+ Complete example for MCP Microservice.
3
+
4
+ This package contains a complete example of using MCP Microservice framework
5
+ with Docker support, multiple commands, configuration management, and tests.
6
+ """
7
+
8
+ __all__ = []
@@ -0,0 +1,5 @@
1
+ """
2
+ Command package for complete example.
3
+
4
+ This package contains all commands for the complete microservice example.
5
+ """