#!/bin/sh # Container entrypoint: make sure /kb holds a clone of the KB, then serve it. # The server code itself comes from the clone (.agents/modules/mcp/server/), so # a template upgrade pulled into the KB upgrades the server with it. set -eu KB=${CKB_ROOT:-/kb} # SSH deploy key (recommended): mounted at /run/secrets/ckb-deploy-key. ssh refuses # a key others can read and a host mount rarely has the right owner, so use a # private copy. Unknown hosts are accepted on first contact and pinned after. KEY=${CKB_SSH_KEY:-/run/secrets/ckb-deploy-key} if [ -d "$KEY" ]; then # Docker turns a bind mount of a missing host file into an empty directory. echo "ckb-mcp: $KEY is a directory - the deploy key file to mount does not exist on the host" >&2 exit 1 fi if [ -f "$KEY" ] && [ -z "${GIT_SSH_COMMAND:-}" ]; then mkdir -p "$HOME/.ssh" && chmod 700 "$HOME/.ssh" cp "$KEY" "$HOME/.ssh/deploy_key" && chmod 600 "$HOME/.ssh/deploy_key" export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/deploy_key -o IdentitiesOnly=yes -o StrictHostKeyChecking=accept-new" fi if [ ! -d "$KB/.git" ]; then [ -n "${CKB_REPO_URL:-}" ] || { echo "ckb-mcp: $KB is not a clone and CKB_REPO_URL is unset" >&2; exit 1; } git clone --quiet ${CKB_MCP_GIT_BRANCH:+--branch "$CKB_MCP_GIT_BRANCH"} "$CKB_REPO_URL" "$KB" fi git config --global --add safe.directory "$KB" exec python "$KB/.agents/modules/mcp/server/server.py"