Peter Michael Gits commited on
Commit
795ea6f
·
1 Parent(s): 8caf3b5

2nd checkin

Browse files
Files changed (5) hide show
  1. .python-version +1 -0
  2. main.py +6 -0
  3. proxy_script.py +98 -0
  4. pyproject.toml +18 -0
  5. uv.lock +0 -0
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.13.5
main.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ def main():
2
+ print("Hello from docker-mcp-server!")
3
+
4
+
5
+ if __name__ == "__main__":
6
+ main()
proxy_script.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Local MCP proxy script for connecting Claude Desktop to remote HTTP MCP server
4
+ Save as: mcp_proxy.py
5
+ """
6
+
7
+ import asyncio
8
+ import json
9
+ import sys
10
+ import aiohttp
11
+ import logging
12
+
13
+ # Configure logging
14
+ logging.basicConfig(level=logging.INFO)
15
+ logger = logging.getLogger(__name__)
16
+
17
+ # Your Hugging Face Spaces MCP server URL
18
+ MCP_SERVER_URL = "https://pgits-docker-mcp-server.hf.space/mcp"
19
+
20
+ async def proxy_request(request_data):
21
+ """Proxy MCP request to HTTP server"""
22
+ try:
23
+ async with aiohttp.ClientSession() as session:
24
+ async with session.post(
25
+ MCP_SERVER_URL,
26
+ json=request_data,
27
+ headers={"Content-Type": "application/json"},
28
+ timeout=aiohttp.ClientTimeout(total=30)
29
+ ) as response:
30
+ if response.status == 200:
31
+ return await response.json()
32
+ else:
33
+ logger.error(f"HTTP error: {response.status}")
34
+ return {
35
+ "jsonrpc": "2.0",
36
+ "id": request_data.get("id"),
37
+ "error": {
38
+ "code": -32603,
39
+ "message": f"HTTP error: {response.status}"
40
+ }
41
+ }
42
+ except Exception as e:
43
+ logger.error(f"Request failed: {e}")
44
+ return {
45
+ "jsonrpc": "2.0",
46
+ "id": request_data.get("id"),
47
+ "error": {
48
+ "code": -32603,
49
+ "message": f"Connection error: {str(e)}"
50
+ }
51
+ }
52
+
53
+ async def main():
54
+ """Main proxy loop"""
55
+ logger.info(f"Starting MCP proxy for {MCP_SERVER_URL}")
56
+
57
+ try:
58
+ while True:
59
+ try:
60
+ # Read from stdin
61
+ line = await asyncio.get_event_loop().run_in_executor(
62
+ None, sys.stdin.readline
63
+ )
64
+
65
+ if not line:
66
+ break
67
+
68
+ # Parse JSON request
69
+ request_data = json.loads(line.strip())
70
+ logger.info(f"Proxying request: {request_data.get('method')}")
71
+
72
+ # Send to remote server
73
+ response = await proxy_request(request_data)
74
+
75
+ # Send response back
76
+ print(json.dumps(response))
77
+ sys.stdout.flush()
78
+
79
+ except json.JSONDecodeError as e:
80
+ logger.error(f"JSON decode error: {e}")
81
+ error_response = {
82
+ "jsonrpc": "2.0",
83
+ "id": None,
84
+ "error": {
85
+ "code": -32700,
86
+ "message": "Parse error"
87
+ }
88
+ }
89
+ print(json.dumps(error_response))
90
+ sys.stdout.flush()
91
+
92
+ except KeyboardInterrupt:
93
+ logger.info("Proxy shutting down")
94
+ except Exception as e:
95
+ logger.error(f"Proxy error: {e}")
96
+
97
+ if __name__ == "__main__":
98
+ asyncio.run(main())
pyproject.toml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "docker-mcp-server"
3
+ version = "0.1.0"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13.5"
7
+ dependencies = [
8
+ "aiohttp>=3.12.13",
9
+ "async>=0.6.2",
10
+ "fastapi>=0.104.1",
11
+ "httpx>=0.25.0",
12
+ "pydantic>=2.5.0",
13
+ "python-dotenv>=1.0.0",
14
+ "python-json-logger>=2.0.7",
15
+ "python-multipart>=0.0.6",
16
+ "requests>=2.31.0",
17
+ "uvicorn[standard]>=0.24.0",
18
+ ]
uv.lock ADDED
The diff for this file is too large to render. See raw diff