From ad4d31d792d11a381889f25859a94afc75614936 Mon Sep 17 00:00:00 2001 From: melabidi Date: Fri, 31 Jul 2026 16:18:28 -0400 Subject: [PATCH] Add Codex multi-workspace config and Linux/mac run script. --- examples/codex/config.toml | 43 +++++++++++++++++++++++++++ examples/codex/docker-compose.yml | 42 ++++++++++++++++++++++++++ examples/codex/run-workspaces.sh | 49 +++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 examples/codex/config.toml create mode 100644 examples/codex/docker-compose.yml create mode 100644 examples/codex/run-workspaces.sh diff --git a/examples/codex/config.toml b/examples/codex/config.toml new file mode 100644 index 0000000..fc54744 --- /dev/null +++ b/examples/codex/config.toml @@ -0,0 +1,43 @@ +# Merge these tables into ~/.codex/config.toml (or a trusted project .codex/config.toml). +# Each entry points at a dedicated web-dev-mcp container (one WORKSPACE_ROOT per server). +# +# Edit the four workspace names/ports if needed, then start containers with: +# ./examples/codex/run-workspaces.sh +# +# Localhost bind = no MCP_HTTP_TOKEN required. + +[mcp_servers.web-dev-ws1] +url = "http://127.0.0.1:3939/mcp" +startup_timeout_sec = 20 +tool_timeout_sec = 120 +enabled = true + +[mcp_servers.web-dev-ws2] +url = "http://127.0.0.1:3940/mcp" +startup_timeout_sec = 20 +tool_timeout_sec = 120 +enabled = true + +[mcp_servers.web-dev-ws3] +url = "http://127.0.0.1:3941/mcp" +startup_timeout_sec = 20 +tool_timeout_sec = 120 +enabled = true + +[mcp_servers.web-dev-ws4] +url = "http://127.0.0.1:3942/mcp" +startup_timeout_sec = 20 +tool_timeout_sec = 120 +enabled = true + +# Optional: if you bind containers to 0.0.0.0 and set MCP_HTTP_TOKEN, +# set the token in your shell env and uncomment: +# +# [mcp_servers.web-dev-ws1] +# url = "http://127.0.0.1:3939/mcp" +# bearer_token_env_var = "MCP_HTTP_TOKEN_WS1" +# +# [mcp_servers.web-dev-ws2] +# url = "http://127.0.0.1:3940/mcp" +# bearer_token_env_var = "MCP_HTTP_TOKEN_WS2" +# ... etc diff --git a/examples/codex/docker-compose.yml b/examples/codex/docker-compose.yml new file mode 100644 index 0000000..03d8298 --- /dev/null +++ b/examples/codex/docker-compose.yml @@ -0,0 +1,42 @@ +# Alternative to run-workspaces.sh — edit the four volume sources, then: +# docker compose -f examples/codex/docker-compose.yml up -d +# +# Image: 192.168.3.80/melabidi/mcp_web_dev_server:latest +# Codex: merge examples/codex/config.toml into ~/.codex/config.toml + +services: + web-dev-ws1: + image: 192.168.3.80/melabidi/mcp_web_dev_server:latest + container_name: web-dev-ws1 + restart: unless-stopped + ports: + - "127.0.0.1:3939:3939" + volumes: + - /path/to/workspace1:/workspace + + web-dev-ws2: + image: 192.168.3.80/melabidi/mcp_web_dev_server:latest + container_name: web-dev-ws2 + restart: unless-stopped + ports: + - "127.0.0.1:3940:3939" + volumes: + - /path/to/workspace2:/workspace + + web-dev-ws3: + image: 192.168.3.80/melabidi/mcp_web_dev_server:latest + container_name: web-dev-ws3 + restart: unless-stopped + ports: + - "127.0.0.1:3941:3939" + volumes: + - /path/to/workspace3:/workspace + + web-dev-ws4: + image: 192.168.3.80/melabidi/mcp_web_dev_server:latest + container_name: web-dev-ws4 + restart: unless-stopped + ports: + - "127.0.0.1:3942:3939" + volumes: + - /path/to/workspace4:/workspace diff --git a/examples/codex/run-workspaces.sh b/examples/codex/run-workspaces.sh new file mode 100644 index 0000000..cdc77db --- /dev/null +++ b/examples/codex/run-workspaces.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# Start 4 web-dev-mcp containers (one workspace each) for Codex. +# Edit the WORKSPACE_* paths below, then run: +# chmod +x examples/codex/run-workspaces.sh +# ./examples/codex/run-workspaces.sh + +set -euo pipefail + +IMAGE='192.168.3.80/melabidi/mcp_web_dev_server:latest' + +# --- edit these four absolute paths --- +WORKSPACE_1='/path/to/workspace1' +WORKSPACE_2='/path/to/workspace2' +WORKSPACE_3='/path/to/workspace3' +WORKSPACE_4='/path/to/workspace4' + +NAMES=(web-dev-ws1 web-dev-ws2 web-dev-ws3 web-dev-ws4) +PORTS=(3939 3940 3941 3942) +PATHS=("$WORKSPACE_1" "$WORKSPACE_2" "$WORKSPACE_3" "$WORKSPACE_4") + +for i in "${!NAMES[@]}"; do + name="${NAMES[$i]}" + port="${PORTS[$i]}" + path="${PATHS[$i]}" + + if [[ ! -d "$path" ]]; then + echo "error: workspace path does not exist: $path" >&2 + exit 1 + fi + + docker rm -f "$name" >/dev/null 2>&1 || true + + # Default MCP_HTTP_HOST=127.0.0.1 inside the image — no token needed. + # Publish to host loopback so only this machine can reach the MCP port. + docker run -d \ + --name "$name" \ + --restart unless-stopped \ + -p "127.0.0.1:${port}:3939" \ + -v "${path}:/workspace" \ + "$IMAGE" + + echo "Started ${name} -> http://127.0.0.1:${port}/mcp (${path})" +done + +echo +echo 'Codex MCP endpoints (see examples/codex/config.toml):' +for i in "${!NAMES[@]}"; do + echo " ${NAMES[$i]}: http://127.0.0.1:${PORTS[$i]}/mcp" +done