feat: dockerize infracloud mcp for echo
This commit is contained in:
parent
d64e38a610
commit
5281bceda9
5 changed files with 55 additions and 1 deletions
4
.dockerignore
Normal file
4
.dockerignore
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
.git
|
||||
**/__pycache__/
|
||||
**/*.pyc
|
||||
**/.venv/
|
||||
13
mcp/Dockerfile
Normal file
13
mcp/Dockerfile
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
FROM python:3.12-slim
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY mcp/requirements.txt /app/mcp/requirements.txt
|
||||
RUN pip install --no-cache-dir -r /app/mcp/requirements.txt
|
||||
|
||||
COPY . /app
|
||||
|
||||
CMD ["python", "/app/mcp/server.py"]
|
||||
|
|
@ -23,6 +23,17 @@ pip install -r C:\dev\infracloud\mcp\requirements.txt
|
|||
python C:\dev\infracloud\mcp\server.py
|
||||
```
|
||||
|
||||
### HTTP transport
|
||||
|
||||
For container or VPS usage:
|
||||
|
||||
```powershell
|
||||
$env:INFRA_MCP_TRANSPORT="streamable-http"
|
||||
$env:INFRA_MCP_HOST="0.0.0.0"
|
||||
$env:INFRA_MCP_PORT="18000"
|
||||
python C:\dev\infracloud\mcp\server.py
|
||||
```
|
||||
|
||||
## Postgres
|
||||
|
||||
Set `INFRA_MCP_POSTGRES_DSN` if you want the server to use Postgres for notes and SQL diagnostics.
|
||||
|
|
@ -34,6 +45,14 @@ $env:INFRA_MCP_POSTGRES_DSN="postgresql://user:password@127.0.0.1:5432/infraclou
|
|||
python C:\dev\infracloud\mcp\server.py
|
||||
```
|
||||
|
||||
## Docker on echo
|
||||
|
||||
The repo includes [docker-compose.echo.yml](C:\dev\infracloud\mcp\docker-compose.echo.yml) for running the MCP server on the echo VPS with:
|
||||
|
||||
- `streamable-http` transport
|
||||
- port `18000`
|
||||
- Postgres database `infracloud_mcp`
|
||||
|
||||
## Claude Desktop
|
||||
|
||||
Use `claude_desktop_config.infracloud.json` as a base and merge it into your Claude Desktop MCP config.
|
||||
|
|
|
|||
13
mcp/docker-compose.echo.yml
Normal file
13
mcp/docker-compose.echo.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
services:
|
||||
infracloud-mcp:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: mcp/Dockerfile
|
||||
container_name: infracloud-mcp
|
||||
restart: unless-stopped
|
||||
network_mode: host
|
||||
environment:
|
||||
INFRA_MCP_TRANSPORT: streamable-http
|
||||
INFRA_MCP_HOST: 0.0.0.0
|
||||
INFRA_MCP_PORT: "18000"
|
||||
INFRA_MCP_POSTGRES_DSN: postgresql://user:password@127.0.0.1:5432/infracloud_mcp
|
||||
|
|
@ -18,6 +18,9 @@ CONTAINERS_ROOT = REPO_ROOT / "containers"
|
|||
DATABASES_ROOT = REPO_ROOT / "databases"
|
||||
K3S_ROOT = REPO_ROOT / "k3s"
|
||||
POSTGRES_DSN_ENV = "INFRA_MCP_POSTGRES_DSN"
|
||||
TRANSPORT_ENV = "INFRA_MCP_TRANSPORT"
|
||||
HOST_ENV = "INFRA_MCP_HOST"
|
||||
PORT_ENV = "INFRA_MCP_PORT"
|
||||
DOC_ALLOWLIST = (
|
||||
REPO_ROOT / "README.md",
|
||||
VPS_ROOT,
|
||||
|
|
@ -52,6 +55,8 @@ mcp = FastMCP(
|
|||
"Do not assume paths like dev-scripts or docs/openproject if they do not exist. "
|
||||
"If Postgres is configured, prefer the MCP Postgres helpers for server-side persistence and diagnostics."
|
||||
),
|
||||
host=os.getenv(HOST_ENV, "127.0.0.1"),
|
||||
port=int(os.getenv(PORT_ENV, "8000")),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -533,4 +538,4 @@ def list_operational_notes(scope: str | None = None, limit: int = 20) -> list[di
|
|||
|
||||
if __name__ == "__main__":
|
||||
_ensure_mcp_tables()
|
||||
mcp.run()
|
||||
mcp.run(transport=os.getenv(TRANSPORT_ENV, "stdio"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue