#!/bin/bash set -euo pipefail # Staying logged in across rebuilds is handled entirely by `claudaris start`, # which bind-mounts ~/.claude/.credentials.json and ~/.claude.json individually # from the host (see claudaris) — nothing to seed or symlink here. # Register the MCP servers baked into the image (see Dockerfile) at user # scope. Done here rather than at build time because user-scope MCP config # lives in ~/.claude.json, which is bind-mounted from the host. Each server # is only added if missing, so hand edits survive restarts — but a server # removed via `claude mcp remove` comes back on the next container start. [ -s /root/.claude.json ] || echo '{}' > /root/.claude.json register_mcp() { local name="$1"; shift /root/.local/bin/claude mcp get "$name" >/dev/null 2>&1 || /root/.local/bin/claude mcp add --scope user "$name" "$@" || true } register_mcp gitea -- /usr/local/bin/gitea-mcp -t stdio register_mcp n8n --env MCP_MODE=stdio --env LOG_LEVEL=error \ --env DISABLE_CONSOLE_OUTPUT=true -- /usr/local/bin/n8n-mcp # Not the `invokeai-mcp-server` console script — it's broken upstream # (calls the async main() without asyncio.run); `python -m` is the # invocation upstream documents. register_mcp invokeai -- \ /root/.local/share/uv/tools/invokeai-mcp-server/bin/python -m invokeai_mcp_server # Create the main tmux session if it does not exist. /usr/bin/tmux new-session -d -s main 2>/dev/null || true # tmux's defaults apply here (remain-on-exit off, exit-empty on): a window # closes when its shell exits, the session closes when its last window does, # and the server exits when its last session does. Poll for that and exit # the container once it happens, instead of running forever. while /usr/bin/tmux has-session -t main 2>/dev/null; do sleep 2 done exit 0