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
@@ -0,0 +1,176 @@
|
|
1
|
+
"""
|
2
|
+
Test Hooks Example
|
3
|
+
|
4
|
+
This script demonstrates the hooks system by making requests to the server
|
5
|
+
and showing how hooks process the commands.
|
6
|
+
"""
|
7
|
+
|
8
|
+
import requests
|
9
|
+
import json
|
10
|
+
import time
|
11
|
+
|
12
|
+
|
13
|
+
def test_echo_hooks():
|
14
|
+
"""Test echo command with hooks."""
|
15
|
+
print("\n🔔 Testing Echo Command with Hooks")
|
16
|
+
print("=" * 50)
|
17
|
+
|
18
|
+
# Test basic echo
|
19
|
+
response = requests.post(
|
20
|
+
"http://localhost:8000/cmd",
|
21
|
+
json={
|
22
|
+
"command": "echo",
|
23
|
+
"params": {"message": "Hello from hooks!"}
|
24
|
+
}
|
25
|
+
)
|
26
|
+
|
27
|
+
if response.status_code == 200:
|
28
|
+
result = response.json()
|
29
|
+
print("✅ Echo command executed successfully")
|
30
|
+
print(f"📤 Result: {json.dumps(result, indent=2)}")
|
31
|
+
else:
|
32
|
+
print(f"❌ Error: {response.status_code} - {response.text}")
|
33
|
+
|
34
|
+
|
35
|
+
def test_help_hooks():
|
36
|
+
"""Test help command with hooks."""
|
37
|
+
print("\n📖 Testing Help Command with Hooks")
|
38
|
+
print("=" * 50)
|
39
|
+
|
40
|
+
# Test help for all commands
|
41
|
+
response = requests.post(
|
42
|
+
"http://localhost:8000/cmd",
|
43
|
+
json={"command": "help"}
|
44
|
+
)
|
45
|
+
|
46
|
+
if response.status_code == 200:
|
47
|
+
result = response.json()
|
48
|
+
print("✅ Help command executed successfully")
|
49
|
+
print(f"📚 Total commands: {result.get('total', 0)}")
|
50
|
+
print(f"🔧 Custom features: {result.get('custom_features', {})}")
|
51
|
+
else:
|
52
|
+
print(f"❌ Error: {response.status_code} - {response.text}")
|
53
|
+
|
54
|
+
# Test help for specific command
|
55
|
+
response = requests.post(
|
56
|
+
"http://localhost:8000/cmd",
|
57
|
+
json={
|
58
|
+
"command": "help",
|
59
|
+
"params": {"cmdname": "echo"}
|
60
|
+
}
|
61
|
+
)
|
62
|
+
|
63
|
+
if response.status_code == 200:
|
64
|
+
result = response.json()
|
65
|
+
print("✅ Help for echo command executed successfully")
|
66
|
+
print(f"📖 Command info: {result.get('info', {}).get('description', 'N/A')}")
|
67
|
+
else:
|
68
|
+
print(f"❌ Error: {response.status_code} - {response.text}")
|
69
|
+
|
70
|
+
|
71
|
+
def test_health_hooks():
|
72
|
+
"""Test health command with hooks."""
|
73
|
+
print("\n🏥 Testing Health Command with Hooks")
|
74
|
+
print("=" * 50)
|
75
|
+
|
76
|
+
response = requests.post(
|
77
|
+
"http://localhost:8000/cmd",
|
78
|
+
json={"command": "health"}
|
79
|
+
)
|
80
|
+
|
81
|
+
if response.status_code == 200:
|
82
|
+
result = response.json()
|
83
|
+
print("✅ Health command executed successfully")
|
84
|
+
|
85
|
+
data = result.get("data", {})
|
86
|
+
print(f"🏥 Status: {data.get('status', 'unknown')}")
|
87
|
+
print(f"⏱️ Uptime: {data.get('uptime', 0):.2f}s")
|
88
|
+
|
89
|
+
custom_metrics = data.get("custom_metrics", {})
|
90
|
+
print(f"🔧 Hook enhanced: {custom_metrics.get('hook_enhanced', False)}")
|
91
|
+
print(f"🆔 Health check ID: {custom_metrics.get('health_check_id', 'N/A')}")
|
92
|
+
else:
|
93
|
+
print(f"❌ Error: {response.status_code} - {response.text}")
|
94
|
+
|
95
|
+
|
96
|
+
def test_security_hooks():
|
97
|
+
"""Test security hooks with sensitive data."""
|
98
|
+
print("\n🔒 Testing Security Hooks")
|
99
|
+
print("=" * 50)
|
100
|
+
|
101
|
+
# Test with sensitive parameter
|
102
|
+
response = requests.post(
|
103
|
+
"http://localhost:8000/cmd",
|
104
|
+
json={
|
105
|
+
"command": "echo",
|
106
|
+
"params": {
|
107
|
+
"message": "Test message",
|
108
|
+
"password": "secret123",
|
109
|
+
"api_token": "sensitive_data"
|
110
|
+
}
|
111
|
+
}
|
112
|
+
)
|
113
|
+
|
114
|
+
if response.status_code == 200:
|
115
|
+
result = response.json()
|
116
|
+
print("✅ Echo command with sensitive data executed")
|
117
|
+
print("🔒 Security hooks should have logged warnings")
|
118
|
+
else:
|
119
|
+
print(f"❌ Error: {response.status_code} - {response.text}")
|
120
|
+
|
121
|
+
|
122
|
+
def test_performance_hooks():
|
123
|
+
"""Test performance hooks with slow operation simulation."""
|
124
|
+
print("\n⏱️ Testing Performance Hooks")
|
125
|
+
print("=" * 50)
|
126
|
+
|
127
|
+
# Test with a command that might be slow
|
128
|
+
response = requests.post(
|
129
|
+
"http://localhost:8000/cmd",
|
130
|
+
json={
|
131
|
+
"command": "health",
|
132
|
+
"params": {}
|
133
|
+
}
|
134
|
+
)
|
135
|
+
|
136
|
+
if response.status_code == 200:
|
137
|
+
result = response.json()
|
138
|
+
print("✅ Health command executed")
|
139
|
+
print("⏱️ Performance hooks should have logged execution time")
|
140
|
+
else:
|
141
|
+
print(f"❌ Error: {response.status_code} - {response.text}")
|
142
|
+
|
143
|
+
|
144
|
+
def main():
|
145
|
+
"""Run all hook tests."""
|
146
|
+
print("🧪 Testing Custom Commands with Hooks")
|
147
|
+
print("=" * 60)
|
148
|
+
print("Make sure the server is running on http://localhost:8000")
|
149
|
+
print("Check the server logs to see hook activity")
|
150
|
+
print("=" * 60)
|
151
|
+
|
152
|
+
# Wait a moment for server to be ready
|
153
|
+
time.sleep(1)
|
154
|
+
|
155
|
+
try:
|
156
|
+
test_echo_hooks()
|
157
|
+
test_help_hooks()
|
158
|
+
test_health_hooks()
|
159
|
+
test_security_hooks()
|
160
|
+
test_performance_hooks()
|
161
|
+
|
162
|
+
print("\n✅ All tests completed!")
|
163
|
+
print("📋 Check the server logs to see hook activity:")
|
164
|
+
print(" - Command-specific hooks")
|
165
|
+
print(" - Global hooks")
|
166
|
+
print(" - Performance monitoring")
|
167
|
+
print(" - Security monitoring")
|
168
|
+
|
169
|
+
except requests.exceptions.ConnectionError:
|
170
|
+
print("❌ Could not connect to server. Make sure it's running on http://localhost:8000")
|
171
|
+
except Exception as e:
|
172
|
+
print(f"❌ Error during testing: {e}")
|
173
|
+
|
174
|
+
|
175
|
+
if __name__ == "__main__":
|
176
|
+
main()
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Deployment Examples
|
2
|
+
|
3
|
+
This directory contains deployment examples for the MCP Proxy Adapter framework.
|
4
|
+
|
5
|
+
## Files
|
6
|
+
|
7
|
+
### Docker Deployment
|
8
|
+
- `Dockerfile` - Docker image configuration for the framework
|
9
|
+
- `docker-compose.yml` - Docker Compose configuration for easy deployment
|
10
|
+
- `run_docker.sh` - Script to run the application in Docker
|
11
|
+
|
12
|
+
### Local Deployment
|
13
|
+
- `run.sh` - Script to run the application locally
|
14
|
+
|
15
|
+
### Configuration Files
|
16
|
+
- `config.json` - Default configuration file
|
17
|
+
- `config.development.json` - Development environment configuration
|
18
|
+
- `config.staging.json` - Staging environment configuration
|
19
|
+
- `config.production.json` - Production environment configuration
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Local Development
|
24
|
+
```bash
|
25
|
+
./run.sh
|
26
|
+
```
|
27
|
+
|
28
|
+
### Docker Deployment
|
29
|
+
```bash
|
30
|
+
./run_docker.sh
|
31
|
+
```
|
32
|
+
|
33
|
+
### Docker Compose
|
34
|
+
```bash
|
35
|
+
docker-compose up -d
|
36
|
+
```
|
37
|
+
|
38
|
+
## Configuration
|
39
|
+
|
40
|
+
Copy the appropriate configuration file to your project root:
|
41
|
+
```bash
|
42
|
+
cp config.development.json config.json
|
43
|
+
```
|
44
|
+
|
45
|
+
## Notes
|
46
|
+
|
47
|
+
- These are example configurations and should be customized for your specific use case
|
48
|
+
- The framework itself is designed to be used as a library, not as a standalone application
|
49
|
+
- Modify the configuration files according to your deployment requirements
|
@@ -1,25 +1,29 @@
|
|
1
1
|
{
|
2
|
-
"service": {
|
3
|
-
"name": "Basic Example",
|
4
|
-
"version": "1.0.0"
|
5
|
-
},
|
6
2
|
"server": {
|
7
3
|
"host": "0.0.0.0",
|
8
4
|
"port": 8000,
|
9
|
-
"debug":
|
5
|
+
"debug": false,
|
10
6
|
"log_level": "info"
|
11
7
|
},
|
12
8
|
"logging": {
|
13
9
|
"level": "INFO",
|
14
|
-
"file": "
|
10
|
+
"file": "adapter.log",
|
15
11
|
"rotation": {
|
16
12
|
"type": "size",
|
17
13
|
"max_bytes": 10485760,
|
18
14
|
"backup_count": 5
|
19
15
|
}
|
20
16
|
},
|
17
|
+
"service": {
|
18
|
+
"name": "MCP Proxy Adapter",
|
19
|
+
"version": "1.0.0"
|
20
|
+
},
|
21
21
|
"discovery": {
|
22
22
|
"enabled": true,
|
23
23
|
"package": "commands"
|
24
|
+
},
|
25
|
+
"docker": {
|
26
|
+
"container_name": "mcp-proxy-adapter",
|
27
|
+
"network": "default"
|
24
28
|
}
|
25
|
-
}
|
29
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"host": "0.0.0.0",
|
3
|
+
"port": 8000,
|
4
|
+
"log_level": "WARNING",
|
5
|
+
"log_file": "logs/mcp_proxy.log",
|
6
|
+
"log_rotation_type": "time",
|
7
|
+
"log_rotation_when": "D",
|
8
|
+
"log_rotation_interval": 1,
|
9
|
+
"log_rotation_backup_count": 30,
|
10
|
+
"cors_origins": ["https://example.com"],
|
11
|
+
"api_keys": ["${API_KEY}"]
|
12
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{
|
2
|
+
"host": "0.0.0.0",
|
3
|
+
"port": 8000,
|
4
|
+
"log_level": "INFO",
|
5
|
+
"log_file": "logs/mcp_proxy.log",
|
6
|
+
"log_rotation_type": "size",
|
7
|
+
"log_max_bytes": 10485760,
|
8
|
+
"log_backup_count": 5,
|
9
|
+
"cors_origins": ["https://staging.example.com"],
|
10
|
+
"api_keys": ["staging-api-key"]
|
11
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
version: '3.8'
|
2
|
+
|
3
|
+
# Variables for docker-compose
|
4
|
+
x-environment: &default-env
|
5
|
+
- CONFIG_PATH=/app/config.json
|
6
|
+
- LOG_LEVEL=INFO
|
7
|
+
|
8
|
+
x-volume-mounts: &default-mounts
|
9
|
+
- ./config.json:/app/config.json:ro
|
10
|
+
- ./logs:/app/logs:rw
|
11
|
+
- ./data:/app/data:rw
|
12
|
+
- ./cache:/app/cache:rw
|
13
|
+
|
14
|
+
services:
|
15
|
+
mcp-proxy-adapter:
|
16
|
+
container_name: ${CONTAINER_NAME:-mcp-proxy-adapter}
|
17
|
+
build:
|
18
|
+
context: ../../
|
19
|
+
dockerfile: mcp_proxy_adapter/examples/deployment/Dockerfile
|
20
|
+
ports:
|
21
|
+
- "127.0.0.1:${HOST_PORT:-8000}:${SERVICE_PORT:-8000}"
|
22
|
+
volumes: *default-mounts
|
23
|
+
environment: *default-env
|
24
|
+
restart: unless-stopped
|
25
|
+
user: "${USER_ID:-1000}:${GROUP_ID:-1000}"
|
26
|
+
networks:
|
27
|
+
- default
|
28
|
+
|
29
|
+
networks:
|
30
|
+
default:
|
31
|
+
driver: bridge
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# MCP Proxy Adapter - Local Development Script
|
4
|
+
# This script runs the framework locally for development
|
5
|
+
|
6
|
+
# Variables
|
7
|
+
HOST_PORT=${HOST_PORT:-8000}
|
8
|
+
CONFIG_PATH=${CONFIG_PATH:-"config.json"}
|
9
|
+
LOG_LEVEL=${LOG_LEVEL:-"INFO"}
|
10
|
+
|
11
|
+
# Get the project root directory (3 levels up from this script)
|
12
|
+
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
13
|
+
|
14
|
+
echo "Starting MCP Proxy Adapter locally..."
|
15
|
+
echo "Project root: $PROJECT_ROOT"
|
16
|
+
echo "Config path: $CONFIG_PATH"
|
17
|
+
echo "Port: $HOST_PORT"
|
18
|
+
|
19
|
+
# Activate virtual environment if it exists
|
20
|
+
if [ -d "$PROJECT_ROOT/.venv" ]; then
|
21
|
+
echo "Activating virtual environment..."
|
22
|
+
source "$PROJECT_ROOT/.venv/bin/activate"
|
23
|
+
fi
|
24
|
+
|
25
|
+
# Install dependencies if needed
|
26
|
+
if [ ! -d "$PROJECT_ROOT/.venv" ]; then
|
27
|
+
echo "Creating virtual environment..."
|
28
|
+
python3 -m venv "$PROJECT_ROOT/.venv"
|
29
|
+
source "$PROJECT_ROOT/.venv/bin/activate"
|
30
|
+
pip install -r "$PROJECT_ROOT/requirements.txt"
|
31
|
+
fi
|
32
|
+
|
33
|
+
# Copy config file if it doesn't exist
|
34
|
+
if [ ! -f "$PROJECT_ROOT/config.json" ]; then
|
35
|
+
echo "Copying default config..."
|
36
|
+
cp "$(dirname "${BASH_SOURCE[0]}")/config.json" "$PROJECT_ROOT/config.json"
|
37
|
+
fi
|
38
|
+
|
39
|
+
# Run the application
|
40
|
+
cd "$PROJECT_ROOT"
|
41
|
+
python -m uvicorn mcp_proxy_adapter.api.app:create_app --host 0.0.0.0 --port $HOST_PORT --reload
|
42
|
+
|
43
|
+
echo "MCP Proxy Adapter started on http://localhost:$HOST_PORT"
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# MCP Proxy Adapter - Docker Deployment Script
|
4
|
+
# This script runs the framework in Docker
|
5
|
+
|
6
|
+
# Function to extract value from JSON config
|
7
|
+
function get_json_value {
|
8
|
+
local json_file=$1
|
9
|
+
local json_path=$2
|
10
|
+
|
11
|
+
python3 -c "
|
12
|
+
import json
|
13
|
+
with open('$json_file', 'r') as f:
|
14
|
+
config = json.load(f)
|
15
|
+
path = '$json_path'.split('.')
|
16
|
+
result = config
|
17
|
+
for key in path:
|
18
|
+
result = result.get(key, {})
|
19
|
+
print(result)
|
20
|
+
"
|
21
|
+
}
|
22
|
+
|
23
|
+
# Get project root directory
|
24
|
+
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)"
|
25
|
+
CONFIG_FILE="$PROJECT_ROOT/config.json"
|
26
|
+
|
27
|
+
# Check if config.json exists, copy from examples if not
|
28
|
+
if [ ! -f "$CONFIG_FILE" ]; then
|
29
|
+
echo "Config file not found, copying from examples..."
|
30
|
+
cp "$(dirname "${BASH_SOURCE[0]}")/config.json" "$CONFIG_FILE"
|
31
|
+
fi
|
32
|
+
|
33
|
+
# Create necessary directories
|
34
|
+
mkdir -p "$PROJECT_ROOT/logs" "$PROJECT_ROOT/data" "$PROJECT_ROOT/cache"
|
35
|
+
|
36
|
+
# Extract values from configuration
|
37
|
+
CONTAINER_NAME=$(get_json_value "$CONFIG_FILE" "docker.container_name")
|
38
|
+
SERVICE_PORT=$(get_json_value "$CONFIG_FILE" "server.port")
|
39
|
+
USER_ID=$(id -u)
|
40
|
+
GROUP_ID=$(id -g)
|
41
|
+
|
42
|
+
# Use default values if not defined in config
|
43
|
+
CONTAINER_NAME=${CONTAINER_NAME:-mcp-proxy-adapter}
|
44
|
+
SERVICE_PORT=${SERVICE_PORT:-8000}
|
45
|
+
HOST_PORT=${SERVICE_PORT}
|
46
|
+
|
47
|
+
echo "Using configuration:"
|
48
|
+
echo " Container name: $CONTAINER_NAME"
|
49
|
+
echo " Port mapping: 127.0.0.1:$HOST_PORT -> $SERVICE_PORT"
|
50
|
+
echo " User/Group: $USER_ID:$GROUP_ID"
|
51
|
+
|
52
|
+
# Export variables for docker-compose
|
53
|
+
export CONTAINER_NAME=$CONTAINER_NAME
|
54
|
+
export SERVICE_PORT=$SERVICE_PORT
|
55
|
+
export HOST_PORT=$HOST_PORT
|
56
|
+
export USER_ID=$USER_ID
|
57
|
+
export GROUP_ID=$GROUP_ID
|
58
|
+
|
59
|
+
# Stop container if it already exists
|
60
|
+
docker-compose -f "$(dirname "${BASH_SOURCE[0]}")/docker-compose.yml" down
|
61
|
+
|
62
|
+
# Start container
|
63
|
+
docker-compose -f "$(dirname "${BASH_SOURCE[0]}")/docker-compose.yml" up -d
|
64
|
+
|
65
|
+
# Check if we need to connect to additional network
|
66
|
+
NETWORK=$(get_json_value "$CONFIG_FILE" "docker.network")
|
67
|
+
if [ ! -z "$NETWORK" ] && [ "$NETWORK" != "{}" ]; then
|
68
|
+
echo "Connecting to network: $NETWORK"
|
69
|
+
# Check if network exists
|
70
|
+
if docker network inspect "$NETWORK" &>/dev/null; then
|
71
|
+
# Connect container to network if not already connected
|
72
|
+
if ! docker network inspect "$NETWORK" | grep -q "$CONTAINER_NAME"; then
|
73
|
+
docker network connect "$NETWORK" "$CONTAINER_NAME"
|
74
|
+
echo "Container connected to network: $NETWORK"
|
75
|
+
else
|
76
|
+
echo "Container already connected to network: $NETWORK"
|
77
|
+
fi
|
78
|
+
else
|
79
|
+
echo "Warning: Network $NETWORK does not exist"
|
80
|
+
fi
|
81
|
+
fi
|
82
|
+
|
83
|
+
echo "Container started. Use the following command to check logs:"
|
84
|
+
echo " docker logs $CONTAINER_NAME"
|
mcp_proxy_adapter/openapi.py
CHANGED
@@ -7,8 +7,9 @@ import inspect
|
|
7
7
|
import json
|
8
8
|
from pathlib import Path
|
9
9
|
|
10
|
-
from .
|
11
|
-
from .
|
10
|
+
from .commands.command_registry import CommandRegistry
|
11
|
+
from .commands.base import Command
|
12
|
+
from .core.errors import ValidationError as SchemaValidationError
|
12
13
|
|
13
14
|
|
14
15
|
@dataclass
|