iflow-mcp_chuckwilliams37-mcp-server-docker 0.1.0__tar.gz
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.
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/.env.example +16 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/.gitignore +1 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/3167_process.log +4 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/Dockerfile +24 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/PKG-INFO +192 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/README.md +177 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/app/app.py +136 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/docker-compose.yml +32 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/language.json +1 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/package_name +1 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/push_info.json +5 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/pyproject.toml +28 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/requirements.txt +8 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/scripts/bootstrap-mcp.sh +78 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/scripts/full-bootstrap-mcp.sh +132 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/scripts/init-repo.sh +54 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/scripts/push-repo.sh +47 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/scripts/setup-mcpserver.sh +90 -0
- iflow_mcp_chuckwilliams37_mcp_server_docker-0.1.0/setup-mcp001.sh +43 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# === MCP Server Environment Variables ===
|
|
2
|
+
|
|
3
|
+
# Redis
|
|
4
|
+
REDIS_HOST=redis
|
|
5
|
+
REDIS_PORT=6379
|
|
6
|
+
|
|
7
|
+
# Postgres / TimescaleDB
|
|
8
|
+
PG_HOST=timescaledb
|
|
9
|
+
PG_PORT=5432
|
|
10
|
+
PG_DB=mcpdb
|
|
11
|
+
PG_USER=mcpuser
|
|
12
|
+
PG_PASSWORD=example
|
|
13
|
+
|
|
14
|
+
# Server Settings
|
|
15
|
+
MCP_SERVER_PORT=8080
|
|
16
|
+
LOG_LEVEL=info
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.env
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Base image
|
|
2
|
+
FROM python:3.11-slim
|
|
3
|
+
|
|
4
|
+
# Set environment variables
|
|
5
|
+
ENV VIRTUAL_ENV=/opt/venv
|
|
6
|
+
RUN python3 -m venv $VIRTUAL_ENV
|
|
7
|
+
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
8
|
+
|
|
9
|
+
# Install dependencies
|
|
10
|
+
RUN apt-get update && apt-get install -y build-essential git curl wget vim netcat-openbsd && rm -rf /var/lib/apt/lists/*
|
|
11
|
+
|
|
12
|
+
# Install Python dependencies
|
|
13
|
+
COPY requirements.txt .
|
|
14
|
+
RUN pip install --upgrade pip && pip install -r requirements.txt
|
|
15
|
+
|
|
16
|
+
# Copy application files
|
|
17
|
+
COPY ./app /app
|
|
18
|
+
WORKDIR /app
|
|
19
|
+
|
|
20
|
+
# Expose port
|
|
21
|
+
EXPOSE 8080
|
|
22
|
+
|
|
23
|
+
# Run the MCP server
|
|
24
|
+
CMD ["python", "app.py"]
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: iflow-mcp_chuckwilliams37-mcp-server-docker
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP Server with Docker, Redis, and TimescaleDB
|
|
5
|
+
Project-URL: Homepage, https://github.com/chuckwilliams37/mcp-server-docker
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Requires-Dist: fastapi
|
|
8
|
+
Requires-Dist: mcp
|
|
9
|
+
Requires-Dist: psycopg2-binary
|
|
10
|
+
Requires-Dist: python-dotenv
|
|
11
|
+
Requires-Dist: redis
|
|
12
|
+
Requires-Dist: torch
|
|
13
|
+
Requires-Dist: uvicorn[standard]
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# 🚀 MCP Server with Docker, Redis, and TimescaleDB
|
|
17
|
+
|
|
18
|
+
This repository sets up a **Model Context Protocol (MCP) Server** using Docker, integrating Redis and TimescaleDB for efficient data management.
|
|
19
|
+
|
|
20
|
+
## 🛠️ Features
|
|
21
|
+
|
|
22
|
+
- **FastAPI**: Serves as the web framework for the MCP server.
|
|
23
|
+
- **Redis**: Provides caching mechanisms.
|
|
24
|
+
- **TimescaleDB**: A time-series database built on PostgreSQL.
|
|
25
|
+
- **Docker Compose**: Orchestrates multi-container Docker applications.
|
|
26
|
+
- **Environment Variables**: Configurable via `.env` file.
|
|
27
|
+
- **Systemd Service**: Ensures the server auto-starts on reboot.
|
|
28
|
+
|
|
29
|
+
## 📋 Prerequisites
|
|
30
|
+
|
|
31
|
+
- **Docker** and **Docker Compose** installed on your system.
|
|
32
|
+
- **Git** for version control.
|
|
33
|
+
- **Zsh** with **Oh-My-Zsh** (optional, for enhanced shell experience).
|
|
34
|
+
|
|
35
|
+
## 📂 Repository Structure
|
|
36
|
+
|
|
37
|
+
```plaintext
|
|
38
|
+
mcp-server-docker/
|
|
39
|
+
├── app/
|
|
40
|
+
│ └── app.py
|
|
41
|
+
├── .env.example
|
|
42
|
+
├── docker-compose.yml
|
|
43
|
+
├── Dockerfile
|
|
44
|
+
├── requirements.txt
|
|
45
|
+
├── scripts/
|
|
46
|
+
│ ├── bootstrap-mcp.sh
|
|
47
|
+
│ ├── full-bootstrap-mcp.sh
|
|
48
|
+
│ ├── init-repo.sh
|
|
49
|
+
│ ├── push-repo.sh
|
|
50
|
+
│ └── setup-mcpserver.sh
|
|
51
|
+
└── README.md
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 🚀 Setup Instructions
|
|
55
|
+
|
|
56
|
+
1. **Clone the Repository**:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
git clone https://github.com/chuckwilliams37/mcp-server-docker.git
|
|
60
|
+
cd mcp-server-docker
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
2. **Configure Environment Variables**:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
cp .env.example .env
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Modify `.env` as needed.
|
|
70
|
+
|
|
71
|
+
3. **Build and Start the Containers**:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
docker compose build
|
|
75
|
+
docker compose up -d
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
4. **Access the MCP Server**:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
http://localhost:8080
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 🔄 Auto-Restart on Reboot
|
|
85
|
+
|
|
86
|
+
Create a systemd service to keep your app alive:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
sudo nano /etc/systemd/system/mcp-docker.service
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Paste:
|
|
93
|
+
|
|
94
|
+
```ini
|
|
95
|
+
[Unit]
|
|
96
|
+
Description=MCP Docker Compose App
|
|
97
|
+
Requires=docker.service
|
|
98
|
+
After=docker.service
|
|
99
|
+
|
|
100
|
+
[Service]
|
|
101
|
+
WorkingDirectory=/home/youruser/mcp-server-docker
|
|
102
|
+
ExecStart=/usr/bin/docker compose up -d
|
|
103
|
+
ExecStop=/usr/bin/docker compose down
|
|
104
|
+
Restart=always
|
|
105
|
+
TimeoutStartSec=0
|
|
106
|
+
|
|
107
|
+
[Install]
|
|
108
|
+
WantedBy=multi-user.target
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Enable it:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
sudo systemctl daemon-reload
|
|
115
|
+
sudo systemctl enable mcp-docker
|
|
116
|
+
sudo systemctl start mcp-docker
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 🧪 Scripts
|
|
122
|
+
|
|
123
|
+
The `scripts/` directory contains utility scripts to automate infrastructure tasks.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### 🛠️ `scripts/full-bootstrap-mcp.sh`
|
|
128
|
+
|
|
129
|
+
💡 **Use this on a fresh Ubuntu VM** to fully prepare it for MCP deployment. It:
|
|
130
|
+
|
|
131
|
+
- Installs system dependencies (Docker, Git, Zsh, UFW, Fail2Ban, etc.)
|
|
132
|
+
- Sets up `oh-my-zsh` with the `jonathan` theme
|
|
133
|
+
- Configures Remote Desktop with XFCE + XRDP
|
|
134
|
+
- Clones the MCP repo
|
|
135
|
+
- Builds and launches the app with `docker compose`
|
|
136
|
+
- Adds a systemd service to relaunch containers on reboot
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
chmod +x scripts/full-bootstrap-mcp.sh
|
|
140
|
+
./scripts/full-bootstrap-mcp.sh
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
### 📜 `scripts/init-repo.sh`
|
|
146
|
+
|
|
147
|
+
Initializes a new local Git repository and commits the current directory:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
chmod +x scripts/init-repo.sh
|
|
151
|
+
./scripts/init-repo.sh
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
### 📤 `scripts/push-repo.sh`
|
|
157
|
+
|
|
158
|
+
Pushes your local repo to a remote (update URL first):
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
chmod +x scripts/push-repo.sh
|
|
162
|
+
./scripts/push-repo.sh
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### 🧠 `scripts/setup-mcpserver.sh`
|
|
168
|
+
|
|
169
|
+
Configures your local SSH environment to access a remote MCP server:
|
|
170
|
+
|
|
171
|
+
- Pushes your public key
|
|
172
|
+
- Adds an SSH alias
|
|
173
|
+
- Prints a sample A-record
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
chmod +x scripts/setup-mcpserver.sh
|
|
177
|
+
./scripts/setup-mcpserver.sh
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
> ⚠️ Edit placeholder values (e.g., IPs, usernames, repo URLs) before executing.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## 🤝 Contributions
|
|
187
|
+
|
|
188
|
+
Feel free to fork this repository, submit issues, or create pull requests.
|
|
189
|
+
|
|
190
|
+
## 📄 License
|
|
191
|
+
|
|
192
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# 🚀 MCP Server with Docker, Redis, and TimescaleDB
|
|
2
|
+
|
|
3
|
+
This repository sets up a **Model Context Protocol (MCP) Server** using Docker, integrating Redis and TimescaleDB for efficient data management.
|
|
4
|
+
|
|
5
|
+
## 🛠️ Features
|
|
6
|
+
|
|
7
|
+
- **FastAPI**: Serves as the web framework for the MCP server.
|
|
8
|
+
- **Redis**: Provides caching mechanisms.
|
|
9
|
+
- **TimescaleDB**: A time-series database built on PostgreSQL.
|
|
10
|
+
- **Docker Compose**: Orchestrates multi-container Docker applications.
|
|
11
|
+
- **Environment Variables**: Configurable via `.env` file.
|
|
12
|
+
- **Systemd Service**: Ensures the server auto-starts on reboot.
|
|
13
|
+
|
|
14
|
+
## 📋 Prerequisites
|
|
15
|
+
|
|
16
|
+
- **Docker** and **Docker Compose** installed on your system.
|
|
17
|
+
- **Git** for version control.
|
|
18
|
+
- **Zsh** with **Oh-My-Zsh** (optional, for enhanced shell experience).
|
|
19
|
+
|
|
20
|
+
## 📂 Repository Structure
|
|
21
|
+
|
|
22
|
+
```plaintext
|
|
23
|
+
mcp-server-docker/
|
|
24
|
+
├── app/
|
|
25
|
+
│ └── app.py
|
|
26
|
+
├── .env.example
|
|
27
|
+
├── docker-compose.yml
|
|
28
|
+
├── Dockerfile
|
|
29
|
+
├── requirements.txt
|
|
30
|
+
├── scripts/
|
|
31
|
+
│ ├── bootstrap-mcp.sh
|
|
32
|
+
│ ├── full-bootstrap-mcp.sh
|
|
33
|
+
│ ├── init-repo.sh
|
|
34
|
+
│ ├── push-repo.sh
|
|
35
|
+
│ └── setup-mcpserver.sh
|
|
36
|
+
└── README.md
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 🚀 Setup Instructions
|
|
40
|
+
|
|
41
|
+
1. **Clone the Repository**:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
git clone https://github.com/chuckwilliams37/mcp-server-docker.git
|
|
45
|
+
cd mcp-server-docker
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
2. **Configure Environment Variables**:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
cp .env.example .env
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Modify `.env` as needed.
|
|
55
|
+
|
|
56
|
+
3. **Build and Start the Containers**:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
docker compose build
|
|
60
|
+
docker compose up -d
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
4. **Access the MCP Server**:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
http://localhost:8080
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 🔄 Auto-Restart on Reboot
|
|
70
|
+
|
|
71
|
+
Create a systemd service to keep your app alive:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
sudo nano /etc/systemd/system/mcp-docker.service
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Paste:
|
|
78
|
+
|
|
79
|
+
```ini
|
|
80
|
+
[Unit]
|
|
81
|
+
Description=MCP Docker Compose App
|
|
82
|
+
Requires=docker.service
|
|
83
|
+
After=docker.service
|
|
84
|
+
|
|
85
|
+
[Service]
|
|
86
|
+
WorkingDirectory=/home/youruser/mcp-server-docker
|
|
87
|
+
ExecStart=/usr/bin/docker compose up -d
|
|
88
|
+
ExecStop=/usr/bin/docker compose down
|
|
89
|
+
Restart=always
|
|
90
|
+
TimeoutStartSec=0
|
|
91
|
+
|
|
92
|
+
[Install]
|
|
93
|
+
WantedBy=multi-user.target
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Enable it:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
sudo systemctl daemon-reload
|
|
100
|
+
sudo systemctl enable mcp-docker
|
|
101
|
+
sudo systemctl start mcp-docker
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 🧪 Scripts
|
|
107
|
+
|
|
108
|
+
The `scripts/` directory contains utility scripts to automate infrastructure tasks.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
### 🛠️ `scripts/full-bootstrap-mcp.sh`
|
|
113
|
+
|
|
114
|
+
💡 **Use this on a fresh Ubuntu VM** to fully prepare it for MCP deployment. It:
|
|
115
|
+
|
|
116
|
+
- Installs system dependencies (Docker, Git, Zsh, UFW, Fail2Ban, etc.)
|
|
117
|
+
- Sets up `oh-my-zsh` with the `jonathan` theme
|
|
118
|
+
- Configures Remote Desktop with XFCE + XRDP
|
|
119
|
+
- Clones the MCP repo
|
|
120
|
+
- Builds and launches the app with `docker compose`
|
|
121
|
+
- Adds a systemd service to relaunch containers on reboot
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
chmod +x scripts/full-bootstrap-mcp.sh
|
|
125
|
+
./scripts/full-bootstrap-mcp.sh
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
### 📜 `scripts/init-repo.sh`
|
|
131
|
+
|
|
132
|
+
Initializes a new local Git repository and commits the current directory:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
chmod +x scripts/init-repo.sh
|
|
136
|
+
./scripts/init-repo.sh
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
### 📤 `scripts/push-repo.sh`
|
|
142
|
+
|
|
143
|
+
Pushes your local repo to a remote (update URL first):
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
chmod +x scripts/push-repo.sh
|
|
147
|
+
./scripts/push-repo.sh
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### 🧠 `scripts/setup-mcpserver.sh`
|
|
153
|
+
|
|
154
|
+
Configures your local SSH environment to access a remote MCP server:
|
|
155
|
+
|
|
156
|
+
- Pushes your public key
|
|
157
|
+
- Adds an SSH alias
|
|
158
|
+
- Prints a sample A-record
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
chmod +x scripts/setup-mcpserver.sh
|
|
162
|
+
./scripts/setup-mcpserver.sh
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
> ⚠️ Edit placeholder values (e.g., IPs, usernames, repo URLs) before executing.
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 🤝 Contributions
|
|
172
|
+
|
|
173
|
+
Feel free to fork this repository, submit issues, or create pull requests.
|
|
174
|
+
|
|
175
|
+
## 📄 License
|
|
176
|
+
|
|
177
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
from mcp.server import Server
|
|
2
|
+
from mcp.types import Tool, TextContent, ServerCapabilities
|
|
3
|
+
from mcp.server.models import InitializationOptions
|
|
4
|
+
import redis
|
|
5
|
+
import os
|
|
6
|
+
from dotenv import load_dotenv
|
|
7
|
+
import asyncio
|
|
8
|
+
|
|
9
|
+
load_dotenv() # Load .env into environment
|
|
10
|
+
|
|
11
|
+
# Redis connection from env (optional for testing)
|
|
12
|
+
redis_client = None
|
|
13
|
+
try:
|
|
14
|
+
redis_host = os.getenv("REDIS_HOST", "localhost")
|
|
15
|
+
redis_port = int(os.getenv("REDIS_PORT", "6379"))
|
|
16
|
+
redis_client = redis.Redis(host=redis_host, port=redis_port, socket_connect_timeout=1)
|
|
17
|
+
redis_client.ping() # Test connection
|
|
18
|
+
except:
|
|
19
|
+
# Redis connection failed, but continue without it
|
|
20
|
+
redis_client = None
|
|
21
|
+
|
|
22
|
+
# Create MCP server
|
|
23
|
+
app = Server("mcp-server-docker", version="0.1.0")
|
|
24
|
+
|
|
25
|
+
@app.list_resources()
|
|
26
|
+
async def list_resources() -> list:
|
|
27
|
+
"""List available resources"""
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
"uri": "greeting://",
|
|
31
|
+
"name": "Greeting",
|
|
32
|
+
"description": "Get a personalized greeting",
|
|
33
|
+
"mimeType": "text/plain"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"uri": "data://item/",
|
|
37
|
+
"name": "Item",
|
|
38
|
+
"description": "Retrieve item details by ID",
|
|
39
|
+
"mimeType": "application/json"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
@app.read_resource()
|
|
44
|
+
async def read_resource(uri: str) -> str:
|
|
45
|
+
"""Read a resource by URI"""
|
|
46
|
+
if uri.startswith("greeting://"):
|
|
47
|
+
name = uri.replace("greeting://", "")
|
|
48
|
+
return f"Hello, {name}!"
|
|
49
|
+
elif uri.startswith("data://item/"):
|
|
50
|
+
item_id = uri.replace("data://item/", "")
|
|
51
|
+
return f'{{"id": {item_id}, "name": "Sample Item"}}'
|
|
52
|
+
else:
|
|
53
|
+
raise ValueError(f"Unknown resource: {uri}")
|
|
54
|
+
|
|
55
|
+
@app.list_tools()
|
|
56
|
+
async def list_tools() -> list[Tool]:
|
|
57
|
+
"""List available tools"""
|
|
58
|
+
return [
|
|
59
|
+
Tool(
|
|
60
|
+
name="calculator",
|
|
61
|
+
description="Evaluate a mathematical expression",
|
|
62
|
+
inputSchema={
|
|
63
|
+
"type": "object",
|
|
64
|
+
"properties": {
|
|
65
|
+
"expression": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "Mathematical expression to evaluate"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"required": ["expression"]
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
@app.call_tool()
|
|
76
|
+
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
|
|
77
|
+
"""Handle tool calls"""
|
|
78
|
+
if name == "calculator":
|
|
79
|
+
expression = arguments.get("expression", "")
|
|
80
|
+
try:
|
|
81
|
+
result = eval(expression)
|
|
82
|
+
return [TextContent(type="text", text=str(result))]
|
|
83
|
+
except Exception as e:
|
|
84
|
+
return [TextContent(type="text", text=f"Error: {str(e)}")]
|
|
85
|
+
else:
|
|
86
|
+
raise ValueError(f"Unknown tool: {name}")
|
|
87
|
+
|
|
88
|
+
@app.list_prompts()
|
|
89
|
+
async def list_prompts() -> list:
|
|
90
|
+
"""List available prompts"""
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
"name": "summarize",
|
|
94
|
+
"description": "Summarize the provided text",
|
|
95
|
+
"arguments": [
|
|
96
|
+
{
|
|
97
|
+
"name": "text",
|
|
98
|
+
"description": "Text to summarize",
|
|
99
|
+
"required": True
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
@app.get_prompt()
|
|
106
|
+
async def get_prompt(name: str, arguments: dict) -> str:
|
|
107
|
+
"""Get a prompt by name"""
|
|
108
|
+
if name == "summarize":
|
|
109
|
+
text = arguments.get("text", "")
|
|
110
|
+
return f"Summary of the text: {text}"
|
|
111
|
+
else:
|
|
112
|
+
raise ValueError(f"Unknown prompt: {name}")
|
|
113
|
+
|
|
114
|
+
def main():
|
|
115
|
+
"""Main entry point for the MCP server"""
|
|
116
|
+
import asyncio
|
|
117
|
+
from mcp.server.stdio import stdio_server
|
|
118
|
+
|
|
119
|
+
async def run_server():
|
|
120
|
+
async with stdio_server() as (read_stream, write_stream):
|
|
121
|
+
capabilities = ServerCapabilities(
|
|
122
|
+
resources={},
|
|
123
|
+
tools={},
|
|
124
|
+
prompts={}
|
|
125
|
+
)
|
|
126
|
+
init_options = InitializationOptions(
|
|
127
|
+
server_name="mcp-server-docker",
|
|
128
|
+
server_version="0.1.0",
|
|
129
|
+
capabilities=capabilities
|
|
130
|
+
)
|
|
131
|
+
await app.run(read_stream, write_stream, init_options)
|
|
132
|
+
|
|
133
|
+
asyncio.run(run_server())
|
|
134
|
+
|
|
135
|
+
if __name__ == "__main__":
|
|
136
|
+
main()
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
services:
|
|
2
|
+
mcp-server:
|
|
3
|
+
build: .
|
|
4
|
+
ports:
|
|
5
|
+
- "8080:8080"
|
|
6
|
+
depends_on:
|
|
7
|
+
- redis
|
|
8
|
+
- timescaledb
|
|
9
|
+
environment:
|
|
10
|
+
- REDIS_HOST=redis
|
|
11
|
+
- PG_HOST=timescaledb
|
|
12
|
+
volumes:
|
|
13
|
+
- ./app:/app
|
|
14
|
+
|
|
15
|
+
redis:
|
|
16
|
+
image: redis:7
|
|
17
|
+
ports:
|
|
18
|
+
- "6379:6379"
|
|
19
|
+
|
|
20
|
+
timescaledb:
|
|
21
|
+
image: timescale/timescaledb-ha:pg14-latest
|
|
22
|
+
environment:
|
|
23
|
+
POSTGRES_PASSWORD: example
|
|
24
|
+
POSTGRES_DB: mcpdb
|
|
25
|
+
POSTGRES_USER: mcpuser
|
|
26
|
+
ports:
|
|
27
|
+
- "5432:5432"
|
|
28
|
+
volumes:
|
|
29
|
+
- timescale_data:/var/lib/postgresql/data
|
|
30
|
+
|
|
31
|
+
volumes:
|
|
32
|
+
timescale_data:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
python
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
iflow-mcp_chuckwilliams37-mcp-server-docker
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "iflow-mcp_chuckwilliams37-mcp-server-docker"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "MCP Server with Docker, Redis, and TimescaleDB"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"fastapi",
|
|
13
|
+
"uvicorn[standard]",
|
|
14
|
+
"torch",
|
|
15
|
+
"redis",
|
|
16
|
+
"psycopg2-binary",
|
|
17
|
+
"mcp",
|
|
18
|
+
"python-dotenv",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
mcp-server-docker = "app.app:main"
|
|
23
|
+
|
|
24
|
+
[tool.hatch.build.targets.wheel]
|
|
25
|
+
packages = ["app"]
|
|
26
|
+
|
|
27
|
+
[project.urls]
|
|
28
|
+
Homepage = "https://github.com/chuckwilliams37/mcp-server-docker"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Installs prerequisites and clones the MCP server repository
|
|
3
|
+
# Usage: ./bootstrap-mcp.sh [repo_url] [repo_dir]
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Default values - can be overridden with environment variables or command-line arguments
|
|
8
|
+
DEFAULT_REPO_URL="https://github.com/username/mcp-server-docker.git"
|
|
9
|
+
DEFAULT_REPO_DIR="mcp-server-docker"
|
|
10
|
+
|
|
11
|
+
# Accept parameters from command line or environment variables, fallback to defaults
|
|
12
|
+
REPO_URL="${1:-${MCP_REPO_URL:-$DEFAULT_REPO_URL}}"
|
|
13
|
+
REPO_DIR="${2:-${MCP_REPO_DIR:-$DEFAULT_REPO_DIR}}"
|
|
14
|
+
|
|
15
|
+
echo "🚀 Updating and installing essentials..."
|
|
16
|
+
sudo apt update && sudo apt upgrade -y
|
|
17
|
+
sudo apt install -y git curl ca-certificates lsb-release gnupg unzip ufw
|
|
18
|
+
|
|
19
|
+
echo "🐳 Installing Docker..."
|
|
20
|
+
# Add Docker's official GPG key and repo
|
|
21
|
+
sudo install -m 0755 -d /etc/apt/keyrings
|
|
22
|
+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
|
|
23
|
+
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
24
|
+
|
|
25
|
+
echo \
|
|
26
|
+
"deb [arch=$(dpkg --print-architecture) \
|
|
27
|
+
signed-by=/etc/apt/keyrings/docker.gpg] \
|
|
28
|
+
https://download.docker.com/linux/ubuntu \
|
|
29
|
+
$(lsb_release -cs) stable" | \
|
|
30
|
+
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
31
|
+
|
|
32
|
+
# Install Docker Engine
|
|
33
|
+
sudo apt update
|
|
34
|
+
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
35
|
+
|
|
36
|
+
# Enable Docker as a service
|
|
37
|
+
sudo systemctl enable docker
|
|
38
|
+
sudo usermod -aG docker $USER
|
|
39
|
+
|
|
40
|
+
echo "🔁 Logging out required to activate Docker group permissions."
|
|
41
|
+
|
|
42
|
+
echo "📁 Cloning repo..."
|
|
43
|
+
git clone "$REPO_URL"
|
|
44
|
+
cd "$REPO_DIR"
|
|
45
|
+
|
|
46
|
+
echo "🔧 Building Docker containers..."
|
|
47
|
+
docker compose build
|
|
48
|
+
|
|
49
|
+
echo "🚀 Starting containers..."
|
|
50
|
+
docker compose up -d
|
|
51
|
+
|
|
52
|
+
echo "🧠 Writing systemd service for auto-start..."
|
|
53
|
+
SERVICE_NAME="mcp-docker"
|
|
54
|
+
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
|
|
55
|
+
|
|
56
|
+
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
|
|
57
|
+
[Unit]
|
|
58
|
+
Description=MCP Docker Compose App
|
|
59
|
+
Requires=docker.service
|
|
60
|
+
After=docker.service
|
|
61
|
+
|
|
62
|
+
[Service]
|
|
63
|
+
WorkingDirectory=/home/$USER/$REPO_DIR
|
|
64
|
+
ExecStart=/usr/bin/docker compose up -d
|
|
65
|
+
ExecStop=/usr/bin/docker compose down
|
|
66
|
+
Restart=always
|
|
67
|
+
TimeoutStartSec=0
|
|
68
|
+
|
|
69
|
+
[Install]
|
|
70
|
+
WantedBy=multi-user.target
|
|
71
|
+
EOF
|
|
72
|
+
|
|
73
|
+
echo "📡 Enabling and starting $SERVICE_NAME service..."
|
|
74
|
+
sudo systemctl daemon-reexec
|
|
75
|
+
sudo systemctl enable "$SERVICE_NAME"
|
|
76
|
+
sudo systemctl start "$SERVICE_NAME"
|
|
77
|
+
|
|
78
|
+
echo "✅ Setup complete. Your MCP server is live and will restart on reboot."
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Usage: ./full-bootstrap-mcp.sh [repo_url] [repo_dir]
|
|
3
|
+
set -e
|
|
4
|
+
|
|
5
|
+
# Default values - can be overridden with environment variables or command-line arguments
|
|
6
|
+
DEFAULT_REPO_URL="https://github.com/username/mcp-server-docker.git"
|
|
7
|
+
DEFAULT_REPO_DIR="mcp-server-docker"
|
|
8
|
+
|
|
9
|
+
# Accept parameters from command line or environment variables, fallback to defaults
|
|
10
|
+
REPO_URL="${1:-${MCP_REPO_URL:-$DEFAULT_REPO_URL}}"
|
|
11
|
+
REPO_DIR="${2:-${MCP_REPO_DIR:-$DEFAULT_REPO_DIR}}"
|
|
12
|
+
|
|
13
|
+
# Function to wait for apt locks to be released
|
|
14
|
+
wait_for_apt_locks() {
|
|
15
|
+
echo "⏳ Checking for apt locks..."
|
|
16
|
+
while sudo lsof /var/lib/dpkg/lock >/dev/null 2>&1 || sudo lsof /var/lib/apt/lists/lock >/dev/null 2>&1 || sudo lsof /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do
|
|
17
|
+
echo "Waiting for package manager locks to be released... (Process holding lock: $(sudo lsof /var/lib/dpkg/lock-frontend 2>/dev/null | tail -n 1 | awk '{print $2" ("$1")"}' || echo "unknown"))"
|
|
18
|
+
sleep 10
|
|
19
|
+
done
|
|
20
|
+
echo "✅ Package manager locks released."
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
echo "🚀 Updating system and installing essentials..."
|
|
24
|
+
wait_for_apt_locks
|
|
25
|
+
sudo apt update && sudo apt upgrade -y
|
|
26
|
+
wait_for_apt_locks
|
|
27
|
+
sudo apt install -y git curl wget vim zsh ufw fail2ban net-tools unzip \
|
|
28
|
+
ca-certificates gnupg lsb-release build-essential
|
|
29
|
+
|
|
30
|
+
echo "🐚 Installing Oh-My-Zsh with 'jonathan' theme..."
|
|
31
|
+
if [ ! -d "$HOME/.oh-my-zsh" ]; then
|
|
32
|
+
chsh -s $(which zsh)
|
|
33
|
+
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
|
34
|
+
sed -i 's/ZSH_THEME=".*"/ZSH_THEME="jonathan"/g' "$HOME/.zshrc"
|
|
35
|
+
echo "export TERM=xterm-256color" >> "$HOME/.zshrc"
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
echo "🐳 Installing Docker and Compose..."
|
|
39
|
+
# Docker GPG and repo
|
|
40
|
+
sudo install -m 0755 -d /etc/apt/keyrings
|
|
41
|
+
wait_for_apt_locks
|
|
42
|
+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
|
|
43
|
+
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
44
|
+
echo \
|
|
45
|
+
"deb [arch=$(dpkg --print-architecture) \
|
|
46
|
+
signed-by=/etc/apt/keyrings/docker.gpg] \
|
|
47
|
+
https://download.docker.com/linux/ubuntu \
|
|
48
|
+
$(lsb_release -cs) stable" | \
|
|
49
|
+
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
50
|
+
|
|
51
|
+
# Install Docker engine & plugin-based compose
|
|
52
|
+
wait_for_apt_locks
|
|
53
|
+
sudo apt update
|
|
54
|
+
wait_for_apt_locks
|
|
55
|
+
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
|
56
|
+
sudo systemctl enable docker
|
|
57
|
+
sudo usermod -aG docker $USER
|
|
58
|
+
|
|
59
|
+
echo "🔥 Enabling UFW firewall and Fail2Ban..."
|
|
60
|
+
sudo ufw allow OpenSSH
|
|
61
|
+
sudo ufw allow 8080/tcp
|
|
62
|
+
sudo ufw --force enable
|
|
63
|
+
sudo systemctl enable --now fail2ban
|
|
64
|
+
|
|
65
|
+
echo "🖥️ Installing XFCE Desktop Environment and XRDP for Remote Desktop..."
|
|
66
|
+
wait_for_apt_locks
|
|
67
|
+
sudo apt install -y xfce4 xfce4-goodies xrdp
|
|
68
|
+
sudo systemctl enable --now xrdp
|
|
69
|
+
|
|
70
|
+
# Set default session to XFCE for all users
|
|
71
|
+
echo "startxfce4" | sudo tee /etc/skel/.xsession > /dev/null
|
|
72
|
+
echo "startxfce4" > ~/.xsession
|
|
73
|
+
|
|
74
|
+
# Fix permissions if needed
|
|
75
|
+
sudo adduser xrdp ssl-cert
|
|
76
|
+
|
|
77
|
+
echo "🔐 Setting default password for $USER (you'll be prompted to change it)..."
|
|
78
|
+
echo "$USER:changeme" | sudo chpasswd
|
|
79
|
+
|
|
80
|
+
echo "📁 Setting up MCP repository..."
|
|
81
|
+
cd "$HOME"
|
|
82
|
+
|
|
83
|
+
# Check if the repository directory already exists
|
|
84
|
+
if [ -d "$REPO_DIR" ]; then
|
|
85
|
+
echo "Repository directory already exists, updating instead of cloning..."
|
|
86
|
+
cd "$REPO_DIR"
|
|
87
|
+
git fetch
|
|
88
|
+
git pull
|
|
89
|
+
else
|
|
90
|
+
echo "Cloning MCP repo..."
|
|
91
|
+
git clone "$REPO_URL"
|
|
92
|
+
cd "$REPO_DIR"
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
echo "🔧 Building and launching containers..."
|
|
96
|
+
# Check if docker compose is available
|
|
97
|
+
if ! command -v docker &> /dev/null; then
|
|
98
|
+
echo "❌ Error: Docker is not installed or not in PATH. Please check Docker installation."
|
|
99
|
+
exit 1
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
# Use docker compose (no hyphen) as that's the newer syntax
|
|
103
|
+
docker compose build
|
|
104
|
+
docker compose up -d
|
|
105
|
+
|
|
106
|
+
echo "🧠 Creating systemd service for reboot resilience..."
|
|
107
|
+
SERVICE_NAME="mcp-docker"
|
|
108
|
+
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
|
|
109
|
+
|
|
110
|
+
sudo tee "$SERVICE_FILE" > /dev/null <<EOF
|
|
111
|
+
[Unit]
|
|
112
|
+
Description=MCP Docker Compose App
|
|
113
|
+
Requires=docker.service
|
|
114
|
+
After=docker.service
|
|
115
|
+
|
|
116
|
+
[Service]
|
|
117
|
+
WorkingDirectory=/home/$USER/$REPO_DIR
|
|
118
|
+
ExecStart=/usr/bin/docker compose up -d
|
|
119
|
+
ExecStop=/usr/bin/docker compose down
|
|
120
|
+
Restart=always
|
|
121
|
+
TimeoutStartSec=0
|
|
122
|
+
|
|
123
|
+
[Install]
|
|
124
|
+
WantedBy=multi-user.target
|
|
125
|
+
EOF
|
|
126
|
+
|
|
127
|
+
sudo systemctl daemon-reexec
|
|
128
|
+
sudo systemctl enable "$SERVICE_NAME"
|
|
129
|
+
sudo systemctl start "$SERVICE_NAME"
|
|
130
|
+
|
|
131
|
+
echo "✅ MCP setup complete. Server will auto-start on reboot."
|
|
132
|
+
echo "💡 You may need to reboot or log out and back in for Docker group to take effect."
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Initialize a new Git repository and commit the current directory contents
|
|
3
|
+
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
echo "🚀 Initializing Git repository..."
|
|
7
|
+
git init
|
|
8
|
+
|
|
9
|
+
echo "📝 Creating initial .gitignore..."
|
|
10
|
+
cat > .gitignore << EOF
|
|
11
|
+
# Environment variables
|
|
12
|
+
.env
|
|
13
|
+
|
|
14
|
+
# Python
|
|
15
|
+
__pycache__/
|
|
16
|
+
*.py[cod]
|
|
17
|
+
*$py.class
|
|
18
|
+
*.so
|
|
19
|
+
.Python
|
|
20
|
+
env/
|
|
21
|
+
build/
|
|
22
|
+
develop-eggs/
|
|
23
|
+
dist/
|
|
24
|
+
downloads/
|
|
25
|
+
eggs/
|
|
26
|
+
.eggs/
|
|
27
|
+
lib/
|
|
28
|
+
lib64/
|
|
29
|
+
parts/
|
|
30
|
+
sdist/
|
|
31
|
+
var/
|
|
32
|
+
*.egg-info/
|
|
33
|
+
.installed.cfg
|
|
34
|
+
*.egg
|
|
35
|
+
|
|
36
|
+
# Docker volumes
|
|
37
|
+
docker-volumes/
|
|
38
|
+
|
|
39
|
+
# OS specific
|
|
40
|
+
.DS_Store
|
|
41
|
+
Thumbs.db
|
|
42
|
+
EOF
|
|
43
|
+
|
|
44
|
+
echo "➕ Adding files to Git..."
|
|
45
|
+
git add .
|
|
46
|
+
|
|
47
|
+
echo "✅ Creating initial commit..."
|
|
48
|
+
git commit -m "Initial commit for MCP Server Docker setup"
|
|
49
|
+
|
|
50
|
+
echo "💡 Repository initialized. Next steps:"
|
|
51
|
+
echo "1. Add a remote with: git remote add origin <your-repository-url>"
|
|
52
|
+
echo "2. Push to remote with: git push -u origin main"
|
|
53
|
+
echo ""
|
|
54
|
+
echo "Or use the push-repo.sh script after setting your repository URL."
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Push your local repository to a remote Git repository
|
|
3
|
+
# Usage: ./push-repo.sh [repository_url]
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Default repository URL - Will prompt if not provided
|
|
8
|
+
DEFAULT_REPO_URL="https://github.com/username/repository.git"
|
|
9
|
+
|
|
10
|
+
# Get repository URL from command line argument or environment variable
|
|
11
|
+
REPO_URL="${1:-${GIT_REPO_URL:-}}"
|
|
12
|
+
|
|
13
|
+
# If no URL provided, prompt for one
|
|
14
|
+
if [ -z "$REPO_URL" ]; then
|
|
15
|
+
read -p "Enter Git repository URL: " REPO_URL
|
|
16
|
+
|
|
17
|
+
# If still empty, use default
|
|
18
|
+
if [ -z "$REPO_URL" ]; then
|
|
19
|
+
echo "⚠️ No repository URL provided, using default: $DEFAULT_REPO_URL"
|
|
20
|
+
REPO_URL="$DEFAULT_REPO_URL"
|
|
21
|
+
fi
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
# Check if repository already has a remote origin
|
|
25
|
+
if git remote | grep -q "^origin$"; then
|
|
26
|
+
echo "Remote 'origin' already exists."
|
|
27
|
+
echo "Current URL: $(git remote get-url origin)"
|
|
28
|
+
|
|
29
|
+
read -p "Do you want to update it to $REPO_URL? (y/n): " update_remote
|
|
30
|
+
if [ "$update_remote" = "y" ]; then
|
|
31
|
+
git remote set-url origin "$REPO_URL"
|
|
32
|
+
echo "✅ Remote 'origin' updated to $REPO_URL"
|
|
33
|
+
fi
|
|
34
|
+
else
|
|
35
|
+
echo "Adding remote 'origin'..."
|
|
36
|
+
git remote add origin "$REPO_URL"
|
|
37
|
+
echo "✅ Remote 'origin' added: $REPO_URL"
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
# Get current branch
|
|
41
|
+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
42
|
+
|
|
43
|
+
echo "🚀 Pushing to remote repository..."
|
|
44
|
+
git push -u origin "$CURRENT_BRANCH"
|
|
45
|
+
|
|
46
|
+
echo "✅ Repository pushed successfully!"
|
|
47
|
+
echo "Your code is now available at: $REPO_URL"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Configure local SSH environment for connecting to an MCP server
|
|
3
|
+
# Usage: ./setup-mcpserver.sh [server_ip] [server_name] [server_domain] [server_user]
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Default configuration - should be overridden with environment variables or arguments
|
|
8
|
+
DEFAULT_SERVER_IP="your-server-ip"
|
|
9
|
+
DEFAULT_SERVER_NAME="mcpserver"
|
|
10
|
+
DEFAULT_SERVER_DOMAIN="example.com"
|
|
11
|
+
DEFAULT_SERVER_USER="admin"
|
|
12
|
+
DEFAULT_SSH_KEY_PATH="$HOME/.ssh/id_rsa"
|
|
13
|
+
|
|
14
|
+
# Accept parameters from command line or use defaults
|
|
15
|
+
SERVER_IP="${1:-${MCP_SERVER_IP:-$DEFAULT_SERVER_IP}}"
|
|
16
|
+
SERVER_NAME="${2:-${MCP_SERVER_NAME:-$DEFAULT_SERVER_NAME}}"
|
|
17
|
+
SERVER_DOMAIN="${3:-${MCP_SERVER_DOMAIN:-$DEFAULT_SERVER_DOMAIN}}"
|
|
18
|
+
SERVER_USER="${4:-${MCP_SERVER_USER:-$DEFAULT_SERVER_USER}}"
|
|
19
|
+
SSH_KEY_PATH="${MCP_SSH_KEY_PATH:-$DEFAULT_SSH_KEY_PATH}"
|
|
20
|
+
|
|
21
|
+
SERVER_HOSTNAME="${SERVER_NAME}.${SERVER_DOMAIN}"
|
|
22
|
+
|
|
23
|
+
# Prompt for missing values
|
|
24
|
+
if [ "$SERVER_IP" = "$DEFAULT_SERVER_IP" ]; then
|
|
25
|
+
read -p "Enter server IP address: " SERVER_IP
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
if [ "$SERVER_NAME" = "$DEFAULT_SERVER_NAME" ]; then
|
|
29
|
+
read -p "Enter server name (e.g., mcp001): " SERVER_NAME
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
if [ "$SERVER_DOMAIN" = "$DEFAULT_SERVER_DOMAIN" ]; then
|
|
33
|
+
read -p "Enter server domain (e.g., example.com): " SERVER_DOMAIN
|
|
34
|
+
SERVER_HOSTNAME="${SERVER_NAME}.${SERVER_DOMAIN}"
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
if [ "$SERVER_USER" = "$DEFAULT_SERVER_USER" ]; then
|
|
38
|
+
read -p "Enter server user (e.g., root): " SERVER_USER
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
echo "🔧 Setting up SSH configuration for $SERVER_HOSTNAME ($SERVER_IP)..."
|
|
42
|
+
|
|
43
|
+
# Ensure SSH directory exists
|
|
44
|
+
mkdir -p ~/.ssh
|
|
45
|
+
chmod 700 ~/.ssh
|
|
46
|
+
|
|
47
|
+
# Add SSH config entry if it doesn't exist
|
|
48
|
+
if ! grep -q "Host $SERVER_NAME" ~/.ssh/config 2>/dev/null; then
|
|
49
|
+
echo "➕ Adding SSH config entry for $SERVER_NAME..."
|
|
50
|
+
cat >> ~/.ssh/config << EOF
|
|
51
|
+
# MCP Server Configuration
|
|
52
|
+
Host $SERVER_NAME
|
|
53
|
+
HostName $SERVER_HOSTNAME
|
|
54
|
+
User $SERVER_USER
|
|
55
|
+
IdentityFile $SSH_KEY_PATH
|
|
56
|
+
ForwardAgent yes
|
|
57
|
+
|
|
58
|
+
EOF
|
|
59
|
+
echo "✅ SSH config entry added."
|
|
60
|
+
else
|
|
61
|
+
echo "✅ SSH config entry already exists."
|
|
62
|
+
fi
|
|
63
|
+
|
|
64
|
+
# Check if we need to generate SSH key
|
|
65
|
+
if [ ! -f "$SSH_KEY_PATH" ]; then
|
|
66
|
+
echo "🔑 Generating SSH key..."
|
|
67
|
+
ssh-keygen -t rsa -b 4096 -f "$SSH_KEY_PATH" -N ""
|
|
68
|
+
echo "✅ SSH key generated."
|
|
69
|
+
else
|
|
70
|
+
echo "✅ SSH key already exists."
|
|
71
|
+
fi
|
|
72
|
+
|
|
73
|
+
# Instructions for DNS and SSH key deployment
|
|
74
|
+
echo ""
|
|
75
|
+
echo "📝 Next steps:"
|
|
76
|
+
echo ""
|
|
77
|
+
echo "1. Add this DNS A record to your domain:"
|
|
78
|
+
echo " $SERVER_NAME.$SERVER_DOMAIN. IN A $SERVER_IP"
|
|
79
|
+
echo ""
|
|
80
|
+
echo "2. To copy your SSH key to the server, run:"
|
|
81
|
+
echo " ssh-copy-id -i $SSH_KEY_PATH $SERVER_USER@$SERVER_IP"
|
|
82
|
+
echo ""
|
|
83
|
+
echo "3. Once configured, you can connect with:"
|
|
84
|
+
echo " ssh $SERVER_NAME"
|
|
85
|
+
echo ""
|
|
86
|
+
echo "4. If you want to use port forwarding for services, use:"
|
|
87
|
+
echo " ssh -L 8080:localhost:8080 $SERVER_NAME"
|
|
88
|
+
echo " (This forwards local port 8080 to the server's port 8080)"
|
|
89
|
+
echo ""
|
|
90
|
+
echo "✅ Setup complete!"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# === CONFIG ===
|
|
4
|
+
IP="192.0.2.123" # Sample IP for documentation
|
|
5
|
+
HOST_ALIAS="mcp001"
|
|
6
|
+
FQDN="mcp001.example.com"
|
|
7
|
+
SSH_USER="root"
|
|
8
|
+
KEY_PATH="$HOME/.ssh/id_rsa.pub"
|
|
9
|
+
|
|
10
|
+
# === CHECK SSH KEY ===
|
|
11
|
+
if [ ! -f "$KEY_PATH" ]; then
|
|
12
|
+
echo "No SSH public key found at $KEY_PATH. Generating one..."
|
|
13
|
+
ssh-keygen -t rsa -b 4096 -f "${KEY_PATH%.*}" -N ""
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
# === PUSH SSH KEY ===
|
|
17
|
+
echo "Pushing SSH key to $SSH_USER@$IP..."
|
|
18
|
+
ssh-copy-id -i "$KEY_PATH" "$SSH_USER@$IP"
|
|
19
|
+
|
|
20
|
+
# === ADD SSH CONFIG ALIAS ===
|
|
21
|
+
SSH_CONFIG="$HOME/.ssh/config"
|
|
22
|
+
if ! grep -q "$HOST_ALIAS" "$SSH_CONFIG" 2>/dev/null; then
|
|
23
|
+
echo "Adding SSH config alias for $HOST_ALIAS..."
|
|
24
|
+
cat <<EOF >> "$SSH_CONFIG"
|
|
25
|
+
|
|
26
|
+
# MCP Server Shortcut
|
|
27
|
+
Host $HOST_ALIAS
|
|
28
|
+
HostName $IP
|
|
29
|
+
User $SSH_USER
|
|
30
|
+
IdentityFile ${KEY_PATH%.*}
|
|
31
|
+
EOF
|
|
32
|
+
echo "Alias '$HOST_ALIAS' added to SSH config."
|
|
33
|
+
else
|
|
34
|
+
echo "Alias '$HOST_ALIAS' already exists in SSH config."
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# === OUTPUT DNS A RECORD ===
|
|
38
|
+
echo -e "\n📡 Add the following A record to your DNS provider:"
|
|
39
|
+
echo "$FQDN. IN A $IP"
|
|
40
|
+
|
|
41
|
+
# === TEST CONNECTION ===
|
|
42
|
+
echo -e "\n🔗 Testing connection: ssh $HOST_ALIAS\n"
|
|
43
|
+
ssh "$HOST_ALIAS"
|